diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-10-17 20:48:31 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-10-17 20:48:31 +0800 |
commit | 0960240a229b324dd874f60a2f385daebb1627ad (patch) | |
tree | f918d2487b83ee5b8cb8967aa16fe12fd15a59a1 | |
parent | 545e74dd116e05cbb89ce52913ce3bf797629d27 (diff) | |
download | gsoc2013-empathy-0960240a229b324dd874f60a2f385daebb1627ad.tar gsoc2013-empathy-0960240a229b324dd874f60a2f385daebb1627ad.tar.gz gsoc2013-empathy-0960240a229b324dd874f60a2f385daebb1627ad.tar.bz2 gsoc2013-empathy-0960240a229b324dd874f60a2f385daebb1627ad.tar.lz gsoc2013-empathy-0960240a229b324dd874f60a2f385daebb1627ad.tar.xz gsoc2013-empathy-0960240a229b324dd874f60a2f385daebb1627ad.tar.zst gsoc2013-empathy-0960240a229b324dd874f60a2f385daebb1627ad.zip |
Connect to the "destroy" and "response" signals on the import window instead of connecting OK/Cancel buttons.
svn path=/trunk/; revision=1643
-rw-r--r-- | src/empathy-import-dialog.c | 114 | ||||
-rw-r--r-- | src/empathy-import-dialog.glade | 4 |
2 files changed, 59 insertions, 59 deletions
diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c index f8f27f1ce..eeb8b1bf1 100644 --- a/src/empathy-import-dialog.c +++ b/src/empathy-import-dialog.c @@ -398,54 +398,6 @@ FILENAME: } static gboolean -import_dialog_tree_model_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - gboolean to_import; - AccountData *data; - - gtk_tree_model_get (model, iter, - COL_IMPORT, &to_import, - COL_ACCOUNT_DATA, &data, - -1); - - if (to_import) - import_dialog_add_account (data); - - import_dialog_account_data_free (data); - return FALSE; -} - -static void -import_dialog_free (EmpathyImportDialog *dialog) -{ - if (dialog->window) - gtk_widget_destroy (dialog->window); - g_list_free (dialog->accounts); - g_slice_free (EmpathyImportDialog, dialog); -} - -static void -import_dialog_button_ok_clicked_cb (GtkButton *button, - EmpathyImportDialog *dialog) -{ - GtkTreeModel *model; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); - gtk_tree_model_foreach (model, import_dialog_tree_model_foreach, dialog); - import_dialog_free (dialog); -} - -static void -import_dialog_button_cancel_clicked_cb (GtkButton *button, - EmpathyImportDialog *dialog) -{ - import_dialog_free (dialog); -} - -static gboolean import_dialog_account_id_in_list (GList *accounts, const gchar *account_id) { @@ -603,6 +555,52 @@ import_dialog_set_up_account_list (EmpathyImportDialog *dialog) import_dialog_add_accounts_to_model (dialog); } +static gboolean +import_dialog_tree_model_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data) +{ + gboolean to_import; + AccountData *data; + + gtk_tree_model_get (model, iter, + COL_IMPORT, &to_import, + COL_ACCOUNT_DATA, &data, + -1); + + if (to_import) + import_dialog_add_account (data); + + return FALSE; +} + +static void +import_dialog_response_cb (GtkWidget *widget, + gint response, + EmpathyImportDialog *dialog) +{ + if (response == GTK_RESPONSE_OK) + { + GtkTreeModel *model; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + gtk_tree_model_foreach (model, import_dialog_tree_model_foreach, dialog); + } + + gtk_widget_destroy (dialog->window); +} + +static void +import_dialog_destroy_cb (GtkWidget *widget, + EmpathyImportDialog *dialog) +{ + g_list_foreach (dialog->accounts, (GFunc) import_dialog_account_data_free, + NULL); + g_list_free (dialog->accounts); + g_slice_free (EmpathyImportDialog, dialog); +} + void empathy_import_dialog_show (GtkWindow *parent, gboolean warning) @@ -610,18 +608,18 @@ empathy_import_dialog_show (GtkWindow *parent, static EmpathyImportDialog *dialog = NULL; GladeXML *glade; gchar *filename; + GList *accounts; + /* This window is a singleton. If it already exist, present it */ if (dialog) { gtk_window_present (GTK_WINDOW (dialog->window)); return; } - dialog = g_slice_new0 (EmpathyImportDialog); - - dialog->accounts = import_dialog_pidgin_load (); - - if (!dialog->accounts) + /* Check if we have accounts to import before creating the window */ + accounts = import_dialog_pidgin_load (); + if (!accounts) { GtkWidget *message; @@ -638,10 +636,12 @@ empathy_import_dialog_show (GtkWindow *parent, else DEBUG ("No accounts to import; closing dialog silently."); - import_dialog_free (dialog); - dialog = NULL; return; } + + /* We have accounts, let's display the window with them */ + dialog = g_slice_new0 (EmpathyImportDialog); + dialog->accounts = accounts; filename = empathy_file_lookup ("empathy-import-dialog.glade", "src"); glade = empathy_glade_get_file (filename, @@ -653,8 +653,8 @@ empathy_import_dialog_show (GtkWindow *parent, empathy_glade_connect (glade, dialog, - "button_ok", "clicked", import_dialog_button_ok_clicked_cb, - "button_cancel", "clicked", import_dialog_button_cancel_clicked_cb, + "import_dialog", "destroy", import_dialog_destroy_cb, + "import_dialog", "response", import_dialog_response_cb, NULL); g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog); diff --git a/src/empathy-import-dialog.glade b/src/empathy-import-dialog.glade index 2725c5eae..bc71f7648 100644 --- a/src/empathy-import-dialog.glade +++ b/src/empathy-import-dialog.glade @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> -<!--Generated with glade3 3.4.5 on Fri Oct 3 19:30:53 2008 --> +<!--Generated with glade3 3.4.5 on Fri Oct 17 11:01:30 2008 --> <glade-interface> <widget class="GtkDialog" id="import_dialog"> <property name="border_width">5</property> @@ -54,7 +54,7 @@ <property name="receives_default">True</property> <property name="label" translatable="yes">gtk-ok</property> <property name="use_stock">True</property> - <property name="response_id">0</property> + <property name="response_id">-5</property> </widget> <packing> <property name="position">1</property> |