diff --git a/data/ui/tvchannelsdatabase.glade b/data/ui/tvchannelsdatabase.glade
new file mode 100644
index 0000000..c78dcaa
--- /dev/null
+++ b/data/ui/tvchannelsdatabase.glade
@@ -0,0 +1,290 @@
+
+
+
+
+
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 1d9b9a3..47304d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,12 +62,14 @@ freetuxtv_SOURCES = \
freetuxtv-utils.h \
freetuxtv-window-add-channels-group.c \
freetuxtv-window-add-channels-group.h \
+ freetuxtv-window-add-recording.c \
+ freetuxtv-window-add-recording.h \
freetuxtv-window-channel-properties.c \
freetuxtv-window-channel-properties.h \
freetuxtv-window-main.c \
freetuxtv-window-main.h \
- freetuxtv-window-add-recording.c \
- freetuxtv-window-add-recording.h \
+ freetuxtv-window-tv-channels-database.c \
+ freetuxtv-window-tv-channels-database.h \
lib-gmmkeys.c \
lib-gmmkeys.h \
lib-m3uparser.c \
diff --git a/src/freetuxtv-gladexml.h b/src/freetuxtv-gladexml.h
index c0fc8e9..ddd2d0d 100644
--- a/src/freetuxtv-gladexml.h
+++ b/src/freetuxtv-gladexml.h
@@ -23,6 +23,7 @@
#define FREETUXTV_GUIFILE_ADDRECORDING "addrecording.glade"
#define FREETUXTV_GUIFILE_ADDCHANNELSGROUPS "addchannelsgroups.glade"
#define FREETUXTV_GUIFILE_CHANNELPROPERTIES "channelproperties.glade"
+#define FREETUXTV_GUIFILE_TVCHANNELSDATABASE "tvchannelsdatabase.glade"
// List of windows and dialogs
#define FREETUXTV_GUI_DIALOG_ADDRECORDING "dialogaddrecording"
\ No newline at end of file
diff --git a/src/freetuxtv-window-main.c b/src/freetuxtv-window-main.c
index f8c3393..1553c4e 100644
--- a/src/freetuxtv-window-main.c
+++ b/src/freetuxtv-window-main.c
@@ -25,6 +25,7 @@
#include "freetuxtv-window-main.h"
#include "freetuxtv-window-add-recording.h"
#include "freetuxtv-window-add-channels-group.h"
+#include "freetuxtv-window-tv-channels-database.h"
#include "freetuxtv-app.h"
#include "freetuxtv-i18n.h"
@@ -1582,20 +1583,19 @@ on_windowmain_menuitemupdatetvchannels_activate (GtkMenuItem *menuitem,
FreetuxTVApp *app = (FreetuxTVApp *) user_data;
GError* error = NULL;
+
+ GtkWindow* pWindow;
+ GtkWidget* pParent;
+ pParent = (GtkWidget *) gtk_builder_get_object (app->gui, "windowmain");
- DBSync dbsync;
- dbsync_open_db (&dbsync, &error);
-
- if(error == NULL){
- tvchannels_list_synchronize (app, &dbsync, &error);
- }
+ FreetuxTVWindowTVChannelsDatabase* pWindowTVChannelsDatabase;
+ pWindowTVChannelsDatabase = freetuxtv_window_tv_channels_database_new(GTK_WINDOW(pParent), app);
if(error == NULL){
- channels_list_load_channels (app, &dbsync, &error);
+ pWindow = gtk_builder_window_get_top_window (GTK_BUILDER_WINDOW(pWindowTVChannelsDatabase));
+ gtk_widget_show(GTK_WIDGET(pWindow));
}
- dbsync_close_db(&dbsync);
-
if(error != NULL){
windowmain_show_gerror (app, error);
g_error_free (error);
diff --git a/src/freetuxtv-window-tv-channels-database.c b/src/freetuxtv-window-tv-channels-database.c
new file mode 100644
index 0000000..9aa795e
--- /dev/null
+++ b/src/freetuxtv-window-tv-channels-database.c
@@ -0,0 +1,169 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * freetuxtv
+ * Copyright (C) Eric Beuque 2012
+ *
+freetuxtv is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * freetuxtv is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#include "freetuxtv-window-tv-channels-database.h"
+
+#include "freetuxtv-gladexml.h"
+#include "freetuxtv-db-sync.h"
+#include "freetuxtv-channels-list.h"
+#include "freetuxtv-tv-channels-list.h"
+#include "freetuxtv-window-main.h"
+
+typedef struct _FreetuxTVWindowTVChannelsDatabasePrivate FreetuxTVWindowTVChannelsDatabasePrivate;
+struct _FreetuxTVWindowTVChannelsDatabasePrivate
+{
+ FreetuxTVApp* app;
+};
+
+#define FREETUXTV_WINDOW_TV_CHANNELS_DATABASE_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), FREETUXTV_TYPE_WINDOW_TV_CHANNELS_DATABASE, FreetuxTVWindowTVChannelsDatabasePrivate))
+
+G_DEFINE_TYPE (FreetuxTVWindowTVChannelsDatabase, freetuxtv_window_tv_channels_database, GTK_TYPE_BUILDER_WINDOW);
+
+static void
+freetuxtv_window_tv_channels_database_init (FreetuxTVWindowTVChannelsDatabase *pWindowTVChannelsDatabase)
+{
+
+}
+
+static void
+freetuxtv_window_tv_channels_database_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (freetuxtv_window_tv_channels_database_parent_class)->finalize (object);
+}
+
+static void
+freetuxtv_window_tv_channels_database_class_init (FreetuxTVWindowTVChannelsDatabaseClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ //GtkBuilderDialogClass* parent_class = GTK_BUILDER_DIALOG_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (FreetuxTVWindowTVChannelsDatabasePrivate));
+
+ object_class->finalize = freetuxtv_window_tv_channels_database_finalize;
+}
+
+static gboolean
+do_idle_destroy_window (gpointer user_data)
+{
+ g_return_val_if_fail(GTK_IS_BUILDER_WIDGET(user_data), FALSE);
+ gtk_builder_widget_destroy (GTK_BUILDER_WIDGET(user_data));
+
+ return FALSE;
+}
+
+static void
+on_buttonclose_clicked (GtkButton *button, gpointer user_data)
+{
+ // We do the destruction after the button clicked event is finished
+ g_idle_add (do_idle_destroy_window, user_data);
+}
+
+static void
+on_buttonapply_clicked (GtkButton *button, gpointer user_data)
+{
+ FreetuxTVWindowTVChannelsDatabase* pWindowTVChannelsDatabase;
+ FreetuxTVWindowTVChannelsDatabasePrivate* priv;
+
+ pWindowTVChannelsDatabase = (FreetuxTVWindowTVChannelsDatabase*)user_data;
+ priv = FREETUXTV_WINDOW_TV_CHANNELS_DATABASE_PRIVATE(pWindowTVChannelsDatabase);
+
+ GError* error = NULL;
+
+ GtkBuilder *builder;
+ builder = gtk_builder_object_get_builder(GTK_BUILDER_OBJECT(pWindowTVChannelsDatabase));
+
+ DBSync dbsync;
+
+ gboolean bSynchronize = FALSE;
+
+ // Check if must synchronize
+ GtkWidget* pWidget;
+ pWidget = (GtkWidget *) gtk_builder_get_object (builder, "checkbutton_synchronize");
+
+ bSynchronize = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pWidget));
+
+ // Do synchronize
+ if(bSynchronize){
+ dbsync_open_db (&dbsync, &error);
+
+ if(error == NULL){
+ tvchannels_list_synchronize (priv->app, &dbsync, &error);
+ }
+
+ if(error == NULL){
+ channels_list_load_channels (priv->app, &dbsync, &error);
+ }
+
+ dbsync_close_db(&dbsync);
+ }
+
+ if(error != NULL){
+ windowmain_show_gerror (priv->app, error);
+ g_error_free (error);
+ }
+}
+
+FreetuxTVWindowTVChannelsDatabase*
+freetuxtv_window_tv_channels_database_new (GtkWindow *parent, FreetuxTVApp* app)
+{
+ g_return_val_if_fail(parent != NULL, NULL);
+ g_return_val_if_fail(GTK_IS_WINDOW(parent), NULL);
+ g_return_val_if_fail(app != NULL, NULL);
+
+ FreetuxTVWindowTVChannelsDatabase* pWindowTVChannelsDatabase;
+
+ gchar* szUiFile = NULL;
+ szUiFile = g_build_filename (app->paths.szPathGladeXml, FREETUXTV_GUIFILE_TVCHANNELSDATABASE, NULL);
+
+ pWindowTVChannelsDatabase = g_object_new (FREETUXTV_TYPE_WINDOW_TV_CHANNELS_DATABASE,
+ "ui-file", szUiFile,
+ "toplevel-widget-name", "dialogtvchannelsdatabase",
+ NULL);
+
+ if(szUiFile){
+ g_free(szUiFile);
+ szUiFile = NULL;
+ }
+
+ // Private members
+ FreetuxTVWindowTVChannelsDatabasePrivate* priv;
+ priv = FREETUXTV_WINDOW_TV_CHANNELS_DATABASE_PRIVATE(pWindowTVChannelsDatabase);
+ priv->app = app;
+
+ // Signal to connect instance
+ GtkWidget *widget;
+ widget = (GtkWidget *)gtk_builder_object_get_object (
+ GTK_BUILDER_OBJECT(pWindowTVChannelsDatabase),
+ "button_apply");
+ g_signal_connect(G_OBJECT(widget),
+ "clicked",
+ G_CALLBACK(on_buttonapply_clicked),
+ pWindowTVChannelsDatabase);
+
+ widget = (GtkWidget *)gtk_builder_object_get_object (
+ GTK_BUILDER_OBJECT(pWindowTVChannelsDatabase),
+ "button_close");
+ g_signal_connect(G_OBJECT(widget),
+ "clicked",
+ G_CALLBACK(on_buttonclose_clicked),
+ pWindowTVChannelsDatabase);
+
+ return pWindowTVChannelsDatabase;
+}
+
diff --git a/src/freetuxtv-window-tv-channels-database.h b/src/freetuxtv-window-tv-channels-database.h
new file mode 100644
index 0000000..2d90b55
--- /dev/null
+++ b/src/freetuxtv-window-tv-channels-database.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * freetuxtv
+ * Copyright (C) Eric Beuque 2012
+ *
+freetuxtv is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * freetuxtv is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#ifndef _FREETUXTV_WINDOW_TV_CHANNELS_DATABASE_H_
+#define _FREETUXTV_WINDOW_TV_CHANNELS_DATABASE_H_
+
+#include
+
+#include "gtk-builder-window.h"
+#include "freetuxtv-app.h"
+
+G_BEGIN_DECLS
+
+#define FREETUXTV_TYPE_WINDOW_TV_CHANNELS_DATABASE (freetuxtv_window_tv_channels_database_get_type ())
+#define FREETUXTV_WINDOW_TV_CHANNELS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FREETUXTV_TYPE_WINDOW_TV_CHANNELS_DATABASE, FreetuxTVWindowTVChannelsDatabase))
+#define FREETUXTV_WINDOW_TV_CHANNELS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FREETUXTV_TYPE_WINDOW_TV_CHANNELS_DATABASE, FreetuxTVWindowTVChannelsDatabaseClass))
+#define FREETUXTV_IS_WINDOW_TV_CHANNELS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FREETUXTV_TYPE_WINDOW_TV_CHANNELS_DATABASE))
+#define FREETUXTV_IS_WINDOW_TV_CHANNELS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FREETUXTV_TYPE_WINDOW_TV_CHANNELS_DATABASE))
+#define FREETUXTV_WINDOW_TV_CHANNELS_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FREETUXTV_TYPE_WINDOW_TV_CHANNELS_DATABASE, FreetuxTVWindowTVChannelsDatabaseClass))
+
+typedef struct _FreetuxTVWindowTVChannelsDatabaseClass FreetuxTVWindowTVChannelsDatabaseClass;
+typedef struct _FreetuxTVWindowTVChannelsDatabase FreetuxTVWindowTVChannelsDatabase;
+
+
+
+struct _FreetuxTVWindowTVChannelsDatabaseClass
+{
+ GtkBuilderWindowClass parent_class;
+};
+
+struct _FreetuxTVWindowTVChannelsDatabase
+{
+ GtkBuilderWindow parent_instance;
+};
+
+GType freetuxtv_window_tv_channels_database_get_type (void) G_GNUC_CONST;
+
+FreetuxTVWindowTVChannelsDatabase*
+freetuxtv_window_tv_channels_database_new (GtkWindow *parent, FreetuxTVApp* app);
+
+G_END_DECLS
+
+#endif /* _FREETUXTV_WINDOW_TV_CHANNELS_DATABASE_H_ */