From ddcb104dfa874375ea17cac4de2f273af7327fc4 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 5 Jul 2009 10:43:50 +0100 Subject: Get the icon name from the account object directly --- src/empathy-accounts-dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 98e848566..f427b9994 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -466,7 +466,7 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, COL_ACCOUNT_POINTER, &account, -1); - icon_name = empathy_icon_name_from_account (account); + icon_name = empathy_account_get_icon_name (account); pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); if (pixbuf) { -- cgit v1.2.3 From 2d517a8bf5f8048a83d753fb0977d4949cbdeb7a Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 5 Jul 2009 13:08:11 +0100 Subject: Remove usage of McProfiles --- src/empathy-accounts-dialog.c | 95 +++++++++++++++++---------------------- src/empathy-new-chatroom-dialog.c | 5 +-- 2 files changed, 41 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index f427b9994..1b48c1488 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -164,13 +164,45 @@ accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog, g_free (text); } +typedef GtkWidget *CreateWidget (EmpathyAccount *); + +static GtkWidget * +get_account_setup_widget (EmpathyAccount *account) +{ + const gchar *cm = empathy_account_get_connection_manager (account); + const gchar *proto = empathy_account_get_protocol (account); + struct { + const gchar *cm; + const gchar *proto; + CreateWidget *cb; + } dialogs[] = { + { "gabble", "jabber", empathy_account_widget_jabber_new}, + { "butterfly", "msn", empathy_account_widget_msn_new}, + { "salut", "local-xmpp", empathy_account_widget_salut_new}, + { "idle", "irc", empathy_account_widget_irc_new}, + { "haze", "icq", empathy_account_widget_icq_new}, + { "haze", "aim", empathy_account_widget_aim_new}, + { "haze", "yahoo", empathy_account_widget_yahoo_new}, + { "haze", "groupwise", empathy_account_widget_groupwise_new}, + { "sofiasip", "sip", empathy_account_widget_sip_new}, + { NULL, NULL, NULL } + }; + int i; + + for (i = 0; dialogs[i].cm != NULL; i++) { + if (!tp_strdiff (cm, dialogs[i].cm) + && !tp_strdiff (proto, dialogs[i].proto)) + return dialogs[i].cb(account); + } + + return empathy_account_widget_generic_new (account); +} + + static void accounts_dialog_update_account (EmpathyAccountsDialog *dialog, EmpathyAccount *account) { - McProfile *profile; - const gchar *config_ui; - if (!account) { GtkTreeView *view; GtkTreeModel *model; @@ -215,48 +247,7 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog, dialog->settings_widget = NULL; } - profile = empathy_account_get_profile (account); - config_ui = mc_profile_get_configuration_ui (profile); - if (!tp_strdiff (config_ui, "jabber")) { - dialog->settings_widget = - empathy_account_widget_jabber_new (account); - } - else if (!tp_strdiff (config_ui, "msn")) { - dialog ->settings_widget = - empathy_account_widget_msn_new (account); - } - else if (!tp_strdiff (config_ui, "local-xmpp")) { - dialog->settings_widget = - empathy_account_widget_salut_new (account); - } - else if (!tp_strdiff (config_ui, "irc")) { - dialog->settings_widget = - empathy_account_widget_irc_new (account); - } - else if (!tp_strdiff (config_ui, "icq")) { - dialog->settings_widget = - empathy_account_widget_icq_new (account); - } - else if (!tp_strdiff (config_ui, "aim")) { - dialog->settings_widget = - empathy_account_widget_aim_new (account); - } - else if (!tp_strdiff (config_ui, "yahoo")) { - dialog->settings_widget = - empathy_account_widget_yahoo_new (account); - } - else if (!tp_strdiff (config_ui, "sofiasip")) { - dialog->settings_widget = - empathy_account_widget_sip_new (account); - } - else if (!tp_strdiff (config_ui, "groupwise")) { - dialog->settings_widget = - empathy_account_widget_groupwise_new (account); - } - else { - dialog->settings_widget = - empathy_account_widget_generic_new (account); - } + dialog->settings_widget = get_account_setup_widget (account); gtk_container_add (GTK_CONTAINER (dialog->alignment_settings), dialog->settings_widget); @@ -264,14 +255,12 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog, gtk_image_set_from_icon_name (GTK_IMAGE (dialog->image_type), - mc_profile_get_icon_name (profile), + empathy_account_get_icon_name (account), GTK_ICON_SIZE_DIALOG); gtk_widget_set_tooltip_text (dialog->image_type, - mc_profile_get_display_name (profile)); + empathy_account_get_protocol (account)); accounts_dialog_update_name_label (dialog, account); - - g_object_unref (profile); } static void @@ -661,13 +650,10 @@ accounts_dialog_account_added_cb (EmpathyAccountManager *manager, current_name = empathy_account_get_display_name (account); account_param = empathy_account_get_param_string (account, "account"); if (!EMP_STR_EMPTY (account_param)) { - McProfile *profile; - const gchar *profile_name; gchar *new_name; - profile = empathy_account_get_profile (account); - profile_name = mc_profile_get_display_name (profile); - new_name = g_strdup_printf ("%s (%s)", profile_name, + new_name = g_strdup_printf ("%s (%s)", + empathy_account_get_protocol (account), account_param); DEBUG ("Setting new display name for account %s: '%s'", @@ -675,7 +661,6 @@ accounts_dialog_account_added_cb (EmpathyAccountManager *manager, empathy_account_set_display_name (account, new_name); g_free (new_name); - g_object_unref (profile); } else { /* FIXME: This CM has no account parameter, what can be done? */ } diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c index e16da91a7..7313fd1e6 100644 --- a/src/empathy-new-chatroom-dialog.c +++ b/src/empathy-new-chatroom-dialog.c @@ -358,14 +358,12 @@ new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog) { EmpathyAccountChooser *account_chooser; EmpathyAccount *account; - McProfile *profile; const gchar *protocol; const gchar *room; account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); account = empathy_account_chooser_dup_account (account_chooser); - profile = empathy_account_get_profile (account); - protocol = mc_profile_get_protocol_name (profile); + protocol = empathy_account_get_protocol (account); gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), ""); @@ -390,7 +388,6 @@ new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog) gtk_widget_grab_focus (dialog->entry_room); g_object_unref (account); - g_object_unref (profile); } static void -- cgit v1.2.3 From da5b54cd7fb15a4388d494348b94f96787896155 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 6 Jul 2009 10:51:05 +0100 Subject: use newly deprecated API --- src/empathy-import-dialog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c index 1e135892d..1d0854dd0 100644 --- a/src/empathy-import-dialog.c +++ b/src/empathy-import-dialog.c @@ -99,7 +99,9 @@ import_dialog_add_account (EmpathyImportAccountData *data) GValue *username; account_manager = empathy_account_manager_dup_singleton (); - account = empathy_account_manager_create (account_manager, data->profile); + account = empathy_account_manager_create_by_profile (account_manager, + data->profile); + g_object_unref (account_manager); if (account == NULL) { -- cgit v1.2.3 From eb9dc0cc2b90d53b87b52e13122f760d291d211e Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 6 Jul 2009 10:55:03 +0100 Subject: Rework creating a salut account so it doesn't need profiles --- src/empathy.c | 128 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/empathy.c b/src/empathy.c index 40626b532..4b754c472 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -220,15 +221,40 @@ use_nm_notify_cb (EmpathyConf *conf, } } +static gboolean +should_create_salut_account (void) +{ + EmpathyAccountManager *manager; + gboolean salut_created = FALSE; + GList *accounts, *l; + + /* Check if we already created a salut account */ + empathy_conf_get_bool (empathy_conf_get (), + EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, + &salut_created); + + manager = empathy_account_manager_dup_singleton (); + accounts = empathy_account_manager_dup_accounts (manager); + + for (l = accounts; l != NULL; l = g_list_next (l)) { + EmpathyAccount *account = EMPATHY_ACCOUNT (l->data); + + if (!tp_strdiff (empathy_account_get_protocol (account), "local-xmpp")) + salut_created = TRUE; + + g_object_unref (account); + } + + g_object_unref (manager); + + return !salut_created; +} + static void -create_salut_account (void) +create_salut_account_if_needed (void) { - McProfile *profile; - McProtocol *protocol; - gboolean salut_created = FALSE; EmpathyAccount *account; EmpathyAccountManager *account_manager; - GList *accounts; EBook *book; EContact *contact; gchar *nickname = NULL; @@ -238,56 +264,25 @@ create_salut_account (void) gchar *jid = NULL; GError *error = NULL; - /* Check if we already created a salut account */ - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, - &salut_created); - if (salut_created) { - return; - } - - DEBUG ("Try to add a salut account..."); - /* Check if the salut CM is installed */ - profile = mc_profile_lookup ("salut"); - if (!profile) { - DEBUG ("No salut profile"); + if (!should_create_salut_account()) return; - } - protocol = mc_profile_get_protocol (profile); - if (!protocol) { - DEBUG ("Salut not installed"); - g_object_unref (profile); - return; - } - g_object_unref (protocol); + + DEBUG ("Trying to add a salut account..."); /* Get self EContact from EDS */ if (!e_book_get_self (&contact, &book, &error)) { DEBUG ("Failed to get self econtact: %s", error ? error->message : "No error given"); g_clear_error (&error); - g_object_unref (profile); - return; - } - - empathy_conf_set_bool (empathy_conf_get (), - EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, - TRUE); - - /* Check if there is already a salut account */ - accounts = mc_accounts_list_by_profile (profile); - if (accounts) { - DEBUG ("There is already a salut account"); - mc_accounts_list_free (accounts); - g_object_unref (profile); return; } account_manager = empathy_account_manager_dup_singleton (); - account = empathy_account_manager_create (account_manager, profile); - empathy_account_set_display_name (account, _("People nearby")); + account = empathy_account_manager_create (account_manager, + "salut", "local-xmpp", _("People nearby")); g_object_unref (account_manager); + empathy_account_set_enabled (account, TRUE); nickname = e_contact_get (contact, E_CONTACT_NICKNAME); first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME); @@ -316,9 +311,51 @@ create_salut_account (void) g_free (email); g_free (jid); g_object_unref (account); - g_object_unref (profile); g_object_unref (contact); g_object_unref (book); + + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, + TRUE); + +} + +static void +connection_manager_listed (TpConnectionManager * const * cms, + gsize n_cms, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + int i; + if (error != NULL) { + DEBUG ("Couldn't get the connection manager list: %s", error->message); + return; + } + + for (i = 0; i < n_cms; i++) { + if (!tp_strdiff (tp_connection_manager_get_name (cms[i]), "salut")) { + /* salut installed, see if we need to create a new account */ + create_salut_account_if_needed (); + return; + } + } +} + +static void +create_salut_account (void) +{ + TpDBusDaemon *d; + + if (!should_create_salut_account()) + return; + + d = tp_dbus_daemon_dup (NULL); + + tp_list_connection_managers (d, connection_manager_listed, NULL, + NULL, NULL); + + g_object_unref (d); } /* The code that handles single-instance and startup notification is @@ -487,6 +524,7 @@ main (int argc, char *argv[]) #endif EmpathyStatusIcon *icon; EmpathyDispatcher *dispatcher; + EmpathyAccountManager *account_manager; EmpathyLogManager *log_manager; EmpathyChatroomManager *chatroom_manager; EmpathyCallFactory *call_factory; @@ -637,6 +675,9 @@ main (int argc, char *argv[]) empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE); } + /* account management */ + account_manager = empathy_account_manager_dup_singleton (); + create_salut_account (); /* Setting up UI */ @@ -685,6 +726,7 @@ main (int argc, char *argv[]) g_object_unref (mc); g_object_unref (idle); g_object_unref (icon); + g_object_unref (account_manager); g_object_unref (log_manager); g_object_unref (dispatcher); g_object_unref (chatroom_manager); -- cgit v1.2.3 From 0ddbfabe32f0d02a63a21fca5bfb015f4e56bf97 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 6 Jul 2009 11:29:55 +0100 Subject: Transform profile chooser into a protocol chooser --- src/empathy-accounts-dialog.c | 81 ++++++++++++++++++++---------------------- src/empathy-accounts-dialog.ui | 2 +- 2 files changed, 40 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 1b48c1488..c523a2138 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -31,13 +31,12 @@ #include #include -#include #include #include #include #include -#include +#include #include #include #include @@ -58,7 +57,7 @@ typedef struct { GtkWidget *alignment_settings; GtkWidget *vbox_details; - GtkWidget *frame_no_profile; + GtkWidget *frame_no_protocol; GtkWidget *treeview; @@ -67,7 +66,7 @@ typedef struct { GtkWidget *button_import; GtkWidget *frame_new_account; - GtkWidget *combobox_profile; + GtkWidget *combobox_protocol; GtkWidget *hbox_type; GtkWidget *button_create; GtkWidget *button_back; @@ -215,8 +214,8 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog, accounts_dialog_model_select_first (dialog); return; } - if (empathy_profile_chooser_n_profiles ( - EMPATHY_PROFILE_CHOOSER (dialog->combobox_profile)) > 0) { + if (empathy_protocol_chooser_n_protocols ( + EMPATHY_PROTOCOL_CHOOSER (dialog->combobox_protocol)) > 0) { /* We have no account configured but we have some * profiles instsalled. The user obviously wants to add * an account. Click on the Add button for him. */ @@ -228,7 +227,7 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog, /* No account and no profile, warn the user */ gtk_widget_hide (dialog->vbox_details); gtk_widget_hide (dialog->frame_new_account); - gtk_widget_show (dialog->frame_no_profile); + gtk_widget_show (dialog->frame_no_protocol); gtk_widget_set_sensitive (dialog->button_add, FALSE); gtk_widget_set_sensitive (dialog->button_remove, FALSE); return; @@ -237,7 +236,7 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog, /* We have an account selected, destroy old settings and create a new * one for the account selected */ gtk_widget_hide (dialog->frame_new_account); - gtk_widget_hide (dialog->frame_no_profile); + gtk_widget_hide (dialog->frame_no_protocol); gtk_widget_show (dialog->vbox_details); gtk_widget_set_sensitive (dialog->button_add, TRUE); gtk_widget_set_sensitive (dialog->button_remove, TRUE); @@ -801,31 +800,30 @@ static void accounts_dialog_button_create_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { - McProfile *profile; EmpathyAccount *account; gchar *str; - McProfileCapabilityFlags cap; + TpConnectionManager *cm; + TpConnectionManagerProtocol *proto; - profile = empathy_profile_chooser_dup_selected ( - EMPATHY_PROFILE_CHOOSER (dialog->combobox_profile)); + cm = empathy_protocol_chooser_dup_selected ( + EMPATHY_PROTOCOL_CHOOSER (dialog->combobox_protocol), &proto); /* Create account */ - account = empathy_account_manager_create (dialog->account_manager, profile); + /* To translator: %s is the protocol name */ + str = g_strdup_printf (_("New %s account"), proto->name); + + account = empathy_account_manager_create (dialog->account_manager, + cm->name, proto->name, str); + + g_free (str); + if (account == NULL) { /* We can't display an error to the user as MC doesn't give us * any clue about the reason of the failure... */ - g_object_unref (profile); return; } - /* To translator: %s is the protocol name */ - str = g_strdup_printf (_("New %s account"), - mc_profile_get_display_name (profile)); - empathy_account_set_display_name (account, str); - g_free (str); - - cap = mc_profile_get_capabilities (profile); - if (cap & MC_PROFILE_CAPABILITY_REGISTRATION_UI) { + if (tp_connection_manager_protocol_can_register (proto)) { gboolean active; active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_register)); @@ -838,7 +836,7 @@ accounts_dialog_button_create_clicked_cb (GtkWidget *button, accounts_dialog_model_set_selected (dialog, account); g_object_unref (account); - g_object_unref (profile); + g_object_unref (cm); } static void @@ -852,24 +850,23 @@ accounts_dialog_button_back_clicked_cb (GtkWidget *button, } static void -accounts_dialog_profile_changed_cb (GtkWidget *widget, +accounts_dialog_protocol_changed_cb (GtkWidget *widget, EmpathyAccountsDialog *dialog) { - McProfile *profile; - McProfileCapabilityFlags cap; + TpConnectionManager *cm; + TpConnectionManagerProtocol *proto; - profile = empathy_profile_chooser_dup_selected ( - EMPATHY_PROFILE_CHOOSER (dialog->combobox_profile)); - cap = mc_profile_get_capabilities (profile); + cm = empathy_protocol_chooser_dup_selected ( + EMPATHY_PROTOCOL_CHOOSER (dialog->combobox_protocol), &proto); - if (cap & MC_PROFILE_CAPABILITY_REGISTRATION_UI) { + if (tp_connection_manager_protocol_can_register (proto)) { gtk_widget_show (dialog->radiobutton_register); gtk_widget_show (dialog->radiobutton_reuse); } else { gtk_widget_hide (dialog->radiobutton_register); gtk_widget_hide (dialog->radiobutton_reuse); } - g_object_unref (profile); + g_object_unref (cm); } static void @@ -888,7 +885,7 @@ accounts_dialog_button_add_clicked_cb (GtkWidget *button, gtk_widget_set_sensitive (dialog->button_add, FALSE); gtk_widget_set_sensitive (dialog->button_remove, FALSE); gtk_widget_hide (dialog->vbox_details); - gtk_widget_hide (dialog->frame_no_profile); + gtk_widget_hide (dialog->frame_no_protocol); gtk_widget_show (dialog->frame_new_account); /* If we have no account, no need of a back button */ @@ -898,11 +895,11 @@ accounts_dialog_button_add_clicked_cb (GtkWidget *button, gtk_widget_hide (dialog->button_back); } - accounts_dialog_profile_changed_cb (dialog->radiobutton_register, dialog); + accounts_dialog_protocol_changed_cb (dialog->radiobutton_register, dialog); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_reuse), TRUE); - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_profile), 0); - gtk_widget_grab_focus (dialog->combobox_profile); + gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_protocol), 0); + gtk_widget_grab_focus (dialog->combobox_protocol); } static void @@ -1052,7 +1049,7 @@ empathy_accounts_dialog_show (GtkWindow *parent, gui = empathy_builder_get_file (filename, "accounts_dialog", &dialog->window, "vbox_details", &dialog->vbox_details, - "frame_no_profile", &dialog->frame_no_profile, + "frame_no_protocol", &dialog->frame_no_protocol, "alignment_settings", &dialog->alignment_settings, "treeview", &dialog->treeview, "frame_new_account", &dialog->frame_new_account, @@ -1084,14 +1081,14 @@ empathy_accounts_dialog_show (GtkWindow *parent, g_object_unref (gui); - /* Create profile chooser */ - dialog->combobox_profile = empathy_profile_chooser_new (); + /* Create protocol chooser */ + dialog->combobox_protocol = empathy_protocol_chooser_new (); gtk_box_pack_end (GTK_BOX (dialog->hbox_type), - dialog->combobox_profile, + dialog->combobox_protocol, TRUE, TRUE, 0); - gtk_widget_show (dialog->combobox_profile); - g_signal_connect (dialog->combobox_profile, "changed", - G_CALLBACK (accounts_dialog_profile_changed_cb), + gtk_widget_show (dialog->combobox_protocol); + g_signal_connect (dialog->combobox_protocol, "changed", + G_CALLBACK (accounts_dialog_protocol_changed_cb), dialog); /* Set up signalling */ diff --git a/src/empathy-accounts-dialog.ui b/src/empathy-accounts-dialog.ui index cf1b23ef4..a76b4ae7f 100644 --- a/src/empathy-accounts-dialog.ui +++ b/src/empathy-accounts-dialog.ui @@ -391,7 +391,7 @@ - + 0 none -- cgit v1.2.3 From 13f92652db89b2c15c3302b4af7560a4e4ee22c9 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 6 Jul 2009 11:56:14 +0100 Subject: Remove useless mission-control includes --- src/empathy-chat-window.c | 1 - src/empathy-main-window.c | 2 -- src/empathy-new-chatroom-dialog.c | 3 --- src/empathy.c | 1 - 4 files changed, 7 deletions(-) (limited to 'src') diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index f9d0b924a..937e68aff 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -35,7 +35,6 @@ #include #include -#include #include #include diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index c7816d7fd..0d04153a3 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -49,8 +49,6 @@ #include #include -#include - #include "empathy-accounts-dialog.h" #include "empathy-main-window.h" #include "ephy-spinner.h" diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c index 7313fd1e6..b36d0d4f5 100644 --- a/src/empathy-new-chatroom-dialog.c +++ b/src/empathy-new-chatroom-dialog.c @@ -32,9 +32,6 @@ #include #include -#include -#include - #include #include #include diff --git a/src/empathy.c b/src/empathy.c index 4b754c472..6439eecfa 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 96fad6a1159582a3e8792dd3308ce1fbeb178234 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 8 Jul 2009 11:35:43 +0100 Subject: Initial port of Account and AccountManager to MC5 --- src/empathy-accounts-dialog.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index c523a2138..47e2887b0 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -637,7 +637,7 @@ accounts_dialog_account_added_cb (EmpathyAccountManager *manager, EmpathyAccountsDialog *dialog) { const gchar *current_name; - gchar *account_param = NULL; + const gchar *account_param = NULL; accounts_dialog_add_or_update_account (dialog, account); @@ -663,7 +663,6 @@ accounts_dialog_account_added_cb (EmpathyAccountManager *manager, } else { /* FIXME: This CM has no account parameter, what can be done? */ } - g_free (account_param); } static void -- cgit v1.2.3 From 5dc89d6d5a3f5e47ea7b65fdfdbd84ff178625c5 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 15 Jul 2009 15:14:17 +0100 Subject: Temporarily disable account importing as it still depends on profiles --- src/Makefile.am | 2 -- src/empathy-accounts-dialog.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 42485b7d1..50d317fbb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,8 +39,6 @@ empathy_handwritten_source = \ empathy-chat-window.c empathy-chat-window.h \ empathy-event-manager.c empathy-event-manager.h \ empathy-ft-manager.c empathy-ft-manager.h \ - empathy-import-dialog.c empathy-import-dialog.h \ - empathy-import-pidgin.c empathy-import-pidgin.h \ empathy-main-window.c empathy-main-window.h \ empathy-misc.c empathy-misc.h \ empathy-new-chatroom-dialog.c empathy-new-chatroom-dialog.h \ diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 47e2887b0..bfb92af37 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -43,7 +43,10 @@ #include #include "empathy-accounts-dialog.h" +#if 0 +/* FIXME MC-5 */ #include "empathy-import-dialog.h" +#endif #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT #include @@ -142,8 +145,11 @@ static void accounts_dialog_button_help_clicked_cb (GtkWidget EmpathyAccountsDialog *dialog); static void accounts_dialog_button_remove_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog); +#if 0 +/* FIXME MC-5 */ static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog); +#endif static void accounts_dialog_response_cb (GtkWidget *widget, gint response, EmpathyAccountsDialog *dialog); @@ -957,12 +963,15 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget *button, gtk_widget_destroy (message_dialog); } +#if 0 +/* FIXME MC-5 */ static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { empathy_import_dialog_show (GTK_WINDOW (dialog->window), TRUE); } +#endif static void accounts_dialog_response_cb (GtkWidget *widget, @@ -1072,7 +1081,10 @@ empathy_accounts_dialog_show (GtkWindow *parent, "button_back", "clicked", accounts_dialog_button_back_clicked_cb, "button_add", "clicked", accounts_dialog_button_add_clicked_cb, "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb, +#if 0 +/* FIXME MC-5 */ "button_import", "clicked", accounts_dialog_button_import_clicked_cb, +#endif "button_help", "clicked", accounts_dialog_button_help_clicked_cb, NULL); @@ -1140,6 +1152,8 @@ empathy_accounts_dialog_show (GtkWindow *parent, EMPATHY_PREFS_IMPORT_ASKED, &import_asked); +#if 0 +/* FIXME MC-5 */ if (empathy_import_dialog_accounts_to_import ()) { if (!import_asked) { @@ -1151,6 +1165,7 @@ empathy_accounts_dialog_show (GtkWindow *parent, } else { gtk_widget_set_sensitive (dialog->button_import, FALSE); } +#endif return dialog->window; } -- cgit v1.2.3 From 3546af6b2b14fa640c1a86e6a975eef6fcb37a00 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 15 Jul 2009 15:24:48 +0100 Subject: Remove last references to mission-control 4 --- src/empathy-accounts-dialog.c | 3 -- src/empathy-debug-dialog.c | 4 --- src/empathy-event-manager.c | 1 + src/empathy-main-window.c | 3 -- src/empathy-tube-dispatch.c | 1 + src/empathy.c | 76 ++----------------------------------------- 6 files changed, 4 insertions(+), 84 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index bfb92af37..080a6cae3 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -85,7 +85,6 @@ typedef struct { guint connecting_id; EmpathyAccountManager *account_manager; - MissionControl *mc; } EmpathyAccountsDialog; enum { @@ -1030,7 +1029,6 @@ accounts_dialog_destroy_cb (GtkWidget *widget, } g_object_unref (dialog->account_manager); - g_object_unref (dialog->mc); g_free (dialog); } @@ -1104,7 +1102,6 @@ empathy_accounts_dialog_show (GtkWindow *parent, /* Set up signalling */ dialog->account_manager = empathy_account_manager_dup_singleton (); - dialog->mc = empathy_mission_control_dup_singleton (); g_signal_connect (dialog->account_manager, "account-created", G_CALLBACK (accounts_dialog_account_added_cb), diff --git a/src/empathy-debug-dialog.c b/src/empathy-debug-dialog.c index cd0d925f9..9b420fd02 100644 --- a/src/empathy-debug-dialog.c +++ b/src/empathy-debug-dialog.c @@ -284,7 +284,6 @@ debug_dialog_cm_chooser_changed_cb (GtkComboBox *cm_chooser, EmpathyDebugDialog *debug_dialog) { EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog); - MissionControl *mc; TpDBusDaemon *dbus; GError *error = NULL; gchar *bus_name; @@ -302,13 +301,11 @@ debug_dialog_cm_chooser_changed_cb (GtkComboBox *cm_chooser, return; } - mc = empathy_mission_control_dup_singleton (); dbus = tp_dbus_daemon_dup (&error); if (error != NULL) { DEBUG ("Failed at duping the dbus daemon: %s", error->message); - g_object_unref (mc); } gtk_tree_model_get (GTK_TREE_MODEL (priv->cms), &iter, @@ -344,7 +341,6 @@ debug_dialog_cm_chooser_changed_cb (GtkComboBox *cm_chooser, debug_dialog_get_messages_cb, debug_dialog, NULL, NULL); g_object_unref (dbus); - g_object_unref (mc); } typedef struct diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index 1a7ec09cb..1be3ff7ce 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -25,6 +25,7 @@ #include #include +#include #include #include diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 0d04153a3..05eb0774e 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -79,7 +79,6 @@ typedef struct { EmpathyContactListView *list_view; EmpathyContactListStore *list_store; - MissionControl *mc; EmpathyAccountManager *account_manager; EmpathyChatroomManager *chatroom_manager; EmpathyEventManager *event_manager; @@ -646,7 +645,6 @@ main_window_destroy_cb (GtkWidget *widget, g_list_free (window->actions_connected); - g_object_unref (window->mc); g_object_unref (window->account_manager); g_object_unref (window->list_store); g_hash_table_destroy (window->errors); @@ -1175,7 +1173,6 @@ empathy_main_window_show (void) gtk_action_set_visible (show_map_widget, FALSE); #endif - window->mc = empathy_mission_control_dup_singleton (); window->account_manager = empathy_account_manager_dup_singleton (); g_signal_connect (window->account_manager, diff --git a/src/empathy-tube-dispatch.c b/src/empathy-tube-dispatch.c index 67db5a3a3..66efa217d 100644 --- a/src/empathy-tube-dispatch.c +++ b/src/empathy-tube-dispatch.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/src/empathy.c b/src/empathy.c index 6439eecfa..5e3d983aa 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -145,68 +146,6 @@ dispatch_cb (EmpathyDispatcher *dispatcher, } } -static void -service_ended_cb (MissionControl *mc, - gpointer user_data) -{ - DEBUG ("Mission Control stopped"); -} - -static void -operation_error_cb (MissionControl *mc, - guint operation_id, - guint error_code, - gpointer user_data) -{ - const gchar *message; - - switch (error_code) { - case MC_DISCONNECTED_ERROR: - message = "Disconnected"; - break; - case MC_INVALID_HANDLE_ERROR: - message = "Invalid handle"; - break; - case MC_NO_MATCHING_CONNECTION_ERROR: - message = "No matching connection"; - break; - case MC_INVALID_ACCOUNT_ERROR: - message = "Invalid account"; - break; - case MC_PRESENCE_FAILURE_ERROR: - message = "Presence failure"; - break; - case MC_NO_ACCOUNTS_ERROR: - message = "No accounts"; - break; - case MC_NETWORK_ERROR: - message = "Network error"; - break; - case MC_CONTACT_DOES_NOT_SUPPORT_VOICE_ERROR: - message = "Contact does not support voice"; - break; - case MC_LOWMEM_ERROR: - message = "Lowmem"; - break; - case MC_CHANNEL_REQUEST_GENERIC_ERROR: - message = "Channel request generic error"; - break; - case MC_CHANNEL_BANNED_ERROR: - message = "Channel banned"; - break; - case MC_CHANNEL_FULL_ERROR: - message = "Channel full"; - break; - case MC_CHANNEL_INVITE_ONLY_ERROR: - message = "Channel invite only"; - break; - default: - message = "Unknown error code"; - } - - DEBUG ("Error during operation %d: %s", operation_id, message); -} - static void use_nm_notify_cb (EmpathyConf *conf, const gchar *key, @@ -529,7 +468,6 @@ main (int argc, char *argv[]) EmpathyCallFactory *call_factory; EmpathyFTFactory *ft_factory; GtkWidget *window; - MissionControl *mc; EmpathyIdle *idle; gboolean autoconnect = TRUE; gboolean no_connect = FALSE; @@ -636,15 +574,6 @@ main (int argc, char *argv[]) g_clear_error (&error); } - /* Setting up MC */ - mc = empathy_mission_control_dup_singleton (); - g_signal_connect (mc, "ServiceEnded", - G_CALLBACK (service_ended_cb), - NULL); - g_signal_connect (mc, "Error", - G_CALLBACK (operation_error_cb), - NULL); - if (accounts_dialog) { GtkWidget *dialog; @@ -671,7 +600,7 @@ main (int argc, char *argv[]) if (autoconnect && ! no_connect && tp_connection_presence_type_cmp_availability (empathy_idle_get_state (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) { - empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE); + empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE); } /* account management */ @@ -722,7 +651,6 @@ main (int argc, char *argv[]) empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE); - g_object_unref (mc); g_object_unref (idle); g_object_unref (icon); g_object_unref (account_manager); -- cgit v1.2.3 From 1c95c220ca3830e83ed436d840528126e9ba9d15 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 16 Jul 2009 11:41:15 +0100 Subject: Move the responsibility of popping up the empathy accounts dialog out of the status icon --- src/empathy-status-icon.c | 17 ----------------- src/empathy.c | 21 ++++++++++++++++++--- 2 files changed, 18 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c index f6c63c537..aca2d85c2 100644 --- a/src/empathy-status-icon.c +++ b/src/empathy-status-icon.c @@ -305,24 +305,7 @@ status_icon_set_visibility (EmpathyStatusIcon *icon, if (!visible) { empathy_window_iconify (priv->window, priv->icon); } else { - GList *accounts; - GList *l; - gboolean one_enabled = FALSE; - empathy_window_present (GTK_WINDOW (priv->window), TRUE); - - /* Show the accounts dialog if there is no enabled accounts */ - accounts = empathy_account_manager_dup_accounts (priv->account_manager); - for (l = accounts ; l != NULL ; l = g_list_next (l)) { - one_enabled = empathy_account_is_enabled (EMPATHY_ACCOUNT (l->data)) - || one_enabled; - g_object_unref (l->data); - } - g_list_free (accounts); - if (!one_enabled) { - DEBUG ("No enabled account, Showing account dialog"); - empathy_accounts_dialog_show (GTK_WINDOW (priv->window), NULL); - } } } diff --git a/src/empathy.c b/src/empathy.c index 5e3d983aa..1fa7f5a12 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -453,6 +453,22 @@ default_log_handler (const gchar *log_domain, } #endif /* ENABLE_DEBUG */ +static void +account_manager_ready_cb (EmpathyAccountManager *manager, + GParamSpec *spec, + gpointer user_data) +{ + if (!empathy_account_manager_is_ready (manager)) + return; + + if (empathy_account_manager_get_count (manager) != 0) + { + empathy_accounts_dialog_show (GTK_WINDOW (empathy_main_window_get ()), + NULL); + } + create_salut_account (); +} + int main (int argc, char *argv[]) { @@ -605,8 +621,8 @@ main (int argc, char *argv[]) /* account management */ account_manager = empathy_account_manager_dup_singleton (); - - create_salut_account (); + g_signal_connect (account_manager, "notify::ready", + G_CALLBACK (account_manager_ready_cb), NULL); /* Setting up UI */ window = empathy_main_window_show (); @@ -666,4 +682,3 @@ main (int argc, char *argv[]) return EXIT_SUCCESS; } - -- cgit v1.2.3 From 9c3db97dcf9bd237784d401ae3215326a1d77ae2 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Tue, 21 Jul 2009 16:56:22 +0100 Subject: Port to using EmpathyAccountSettings --- src/empathy-accounts-dialog.c | 363 +++++++++++++++++++++++++++++------------- 1 file changed, 252 insertions(+), 111 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 080a6cae3..d6a29ea63 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -84,6 +84,9 @@ typedef struct { gboolean connecting_show; guint connecting_id; + gulong settings_ready_id; + EmpathyAccountSettings *settings_ready; + EmpathyAccountManager *account_manager; } EmpathyAccountsDialog; @@ -92,11 +95,12 @@ enum { COL_NAME, COL_STATUS, COL_ACCOUNT_POINTER, + COL_ACCOUNT_SETTINGS_POINTER, COL_COUNT }; -static void accounts_dialog_update_account (EmpathyAccountsDialog *dialog, - EmpathyAccount *account); +static void accounts_dialog_update (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings); static void accounts_dialog_model_setup (EmpathyAccountsDialog *dialog); static void accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog); static void accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer, @@ -109,14 +113,11 @@ static void accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn GtkTreeModel *model, GtkTreeIter *iter, EmpathyAccountsDialog *dialog); -static EmpathyAccount *accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog); static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, - EmpathyAccount *account); + EmpathyAccountSettings *settings); static gboolean accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog); static void accounts_dialog_model_selection_changed (GtkTreeSelection *selection, EmpathyAccountsDialog *dialog); -static void accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog, - EmpathyAccount *account); static void accounts_dialog_account_added_cb (EmpathyAccountManager *manager, EmpathyAccount *account, EmpathyAccountsDialog *dialog); @@ -157,24 +158,24 @@ static void accounts_dialog_destroy_cb (GtkWidget static void accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog, - EmpathyAccount *account) + EmpathyAccountSettings *settings) { gchar *text; text = g_markup_printf_escaped ("%s", - empathy_account_get_display_name (account)); + empathy_account_settings_get_display_name (settings)); gtk_label_set_markup (GTK_LABEL (dialog->label_name), text); g_free (text); } -typedef GtkWidget *CreateWidget (EmpathyAccount *); +typedef GtkWidget *CreateWidget (EmpathyAccountSettings *); static GtkWidget * -get_account_setup_widget (EmpathyAccount *account) +get_account_setup_widget (EmpathyAccountSettings *settings) { - const gchar *cm = empathy_account_get_connection_manager (account); - const gchar *proto = empathy_account_get_protocol (account); + const gchar *cm = empathy_account_settings_get_cm (settings); + const gchar *proto = empathy_account_settings_get_protocol (settings); struct { const gchar *cm; const gchar *proto; @@ -196,18 +197,53 @@ get_account_setup_widget (EmpathyAccount *account) for (i = 0; dialogs[i].cm != NULL; i++) { if (!tp_strdiff (cm, dialogs[i].cm) && !tp_strdiff (proto, dialogs[i].proto)) - return dialogs[i].cb(account); + return dialogs[i].cb (settings); } - return empathy_account_widget_generic_new (account); + return empathy_account_widget_generic_new (settings); } static void -accounts_dialog_update_account (EmpathyAccountsDialog *dialog, - EmpathyAccount *account) +account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings) +{ + dialog->settings_widget = get_account_setup_widget (settings); + + gtk_container_add (GTK_CONTAINER (dialog->alignment_settings), + dialog->settings_widget); + gtk_widget_show (dialog->settings_widget); + + + gtk_image_set_from_icon_name (GTK_IMAGE (dialog->image_type), + empathy_account_settings_get_icon_name (settings), + GTK_ICON_SIZE_DIALOG); + gtk_widget_set_tooltip_text (dialog->image_type, + empathy_account_settings_get_protocol (settings)); + + accounts_dialog_update_name_label (dialog, settings); +} + +static void +account_dialog_settings_ready_cb (EmpathyAccountSettings *settings, + GParamSpec *spec, EmpathyAccountsDialog *dialog) +{ + if (empathy_account_settings_is_ready (settings)) + account_dialog_create_settings_widget (dialog, settings); +} + +static void +accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings) { - if (!account) { + if (dialog->settings_ready != NULL) { + g_signal_handler_disconnect (dialog->settings_ready, + dialog->settings_ready_id); + dialog->settings_ready = NULL; + dialog->settings_ready_id = 0; + } + + if (!settings) { GtkTreeView *view; GtkTreeModel *model; @@ -251,20 +287,18 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog, dialog->settings_widget = NULL; } - dialog->settings_widget = get_account_setup_widget (account); - - gtk_container_add (GTK_CONTAINER (dialog->alignment_settings), - dialog->settings_widget); - gtk_widget_show (dialog->settings_widget); - - - gtk_image_set_from_icon_name (GTK_IMAGE (dialog->image_type), - empathy_account_get_icon_name (account), - GTK_ICON_SIZE_DIALOG); - gtk_widget_set_tooltip_text (dialog->image_type, - empathy_account_get_protocol (account)); + if (empathy_account_settings_is_ready (settings)) + { + account_dialog_create_settings_widget (dialog, settings); + } + else + { + dialog->settings_ready = settings; + dialog->settings_ready_id = + g_signal_connect (settings, "notify::ready", + G_CALLBACK (account_dialog_settings_ready_cb), dialog); + } - accounts_dialog_update_name_label (dialog, account); } static void @@ -277,7 +311,8 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog) G_TYPE_BOOLEAN, /* enabled */ G_TYPE_STRING, /* name */ G_TYPE_UINT, /* status */ - EMPATHY_TYPE_ACCOUNT); /* account */ + EMPATHY_TYPE_ACCOUNT, /* account */ + EMPATHY_TYPE_ACCOUNT_SETTINGS); /* settings */ gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview), GTK_TREE_MODEL (store)); @@ -303,7 +338,7 @@ accounts_dialog_name_edited_cb (GtkCellRendererText *renderer, gchar *new_text, EmpathyAccountsDialog *dialog) { - EmpathyAccount *account; + EmpathyAccountSettings *settings; GtkTreeModel *model; GtkTreePath *treepath; GtkTreeIter iter; @@ -318,15 +353,16 @@ accounts_dialog_name_edited_cb (GtkCellRendererText *renderer, treepath = gtk_tree_path_new_from_string (path); gtk_tree_model_get_iter (model, &iter, treepath); gtk_tree_model_get (model, &iter, - COL_ACCOUNT_POINTER, &account, + COL_ACCOUNT_SETTINGS_POINTER, &settings, -1); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_NAME, new_text, -1); gtk_tree_path_free (treepath); - empathy_account_set_display_name (account, new_text); - g_object_unref (account); + empathy_account_settings_set_display_name_async (settings, new_text, + NULL, NULL); + g_object_unref (settings); } static void @@ -348,6 +384,9 @@ accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer, -1); gtk_tree_path_free (treepath); + if (account == NULL) + return; + enabled = empathy_account_is_enabled (account); empathy_account_set_enabled (account, !enabled); @@ -438,7 +477,7 @@ accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog) selection = gtk_tree_view_get_selection (view); gtk_tree_selection_select_iter (selection, &iter); } else { - accounts_dialog_update_account (dialog, NULL); + accounts_dialog_update_settings (dialog, NULL); } } @@ -449,17 +488,17 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, GtkTreeIter *iter, EmpathyAccountsDialog *dialog) { - EmpathyAccount *account; + EmpathyAccountSettings *settings; const gchar *icon_name; GdkPixbuf *pixbuf; TpConnectionStatus status; gtk_tree_model_get (model, iter, COL_STATUS, &status, - COL_ACCOUNT_POINTER, &account, + COL_ACCOUNT_SETTINGS_POINTER, &settings, -1); - icon_name = empathy_account_get_icon_name (account); + icon_name = empathy_account_settings_get_icon_name (settings); pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); if (pixbuf) { @@ -488,15 +527,15 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, "pixbuf", pixbuf, NULL); - g_object_unref (account); + g_object_unref (settings); if (pixbuf) { g_object_unref (pixbuf); } } static gboolean -accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, - EmpathyAccount *account, +accounts_dialog_get_settings_iter (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings, GtkTreeIter *iter) { GtkTreeView *view; @@ -509,6 +548,42 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, selection = gtk_tree_view_get_selection (view); model = gtk_tree_view_get_model (view); + for (ok = gtk_tree_model_get_iter_first (model, iter); + ok; + ok = gtk_tree_model_iter_next (model, iter)) { + EmpathyAccountSettings *this_settings; + gboolean equal; + + gtk_tree_model_get (model, iter, + COL_ACCOUNT_SETTINGS_POINTER, &this_settings, + -1); + + equal = (this_settings == settings); + g_object_unref (this_settings); + + if (equal) { + return TRUE; + } + } + + return FALSE; +} + +static gboolean +accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, + EmpathyAccount *account, + GtkTreeIter *iter) +{ + GtkTreeView *view; + GtkTreeSelection *selection; + GtkTreeModel *model; + gboolean ok; + + /* Update the status in the model */ + view = GTK_TREE_VIEW (dialog->treeview); + selection = gtk_tree_view_get_selection (view); + model = gtk_tree_view_get_model (view); + for (ok = gtk_tree_model_get_iter_first (model, iter); ok; ok = gtk_tree_model_iter_next (model, iter)) { @@ -519,7 +594,7 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, COL_ACCOUNT_POINTER, &this_account, -1); - equal = empathy_account_equal (this_account, account); + equal = (this_account == account); g_object_unref (this_account); if (equal) { @@ -530,8 +605,31 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, return FALSE; } +static EmpathyAccountSettings * +accounts_dialog_model_get_selected_settings (EmpathyAccountsDialog *dialog) +{ + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + EmpathyAccountSettings *settings; + + view = GTK_TREE_VIEW (dialog->treeview); + selection = gtk_tree_view_get_selection (view); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { + return NULL; + } + + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_SETTINGS_POINTER, &settings, -1); + + return settings; +} + + static EmpathyAccount * -accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog) +accounts_dialog_model_get_selected_account (EmpathyAccountsDialog *dialog) { GtkTreeView *view; GtkTreeModel *model; @@ -553,13 +651,13 @@ accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog) static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, - EmpathyAccount *account) + EmpathyAccountSettings *settings) { GtkTreeSelection *selection; GtkTreeIter iter; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->treeview)); - if (accounts_dialog_get_account_iter (dialog, account, &iter)) { + if (accounts_dialog_get_settings_iter (dialog, settings, &iter)) { gtk_tree_selection_select_iter (selection, &iter); } } @@ -586,25 +684,48 @@ static void accounts_dialog_model_selection_changed (GtkTreeSelection *selection, EmpathyAccountsDialog *dialog) { - EmpathyAccount *account; + EmpathyAccountSettings *settings; GtkTreeModel *model; GtkTreeIter iter; gboolean is_selection; is_selection = gtk_tree_selection_get_selected (selection, &model, &iter); - account = accounts_dialog_model_get_selected (dialog); - accounts_dialog_update_account (dialog, account); + settings = accounts_dialog_model_get_selected_settings (dialog); + accounts_dialog_update_settings (dialog, settings); - if (account) { - g_object_unref (account); + if (settings) { + g_object_unref (settings); } } static void -accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog, +accounts_dialog_add (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings) +{ + GtkTreeModel *model; + GtkTreeIter iter; + const gchar *name; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + name = empathy_account_settings_get_display_name (settings); + + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_ENABLED, FALSE, + COL_NAME, name, + COL_STATUS, TP_CONNECTION_STATUS_DISCONNECTED, + COL_ACCOUNT_SETTINGS_POINTER, settings, + -1); +} + + +static void +accounts_dialog_add_account (EmpathyAccountsDialog *dialog, EmpathyAccount *account) { + EmpathyAccountSettings *settings; GtkTreeModel *model; GtkTreeIter iter; TpConnectionStatus status; @@ -616,16 +737,16 @@ accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog, name = empathy_account_get_display_name (account); enabled = empathy_account_is_enabled (account); - if (!accounts_dialog_get_account_iter (dialog, account, &iter)) { - DEBUG ("Adding new account"); - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - } + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + + settings = empathy_account_settings_new_for_account (account); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_ENABLED, enabled, COL_NAME, name, COL_STATUS, status, COL_ACCOUNT_POINTER, account, + COL_ACCOUNT_SETTINGS_POINTER, settings, -1); accounts_dialog_connection_changed_cb (dialog->account_manager, @@ -634,6 +755,39 @@ accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog, status, TP_CONNECTION_STATUS_DISCONNECTED, dialog); + + g_object_unref (settings); +} + +static void +accounts_dialog_update (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings) +{ + GtkTreeModel *model; + GtkTreeIter iter; + TpConnectionStatus status = TP_CONNECTION_STATUS_DISCONNECTED; + const gchar *name; + gboolean enabled = FALSE; + EmpathyAccount *account; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + name = empathy_account_settings_get_display_name (settings); + + account = empathy_account_settings_get_account (settings); + if (account != NULL) + { + enabled = empathy_account_is_enabled (account); + g_object_get (account, "connection-status", &status, NULL); + } + + accounts_dialog_get_settings_iter (dialog, settings, &iter); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_ENABLED, enabled, + COL_NAME, name, + COL_STATUS, status, + COL_ACCOUNT_POINTER, account, + COL_ACCOUNT_SETTINGS_POINTER, settings, + -1); } static void @@ -641,43 +795,20 @@ accounts_dialog_account_added_cb (EmpathyAccountManager *manager, EmpathyAccount *account, EmpathyAccountsDialog *dialog) { - const gchar *current_name; - const gchar *account_param = NULL; - - accounts_dialog_add_or_update_account (dialog, account); - - /* Change the display name to "%s (%s)" % (protocol, account). - * - The protocol is the display name of the profile. - * - The account should be the normalized name of the EmpathyAccount but - * it's not set until first connection, so we get the "account" - * parameter for CM that have it. */ - current_name = empathy_account_get_display_name (account); - account_param = empathy_account_get_param_string (account, "account"); - if (!EMP_STR_EMPTY (account_param)) { - gchar *new_name; - - new_name = g_strdup_printf ("%s (%s)", - empathy_account_get_protocol (account), - account_param); - - DEBUG ("Setting new display name for account %s: '%s'", - empathy_account_get_unique_name (account), new_name); - - empathy_account_set_display_name (account, new_name); - g_free (new_name); - } else { - /* FIXME: This CM has no account parameter, what can be done? */ - } + accounts_dialog_add_account (dialog, account); } + static void accounts_dialog_account_removed_cb (EmpathyAccountManager *manager, EmpathyAccount *account, EmpathyAccountsDialog *dialog) { + GtkTreeIter iter; - accounts_dialog_model_set_selected (dialog, account); - accounts_dialog_model_remove_selected (dialog); + if (accounts_dialog_get_account_iter (dialog, account, &iter)) + gtk_list_store_remove (GTK_LIST_STORE ( + gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview))), &iter); } static gboolean @@ -791,20 +922,31 @@ accounts_dialog_account_changed_cb (EmpathyAccountManager *manager, EmpathyAccount *account, EmpathyAccountsDialog *dialog) { - EmpathyAccount *selected_account; + EmpathyAccountSettings *settings, *selected_settings; + GtkTreeModel *model; + GtkTreeIter iter; - accounts_dialog_add_or_update_account (dialog, account); - selected_account = accounts_dialog_model_get_selected (dialog); - if (empathy_account_equal (account, selected_account)) { - accounts_dialog_update_name_label (dialog, account); - } + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + + if (!accounts_dialog_get_account_iter (dialog, account, &iter)) + return; + + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_SETTINGS_POINTER, &settings, + -1); + + accounts_dialog_update (dialog, settings); + selected_settings = accounts_dialog_model_get_selected_settings (dialog); + + if (settings == selected_settings) + accounts_dialog_update_name_label (dialog, settings); } static void accounts_dialog_button_create_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { - EmpathyAccount *account; + EmpathyAccountSettings *settings; gchar *str; TpConnectionManager *cm; TpConnectionManagerProtocol *proto; @@ -816,30 +958,23 @@ accounts_dialog_button_create_clicked_cb (GtkWidget *button, /* To translator: %s is the protocol name */ str = g_strdup_printf (_("New %s account"), proto->name); - account = empathy_account_manager_create (dialog->account_manager, - cm->name, proto->name, str); + settings = empathy_account_settings_new (cm->name, proto->name, str); g_free (str); - if (account == NULL) { - /* We can't display an error to the user as MC doesn't give us - * any clue about the reason of the failure... */ - return; - } - if (tp_connection_manager_protocol_can_register (proto)) { gboolean active; active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_register)); if (active) { - empathy_account_set_param_boolean (account, "register", TRUE); + empathy_account_settings_set_boolean (settings, "register", TRUE); } } - accounts_dialog_add_or_update_account (dialog, account); - accounts_dialog_model_set_selected (dialog, account); + accounts_dialog_add (dialog, settings); + accounts_dialog_model_set_selected (dialog, settings); - g_object_unref (account); + g_object_unref (settings); g_object_unref (cm); } @@ -847,10 +982,10 @@ static void accounts_dialog_button_back_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { - EmpathyAccount *account; + EmpathyAccountSettings *settings; - account = accounts_dialog_model_get_selected (dialog); - accounts_dialog_update_account (dialog, account); + settings = accounts_dialog_model_get_selected_settings (dialog); + accounts_dialog_update (dialog, settings); } static void @@ -921,9 +1056,9 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget *button, GtkWidget *message_dialog; gint res; - account = accounts_dialog_model_get_selected (dialog); + account = accounts_dialog_model_get_selected_account (dialog); - if (!empathy_account_is_valid (account)) { + if (account == NULL || !empathy_account_is_valid (account)) { accounts_dialog_model_remove_selected (dialog); accounts_dialog_model_select_first (dialog); return; @@ -1127,13 +1262,19 @@ empathy_accounts_dialog_show (GtkWindow *parent, /* Add existing accounts */ accounts = empathy_account_manager_dup_accounts (dialog->account_manager); for (l = accounts; l; l = l->next) { - accounts_dialog_add_or_update_account (dialog, l->data); + accounts_dialog_add_account (dialog, l->data); g_object_unref (l->data); } g_list_free (accounts); if (selected_account) { - accounts_dialog_model_set_selected (dialog, selected_account); + GtkTreeSelection *selection; + GtkTreeIter iter; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->treeview)); + if (accounts_dialog_get_account_iter (dialog, selected_account, &iter)) { + gtk_tree_selection_select_iter (selection, &iter); + } } else { accounts_dialog_model_select_first (dialog); } -- cgit v1.2.3 From e24b064cc562a89abf8facba5b9085d4aee862ed Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Tue, 21 Jul 2009 18:02:21 +0100 Subject: Port creating of of a salut account to then new apis --- src/empathy.c | 134 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/empathy.c b/src/empathy.c index 1fa7f5a12..13230d1a0 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -47,7 +47,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -159,6 +161,7 @@ use_nm_notify_cb (EmpathyConf *conf, } } +/* Salut account creation */ static gboolean should_create_salut_account (void) { @@ -171,6 +174,12 @@ should_create_salut_account (void) EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, &salut_created); + if (salut_created) + { + DEBUG ("Gconf says we already created a salut account once"); + return FALSE; + } + manager = empathy_account_manager_dup_singleton (); accounts = empathy_account_manager_dup_accounts (manager); @@ -185,14 +194,46 @@ should_create_salut_account (void) g_object_unref (manager); + if (salut_created) + { + DEBUG ("Existing salut account already exists, flagging so in gconf"); + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, + TRUE); + } + return !salut_created; } static void -create_salut_account_if_needed (void) +salut_account_created (GObject *source, + GAsyncResult *result, gpointer user_data) { - EmpathyAccount *account; - EmpathyAccountManager *account_manager; + EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source); + EmpathyAccount *account; + GError *error = NULL; + + if (!empathy_account_settings_apply_finish (settings, result, &error)) + { + DEBUG ("Failed to create salut account: %s", error->message); + g_error_free (error); + return; + } + + account = empathy_account_settings_get_account (settings); + + empathy_account_set_enabled (account, TRUE); + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, + TRUE); +} + +static void +create_salut_account_if_needed (EmpathyConnectionManagers *managers) +{ + EmpathyAccountSettings *settings; + TpConnectionManager *manager; + const TpConnectionManagerProtocol *protocol; EBook *book; EContact *contact; gchar *nickname = NULL; @@ -205,6 +246,20 @@ create_salut_account_if_needed (void) if (!should_create_salut_account()) return; + + manager = empathy_connection_managers_get_cm (managers, "salut"); + if (manager == NULL) + { + DEBUG ("Salut not installed, not making a salut account"); + return; + } + + protocol = tp_connection_manager_get_protocol (manager, "local-xmpp"); + if (protocol == NULL) + { + DEBUG ("Salut doesn't support local-xmpp!!"); + return; + } DEBUG ("Trying to add a salut account..."); @@ -216,11 +271,8 @@ create_salut_account_if_needed (void) return; } - account_manager = empathy_account_manager_dup_singleton (); - account = empathy_account_manager_create (account_manager, - "salut", "local-xmpp", _("People nearby")); - g_object_unref (account_manager); - empathy_account_set_enabled (account, TRUE); + settings = empathy_account_settings_new ("salut", "local-xmpp", + _("People nearby")); nickname = e_contact_get (contact, E_CONTACT_NICKNAME); first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME); @@ -237,63 +289,57 @@ create_salut_account_if_needed (void) "last-name=%s\nemail=%s\njid=%s\n", nickname, first_name, last_name, email, jid); - empathy_account_set_param_string (account, "nickname", nickname ? nickname : ""); - empathy_account_set_param_string (account, "first-name", first_name ? first_name : ""); - empathy_account_set_param_string (account, "last-name", last_name ? last_name : ""); - empathy_account_set_param_string (account, "email", email ? email : ""); - empathy_account_set_param_string (account, "jid", jid ? jid : ""); + empathy_account_settings_set_string (settings, "nickname", nickname ? nickname : ""); + empathy_account_settings_set_string (settings, "first-name", first_name ? first_name : ""); + empathy_account_settings_set_string (settings, "last-name", last_name ? last_name : ""); + empathy_account_settings_set_string (settings, "email", email ? email : ""); + empathy_account_settings_set_string (settings, "jid", jid ? jid : ""); + + empathy_account_settings_apply_async (settings, + salut_account_created, NULL); g_free (nickname); g_free (first_name); g_free (last_name); g_free (email); g_free (jid); - g_object_unref (account); + g_object_unref (settings); g_object_unref (contact); g_object_unref (book); - - empathy_conf_set_bool (empathy_conf_get (), - EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, - TRUE); - } static void -connection_manager_listed (TpConnectionManager * const * cms, - gsize n_cms, - const GError *error, - gpointer user_data, - GObject *weak_object) +connection_managers_ready_cb (EmpathyConnectionManagers *managers, + GParamSpec *spec, gpointer user_data) { - int i; - if (error != NULL) { - DEBUG ("Couldn't get the connection manager list: %s", error->message); - return; - } - - for (i = 0; i < n_cms; i++) { - if (!tp_strdiff (tp_connection_manager_get_name (cms[i]), "salut")) { - /* salut installed, see if we need to create a new account */ - create_salut_account_if_needed (); - return; - } - } + if (empathy_connection_managers_is_ready (managers)) + { + create_salut_account_if_needed (managers); + g_object_unref (managers); + managers = NULL; + } } static void create_salut_account (void) { - TpDBusDaemon *d; + EmpathyConnectionManagers *managers; if (!should_create_salut_account()) return; - d = tp_dbus_daemon_dup (NULL); + managers = empathy_connection_managers_dup_singleton (); - tp_list_connection_managers (d, connection_manager_listed, NULL, - NULL, NULL); - - g_object_unref (d); + if (empathy_connection_managers_is_ready (managers)) + { + create_salut_account_if_needed (managers); + g_object_unref (managers); + } + else + { + g_signal_connect (managers, "notify::ready", + G_CALLBACK (connection_managers_ready_cb), NULL); + } } /* The code that handles single-instance and startup notification is @@ -461,7 +507,7 @@ account_manager_ready_cb (EmpathyAccountManager *manager, if (!empathy_account_manager_is_ready (manager)) return; - if (empathy_account_manager_get_count (manager) != 0) + if (empathy_account_manager_get_count (manager) == 0) { empathy_accounts_dialog_show (GTK_WINDOW (empathy_main_window_get ()), NULL); -- cgit v1.2.3 From 183bea15838e2ad9dc16f6d86eedb820831a8d7f Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Tue, 21 Jul 2009 18:06:47 +0100 Subject: Coding style fixes --- src/empathy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/empathy.c b/src/empathy.c index 13230d1a0..3d8fe6e12 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -244,7 +244,7 @@ create_salut_account_if_needed (EmpathyConnectionManagers *managers) GError *error = NULL; - if (!should_create_salut_account()) + if (!should_create_salut_account ()) return; manager = empathy_connection_managers_get_cm (managers, "salut"); @@ -253,14 +253,14 @@ create_salut_account_if_needed (EmpathyConnectionManagers *managers) DEBUG ("Salut not installed, not making a salut account"); return; } - + protocol = tp_connection_manager_get_protocol (manager, "local-xmpp"); if (protocol == NULL) { DEBUG ("Salut doesn't support local-xmpp!!"); return; } - + DEBUG ("Trying to add a salut account..."); /* Get self EContact from EDS */ @@ -325,7 +325,7 @@ create_salut_account (void) { EmpathyConnectionManagers *managers; - if (!should_create_salut_account()) + if (!should_create_salut_account ()) return; managers = empathy_connection_managers_dup_singleton (); -- cgit v1.2.3 From d46b6d50cedf6babe686d8a13dea36d5cbc4394f Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Tue, 21 Jul 2009 19:12:01 +0100 Subject: Hook up removing accounts in the accounts dialog --- src/empathy-accounts-dialog.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index d6a29ea63..010493ff2 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -669,6 +669,7 @@ accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog) GtkTreeModel *model; GtkTreeSelection *selection; GtkTreeIter iter; + EmpathyAccount *account; view = GTK_TREE_VIEW (dialog->treeview); selection = gtk_tree_view_get_selection (view); @@ -677,6 +678,13 @@ accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog) return FALSE; } + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_POINTER, &account, + -1); + + if (account != NULL) + empathy_account_remove_async (account, NULL, NULL); + return gtk_list_store_remove (GTK_LIST_STORE (model), &iter); } -- cgit v1.2.3 From df1cf218c8a219caa68fc2f95aed1df84a95382e Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 22 Jul 2009 00:07:03 +0100 Subject: Don't try to update the widgets if no account was selected --- src/empathy-new-chatroom-dialog.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c index b36d0d4f5..219be371d 100644 --- a/src/empathy-new-chatroom-dialog.c +++ b/src/empathy-new-chatroom-dialog.c @@ -360,6 +360,10 @@ new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog) account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); account = empathy_account_chooser_dup_account (account_chooser); + + if (account == NULL) + return; + protocol = empathy_account_get_protocol (account); gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), ""); -- cgit v1.2.3 From a5a46b1dc612eb29b86f4bdfa3b3d80cb35f8893 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 29 Jul 2009 20:20:57 +0200 Subject: Remove empathy_account_hash --- src/empathy-main-window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 4a9f80f76..f8e22d91d 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -1254,8 +1254,8 @@ empathy_main_window_show (void) "account-connection-changed", G_CALLBACK (main_window_connection_changed_cb), window); - window->errors = g_hash_table_new_full (empathy_account_hash, - empathy_account_equal, + window->errors = g_hash_table_new_full (g_direct_hash, + g_direct_equal, g_object_unref, NULL); -- cgit v1.2.3 From 97d122d36a2e387ccdba9689052b0397bbe42a76 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 29 Jul 2009 20:38:13 +0200 Subject: remove usage of empathy_account_equal --- src/empathy-chat-window.c | 2 +- src/empathy-chatrooms-window.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 03644026b..9694a653c 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1778,7 +1778,7 @@ empathy_chat_window_find_chat (EmpathyAccount *account, chat = ll->data; - if (empathy_account_equal (account, empathy_chat_get_account (chat)) && + if (account == empathy_chat_get_account (chat) && !tp_strdiff (id, empathy_chat_get_id (chat))) { return chat; } diff --git a/src/empathy-chatrooms-window.c b/src/empathy-chatrooms-window.c index 3b5dd1f77..4ec71ec49 100644 --- a/src/empathy-chatrooms-window.c +++ b/src/empathy-chatrooms-window.c @@ -514,7 +514,7 @@ chatrooms_window_chatroom_added_cb (EmpathyChatroomManager *manager, if (!account) { chatrooms_window_model_add (window, chatroom, FALSE); } else { - if (empathy_account_equal (account, empathy_chatroom_get_account (chatroom))) { + if (account == empathy_chatroom_get_account (chatroom)) { chatrooms_window_model_add (window, chatroom, FALSE); } -- cgit v1.2.3 From 010828ac98b604438cd0edace9263cd120f4ad10 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 23 Jul 2009 12:32:23 +0200 Subject: GObject-ify and clean-up the code; still WIP --- src/empathy-accounts-dialog.c | 545 ++++++++++++++++++++++++++++-------------- src/empathy-accounts-dialog.h | 27 ++- 2 files changed, 387 insertions(+), 185 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 010493ff2..bad15b974 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -54,6 +55,11 @@ /* Flashing delay for icons (milliseconds). */ #define FLASH_TIMEOUT 500 +#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountsDialog) +G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, G_TYPE_OBJECT); + +static EmpathyAccountsDialog *dialog_singleton = NULL; + typedef struct { GtkWidget *window; @@ -88,7 +94,11 @@ typedef struct { EmpathyAccountSettings *settings_ready; EmpathyAccountManager *account_manager; -} EmpathyAccountsDialog; + EmpathyConnectionManagers *cms; + + EmpathyAccount *selected_account; + GtkWindow *parent_window; +} EmpathyAccountsDialogPriv; enum { COL_ENABLED, @@ -99,6 +109,11 @@ enum { COL_COUNT }; +enum { + PROP_SELECTED_ACCOUNT = 1, + PROP_PARENT +}; + static void accounts_dialog_update (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings); static void accounts_dialog_model_setup (EmpathyAccountsDialog *dialog); @@ -153,18 +168,17 @@ static void accounts_dialog_button_import_clicked_cb (GtkWidget static void accounts_dialog_response_cb (GtkWidget *widget, gint response, EmpathyAccountsDialog *dialog); -static void accounts_dialog_destroy_cb (GtkWidget *widget, - EmpathyAccountsDialog *dialog); static void accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings) { gchar *text; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); text = g_markup_printf_escaped ("%s", empathy_account_settings_get_display_name (settings)); - gtk_label_set_markup (GTK_LABEL (dialog->label_name), text); + gtk_label_set_markup (GTK_LABEL (priv->label_name), text); g_free (text); } @@ -208,17 +222,19 @@ static void account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings) { - dialog->settings_widget = get_account_setup_widget (settings); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + priv->settings_widget = get_account_setup_widget (settings); - gtk_container_add (GTK_CONTAINER (dialog->alignment_settings), - dialog->settings_widget); - gtk_widget_show (dialog->settings_widget); + gtk_container_add (GTK_CONTAINER (priv->alignment_settings), + priv->settings_widget); + gtk_widget_show (priv->settings_widget); - gtk_image_set_from_icon_name (GTK_IMAGE (dialog->image_type), + gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_type), empathy_account_settings_get_icon_name (settings), GTK_ICON_SIZE_DIALOG); - gtk_widget_set_tooltip_text (dialog->image_type, + gtk_widget_set_tooltip_text (priv->image_type, empathy_account_settings_get_protocol (settings)); accounts_dialog_update_name_label (dialog, settings); @@ -236,18 +252,20 @@ static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings) { - if (dialog->settings_ready != NULL) { - g_signal_handler_disconnect (dialog->settings_ready, - dialog->settings_ready_id); - dialog->settings_ready = NULL; - dialog->settings_ready_id = 0; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + if (priv->settings_ready != NULL) { + g_signal_handler_disconnect (priv->settings_ready, + priv->settings_ready_id); + priv->settings_ready = NULL; + priv->settings_ready_id = 0; } if (!settings) { GtkTreeView *view; GtkTreeModel *model; - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); model = gtk_tree_view_get_model (view); if (gtk_tree_model_iter_n_children (model, NULL) > 0) { @@ -255,36 +273,35 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, accounts_dialog_model_select_first (dialog); return; } - if (empathy_protocol_chooser_n_protocols ( - EMPATHY_PROTOCOL_CHOOSER (dialog->combobox_protocol)) > 0) { + if (empathy_connection_managers_get_cms_num (priv->cms) > 0) { /* We have no account configured but we have some * profiles instsalled. The user obviously wants to add * an account. Click on the Add button for him. */ - accounts_dialog_button_add_clicked_cb (dialog->button_add, + accounts_dialog_button_add_clicked_cb (priv->button_add, dialog); return; } /* No account and no profile, warn the user */ - gtk_widget_hide (dialog->vbox_details); - gtk_widget_hide (dialog->frame_new_account); - gtk_widget_show (dialog->frame_no_protocol); - gtk_widget_set_sensitive (dialog->button_add, FALSE); - gtk_widget_set_sensitive (dialog->button_remove, FALSE); + gtk_widget_hide (priv->vbox_details); + gtk_widget_hide (priv->frame_new_account); + gtk_widget_show (priv->frame_no_protocol); + gtk_widget_set_sensitive (priv->button_add, FALSE); + gtk_widget_set_sensitive (priv->button_remove, FALSE); return; } /* We have an account selected, destroy old settings and create a new * one for the account selected */ - gtk_widget_hide (dialog->frame_new_account); - gtk_widget_hide (dialog->frame_no_protocol); - gtk_widget_show (dialog->vbox_details); - gtk_widget_set_sensitive (dialog->button_add, TRUE); - gtk_widget_set_sensitive (dialog->button_remove, TRUE); - - if (dialog->settings_widget) { - gtk_widget_destroy (dialog->settings_widget); - dialog->settings_widget = NULL; + gtk_widget_hide (priv->frame_new_account); + gtk_widget_hide (priv->frame_no_protocol); + gtk_widget_show (priv->vbox_details); + gtk_widget_set_sensitive (priv->button_add, TRUE); + gtk_widget_set_sensitive (priv->button_remove, TRUE); + + if (priv->settings_widget) { + gtk_widget_destroy (priv->settings_widget); + priv->settings_widget = NULL; } if (empathy_account_settings_is_ready (settings)) @@ -293,8 +310,8 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, } else { - dialog->settings_ready = settings; - dialog->settings_ready_id = + priv->settings_ready = settings; + priv->settings_ready_id = g_signal_connect (settings, "notify::ready", G_CALLBACK (account_dialog_settings_ready_cb), dialog); } @@ -306,6 +323,7 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog) { GtkListStore *store; GtkTreeSelection *selection; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); store = gtk_list_store_new (COL_COUNT, G_TYPE_BOOLEAN, /* enabled */ @@ -314,10 +332,10 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog) EMPATHY_TYPE_ACCOUNT, /* account */ EMPATHY_TYPE_ACCOUNT_SETTINGS); /* settings */ - gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview), + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), GTK_TREE_MODEL (store)); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->treeview)); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); g_signal_connect (selection, "changed", @@ -342,14 +360,15 @@ accounts_dialog_name_edited_cb (GtkCellRendererText *renderer, GtkTreeModel *model; GtkTreePath *treepath; GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - if (empathy_account_manager_get_connecting_accounts (dialog->account_manager) > 0) { - dialog->connecting_id = g_timeout_add (FLASH_TIMEOUT, + if (empathy_account_manager_get_connecting_accounts (priv->account_manager) > 0) { + priv->connecting_id = g_timeout_add (FLASH_TIMEOUT, (GSourceFunc) accounts_dialog_flash_connecting_cb, dialog); } - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); treepath = gtk_tree_path_new_from_string (path); gtk_tree_model_get_iter (model, &iter, treepath); gtk_tree_model_get (model, &iter, @@ -375,8 +394,9 @@ accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer, GtkTreePath *treepath; GtkTreeIter iter; gboolean enabled; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); treepath = gtk_tree_path_new_from_string (path); gtk_tree_model_get_iter (model, &iter, treepath); gtk_tree_model_get (model, &iter, @@ -402,8 +422,10 @@ accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer, gchar *path, EmpathyAccountsDialog *dialog) { - if (dialog->connecting_id) { - g_source_remove (dialog->connecting_id); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + if (priv->connecting_id) { + g_source_remove (priv->connecting_id); } DEBUG ("Editing account name started; stopping flashing"); } @@ -414,8 +436,9 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) GtkTreeView *view; GtkTreeViewColumn *column; GtkCellRenderer *cell; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); gtk_tree_view_set_headers_visible (view, TRUE); /* Enabled column */ @@ -468,9 +491,10 @@ accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog) GtkTreeModel *model; GtkTreeSelection *selection; GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); /* select first */ - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); model = gtk_tree_view_get_model (view); if (gtk_tree_model_get_iter_first (model, &iter)) { @@ -492,6 +516,7 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, const gchar *icon_name; GdkPixbuf *pixbuf; TpConnectionStatus status; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); gtk_tree_model_get (model, iter, COL_STATUS, &status, @@ -504,7 +529,7 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, if (pixbuf) { if (status == TP_CONNECTION_STATUS_DISCONNECTED || (status == TP_CONNECTION_STATUS_CONNECTING && - !dialog->connecting_show)) { + !priv->connecting_show)) { GdkPixbuf *modded_pixbuf; modded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, @@ -542,9 +567,10 @@ accounts_dialog_get_settings_iter (EmpathyAccountsDialog *dialog, GtkTreeSelection *selection; GtkTreeModel *model; gboolean ok; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); /* Update the status in the model */ - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); selection = gtk_tree_view_get_selection (view); model = gtk_tree_view_get_model (view); @@ -578,9 +604,10 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, GtkTreeSelection *selection; GtkTreeModel *model; gboolean ok; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); /* Update the status in the model */ - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); selection = gtk_tree_view_get_selection (view); model = gtk_tree_view_get_model (view); @@ -613,8 +640,9 @@ accounts_dialog_model_get_selected_settings (EmpathyAccountsDialog *dialog) GtkTreeSelection *selection; GtkTreeIter iter; EmpathyAccountSettings *settings; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); selection = gtk_tree_view_get_selection (view); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { @@ -636,8 +664,9 @@ accounts_dialog_model_get_selected_account (EmpathyAccountsDialog *dialog) GtkTreeSelection *selection; GtkTreeIter iter; EmpathyAccount *account; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); selection = gtk_tree_view_get_selection (view); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { @@ -655,8 +684,9 @@ accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, { GtkTreeSelection *selection; GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->treeview)); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); if (accounts_dialog_get_settings_iter (dialog, settings, &iter)) { gtk_tree_selection_select_iter (selection, &iter); } @@ -670,8 +700,9 @@ accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog) GtkTreeSelection *selection; GtkTreeIter iter; EmpathyAccount *account; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); selection = gtk_tree_view_get_selection (view); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { @@ -714,8 +745,9 @@ accounts_dialog_add (EmpathyAccountsDialog *dialog, GtkTreeModel *model; GtkTreeIter iter; const gchar *name; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); name = empathy_account_settings_get_display_name (settings); gtk_list_store_append (GTK_LIST_STORE (model), &iter); @@ -739,8 +771,9 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, TpConnectionStatus status; const gchar *name; gboolean enabled; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); g_object_get (account, "status", &status, NULL); name = empathy_account_get_display_name (account); enabled = empathy_account_is_enabled (account); @@ -757,7 +790,7 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, COL_ACCOUNT_SETTINGS_POINTER, settings, -1); - accounts_dialog_connection_changed_cb (dialog->account_manager, + accounts_dialog_connection_changed_cb (priv->account_manager, account, TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED, status, @@ -777,8 +810,9 @@ accounts_dialog_update (EmpathyAccountsDialog *dialog, const gchar *name; gboolean enabled = FALSE; EmpathyAccount *account; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); name = empathy_account_settings_get_display_name (settings); account = empathy_account_settings_get_account (settings); @@ -813,10 +847,11 @@ accounts_dialog_account_removed_cb (EmpathyAccountManager *manager, EmpathyAccountsDialog *dialog) { GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); if (accounts_dialog_get_account_iter (dialog, account, &iter)) gtk_list_store_remove (GTK_LIST_STORE ( - gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview))), &iter); + gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter); } static gboolean @@ -835,10 +870,11 @@ accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog) { GtkTreeView *view; GtkTreeModel *model; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - dialog->connecting_show = !dialog->connecting_show; + priv->connecting_show = !priv->connecting_show; - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); model = gtk_tree_view_get_model (view); gtk_tree_model_foreach (model, accounts_dialog_row_changed_foreach, NULL); @@ -857,9 +893,10 @@ accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager, GtkTreeModel *model; GtkTreeIter iter; gboolean found; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); /* Update the status in the model */ - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); if (accounts_dialog_get_account_iter (dialog, account, &iter)) { GtkTreePath *path; @@ -875,13 +912,13 @@ accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager, found = (empathy_account_manager_get_connecting_accounts (manager) > 0); - if (!found && dialog->connecting_id) { - g_source_remove (dialog->connecting_id); - dialog->connecting_id = 0; + if (!found && priv->connecting_id) { + g_source_remove (priv->connecting_id); + priv->connecting_id = 0; } - if (found && !dialog->connecting_id) { - dialog->connecting_id = g_timeout_add (FLASH_TIMEOUT, + if (found && !priv->connecting_id) { + priv->connecting_id = g_timeout_add (FLASH_TIMEOUT, (GSourceFunc) accounts_dialog_flash_connecting_cb, dialog); } @@ -894,9 +931,10 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog, { GtkTreeModel *model; GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); /* Update the status in the model */ - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); DEBUG ("Account %s is now %s", empathy_account_get_display_name (account), @@ -933,8 +971,9 @@ accounts_dialog_account_changed_cb (EmpathyAccountManager *manager, EmpathyAccountSettings *settings, *selected_settings; GtkTreeModel *model; GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); if (!accounts_dialog_get_account_iter (dialog, account, &iter)) return; @@ -958,9 +997,10 @@ accounts_dialog_button_create_clicked_cb (GtkWidget *button, gchar *str; TpConnectionManager *cm; TpConnectionManagerProtocol *proto; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); cm = empathy_protocol_chooser_dup_selected ( - EMPATHY_PROTOCOL_CHOOSER (dialog->combobox_protocol), &proto); + EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto); /* Create account */ /* To translator: %s is the protocol name */ @@ -973,7 +1013,7 @@ accounts_dialog_button_create_clicked_cb (GtkWidget *button, if (tp_connection_manager_protocol_can_register (proto)) { gboolean active; - active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_register)); + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->radiobutton_register)); if (active) { empathy_account_settings_set_boolean (settings, "register", TRUE); } @@ -1002,16 +1042,17 @@ accounts_dialog_protocol_changed_cb (GtkWidget *widget, { TpConnectionManager *cm; TpConnectionManagerProtocol *proto; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); cm = empathy_protocol_chooser_dup_selected ( - EMPATHY_PROTOCOL_CHOOSER (dialog->combobox_protocol), &proto); + EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto); if (tp_connection_manager_protocol_can_register (proto)) { - gtk_widget_show (dialog->radiobutton_register); - gtk_widget_show (dialog->radiobutton_reuse); + gtk_widget_show (priv->radiobutton_register); + gtk_widget_show (priv->radiobutton_reuse); } else { - gtk_widget_hide (dialog->radiobutton_register); - gtk_widget_hide (dialog->radiobutton_reuse); + gtk_widget_hide (priv->radiobutton_register); + gtk_widget_hide (priv->radiobutton_reuse); } g_object_unref (cm); } @@ -1023,30 +1064,31 @@ accounts_dialog_button_add_clicked_cb (GtkWidget *button, GtkTreeView *view; GtkTreeSelection *selection; GtkTreeModel *model; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - view = GTK_TREE_VIEW (dialog->treeview); + view = GTK_TREE_VIEW (priv->treeview); model = gtk_tree_view_get_model (view); selection = gtk_tree_view_get_selection (view); gtk_tree_selection_unselect_all (selection); - gtk_widget_set_sensitive (dialog->button_add, FALSE); - gtk_widget_set_sensitive (dialog->button_remove, FALSE); - gtk_widget_hide (dialog->vbox_details); - gtk_widget_hide (dialog->frame_no_protocol); - gtk_widget_show (dialog->frame_new_account); + gtk_widget_set_sensitive (priv->button_add, FALSE); + gtk_widget_set_sensitive (priv->button_remove, FALSE); + gtk_widget_hide (priv->vbox_details); + gtk_widget_hide (priv->frame_no_protocol); + gtk_widget_show (priv->frame_new_account); /* If we have no account, no need of a back button */ if (gtk_tree_model_iter_n_children (model, NULL) > 0) { - gtk_widget_show (dialog->button_back); + gtk_widget_show (priv->button_back); } else { - gtk_widget_hide (dialog->button_back); + gtk_widget_hide (priv->button_back); } - accounts_dialog_protocol_changed_cb (dialog->radiobutton_register, dialog); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_reuse), + accounts_dialog_protocol_changed_cb (priv->radiobutton_register, dialog); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->radiobutton_reuse), TRUE); - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_protocol), 0); - gtk_widget_grab_focus (dialog->combobox_protocol); + gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox_protocol), 0); + gtk_widget_grab_focus (priv->combobox_protocol); } static void @@ -1063,6 +1105,7 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget *button, EmpathyAccount *account; GtkWidget *message_dialog; gint res; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); account = accounts_dialog_model_get_selected_account (dialog); @@ -1072,7 +1115,7 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget *button, return; } message_dialog = gtk_message_dialog_new - (GTK_WINDOW (dialog->window), + (GTK_WINDOW (priv->window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, @@ -1099,7 +1142,7 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget *button, res = gtk_dialog_run (GTK_DIALOG (message_dialog)); if (res == GTK_RESPONSE_YES) { - empathy_account_manager_remove (dialog->account_manager, account); + empathy_account_manager_remove (priv->account_manager, account); accounts_dialog_model_select_first (dialog); } gtk_widget_destroy (message_dialog); @@ -1111,7 +1154,9 @@ static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { - empathy_import_dialog_show (GTK_WINDOW (dialog->window), TRUE); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + empathy_import_dialog_show (GTK_WINDOW (priv->window), TRUE); } #endif @@ -1126,33 +1171,109 @@ accounts_dialog_response_cb (GtkWidget *widget, } static void -accounts_dialog_destroy_cb (GtkWidget *widget, - EmpathyAccountsDialog *dialog) +accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms, + GParamSpec *pspec, + EmpathyAccountsDialog *dialog) +{ + if (empathy_connection_managers_is_ready (cms)) { + accounts_dialog_update_settings (dialog, NULL); + } +} + +static void +accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) +{ + GtkBuilder *gui; + gchar *filename; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + filename = empathy_file_lookup ("empathy-accounts-dialog.ui", "src"); + + gui = empathy_builder_get_file (filename, + "accounts_dialog", &priv->window, + "vbox_details", &priv->vbox_details, + "frame_no_protocol", &priv->frame_no_protocol, + "alignment_settings", &priv->alignment_settings, + "treeview", &priv->treeview, + "frame_new_account", &priv->frame_new_account, + "hbox_type", &priv->hbox_type, + "button_create", &priv->button_create, + "button_back", &priv->button_back, + "radiobutton_reuse", &priv->radiobutton_reuse, + "radiobutton_register", &priv->radiobutton_register, + "image_type", &priv->image_type, + "label_name", &priv->label_name, + "button_add", &priv->button_add, + "button_remove", &priv->button_remove, + "button_import", &priv->button_import, + NULL); + g_free (filename); + + empathy_builder_connect (gui, dialog, + "accounts_dialog", "response", accounts_dialog_response_cb, + "button_create", "clicked", accounts_dialog_button_create_clicked_cb, + "button_back", "clicked", accounts_dialog_button_back_clicked_cb, + "button_add", "clicked", accounts_dialog_button_add_clicked_cb, + "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb, +#if 0 +/* FIXME MC-5 */ + "button_import", "clicked", accounts_dialog_button_import_clicked_cb, +#endif + "button_help", "clicked", accounts_dialog_button_help_clicked_cb, + NULL); + + g_object_unref (gui); + + priv->combobox_protocol = empathy_protocol_chooser_new (); + gtk_box_pack_end (GTK_BOX (priv->hbox_type), + priv->combobox_protocol, + TRUE, TRUE, 0); + gtk_widget_show (priv->combobox_protocol); + g_signal_connect (priv->combobox_protocol, "changed", + G_CALLBACK (accounts_dialog_protocol_changed_cb), + dialog); + + if (priv->parent_window) { + gtk_window_set_transient_for (GTK_WINDOW (priv->window), + priv->parent_window); + } +} + +static void +do_finalize (GObject *obj) +{ + +} + +static void +do_dispose (GObject *obj) { + EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (obj); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); GList *accounts, *l; /* Disconnect signals */ - g_signal_handlers_disconnect_by_func (dialog->account_manager, + g_signal_handlers_disconnect_by_func (priv->account_manager, accounts_dialog_account_added_cb, dialog); - g_signal_handlers_disconnect_by_func (dialog->account_manager, + g_signal_handlers_disconnect_by_func (priv->account_manager, accounts_dialog_account_removed_cb, dialog); - g_signal_handlers_disconnect_by_func (dialog->account_manager, + g_signal_handlers_disconnect_by_func (priv->account_manager, accounts_dialog_account_enabled_cb, dialog); - g_signal_handlers_disconnect_by_func (dialog->account_manager, + g_signal_handlers_disconnect_by_func (priv->account_manager, accounts_dialog_account_disabled_cb, dialog); - g_signal_handlers_disconnect_by_func (dialog->account_manager, + g_signal_handlers_disconnect_by_func (priv->account_manager, accounts_dialog_account_changed_cb, dialog); - g_signal_handlers_disconnect_by_func (dialog->account_manager, + g_signal_handlers_disconnect_by_func (priv->account_manager, accounts_dialog_connection_changed_cb, dialog); /* Delete incomplete accounts */ - accounts = empathy_account_manager_dup_accounts (dialog->account_manager); + accounts = empathy_account_manager_dup_accounts (priv->account_manager); for (l = accounts; l; l = l->next) { EmpathyAccount *account; @@ -1160,140 +1281,142 @@ accounts_dialog_destroy_cb (GtkWidget *widget, if (!empathy_account_is_valid (account)) { /* FIXME: Warn the user the account is not complete * and is going to be removed. */ - empathy_account_manager_remove (dialog->account_manager, account); + empathy_account_manager_remove (priv->account_manager, account); } g_object_unref (account); } g_list_free (accounts); - if (dialog->connecting_id) { - g_source_remove (dialog->connecting_id); + if (priv->connecting_id) { + g_source_remove (priv->connecting_id); } - g_object_unref (dialog->account_manager); - - g_free (dialog); + g_object_unref (priv->account_manager); } -GtkWidget * -empathy_accounts_dialog_show (GtkWindow *parent, - EmpathyAccount *selected_account) +static GObject * +do_constructor (GType type, + guint n_props, + GObjectConstructParam *props) { - static EmpathyAccountsDialog *dialog = NULL; - GtkBuilder *gui; - gchar *filename; - GList *accounts, *l; - gboolean import_asked; + GObject *retval; - if (dialog) { - gtk_window_present (GTK_WINDOW (dialog->window)); - return dialog->window; - } + if (dialog_singleton) { + retval = G_OBJECT (dialog_singleton); + } else { + retval = G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->constructor + (type, n_props, props); - dialog = g_new0 (EmpathyAccountsDialog, 1); + dialog_singleton = EMPATHY_ACCOUNTS_DIALOG (retval); + g_object_add_weak_pointer (retval, (gpointer) &dialog_singleton); + } - filename = empathy_file_lookup ("empathy-accounts-dialog.ui", - "src"); - gui = empathy_builder_get_file (filename, - "accounts_dialog", &dialog->window, - "vbox_details", &dialog->vbox_details, - "frame_no_protocol", &dialog->frame_no_protocol, - "alignment_settings", &dialog->alignment_settings, - "treeview", &dialog->treeview, - "frame_new_account", &dialog->frame_new_account, - "hbox_type", &dialog->hbox_type, - "button_create", &dialog->button_create, - "button_back", &dialog->button_back, - "radiobutton_reuse", &dialog->radiobutton_reuse, - "radiobutton_register", &dialog->radiobutton_register, - "image_type", &dialog->image_type, - "label_name", &dialog->label_name, - "button_add", &dialog->button_add, - "button_remove", &dialog->button_remove, - "button_import", &dialog->button_import, - NULL); - g_free (filename); + return retval; +} - empathy_builder_connect (gui, dialog, - "accounts_dialog", "destroy", accounts_dialog_destroy_cb, - "accounts_dialog", "response", accounts_dialog_response_cb, - "button_create", "clicked", accounts_dialog_button_create_clicked_cb, - "button_back", "clicked", accounts_dialog_button_back_clicked_cb, - "button_add", "clicked", accounts_dialog_button_add_clicked_cb, - "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb, -#if 0 -/* FIXME MC-5 */ - "button_import", "clicked", accounts_dialog_button_import_clicked_cb, -#endif - "button_help", "clicked", accounts_dialog_button_help_clicked_cb, - NULL); +static void +do_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + EmpathyAccountsDialogPriv *priv = GET_PRIV (object); + + switch (property_id) { + case PROP_PARENT: + g_value_set_object (value, priv->parent_window); + break; + case PROP_SELECTED_ACCOUNT: + g_value_set_object (value, priv->selected_account); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} - g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog); +static void +do_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + EmpathyAccountsDialogPriv *priv = GET_PRIV (object); + + switch (property_id) { + case PROP_PARENT: + priv->parent_window = g_value_get_object (value); + break; + case PROP_SELECTED_ACCOUNT: + priv->selected_account = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} - g_object_unref (gui); +static void +do_constructed (GObject *object) +{ + EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (object); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + GList *accounts, *l; + gboolean import_asked; - /* Create protocol chooser */ - dialog->combobox_protocol = empathy_protocol_chooser_new (); - gtk_box_pack_end (GTK_BOX (dialog->hbox_type), - dialog->combobox_protocol, - TRUE, TRUE, 0); - gtk_widget_show (dialog->combobox_protocol); - g_signal_connect (dialog->combobox_protocol, "changed", - G_CALLBACK (accounts_dialog_protocol_changed_cb), - dialog); + accounts_dialog_build_ui (dialog); /* Set up signalling */ - dialog->account_manager = empathy_account_manager_dup_singleton (); + priv->account_manager = empathy_account_manager_dup_singleton (); - g_signal_connect (dialog->account_manager, "account-created", + g_signal_connect (priv->account_manager, "account-created", G_CALLBACK (accounts_dialog_account_added_cb), dialog); - g_signal_connect (dialog->account_manager, "account-deleted", + g_signal_connect (priv->account_manager, "account-deleted", G_CALLBACK (accounts_dialog_account_removed_cb), dialog); - g_signal_connect (dialog->account_manager, "account-enabled", + g_signal_connect (priv->account_manager, "account-enabled", G_CALLBACK (accounts_dialog_account_enabled_cb), dialog); - g_signal_connect (dialog->account_manager, "account-disabled", + g_signal_connect (priv->account_manager, "account-disabled", G_CALLBACK (accounts_dialog_account_disabled_cb), dialog); - g_signal_connect (dialog->account_manager, "account-changed", + g_signal_connect (priv->account_manager, "account-changed", G_CALLBACK (accounts_dialog_account_changed_cb), dialog); - g_signal_connect (dialog->account_manager, "account-connection-changed", + g_signal_connect (priv->account_manager, "account-connection-changed", G_CALLBACK (accounts_dialog_connection_changed_cb), dialog); accounts_dialog_model_setup (dialog); /* Add existing accounts */ - accounts = empathy_account_manager_dup_accounts (dialog->account_manager); + accounts = empathy_account_manager_dup_accounts (priv->account_manager); for (l = accounts; l; l = l->next) { accounts_dialog_add_account (dialog, l->data); g_object_unref (l->data); } g_list_free (accounts); - if (selected_account) { + priv->cms = empathy_connection_managers_dup_singleton (); + if (!empathy_connection_managers_is_ready (priv->cms)) { + g_signal_connect (priv->cms, "notify::ready", + G_CALLBACK (accounts_dialog_cms_ready_cb), dialog); + } + + if (priv->selected_account) { GtkTreeSelection *selection; GtkTreeIter iter; - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->treeview)); - if (accounts_dialog_get_account_iter (dialog, selected_account, &iter)) { + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); + if (accounts_dialog_get_account_iter (dialog, priv->selected_account, &iter)) { gtk_tree_selection_select_iter (selection, &iter); } + + priv->selected_account = NULL; } else { accounts_dialog_model_select_first (dialog); } - if (parent) { - gtk_window_set_transient_for (GTK_WINDOW (dialog->window), - GTK_WINDOW (parent)); - } - - gtk_widget_show (dialog->window); - empathy_conf_get_bool (empathy_conf_get (), EMPATHY_PREFS_IMPORT_ASKED, &import_asked); @@ -1305,14 +1428,70 @@ empathy_accounts_dialog_show (GtkWindow *parent, if (!import_asked) { empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_IMPORT_ASKED, TRUE); - empathy_import_dialog_show (GTK_WINDOW (dialog->window), + empathy_import_dialog_show (GTK_WINDOW (priv->window), FALSE); } } else { - gtk_widget_set_sensitive (dialog->button_import, FALSE); + gtk_widget_set_sensitive (priv->button_import, FALSE); } #endif +} - return dialog->window; +static void +empathy_accounts_dialog_class_init (EmpathyAccountsDialogClass *klass) +{ + GObjectClass *oclass = G_OBJECT_CLASS (klass); + GParamSpec *param_spec; + + oclass->constructor = do_constructor; + oclass->finalize = do_finalize; + oclass->dispose = do_dispose; + oclass->constructed = do_constructed; + oclass->set_property = do_set_property; + oclass->get_property = do_get_property; + + param_spec = g_param_spec_object ("parent", + "parent", "The parent window", + GTK_TYPE_WINDOW, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (oclass, PROP_PARENT, param_spec); + + param_spec = g_param_spec_object ("selected-account", + "selected-account", "The account selected by default", + EMPATHY_TYPE_ACCOUNT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (oclass, PROP_SELECTED_ACCOUNT, param_spec); + + + g_type_class_add_private (klass, sizeof (EmpathyAccountsDialogPriv)); } +static void +empathy_accounts_dialog_init (EmpathyAccountsDialog *dialog) +{ + EmpathyAccountsDialogPriv *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE ((dialog), + EMPATHY_TYPE_ACCOUNTS_DIALOG, + EmpathyAccountsDialogPriv); + dialog->priv = priv; +} + +/* public methods */ + +GtkWidget * +empathy_accounts_dialog_show (GtkWindow *parent, + EmpathyAccount *selected_account) +{ + EmpathyAccountsDialog *dialog; + EmpathyAccountsDialogPriv *priv; + + dialog = g_object_new (EMPATHY_TYPE_ACCOUNTS_DIALOG, + "parent", parent, "selected-account", selected_account, NULL); + + priv = GET_PRIV (dialog); + + gtk_window_present (GTK_WINDOW (priv->window)); + + return priv->window; +} diff --git a/src/empathy-accounts-dialog.h b/src/empathy-accounts-dialog.h index 11e237c8f..aa8f7c06b 100644 --- a/src/empathy-accounts-dialog.h +++ b/src/empathy-accounts-dialog.h @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright (C) 2005-2007 Imendio AB * Copyright (C) 2007-2008 Collabora Ltd. @@ -31,8 +30,32 @@ G_BEGIN_DECLS +#define EMPATHY_TYPE_ACCOUNTS_DIALOG empathy_accounts_dialog_get_type() +#define EMPATHY_ACCOUNTS_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_ACCOUNTS_DIALOG, EmpathyAccountsDialog)) +#define EMPATHY_ACCOUNTS_DIALOG_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_ACCOUNTS_DIALOG, EmpathyAccountsDialogClass)) +#define EMPATHY_IS_ACCOUNTS_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_ACCOUNTS_DIALOG)) +#define EMPATHY_IS_ACCOUNTS_DIALOG_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_ACCOUNTS_DIALOG)) +#define EMPATHY_ACCOUNTS_DIALOG_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNTS_DIALOG, EmpathyAccountsDialogClass)) + +typedef struct { + GObject parent; + + /* private */ + gpointer priv; +} EmpathyAccountsDialog; + +typedef struct { + GObjectClass parent_class; +} EmpathyAccountsDialogClass; + +GType empathy_accounts_dialog_get_type (void); GtkWidget *empathy_accounts_dialog_show (GtkWindow *parent, - EmpathyAccount *selected_account); + EmpathyAccount *selected_account); G_END_DECLS -- cgit v1.2.3 From 43208e2ee8fe2371d0562f37d817173857a91268 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 23 Jul 2009 16:21:12 +0200 Subject: Move some code off dispose --- src/empathy-accounts-dialog.c | 49 +++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index bad15b974..f2b433618 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1165,7 +1165,29 @@ accounts_dialog_response_cb (GtkWidget *widget, gint response, EmpathyAccountsDialog *dialog) { + GList *accounts, *l; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + if (response == GTK_RESPONSE_CLOSE) { + /* Delete incomplete accounts */ + accounts = empathy_account_manager_dup_accounts + (priv->account_manager); + for (l = accounts; l; l = l->next) { + EmpathyAccount *account; + + account = l->data; + if (!empathy_account_is_valid (account)) { + /* FIXME: Warn the user the account is not + * complete and is going to be removed. + */ + empathy_account_manager_remove + (priv->account_manager, account); + } + + g_object_unref (account); + } + g_list_free (accounts); + gtk_widget_destroy (widget); } } @@ -1250,7 +1272,6 @@ do_dispose (GObject *obj) { EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (obj); EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - GList *accounts, *l; /* Disconnect signals */ g_signal_handlers_disconnect_by_func (priv->account_manager, @@ -1272,27 +1293,19 @@ do_dispose (GObject *obj) accounts_dialog_connection_changed_cb, dialog); - /* Delete incomplete accounts */ - accounts = empathy_account_manager_dup_accounts (priv->account_manager); - for (l = accounts; l; l = l->next) { - EmpathyAccount *account; - - account = l->data; - if (!empathy_account_is_valid (account)) { - /* FIXME: Warn the user the account is not complete - * and is going to be removed. */ - empathy_account_manager_remove (priv->account_manager, account); - } - - g_object_unref (account); - } - g_list_free (accounts); - if (priv->connecting_id) { g_source_remove (priv->connecting_id); } - g_object_unref (priv->account_manager); + if (priv->account_manager != NULL) { + g_object_unref (priv->account_manager); + priv->account_manager = NULL; + } + + if (priv->cms != NULL) { + g_object_unref (priv->cms); + priv->cms = NULL; + } } static GObject * -- cgit v1.2.3 From 5a729c2ae7018c491216eedc93129fa483cab181 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 23 Jul 2009 16:22:38 +0200 Subject: Chain up dispose and remove useless finalize --- src/empathy-accounts-dialog.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index f2b433618..68f140ff5 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1261,12 +1261,6 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) } } -static void -do_finalize (GObject *obj) -{ - -} - static void do_dispose (GObject *obj) { @@ -1306,6 +1300,8 @@ do_dispose (GObject *obj) g_object_unref (priv->cms); priv->cms = NULL; } + + G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->dispose (obj); } static GObject * @@ -1457,7 +1453,6 @@ empathy_accounts_dialog_class_init (EmpathyAccountsDialogClass *klass) GParamSpec *param_spec; oclass->constructor = do_constructor; - oclass->finalize = do_finalize; oclass->dispose = do_dispose; oclass->constructed = do_constructed; oclass->set_property = do_set_property; -- cgit v1.2.3 From d5c41662829057e80268b6771fbe7452aa36a814 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 23 Jul 2009 16:27:36 +0200 Subject: Unref the dialog when destroying --- src/empathy-accounts-dialog.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 68f140ff5..6ac9eb352 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1192,6 +1192,15 @@ accounts_dialog_response_cb (GtkWidget *widget, } } +static void +accounts_dialog_destroy_cb (GtkObject *obj, + EmpathyAccountsDialog *dialog) +{ + DEBUG ("%p", obj); + + g_object_unref (dialog); +} + static void accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms, GParamSpec *pspec, @@ -1233,6 +1242,7 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) empathy_builder_connect (gui, dialog, "accounts_dialog", "response", accounts_dialog_response_cb, + "accounts_dialog", "destroy", accounts_dialog_destroy_cb, "button_create", "clicked", accounts_dialog_button_create_clicked_cb, "button_back", "clicked", accounts_dialog_button_back_clicked_cb, "button_add", "clicked", accounts_dialog_button_add_clicked_cb, -- cgit v1.2.3 From 113d262b56effb7927d310ca90db3da5840e2dc9 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 23 Jul 2009 19:23:27 +0200 Subject: Make remove work --- src/empathy-accounts-dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 6ac9eb352..3b5386606 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1142,7 +1142,7 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget *button, res = gtk_dialog_run (GTK_DIALOG (message_dialog)); if (res == GTK_RESPONSE_YES) { - empathy_account_manager_remove (priv->account_manager, account); + accounts_dialog_model_remove_selected (dialog); accounts_dialog_model_select_first (dialog); } gtk_widget_destroy (message_dialog); -- cgit v1.2.3 From 6d59456848be4257df0724a610ef224d8c1d2e84 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 24 Jul 2009 21:24:38 +0200 Subject: Make sure the account dialog respects the initial selection --- src/empathy-accounts-dialog.c | 64 +++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 3b5386606..a9a5e7f63 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -96,8 +96,8 @@ typedef struct { EmpathyAccountManager *account_manager; EmpathyConnectionManagers *cms; - EmpathyAccount *selected_account; GtkWindow *parent_window; + EmpathyAccount *initial_selection; } EmpathyAccountsDialogPriv; enum { @@ -110,8 +110,7 @@ enum { }; enum { - PROP_SELECTED_ACCOUNT = 1, - PROP_PARENT + PROP_PARENT = 1 }; static void accounts_dialog_update (EmpathyAccountsDialog *dialog, @@ -1201,13 +1200,34 @@ accounts_dialog_destroy_cb (GtkObject *obj, g_object_unref (dialog); } +static void +accounts_dialog_set_selected_account (EmpathyAccountsDialog *dialog, + EmpathyAccount *account) +{ + GtkTreeSelection *selection; + GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); + if (accounts_dialog_get_account_iter (dialog, account, &iter)) { + gtk_tree_selection_select_iter (selection, &iter); + } +} + static void accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms, GParamSpec *pspec, EmpathyAccountsDialog *dialog) { + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + if (empathy_connection_managers_is_ready (cms)) { accounts_dialog_update_settings (dialog, NULL); + + if (priv->initial_selection != NULL) { + accounts_dialog_set_selected_account (dialog, priv->initial_selection); + priv->initial_selection = NULL; + } } } @@ -1346,9 +1366,6 @@ do_get_property (GObject *object, case PROP_PARENT: g_value_set_object (value, priv->parent_window); break; - case PROP_SELECTED_ACCOUNT: - g_value_set_object (value, priv->selected_account); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -1366,9 +1383,6 @@ do_set_property (GObject *object, case PROP_PARENT: priv->parent_window = g_value_get_object (value); break; - case PROP_SELECTED_ACCOUNT: - priv->selected_account = g_value_get_object (value); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -1422,19 +1436,7 @@ do_constructed (GObject *object) G_CALLBACK (accounts_dialog_cms_ready_cb), dialog); } - if (priv->selected_account) { - GtkTreeSelection *selection; - GtkTreeIter iter; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); - if (accounts_dialog_get_account_iter (dialog, priv->selected_account, &iter)) { - gtk_tree_selection_select_iter (selection, &iter); - } - - priv->selected_account = NULL; - } else { - accounts_dialog_model_select_first (dialog); - } + accounts_dialog_model_select_first (dialog); empathy_conf_get_bool (empathy_conf_get (), EMPATHY_PREFS_IMPORT_ASKED, &import_asked); @@ -1474,13 +1476,6 @@ empathy_accounts_dialog_class_init (EmpathyAccountsDialogClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); g_object_class_install_property (oclass, PROP_PARENT, param_spec); - param_spec = g_param_spec_object ("selected-account", - "selected-account", "The account selected by default", - EMPATHY_TYPE_ACCOUNT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (oclass, PROP_SELECTED_ACCOUNT, param_spec); - - g_type_class_add_private (klass, sizeof (EmpathyAccountsDialogPriv)); } @@ -1505,10 +1500,19 @@ empathy_accounts_dialog_show (GtkWindow *parent, EmpathyAccountsDialogPriv *priv; dialog = g_object_new (EMPATHY_TYPE_ACCOUNTS_DIALOG, - "parent", parent, "selected-account", selected_account, NULL); + "parent", parent, NULL); priv = GET_PRIV (dialog); + if (selected_account && empathy_connection_managers_is_ready (priv->cms)) { + accounts_dialog_set_selected_account (dialog, selected_account); + } else { + /* save the selection to set it later when the cms + * becomes ready. + */ + priv->initial_selection = selected_account; + } + gtk_window_present (GTK_WINDOW (priv->window)); return priv->window; -- cgit v1.2.3 From 7823b045d9b6a00102a44b40943d7d2188412521 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 25 Jul 2009 16:45:01 +0200 Subject: Use the new API when getting the account iter. --- src/empathy-accounts-dialog.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index a9a5e7f63..f358be8b4 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -613,15 +613,16 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, for (ok = gtk_tree_model_get_iter_first (model, iter); ok; ok = gtk_tree_model_iter_next (model, iter)) { - EmpathyAccount *this_account; + EmpathyAccountSettings *settings; gboolean equal; gtk_tree_model_get (model, iter, - COL_ACCOUNT_POINTER, &this_account, + COL_ACCOUNT_SETTINGS_POINTER, &settings, -1); - equal = (this_account == account); - g_object_unref (this_account); + equal = empathy_account_settings_owns_account + (settings, account); + g_object_unref (settings); if (equal) { return TRUE; @@ -777,7 +778,9 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, name = empathy_account_get_display_name (account); enabled = empathy_account_is_enabled (account); - gtk_list_store_append (GTK_LIST_STORE (model), &iter); + if (!accounts_dialog_get_account_iter (dialog, account, &iter)) { + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + } settings = empathy_account_settings_new_for_account (account); -- cgit v1.2.3 From ab51e3524e667dce95c9b792a9cd051f4070d668 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 25 Jul 2009 17:23:38 +0200 Subject: Use the right property name when getting the connection status. --- src/empathy-accounts-dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index f358be8b4..35acf69e8 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -774,7 +774,7 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - g_object_get (account, "status", &status, NULL); + g_object_get (account, "connection-status", &status, NULL); name = empathy_account_get_display_name (account); enabled = empathy_account_is_enabled (account); -- cgit v1.2.3 From 0613221d61c564e4931cf3f62cc95109e71f4c6c Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 25 Jul 2009 18:20:40 +0200 Subject: Adapt to the current telepathy style --- src/empathy-accounts-dialog.c | 2318 ++++++++++++++++++++--------------------- 1 file changed, 1146 insertions(+), 1172 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 35acf69e8..339c53b96 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -37,6 +37,7 @@ #include #include #include + #include #include #include @@ -61,125 +62,79 @@ G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, G_TYPE_OBJECT); static EmpathyAccountsDialog *dialog_singleton = NULL; typedef struct { - GtkWidget *window; + GtkWidget *window; - GtkWidget *alignment_settings; + GtkWidget *alignment_settings; - GtkWidget *vbox_details; - GtkWidget *frame_no_protocol; + GtkWidget *vbox_details; + GtkWidget *frame_no_protocol; - GtkWidget *treeview; + GtkWidget *treeview; - GtkWidget *button_add; - GtkWidget *button_remove; - GtkWidget *button_import; + GtkWidget *button_add; + GtkWidget *button_remove; + GtkWidget *button_import; - GtkWidget *frame_new_account; - GtkWidget *combobox_protocol; - GtkWidget *hbox_type; - GtkWidget *button_create; - GtkWidget *button_back; - GtkWidget *radiobutton_reuse; - GtkWidget *radiobutton_register; + GtkWidget *frame_new_account; + GtkWidget *combobox_protocol; + GtkWidget *hbox_type; + GtkWidget *button_create; + GtkWidget *button_back; + GtkWidget *radiobutton_reuse; + GtkWidget *radiobutton_register; - GtkWidget *image_type; - GtkWidget *label_name; - GtkWidget *label_type; - GtkWidget *settings_widget; + GtkWidget *image_type; + GtkWidget *label_name; + GtkWidget *label_type; + GtkWidget *settings_widget; - gboolean connecting_show; - guint connecting_id; + gboolean connecting_show; + guint connecting_id; - gulong settings_ready_id; - EmpathyAccountSettings *settings_ready; + gulong settings_ready_id; + EmpathyAccountSettings *settings_ready; - EmpathyAccountManager *account_manager; - EmpathyConnectionManagers *cms; + EmpathyAccountManager *account_manager; + EmpathyConnectionManagers *cms; - GtkWindow *parent_window; - EmpathyAccount *initial_selection; + GtkWindow *parent_window; + EmpathyAccount *initial_selection; } EmpathyAccountsDialogPriv; enum { - COL_ENABLED, - COL_NAME, - COL_STATUS, - COL_ACCOUNT_POINTER, - COL_ACCOUNT_SETTINGS_POINTER, - COL_COUNT + COL_ENABLED, + COL_NAME, + COL_STATUS, + COL_ACCOUNT_POINTER, + COL_ACCOUNT_SETTINGS_POINTER, + COL_COUNT }; enum { - PROP_PARENT = 1 + PROP_PARENT = 1 }; -static void accounts_dialog_update (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings); -static void accounts_dialog_model_setup (EmpathyAccountsDialog *dialog); -static void accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog); -static void accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer, - GtkCellEditable *editable, - gchar *path, - EmpathyAccountsDialog *dialog); -static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog); -static void accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyAccountsDialog *dialog); -static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings); -static gboolean accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog); -static void accounts_dialog_model_selection_changed (GtkTreeSelection *selection, - EmpathyAccountsDialog *dialog); -static void accounts_dialog_account_added_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - EmpathyAccountsDialog *dialog); -static void accounts_dialog_account_removed_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - EmpathyAccountsDialog *dialog); -static gboolean accounts_dialog_row_changed_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data); -static gboolean accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog); -static void accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - TpConnectionStatusReason reason, - TpConnectionStatus current, - TpConnectionStatus previous, - EmpathyAccountsDialog *dialog); -static void accounts_dialog_button_create_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog); -static void accounts_dialog_button_back_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog); -static void accounts_dialog_button_add_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog); -static void accounts_dialog_button_help_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog); -static void accounts_dialog_button_remove_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog); +static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings); + #if 0 /* FIXME MC-5 */ static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog); + EmpathyAccountsDialog *dialog); #endif -static void accounts_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathyAccountsDialog *dialog); static void accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings) + EmpathyAccountSettings *settings) { - gchar *text; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + gchar *text; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - text = g_markup_printf_escaped ("%s", - empathy_account_settings_get_display_name (settings)); - gtk_label_set_markup (GTK_LABEL (priv->label_name), text); + text = g_markup_printf_escaped ("%s", + empathy_account_settings_get_display_name (settings)); + gtk_label_set_markup (GTK_LABEL (priv->label_name), text); - g_free (text); + g_free (text); } typedef GtkWidget *CreateWidget (EmpathyAccountSettings *); @@ -187,1336 +142,1355 @@ typedef GtkWidget *CreateWidget (EmpathyAccountSettings *); static GtkWidget * get_account_setup_widget (EmpathyAccountSettings *settings) { - const gchar *cm = empathy_account_settings_get_cm (settings); - const gchar *proto = empathy_account_settings_get_protocol (settings); - struct { - const gchar *cm; - const gchar *proto; - CreateWidget *cb; - } dialogs[] = { - { "gabble", "jabber", empathy_account_widget_jabber_new}, - { "butterfly", "msn", empathy_account_widget_msn_new}, - { "salut", "local-xmpp", empathy_account_widget_salut_new}, - { "idle", "irc", empathy_account_widget_irc_new}, - { "haze", "icq", empathy_account_widget_icq_new}, - { "haze", "aim", empathy_account_widget_aim_new}, - { "haze", "yahoo", empathy_account_widget_yahoo_new}, - { "haze", "groupwise", empathy_account_widget_groupwise_new}, - { "sofiasip", "sip", empathy_account_widget_sip_new}, - { NULL, NULL, NULL } - }; - int i; - - for (i = 0; dialogs[i].cm != NULL; i++) { - if (!tp_strdiff (cm, dialogs[i].cm) - && !tp_strdiff (proto, dialogs[i].proto)) - return dialogs[i].cb (settings); - } - - return empathy_account_widget_generic_new (settings); + const gchar *cm = empathy_account_settings_get_cm (settings); + const gchar *proto = empathy_account_settings_get_protocol (settings); + struct { + const gchar *cm; + const gchar *proto; + CreateWidget *cb; + } dialogs[] = { + { "gabble", "jabber", empathy_account_widget_jabber_new}, + { "butterfly", "msn", empathy_account_widget_msn_new}, + { "salut", "local-xmpp", empathy_account_widget_salut_new}, + { "idle", "irc", empathy_account_widget_irc_new}, + { "haze", "icq", empathy_account_widget_icq_new}, + { "haze", "aim", empathy_account_widget_aim_new}, + { "haze", "yahoo", empathy_account_widget_yahoo_new}, + { "haze", "groupwise", empathy_account_widget_groupwise_new}, + { "sofiasip", "sip", empathy_account_widget_sip_new}, + { NULL, NULL, NULL } + }; + int i; + + for (i = 0; dialogs[i].cm != NULL; i++) + { + if (!tp_strdiff (cm, dialogs[i].cm) + && !tp_strdiff (proto, dialogs[i].proto)) + return dialogs[i].cb (settings); + } + + return empathy_account_widget_generic_new (settings); } static void account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings) + EmpathyAccountSettings *settings) { - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - priv->settings_widget = get_account_setup_widget (settings); + priv->settings_widget = get_account_setup_widget (settings); - gtk_container_add (GTK_CONTAINER (priv->alignment_settings), - priv->settings_widget); - gtk_widget_show (priv->settings_widget); + gtk_container_add (GTK_CONTAINER (priv->alignment_settings), + priv->settings_widget); + gtk_widget_show (priv->settings_widget); - gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_type), - empathy_account_settings_get_icon_name (settings), - GTK_ICON_SIZE_DIALOG); - gtk_widget_set_tooltip_text (priv->image_type, - empathy_account_settings_get_protocol (settings)); + gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_type), + empathy_account_settings_get_icon_name (settings), + GTK_ICON_SIZE_DIALOG); + gtk_widget_set_tooltip_text (priv->image_type, + empathy_account_settings_get_protocol (settings)); - accounts_dialog_update_name_label (dialog, settings); + accounts_dialog_update_name_label (dialog, settings); } static void account_dialog_settings_ready_cb (EmpathyAccountSettings *settings, - GParamSpec *spec, EmpathyAccountsDialog *dialog) + GParamSpec *spec, + EmpathyAccountsDialog *dialog) { - if (empathy_account_settings_is_ready (settings)) - account_dialog_create_settings_widget (dialog, settings); + if (empathy_account_settings_is_ready (settings)) + account_dialog_create_settings_widget (dialog, settings); } static void -accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings) +accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog) { - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - if (priv->settings_ready != NULL) { - g_signal_handler_disconnect (priv->settings_ready, - priv->settings_ready_id); - priv->settings_ready = NULL; - priv->settings_ready_id = 0; - } - - if (!settings) { - GtkTreeView *view; - GtkTreeModel *model; - - view = GTK_TREE_VIEW (priv->treeview); - model = gtk_tree_view_get_model (view); - - if (gtk_tree_model_iter_n_children (model, NULL) > 0) { - /* We have configured accounts, select the first one */ - accounts_dialog_model_select_first (dialog); - return; - } - if (empathy_connection_managers_get_cms_num (priv->cms) > 0) { - /* We have no account configured but we have some - * profiles instsalled. The user obviously wants to add - * an account. Click on the Add button for him. */ - accounts_dialog_button_add_clicked_cb (priv->button_add, - dialog); - return; - } - - /* No account and no profile, warn the user */ - gtk_widget_hide (priv->vbox_details); - gtk_widget_hide (priv->frame_new_account); - gtk_widget_show (priv->frame_no_protocol); - gtk_widget_set_sensitive (priv->button_add, FALSE); - gtk_widget_set_sensitive (priv->button_remove, FALSE); - return; - } - - /* We have an account selected, destroy old settings and create a new - * one for the account selected */ - gtk_widget_hide (priv->frame_new_account); - gtk_widget_hide (priv->frame_no_protocol); - gtk_widget_show (priv->vbox_details); - gtk_widget_set_sensitive (priv->button_add, TRUE); - gtk_widget_set_sensitive (priv->button_remove, TRUE); - - if (priv->settings_widget) { - gtk_widget_destroy (priv->settings_widget); - priv->settings_widget = NULL; - } - - if (empathy_account_settings_is_ready (settings)) - { - account_dialog_create_settings_widget (dialog, settings); - } - else - { - priv->settings_ready = settings; - priv->settings_ready_id = - g_signal_connect (settings, "notify::ready", - G_CALLBACK (account_dialog_settings_ready_cb), dialog); - } - + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + /* select first */ + view = GTK_TREE_VIEW (priv->treeview); + model = gtk_tree_view_get_model (view); + + if (gtk_tree_model_get_iter_first (model, &iter)) + { + selection = gtk_tree_view_get_selection (view); + gtk_tree_selection_select_iter (selection, &iter); + } + else + { + accounts_dialog_update_settings (dialog, NULL); + } } static void -accounts_dialog_model_setup (EmpathyAccountsDialog *dialog) +accounts_dialog_protocol_changed_cb (GtkWidget *widget, + EmpathyAccountsDialog *dialog) { - GtkListStore *store; - GtkTreeSelection *selection; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - store = gtk_list_store_new (COL_COUNT, - G_TYPE_BOOLEAN, /* enabled */ - G_TYPE_STRING, /* name */ - G_TYPE_UINT, /* status */ - EMPATHY_TYPE_ACCOUNT, /* account */ - EMPATHY_TYPE_ACCOUNT_SETTINGS); /* settings */ - - gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), - GTK_TREE_MODEL (store)); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - g_signal_connect (selection, "changed", - G_CALLBACK (accounts_dialog_model_selection_changed), - dialog); - - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - COL_NAME, GTK_SORT_ASCENDING); - - accounts_dialog_model_add_columns (dialog); - - g_object_unref (store); + TpConnectionManager *cm; + TpConnectionManagerProtocol *proto; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + cm = empathy_protocol_chooser_dup_selected ( + EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto); + + if (tp_connection_manager_protocol_can_register (proto)) + { + gtk_widget_show (priv->radiobutton_register); + gtk_widget_show (priv->radiobutton_reuse); + } + else + { + gtk_widget_hide (priv->radiobutton_register); + gtk_widget_hide (priv->radiobutton_reuse); + } + g_object_unref (cm); } static void -accounts_dialog_name_edited_cb (GtkCellRendererText *renderer, - gchar *path, - gchar *new_text, - EmpathyAccountsDialog *dialog) +accounts_dialog_button_add_clicked_cb (GtkWidget *button, + EmpathyAccountsDialog *dialog) { - EmpathyAccountSettings *settings; - GtkTreeModel *model; - GtkTreePath *treepath; - GtkTreeIter iter; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - if (empathy_account_manager_get_connecting_accounts (priv->account_manager) > 0) { - priv->connecting_id = g_timeout_add (FLASH_TIMEOUT, - (GSourceFunc) accounts_dialog_flash_connecting_cb, - dialog); - } - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - treepath = gtk_tree_path_new_from_string (path); - gtk_tree_model_get_iter (model, &iter, treepath); - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_SETTINGS_POINTER, &settings, - -1); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_NAME, new_text, - -1); - gtk_tree_path_free (treepath); - - empathy_account_settings_set_display_name_async (settings, new_text, - NULL, NULL); - g_object_unref (settings); + GtkTreeView *view; + GtkTreeSelection *selection; + GtkTreeModel *model; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + view = GTK_TREE_VIEW (priv->treeview); + model = gtk_tree_view_get_model (view); + selection = gtk_tree_view_get_selection (view); + gtk_tree_selection_unselect_all (selection); + + gtk_widget_set_sensitive (priv->button_add, FALSE); + gtk_widget_set_sensitive (priv->button_remove, FALSE); + gtk_widget_hide (priv->vbox_details); + gtk_widget_hide (priv->frame_no_protocol); + gtk_widget_show (priv->frame_new_account); + + /* If we have no account, no need of a back button */ + if (gtk_tree_model_iter_n_children (model, NULL) > 0) + gtk_widget_show (priv->button_back); + else + gtk_widget_hide (priv->button_back); + + accounts_dialog_protocol_changed_cb (priv->radiobutton_register, dialog); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->radiobutton_reuse), + TRUE); + gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox_protocol), 0); + gtk_widget_grab_focus (priv->combobox_protocol); } static void -accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer, - gchar *path, - EmpathyAccountsDialog *dialog) +accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings) { - EmpathyAccount *account; - GtkTreeModel *model; - GtkTreePath *treepath; - GtkTreeIter iter; - gboolean enabled; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - treepath = gtk_tree_path_new_from_string (path); - gtk_tree_model_get_iter (model, &iter, treepath); - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_POINTER, &account, - -1); - gtk_tree_path_free (treepath); - - if (account == NULL) - return; - - enabled = empathy_account_is_enabled (account); - empathy_account_set_enabled (account, !enabled); - - DEBUG ("%s account %s", enabled ? "Disabled" : "Enable", - empathy_account_get_display_name (account)); - - g_object_unref (account); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + if (priv->settings_ready != NULL) + { + g_signal_handler_disconnect (priv->settings_ready, + priv->settings_ready_id); + priv->settings_ready = NULL; + priv->settings_ready_id = 0; + } + + if (!settings) + { + GtkTreeView *view; + GtkTreeModel *model; + + view = GTK_TREE_VIEW (priv->treeview); + model = gtk_tree_view_get_model (view); + + if (gtk_tree_model_iter_n_children (model, NULL) > 0) + { + /* We have configured accounts, select the first one */ + accounts_dialog_model_select_first (dialog); + return; + } + if (empathy_connection_managers_get_cms_num (priv->cms) > 0) + { + /* We have no account configured but we have some + * profiles instsalled. The user obviously wants to add + * an account. Click on the Add button for him. */ + accounts_dialog_button_add_clicked_cb (priv->button_add, + dialog); + return; + } + + /* No account and no profile, warn the user */ + gtk_widget_hide (priv->vbox_details); + gtk_widget_hide (priv->frame_new_account); + gtk_widget_show (priv->frame_no_protocol); + gtk_widget_set_sensitive (priv->button_add, FALSE); + gtk_widget_set_sensitive (priv->button_remove, FALSE); + return; + } + + /* We have an account selected, destroy old settings and create a new + * one for the account selected */ + gtk_widget_hide (priv->frame_new_account); + gtk_widget_hide (priv->frame_no_protocol); + gtk_widget_show (priv->vbox_details); + gtk_widget_set_sensitive (priv->button_add, TRUE); + gtk_widget_set_sensitive (priv->button_remove, TRUE); + + if (priv->settings_widget) + { + gtk_widget_destroy (priv->settings_widget); + priv->settings_widget = NULL; + } + + if (empathy_account_settings_is_ready (settings)) + { + account_dialog_create_settings_widget (dialog, settings); + } + else + { + priv->settings_ready = settings; + priv->settings_ready_id = + g_signal_connect (settings, "notify::ready", + G_CALLBACK (account_dialog_settings_ready_cb), dialog); + } + } static void -accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer, - GtkCellEditable *editable, - gchar *path, - EmpathyAccountsDialog *dialog) +accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer, + GtkCellEditable *editable, + gchar *path, + EmpathyAccountsDialog *dialog) { - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - if (priv->connecting_id) { - g_source_remove (priv->connecting_id); - } - DEBUG ("Editing account name started; stopping flashing"); + if (priv->connecting_id) + g_source_remove (priv->connecting_id); + + DEBUG ("Editing account name started; stopping flashing"); } static void -accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) +accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + EmpathyAccountsDialog *dialog) { - GtkTreeView *view; - GtkTreeViewColumn *column; - GtkCellRenderer *cell; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - view = GTK_TREE_VIEW (priv->treeview); - gtk_tree_view_set_headers_visible (view, TRUE); - - /* Enabled column */ - cell = gtk_cell_renderer_toggle_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - _("Enabled"), - cell, - "active", COL_ENABLED, - NULL); - g_signal_connect (cell, "toggled", - G_CALLBACK (accounts_dialog_enable_toggled_cb), - dialog); - - /* Account column */ - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Accounts")); - gtk_tree_view_column_set_expand (column, TRUE); - gtk_tree_view_append_column (view, column); - - /* Icon renderer */ - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, cell, FALSE); - gtk_tree_view_column_set_cell_data_func (column, cell, - (GtkTreeCellDataFunc) - accounts_dialog_model_pixbuf_data_func, - dialog, - NULL); - - /* Name renderer */ - cell = gtk_cell_renderer_text_new (); - g_object_set (cell, - "ellipsize", PANGO_ELLIPSIZE_END, - "width-chars", 25, - "editable", TRUE, - NULL); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME); - g_signal_connect (cell, "edited", - G_CALLBACK (accounts_dialog_name_edited_cb), - dialog); - g_signal_connect (cell, "editing-started", - G_CALLBACK (accounts_dialog_name_editing_started_cb), - dialog); + EmpathyAccountSettings *settings; + const gchar *icon_name; + GdkPixbuf *pixbuf; + TpConnectionStatus status; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + gtk_tree_model_get (model, iter, + COL_STATUS, &status, + COL_ACCOUNT_SETTINGS_POINTER, &settings, + -1); + + icon_name = empathy_account_settings_get_icon_name (settings); + pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); + + if (pixbuf) + { + if (status == TP_CONNECTION_STATUS_DISCONNECTED || + (status == TP_CONNECTION_STATUS_CONNECTING && + !priv->connecting_show)) + { + GdkPixbuf *modded_pixbuf; + + modded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, + TRUE, + 8, + gdk_pixbuf_get_width (pixbuf), + gdk_pixbuf_get_height (pixbuf)); + + gdk_pixbuf_saturate_and_pixelate (pixbuf, + modded_pixbuf, + 1.0, + TRUE); + g_object_unref (pixbuf); + pixbuf = modded_pixbuf; + } + } + + g_object_set (cell, + "visible", TRUE, + "pixbuf", pixbuf, + NULL); + + g_object_unref (settings); + + if (pixbuf) + g_object_unref (pixbuf); } static void -accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog) +accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer, + gchar *path, + EmpathyAccountsDialog *dialog) { - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - /* select first */ - view = GTK_TREE_VIEW (priv->treeview); - model = gtk_tree_view_get_model (view); - - if (gtk_tree_model_get_iter_first (model, &iter)) { - selection = gtk_tree_view_get_selection (view); - gtk_tree_selection_select_iter (selection, &iter); - } else { - accounts_dialog_update_settings (dialog, NULL); - } + EmpathyAccount *account; + GtkTreeModel *model; + GtkTreePath *treepath; + GtkTreeIter iter; + gboolean enabled; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + treepath = gtk_tree_path_new_from_string (path); + gtk_tree_model_get_iter (model, &iter, treepath); + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_POINTER, &account, + -1); + gtk_tree_path_free (treepath); + + if (account == NULL) + return; + + enabled = empathy_account_is_enabled (account); + empathy_account_set_enabled (account, !enabled); + + DEBUG ("%s account %s", enabled ? "Disabled" : "Enable", + empathy_account_get_display_name (account)); + + g_object_unref (account); } -static void -accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyAccountsDialog *dialog) +static gboolean +accounts_dialog_row_changed_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data) { - EmpathyAccountSettings *settings; - const gchar *icon_name; - GdkPixbuf *pixbuf; - TpConnectionStatus status; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - gtk_tree_model_get (model, iter, - COL_STATUS, &status, - COL_ACCOUNT_SETTINGS_POINTER, &settings, - -1); - - icon_name = empathy_account_settings_get_icon_name (settings); - pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); - - if (pixbuf) { - if (status == TP_CONNECTION_STATUS_DISCONNECTED || - (status == TP_CONNECTION_STATUS_CONNECTING && - !priv->connecting_show)) { - GdkPixbuf *modded_pixbuf; - - modded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, - TRUE, - 8, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf)); - - gdk_pixbuf_saturate_and_pixelate (pixbuf, - modded_pixbuf, - 1.0, - TRUE); - g_object_unref (pixbuf); - pixbuf = modded_pixbuf; - } - } - - g_object_set (cell, - "visible", TRUE, - "pixbuf", pixbuf, - NULL); - - g_object_unref (settings); - if (pixbuf) { - g_object_unref (pixbuf); - } + gtk_tree_model_row_changed (model, path, iter); + + return FALSE; } static gboolean -accounts_dialog_get_settings_iter (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings, - GtkTreeIter *iter) +accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog) { - GtkTreeView *view; - GtkTreeSelection *selection; - GtkTreeModel *model; - gboolean ok; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - /* Update the status in the model */ - view = GTK_TREE_VIEW (priv->treeview); - selection = gtk_tree_view_get_selection (view); - model = gtk_tree_view_get_model (view); - - for (ok = gtk_tree_model_get_iter_first (model, iter); - ok; - ok = gtk_tree_model_iter_next (model, iter)) { - EmpathyAccountSettings *this_settings; - gboolean equal; - - gtk_tree_model_get (model, iter, - COL_ACCOUNT_SETTINGS_POINTER, &this_settings, - -1); - - equal = (this_settings == settings); - g_object_unref (this_settings); - - if (equal) { - return TRUE; - } - } - - return FALSE; + GtkTreeView *view; + GtkTreeModel *model; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + priv->connecting_show = !priv->connecting_show; + + view = GTK_TREE_VIEW (priv->treeview); + model = gtk_tree_view_get_model (view); + + gtk_tree_model_foreach (model, accounts_dialog_row_changed_foreach, NULL); + + return TRUE; } -static gboolean -accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, - EmpathyAccount *account, - GtkTreeIter *iter) +static void +accounts_dialog_name_edited_cb (GtkCellRendererText *renderer, + gchar *path, + gchar *new_text, + EmpathyAccountsDialog *dialog) { - GtkTreeView *view; - GtkTreeSelection *selection; - GtkTreeModel *model; - gboolean ok; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - /* Update the status in the model */ - view = GTK_TREE_VIEW (priv->treeview); - selection = gtk_tree_view_get_selection (view); - model = gtk_tree_view_get_model (view); - - for (ok = gtk_tree_model_get_iter_first (model, iter); - ok; - ok = gtk_tree_model_iter_next (model, iter)) { - EmpathyAccountSettings *settings; - gboolean equal; - - gtk_tree_model_get (model, iter, - COL_ACCOUNT_SETTINGS_POINTER, &settings, - -1); - - equal = empathy_account_settings_owns_account - (settings, account); - g_object_unref (settings); - - if (equal) { - return TRUE; - } - } - - return FALSE; + EmpathyAccountSettings *settings; + GtkTreeModel *model; + GtkTreePath *treepath; + GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + if (empathy_account_manager_get_connecting_accounts (priv->account_manager) > 0) + { + priv->connecting_id = g_timeout_add (FLASH_TIMEOUT, + (GSourceFunc) accounts_dialog_flash_connecting_cb, + dialog); + } + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + treepath = gtk_tree_path_new_from_string (path); + gtk_tree_model_get_iter (model, &iter, treepath); + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_SETTINGS_POINTER, &settings, + -1); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_NAME, new_text, + -1); + gtk_tree_path_free (treepath); + + empathy_account_settings_set_display_name_async (settings, new_text, + NULL, NULL); + g_object_unref (settings); +} + +static void +accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) +{ + GtkTreeView *view; + GtkTreeViewColumn *column; + GtkCellRenderer *cell; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + view = GTK_TREE_VIEW (priv->treeview); + gtk_tree_view_set_headers_visible (view, TRUE); + + /* Enabled column */ + cell = gtk_cell_renderer_toggle_new (); + gtk_tree_view_insert_column_with_attributes (view, -1, + _("Enabled"), + cell, + "active", COL_ENABLED, + NULL); + g_signal_connect (cell, "toggled", + G_CALLBACK (accounts_dialog_enable_toggled_cb), + dialog); + + /* Account column */ + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_title (column, _("Accounts")); + gtk_tree_view_column_set_expand (column, TRUE); + gtk_tree_view_append_column (view, column); + + /* Icon renderer */ + cell = gtk_cell_renderer_pixbuf_new (); + gtk_tree_view_column_pack_start (column, cell, FALSE); + gtk_tree_view_column_set_cell_data_func (column, cell, + (GtkTreeCellDataFunc) + accounts_dialog_model_pixbuf_data_func, + dialog, + NULL); + + /* Name renderer */ + cell = gtk_cell_renderer_text_new (); + g_object_set (cell, + "ellipsize", PANGO_ELLIPSIZE_END, + "width-chars", 25, + "editable", TRUE, + NULL); + gtk_tree_view_column_pack_start (column, cell, TRUE); + gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME); + g_signal_connect (cell, "edited", + G_CALLBACK (accounts_dialog_name_edited_cb), + dialog); + g_signal_connect (cell, "editing-started", + G_CALLBACK (accounts_dialog_name_editing_started_cb), + dialog); } static EmpathyAccountSettings * accounts_dialog_model_get_selected_settings (EmpathyAccountsDialog *dialog) { - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - EmpathyAccountSettings *settings; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + EmpathyAccountSettings *settings; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + view = GTK_TREE_VIEW (priv->treeview); + selection = gtk_tree_view_get_selection (view); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return NULL; + + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_SETTINGS_POINTER, &settings, -1); + + return settings; +} - view = GTK_TREE_VIEW (priv->treeview); - selection = gtk_tree_view_get_selection (view); +static void +accounts_dialog_model_selection_changed (GtkTreeSelection *selection, + EmpathyAccountsDialog *dialog) +{ + EmpathyAccountSettings *settings; + GtkTreeModel *model; + GtkTreeIter iter; + gboolean is_selection; - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { - return NULL; - } + is_selection = gtk_tree_selection_get_selected (selection, &model, &iter); - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_SETTINGS_POINTER, &settings, -1); + settings = accounts_dialog_model_get_selected_settings (dialog); + accounts_dialog_update_settings (dialog, settings); - return settings; + if (settings) + g_object_unref (settings); } - -static EmpathyAccount * -accounts_dialog_model_get_selected_account (EmpathyAccountsDialog *dialog) +static void +accounts_dialog_model_setup (EmpathyAccountsDialog *dialog) { - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - EmpathyAccount *account; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + GtkListStore *store; + GtkTreeSelection *selection; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + store = gtk_list_store_new (COL_COUNT, + G_TYPE_BOOLEAN, /* enabled */ + G_TYPE_STRING, /* name */ + G_TYPE_UINT, /* status */ + EMPATHY_TYPE_ACCOUNT, /* account */ + EMPATHY_TYPE_ACCOUNT_SETTINGS); /* settings */ + + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), + GTK_TREE_MODEL (store)); - view = GTK_TREE_VIEW (priv->treeview); - selection = gtk_tree_view_get_selection (view); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { - return NULL; - } + g_signal_connect (selection, "changed", + G_CALLBACK (accounts_dialog_model_selection_changed), + dialog); - gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), + COL_NAME, GTK_SORT_ASCENDING); - return account; + accounts_dialog_model_add_columns (dialog); + + g_object_unref (store); } -static void -accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings) +static gboolean +accounts_dialog_get_settings_iter (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings, + GtkTreeIter *iter) { - GtkTreeSelection *selection; - GtkTreeIter iter; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); - if (accounts_dialog_get_settings_iter (dialog, settings, &iter)) { - gtk_tree_selection_select_iter (selection, &iter); - } + GtkTreeView *view; + GtkTreeSelection *selection; + GtkTreeModel *model; + gboolean ok; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + /* Update the status in the model */ + view = GTK_TREE_VIEW (priv->treeview); + selection = gtk_tree_view_get_selection (view); + model = gtk_tree_view_get_model (view); + + for (ok = gtk_tree_model_get_iter_first (model, iter); + ok; + ok = gtk_tree_model_iter_next (model, iter)) + { + EmpathyAccountSettings *this_settings; + gboolean equal; + + gtk_tree_model_get (model, iter, + COL_ACCOUNT_SETTINGS_POINTER, &this_settings, + -1); + + equal = (this_settings == settings); + g_object_unref (this_settings); + + if (equal) + return TRUE; + } + + return FALSE; } static gboolean -accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog) +accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, + EmpathyAccount *account, + GtkTreeIter *iter) { - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - EmpathyAccount *account; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - view = GTK_TREE_VIEW (priv->treeview); - selection = gtk_tree_view_get_selection (view); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { - return FALSE; - } - - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_POINTER, &account, - -1); - - if (account != NULL) - empathy_account_remove_async (account, NULL, NULL); + GtkTreeView *view; + GtkTreeSelection *selection; + GtkTreeModel *model; + gboolean ok; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + /* Update the status in the model */ + view = GTK_TREE_VIEW (priv->treeview); + selection = gtk_tree_view_get_selection (view); + model = gtk_tree_view_get_model (view); + + for (ok = gtk_tree_model_get_iter_first (model, iter); + ok; + ok = gtk_tree_model_iter_next (model, iter)) + { + EmpathyAccountSettings *settings; + gboolean equal; + + gtk_tree_model_get (model, iter, + COL_ACCOUNT_SETTINGS_POINTER, &settings, + -1); + + equal = empathy_account_settings_owns_account + (settings, account); + g_object_unref (settings); + + if (equal) + return TRUE; + } + + return FALSE; +} - return gtk_list_store_remove (GTK_LIST_STORE (model), &iter); +static EmpathyAccount * +accounts_dialog_model_get_selected_account (EmpathyAccountsDialog *dialog) +{ + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + EmpathyAccount *account; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + view = GTK_TREE_VIEW (priv->treeview); + selection = gtk_tree_view_get_selection (view); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return NULL; + + gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); + + return account; } static void -accounts_dialog_model_selection_changed (GtkTreeSelection *selection, - EmpathyAccountsDialog *dialog) +accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings) { - EmpathyAccountSettings *settings; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean is_selection; - - is_selection = gtk_tree_selection_get_selected (selection, &model, &iter); + GtkTreeSelection *selection; + GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - settings = accounts_dialog_model_get_selected_settings (dialog); - accounts_dialog_update_settings (dialog, settings); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); + if (accounts_dialog_get_settings_iter (dialog, settings, &iter)) + gtk_tree_selection_select_iter (selection, &iter); +} - if (settings) { - g_object_unref (settings); - } +static gboolean +accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog) +{ + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + EmpathyAccount *account; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + view = GTK_TREE_VIEW (priv->treeview); + selection = gtk_tree_view_get_selection (view); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return FALSE; + + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_POINTER, &account, + -1); + + if (account != NULL) + empathy_account_remove_async (account, NULL, NULL); + + return gtk_list_store_remove (GTK_LIST_STORE (model), &iter); } static void accounts_dialog_add (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings) + EmpathyAccountSettings *settings) { - GtkTreeModel *model; - GtkTreeIter iter; - const gchar *name; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - name = empathy_account_settings_get_display_name (settings); - - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ENABLED, FALSE, - COL_NAME, name, - COL_STATUS, TP_CONNECTION_STATUS_DISCONNECTED, - COL_ACCOUNT_SETTINGS_POINTER, settings, - -1); + GtkTreeModel *model; + GtkTreeIter iter; + const gchar *name; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + name = empathy_account_settings_get_display_name (settings); + + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_ENABLED, FALSE, + COL_NAME, name, + COL_STATUS, TP_CONNECTION_STATUS_DISCONNECTED, + COL_ACCOUNT_SETTINGS_POINTER, settings, + -1); } +static void +accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager, + EmpathyAccount *account, + TpConnectionStatusReason reason, + TpConnectionStatus current, + TpConnectionStatus previous, + EmpathyAccountsDialog *dialog) +{ + GtkTreeModel *model; + GtkTreeIter iter; + gboolean found; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + /* Update the status in the model */ + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + + if (accounts_dialog_get_account_iter (dialog, account, &iter)) + { + GtkTreePath *path; + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_STATUS, current, + -1); + + path = gtk_tree_model_get_path (model, &iter); + gtk_tree_model_row_changed (model, path, &iter); + gtk_tree_path_free (path); + } + + found = (empathy_account_manager_get_connecting_accounts (manager) > 0); + + if (!found && priv->connecting_id) + { + g_source_remove (priv->connecting_id); + priv->connecting_id = 0; + } + + if (found && !priv->connecting_id) + priv->connecting_id = g_timeout_add (FLASH_TIMEOUT, + (GSourceFunc) accounts_dialog_flash_connecting_cb, + dialog); +} static void accounts_dialog_add_account (EmpathyAccountsDialog *dialog, - EmpathyAccount *account) + EmpathyAccount *account) { - EmpathyAccountSettings *settings; - GtkTreeModel *model; - GtkTreeIter iter; - TpConnectionStatus status; - const gchar *name; - gboolean enabled; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - g_object_get (account, "connection-status", &status, NULL); - name = empathy_account_get_display_name (account); - enabled = empathy_account_is_enabled (account); - - if (!accounts_dialog_get_account_iter (dialog, account, &iter)) { - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - } - - settings = empathy_account_settings_new_for_account (account); - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ENABLED, enabled, - COL_NAME, name, - COL_STATUS, status, - COL_ACCOUNT_POINTER, account, - COL_ACCOUNT_SETTINGS_POINTER, settings, - -1); - - accounts_dialog_connection_changed_cb (priv->account_manager, - account, - TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED, - status, - TP_CONNECTION_STATUS_DISCONNECTED, - dialog); - - g_object_unref (settings); + EmpathyAccountSettings *settings; + GtkTreeModel *model; + GtkTreeIter iter; + TpConnectionStatus status; + const gchar *name; + gboolean enabled; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + g_object_get (account, "connection-status", &status, NULL); + name = empathy_account_get_display_name (account); + enabled = empathy_account_is_enabled (account); + + if (!accounts_dialog_get_account_iter (dialog, account, &iter)) + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + + settings = empathy_account_settings_new_for_account (account); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_ENABLED, enabled, + COL_NAME, name, + COL_STATUS, status, + COL_ACCOUNT_POINTER, account, + COL_ACCOUNT_SETTINGS_POINTER, settings, + -1); + + accounts_dialog_connection_changed_cb (priv->account_manager, + account, + TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED, + status, + TP_CONNECTION_STATUS_DISCONNECTED, + dialog); + + g_object_unref (settings); } static void accounts_dialog_update (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings) + EmpathyAccountSettings *settings) { - GtkTreeModel *model; - GtkTreeIter iter; - TpConnectionStatus status = TP_CONNECTION_STATUS_DISCONNECTED; - const gchar *name; - gboolean enabled = FALSE; - EmpathyAccount *account; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - name = empathy_account_settings_get_display_name (settings); - - account = empathy_account_settings_get_account (settings); - if (account != NULL) - { - enabled = empathy_account_is_enabled (account); - g_object_get (account, "connection-status", &status, NULL); - } - - accounts_dialog_get_settings_iter (dialog, settings, &iter); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ENABLED, enabled, - COL_NAME, name, - COL_STATUS, status, - COL_ACCOUNT_POINTER, account, - COL_ACCOUNT_SETTINGS_POINTER, settings, - -1); + GtkTreeModel *model; + GtkTreeIter iter; + TpConnectionStatus status = TP_CONNECTION_STATUS_DISCONNECTED; + const gchar *name; + gboolean enabled = FALSE; + EmpathyAccount *account; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + name = empathy_account_settings_get_display_name (settings); + + account = empathy_account_settings_get_account (settings); + if (account != NULL) + { + enabled = empathy_account_is_enabled (account); + g_object_get (account, "connection-status", &status, NULL); + } + + accounts_dialog_get_settings_iter (dialog, settings, &iter); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_ENABLED, enabled, + COL_NAME, name, + COL_STATUS, status, + COL_ACCOUNT_POINTER, account, + COL_ACCOUNT_SETTINGS_POINTER, settings, + -1); } static void accounts_dialog_account_added_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - EmpathyAccountsDialog *dialog) + EmpathyAccount *account, + EmpathyAccountsDialog *dialog) { - accounts_dialog_add_account (dialog, account); + accounts_dialog_add_account (dialog, account); } static void accounts_dialog_account_removed_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - EmpathyAccountsDialog *dialog) + EmpathyAccount *account, + EmpathyAccountsDialog *dialog) { - GtkTreeIter iter; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - if (accounts_dialog_get_account_iter (dialog, account, &iter)) - gtk_list_store_remove (GTK_LIST_STORE ( - gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter); + if (accounts_dialog_get_account_iter (dialog, account, &iter)) + gtk_list_store_remove (GTK_LIST_STORE ( + gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter); } -static gboolean -accounts_dialog_row_changed_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - gtk_tree_model_row_changed (model, path, iter); - - return FALSE; -} - -static gboolean -accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog) +static void +enable_or_disable_account (EmpathyAccountsDialog *dialog, + EmpathyAccount *account, + gboolean enabled) { - GtkTreeView *view; - GtkTreeModel *model; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - priv->connecting_show = !priv->connecting_show; + GtkTreeModel *model; + GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - view = GTK_TREE_VIEW (priv->treeview); - model = gtk_tree_view_get_model (view); + /* Update the status in the model */ + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - gtk_tree_model_foreach (model, accounts_dialog_row_changed_foreach, NULL); + DEBUG ("Account %s is now %s", + empathy_account_get_display_name (account), + enabled ? "enabled" : "disabled"); - return TRUE; -} - -static void -accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - TpConnectionStatusReason reason, - TpConnectionStatus current, - TpConnectionStatus previous, - EmpathyAccountsDialog *dialog) -{ - GtkTreeModel *model; - GtkTreeIter iter; - gboolean found; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - /* Update the status in the model */ - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - - if (accounts_dialog_get_account_iter (dialog, account, &iter)) { - GtkTreePath *path; - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_STATUS, current, - -1); - - path = gtk_tree_model_get_path (model, &iter); - gtk_tree_model_row_changed (model, path, &iter); - gtk_tree_path_free (path); - } - - found = (empathy_account_manager_get_connecting_accounts (manager) > 0); - - if (!found && priv->connecting_id) { - g_source_remove (priv->connecting_id); - priv->connecting_id = 0; - } - - if (found && !priv->connecting_id) { - priv->connecting_id = g_timeout_add (FLASH_TIMEOUT, - (GSourceFunc) accounts_dialog_flash_connecting_cb, - dialog); - } -} - -static void -enable_or_disable_account (EmpathyAccountsDialog *dialog, - EmpathyAccount *account, - gboolean enabled) -{ - GtkTreeModel *model; - GtkTreeIter iter; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - /* Update the status in the model */ - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - - DEBUG ("Account %s is now %s", - empathy_account_get_display_name (account), - enabled ? "enabled" : "disabled"); - - if (accounts_dialog_get_account_iter (dialog, account, &iter)) { - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ENABLED, enabled, - -1); - } + if (accounts_dialog_get_account_iter (dialog, account, &iter)) + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_ENABLED, enabled, + -1); } static void accounts_dialog_account_disabled_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - EmpathyAccountsDialog *dialog) + EmpathyAccount *account, + EmpathyAccountsDialog *dialog) { - enable_or_disable_account (dialog, account, FALSE); + enable_or_disable_account (dialog, account, FALSE); } static void accounts_dialog_account_enabled_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - EmpathyAccountsDialog *dialog) + EmpathyAccount *account, + EmpathyAccountsDialog *dialog) { - enable_or_disable_account (dialog, account, TRUE); + enable_or_disable_account (dialog, account, TRUE); } static void accounts_dialog_account_changed_cb (EmpathyAccountManager *manager, - EmpathyAccount *account, - EmpathyAccountsDialog *dialog) + EmpathyAccount *account, + EmpathyAccountsDialog *dialog) { - EmpathyAccountSettings *settings, *selected_settings; - GtkTreeModel *model; - GtkTreeIter iter; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + EmpathyAccountSettings *settings, *selected_settings; + GtkTreeModel *model; + GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - if (!accounts_dialog_get_account_iter (dialog, account, &iter)) - return; + if (!accounts_dialog_get_account_iter (dialog, account, &iter)) + return; - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_SETTINGS_POINTER, &settings, - -1); + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_SETTINGS_POINTER, &settings, + -1); - accounts_dialog_update (dialog, settings); - selected_settings = accounts_dialog_model_get_selected_settings (dialog); + accounts_dialog_update (dialog, settings); + selected_settings = accounts_dialog_model_get_selected_settings (dialog); - if (settings == selected_settings) - accounts_dialog_update_name_label (dialog, settings); + if (settings == selected_settings) + accounts_dialog_update_name_label (dialog, settings); } static void -accounts_dialog_button_create_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) +accounts_dialog_button_create_clicked_cb (GtkWidget *button, + EmpathyAccountsDialog *dialog) { - EmpathyAccountSettings *settings; - gchar *str; - TpConnectionManager *cm; - TpConnectionManagerProtocol *proto; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - cm = empathy_protocol_chooser_dup_selected ( - EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto); - - /* Create account */ - /* To translator: %s is the protocol name */ - str = g_strdup_printf (_("New %s account"), proto->name); + EmpathyAccountSettings *settings; + gchar *str; + TpConnectionManager *cm; + TpConnectionManagerProtocol *proto; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - settings = empathy_account_settings_new (cm->name, proto->name, str); + cm = empathy_protocol_chooser_dup_selected ( + EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto); - g_free (str); + /* Create account */ + /* To translator: %s is the protocol name */ + str = g_strdup_printf (_("New %s account"), proto->name); - if (tp_connection_manager_protocol_can_register (proto)) { - gboolean active; + settings = empathy_account_settings_new (cm->name, proto->name, str); - active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->radiobutton_register)); - if (active) { - empathy_account_settings_set_boolean (settings, "register", TRUE); - } - } + g_free (str); - accounts_dialog_add (dialog, settings); - accounts_dialog_model_set_selected (dialog, settings); + if (tp_connection_manager_protocol_can_register (proto)) + { + gboolean active; - g_object_unref (settings); - g_object_unref (cm); -} + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->radiobutton_register)); + if (active) + empathy_account_settings_set_boolean (settings, "register", TRUE); + } -static void -accounts_dialog_button_back_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) -{ - EmpathyAccountSettings *settings; + accounts_dialog_add (dialog, settings); + accounts_dialog_model_set_selected (dialog, settings); - settings = accounts_dialog_model_get_selected_settings (dialog); - accounts_dialog_update (dialog, settings); + g_object_unref (settings); + g_object_unref (cm); } static void -accounts_dialog_protocol_changed_cb (GtkWidget *widget, - EmpathyAccountsDialog *dialog) +accounts_dialog_button_back_clicked_cb (GtkWidget *button, + EmpathyAccountsDialog *dialog) { - TpConnectionManager *cm; - TpConnectionManagerProtocol *proto; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - cm = empathy_protocol_chooser_dup_selected ( - EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto); - - if (tp_connection_manager_protocol_can_register (proto)) { - gtk_widget_show (priv->radiobutton_register); - gtk_widget_show (priv->radiobutton_reuse); - } else { - gtk_widget_hide (priv->radiobutton_register); - gtk_widget_hide (priv->radiobutton_reuse); - } - g_object_unref (cm); -} + EmpathyAccountSettings *settings; -static void -accounts_dialog_button_add_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) -{ - GtkTreeView *view; - GtkTreeSelection *selection; - GtkTreeModel *model; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - view = GTK_TREE_VIEW (priv->treeview); - model = gtk_tree_view_get_model (view); - selection = gtk_tree_view_get_selection (view); - gtk_tree_selection_unselect_all (selection); - - gtk_widget_set_sensitive (priv->button_add, FALSE); - gtk_widget_set_sensitive (priv->button_remove, FALSE); - gtk_widget_hide (priv->vbox_details); - gtk_widget_hide (priv->frame_no_protocol); - gtk_widget_show (priv->frame_new_account); - - /* If we have no account, no need of a back button */ - if (gtk_tree_model_iter_n_children (model, NULL) > 0) { - gtk_widget_show (priv->button_back); - } else { - gtk_widget_hide (priv->button_back); - } - - accounts_dialog_protocol_changed_cb (priv->radiobutton_register, dialog); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->radiobutton_reuse), - TRUE); - gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox_protocol), 0); - gtk_widget_grab_focus (priv->combobox_protocol); + settings = accounts_dialog_model_get_selected_settings (dialog); + accounts_dialog_update (dialog, settings); } static void -accounts_dialog_button_help_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) +accounts_dialog_button_help_clicked_cb (GtkWidget *button, + EmpathyAccountsDialog *dialog) { - empathy_url_show (button, "ghelp:empathy?empathy-create-account"); + empathy_url_show (button, "ghelp:empathy?empathy-create-account"); } static void -accounts_dialog_button_remove_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) +accounts_dialog_button_remove_clicked_cb (GtkWidget *button, + EmpathyAccountsDialog *dialog) { - EmpathyAccount *account; - GtkWidget *message_dialog; - gint res; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - account = accounts_dialog_model_get_selected_account (dialog); - - if (account == NULL || !empathy_account_is_valid (account)) { - accounts_dialog_model_remove_selected (dialog); - accounts_dialog_model_select_first (dialog); - return; - } - message_dialog = gtk_message_dialog_new - (GTK_WINDOW (priv->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - _("You are about to remove your %s account!\n" - "Are you sure you want to proceed?"), - empathy_account_get_display_name (account)); - - gtk_message_dialog_format_secondary_text - (GTK_MESSAGE_DIALOG (message_dialog), - _("Any associated conversations and chat rooms will NOT be " - "removed if you decide to proceed.\n" - "\n" - "Should you decide to add the account back at a later time, " - "they will still be available.")); - - gtk_dialog_add_button (GTK_DIALOG (message_dialog), - GTK_STOCK_CANCEL, - GTK_RESPONSE_NO); - gtk_dialog_add_button (GTK_DIALOG (message_dialog), - GTK_STOCK_REMOVE, - GTK_RESPONSE_YES); - - gtk_widget_show (message_dialog); - res = gtk_dialog_run (GTK_DIALOG (message_dialog)); - - if (res == GTK_RESPONSE_YES) { - accounts_dialog_model_remove_selected (dialog); - accounts_dialog_model_select_first (dialog); - } - gtk_widget_destroy (message_dialog); + EmpathyAccount *account; + GtkWidget *message_dialog; + gint res; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + account = accounts_dialog_model_get_selected_account (dialog); + + if (account == NULL || !empathy_account_is_valid (account)) + { + accounts_dialog_model_remove_selected (dialog); + accounts_dialog_model_select_first (dialog); + return; + } + message_dialog = gtk_message_dialog_new + (GTK_WINDOW (priv->window), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + _("You are about to remove your %s account!\n" + "Are you sure you want to proceed?"), + empathy_account_get_display_name (account)); + + gtk_message_dialog_format_secondary_text + (GTK_MESSAGE_DIALOG (message_dialog), + _("Any associated conversations and chat rooms will NOT be " + "removed if you decide to proceed.\n" + "\n" + "Should you decide to add the account back at a later time, " + "they will still be available.")); + + gtk_dialog_add_button (GTK_DIALOG (message_dialog), + GTK_STOCK_CANCEL, + GTK_RESPONSE_NO); + gtk_dialog_add_button (GTK_DIALOG (message_dialog), + GTK_STOCK_REMOVE, + GTK_RESPONSE_YES); + + gtk_widget_show (message_dialog); + res = gtk_dialog_run (GTK_DIALOG (message_dialog)); + + if (res == GTK_RESPONSE_YES) + { + accounts_dialog_model_remove_selected (dialog); + accounts_dialog_model_select_first (dialog); + } + gtk_widget_destroy (message_dialog); } #if 0 /* FIXME MC-5 */ static void -accounts_dialog_button_import_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) +accounts_dialog_button_import_clicked_cb (GtkWidget *button, + EmpathyAccountsDialog *dialog) { - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - empathy_import_dialog_show (GTK_WINDOW (priv->window), TRUE); + empathy_import_dialog_show (GTK_WINDOW (priv->window), TRUE); } #endif static void -accounts_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathyAccountsDialog *dialog) +accounts_dialog_response_cb (GtkWidget *widget, + gint response, + EmpathyAccountsDialog *dialog) { - GList *accounts, *l; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - if (response == GTK_RESPONSE_CLOSE) { - /* Delete incomplete accounts */ - accounts = empathy_account_manager_dup_accounts - (priv->account_manager); - for (l = accounts; l; l = l->next) { - EmpathyAccount *account; - - account = l->data; - if (!empathy_account_is_valid (account)) { - /* FIXME: Warn the user the account is not - * complete and is going to be removed. - */ - empathy_account_manager_remove - (priv->account_manager, account); - } - - g_object_unref (account); - } - g_list_free (accounts); - - gtk_widget_destroy (widget); - } + GList *accounts, *l; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + if (response == GTK_RESPONSE_CLOSE) + { + /* Delete incomplete accounts */ + accounts = empathy_account_manager_dup_accounts + (priv->account_manager); + for (l = accounts; l; l = l->next) + { + EmpathyAccount *account; + + account = l->data; + if (!empathy_account_is_valid (account)) + /* FIXME: Warn the user the account is not + * complete and is going to be removed. + */ + empathy_account_manager_remove + (priv->account_manager, account); + + g_object_unref (account); + } + g_list_free (accounts); + + gtk_widget_destroy (widget); + } } static void accounts_dialog_destroy_cb (GtkObject *obj, - EmpathyAccountsDialog *dialog) + EmpathyAccountsDialog *dialog) { - DEBUG ("%p", obj); + DEBUG ("%p", obj); - g_object_unref (dialog); + g_object_unref (dialog); } static void accounts_dialog_set_selected_account (EmpathyAccountsDialog *dialog, - EmpathyAccount *account) + EmpathyAccount *account) { - GtkTreeSelection *selection; - GtkTreeIter iter; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); - if (accounts_dialog_get_account_iter (dialog, account, &iter)) { - gtk_tree_selection_select_iter (selection, &iter); - } + GtkTreeSelection *selection; + GtkTreeIter iter; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); + if (accounts_dialog_get_account_iter (dialog, account, &iter)) + gtk_tree_selection_select_iter (selection, &iter); } static void accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms, - GParamSpec *pspec, - EmpathyAccountsDialog *dialog) + GParamSpec *pspec, + EmpathyAccountsDialog *dialog) { - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - if (empathy_connection_managers_is_ready (cms)) { - accounts_dialog_update_settings (dialog, NULL); - - if (priv->initial_selection != NULL) { - accounts_dialog_set_selected_account (dialog, priv->initial_selection); - priv->initial_selection = NULL; - } - } + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + if (empathy_connection_managers_is_ready (cms)) + { + accounts_dialog_update_settings (dialog, NULL); + + if (priv->initial_selection != NULL) + { + accounts_dialog_set_selected_account (dialog, priv->initial_selection); + priv->initial_selection = NULL; + } + } } static void accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) { - GtkBuilder *gui; - gchar *filename; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - filename = empathy_file_lookup ("empathy-accounts-dialog.ui", "src"); - - gui = empathy_builder_get_file (filename, - "accounts_dialog", &priv->window, - "vbox_details", &priv->vbox_details, - "frame_no_protocol", &priv->frame_no_protocol, - "alignment_settings", &priv->alignment_settings, - "treeview", &priv->treeview, - "frame_new_account", &priv->frame_new_account, - "hbox_type", &priv->hbox_type, - "button_create", &priv->button_create, - "button_back", &priv->button_back, - "radiobutton_reuse", &priv->radiobutton_reuse, - "radiobutton_register", &priv->radiobutton_register, - "image_type", &priv->image_type, - "label_name", &priv->label_name, - "button_add", &priv->button_add, - "button_remove", &priv->button_remove, - "button_import", &priv->button_import, - NULL); - g_free (filename); - - empathy_builder_connect (gui, dialog, - "accounts_dialog", "response", accounts_dialog_response_cb, - "accounts_dialog", "destroy", accounts_dialog_destroy_cb, - "button_create", "clicked", accounts_dialog_button_create_clicked_cb, - "button_back", "clicked", accounts_dialog_button_back_clicked_cb, - "button_add", "clicked", accounts_dialog_button_add_clicked_cb, - "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb, + GtkBuilder *gui; + gchar *filename; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + filename = empathy_file_lookup ("empathy-accounts-dialog.ui", "src"); + + gui = empathy_builder_get_file (filename, + "accounts_dialog", &priv->window, + "vbox_details", &priv->vbox_details, + "frame_no_protocol", &priv->frame_no_protocol, + "alignment_settings", &priv->alignment_settings, + "treeview", &priv->treeview, + "frame_new_account", &priv->frame_new_account, + "hbox_type", &priv->hbox_type, + "button_create", &priv->button_create, + "button_back", &priv->button_back, + "radiobutton_reuse", &priv->radiobutton_reuse, + "radiobutton_register", &priv->radiobutton_register, + "image_type", &priv->image_type, + "label_name", &priv->label_name, + "button_add", &priv->button_add, + "button_remove", &priv->button_remove, + "button_import", &priv->button_import, + NULL); + g_free (filename); + + empathy_builder_connect (gui, dialog, + "accounts_dialog", "response", accounts_dialog_response_cb, + "accounts_dialog", "destroy", accounts_dialog_destroy_cb, + "button_create", "clicked", accounts_dialog_button_create_clicked_cb, + "button_back", "clicked", accounts_dialog_button_back_clicked_cb, + "button_add", "clicked", accounts_dialog_button_add_clicked_cb, + "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb, #if 0 -/* FIXME MC-5 */ - "button_import", "clicked", accounts_dialog_button_import_clicked_cb, + /* FIXME MC-5 */ + "button_import", "clicked", accounts_dialog_button_import_clicked_cb, #endif - "button_help", "clicked", accounts_dialog_button_help_clicked_cb, - NULL); - - g_object_unref (gui); - - priv->combobox_protocol = empathy_protocol_chooser_new (); - gtk_box_pack_end (GTK_BOX (priv->hbox_type), - priv->combobox_protocol, - TRUE, TRUE, 0); - gtk_widget_show (priv->combobox_protocol); - g_signal_connect (priv->combobox_protocol, "changed", - G_CALLBACK (accounts_dialog_protocol_changed_cb), - dialog); - - if (priv->parent_window) { - gtk_window_set_transient_for (GTK_WINDOW (priv->window), - priv->parent_window); - } + "button_help", "clicked", accounts_dialog_button_help_clicked_cb, + NULL); + + g_object_unref (gui); + + priv->combobox_protocol = empathy_protocol_chooser_new (); + gtk_box_pack_end (GTK_BOX (priv->hbox_type), + priv->combobox_protocol, + TRUE, TRUE, 0); + gtk_widget_show (priv->combobox_protocol); + g_signal_connect (priv->combobox_protocol, "changed", + G_CALLBACK (accounts_dialog_protocol_changed_cb), + dialog); + + if (priv->parent_window) + gtk_window_set_transient_for (GTK_WINDOW (priv->window), + priv->parent_window); } static void do_dispose (GObject *obj) { - EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (obj); - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - /* Disconnect signals */ - g_signal_handlers_disconnect_by_func (priv->account_manager, - accounts_dialog_account_added_cb, - dialog); - g_signal_handlers_disconnect_by_func (priv->account_manager, - accounts_dialog_account_removed_cb, - dialog); - g_signal_handlers_disconnect_by_func (priv->account_manager, - accounts_dialog_account_enabled_cb, - dialog); - g_signal_handlers_disconnect_by_func (priv->account_manager, - accounts_dialog_account_disabled_cb, - dialog); - g_signal_handlers_disconnect_by_func (priv->account_manager, - accounts_dialog_account_changed_cb, - dialog); - g_signal_handlers_disconnect_by_func (priv->account_manager, - accounts_dialog_connection_changed_cb, - dialog); - - if (priv->connecting_id) { - g_source_remove (priv->connecting_id); - } - - if (priv->account_manager != NULL) { - g_object_unref (priv->account_manager); - priv->account_manager = NULL; - } - - if (priv->cms != NULL) { - g_object_unref (priv->cms); - priv->cms = NULL; - } - - G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->dispose (obj); + EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (obj); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + /* Disconnect signals */ + g_signal_handlers_disconnect_by_func (priv->account_manager, + accounts_dialog_account_added_cb, + dialog); + g_signal_handlers_disconnect_by_func (priv->account_manager, + accounts_dialog_account_removed_cb, + dialog); + g_signal_handlers_disconnect_by_func (priv->account_manager, + accounts_dialog_account_enabled_cb, + dialog); + g_signal_handlers_disconnect_by_func (priv->account_manager, + accounts_dialog_account_disabled_cb, + dialog); + g_signal_handlers_disconnect_by_func (priv->account_manager, + accounts_dialog_account_changed_cb, + dialog); + g_signal_handlers_disconnect_by_func (priv->account_manager, + accounts_dialog_connection_changed_cb, + dialog); + + if (priv->connecting_id) + g_source_remove (priv->connecting_id); + + if (priv->account_manager != NULL) + { + g_object_unref (priv->account_manager); + priv->account_manager = NULL; + } + + if (priv->cms != NULL) + { + g_object_unref (priv->cms); + priv->cms = NULL; + } + + G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->dispose (obj); } static GObject * do_constructor (GType type, - guint n_props, - GObjectConstructParam *props) + guint n_props, + GObjectConstructParam *props) { - GObject *retval; - - if (dialog_singleton) { - retval = G_OBJECT (dialog_singleton); - } else { - retval = G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->constructor - (type, n_props, props); - - dialog_singleton = EMPATHY_ACCOUNTS_DIALOG (retval); - g_object_add_weak_pointer (retval, (gpointer) &dialog_singleton); - } - - return retval; + GObject *retval; + + if (dialog_singleton) + { + retval = G_OBJECT (dialog_singleton); + } + else + { + retval = G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->constructor + (type, n_props, props); + + dialog_singleton = EMPATHY_ACCOUNTS_DIALOG (retval); + g_object_add_weak_pointer (retval, (gpointer) &dialog_singleton); + } + + return retval; } static void do_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { - EmpathyAccountsDialogPriv *priv = GET_PRIV (object); - - switch (property_id) { - case PROP_PARENT: - g_value_set_object (value, priv->parent_window); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } + EmpathyAccountsDialogPriv *priv = GET_PRIV (object); + + switch (property_id) + { + case PROP_PARENT: + g_value_set_object (value, priv->parent_window); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } } static void do_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { - EmpathyAccountsDialogPriv *priv = GET_PRIV (object); - - switch (property_id) { - case PROP_PARENT: - priv->parent_window = g_value_get_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } + EmpathyAccountsDialogPriv *priv = GET_PRIV (object); + + switch (property_id) + { + case PROP_PARENT: + priv->parent_window = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } } static void do_constructed (GObject *object) { - EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (object); - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - GList *accounts, *l; - gboolean import_asked; - - accounts_dialog_build_ui (dialog); - - /* Set up signalling */ - priv->account_manager = empathy_account_manager_dup_singleton (); - - g_signal_connect (priv->account_manager, "account-created", - G_CALLBACK (accounts_dialog_account_added_cb), - dialog); - g_signal_connect (priv->account_manager, "account-deleted", - G_CALLBACK (accounts_dialog_account_removed_cb), - dialog); - g_signal_connect (priv->account_manager, "account-enabled", - G_CALLBACK (accounts_dialog_account_enabled_cb), - dialog); - g_signal_connect (priv->account_manager, "account-disabled", - G_CALLBACK (accounts_dialog_account_disabled_cb), - dialog); - g_signal_connect (priv->account_manager, "account-changed", - G_CALLBACK (accounts_dialog_account_changed_cb), - dialog); - g_signal_connect (priv->account_manager, "account-connection-changed", - G_CALLBACK (accounts_dialog_connection_changed_cb), - dialog); - - accounts_dialog_model_setup (dialog); - - /* Add existing accounts */ - accounts = empathy_account_manager_dup_accounts (priv->account_manager); - for (l = accounts; l; l = l->next) { - accounts_dialog_add_account (dialog, l->data); - g_object_unref (l->data); - } - g_list_free (accounts); - - priv->cms = empathy_connection_managers_dup_singleton (); - if (!empathy_connection_managers_is_ready (priv->cms)) { - g_signal_connect (priv->cms, "notify::ready", - G_CALLBACK (accounts_dialog_cms_ready_cb), dialog); - } - - accounts_dialog_model_select_first (dialog); - - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_IMPORT_ASKED, &import_asked); + EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (object); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + GList *accounts, *l; + gboolean import_asked; + + accounts_dialog_build_ui (dialog); + + /* Set up signalling */ + priv->account_manager = empathy_account_manager_dup_singleton (); + + g_signal_connect (priv->account_manager, "account-created", + G_CALLBACK (accounts_dialog_account_added_cb), + dialog); + g_signal_connect (priv->account_manager, "account-deleted", + G_CALLBACK (accounts_dialog_account_removed_cb), + dialog); + g_signal_connect (priv->account_manager, "account-enabled", + G_CALLBACK (accounts_dialog_account_enabled_cb), + dialog); + g_signal_connect (priv->account_manager, "account-disabled", + G_CALLBACK (accounts_dialog_account_disabled_cb), + dialog); + g_signal_connect (priv->account_manager, "account-changed", + G_CALLBACK (accounts_dialog_account_changed_cb), + dialog); + g_signal_connect (priv->account_manager, "account-connection-changed", + G_CALLBACK (accounts_dialog_connection_changed_cb), + dialog); + + accounts_dialog_model_setup (dialog); + + /* Add existing accounts */ + accounts = empathy_account_manager_dup_accounts (priv->account_manager); + for (l = accounts; l; l = l->next) + { + accounts_dialog_add_account (dialog, l->data); + g_object_unref (l->data); + } + g_list_free (accounts); + + priv->cms = empathy_connection_managers_dup_singleton (); + if (!empathy_connection_managers_is_ready (priv->cms)) + g_signal_connect (priv->cms, "notify::ready", + G_CALLBACK (accounts_dialog_cms_ready_cb), dialog); + + accounts_dialog_model_select_first (dialog); + + empathy_conf_get_bool (empathy_conf_get (), + EMPATHY_PREFS_IMPORT_ASKED, &import_asked); #if 0 -/* FIXME MC-5 */ - if (empathy_import_dialog_accounts_to_import ()) { - - if (!import_asked) { - empathy_conf_set_bool (empathy_conf_get (), - EMPATHY_PREFS_IMPORT_ASKED, TRUE); - empathy_import_dialog_show (GTK_WINDOW (priv->window), - FALSE); - } - } else { - gtk_widget_set_sensitive (priv->button_import, FALSE); - } + /* FIXME MC-5 */ + if (empathy_import_dialog_accounts_to_import ()) + { + + if (!import_asked) + { + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_IMPORT_ASKED, TRUE); + empathy_import_dialog_show (GTK_WINDOW (priv->window), + FALSE); + } + } + else + { + gtk_widget_set_sensitive (priv->button_import, FALSE); + } #endif } static void empathy_accounts_dialog_class_init (EmpathyAccountsDialogClass *klass) { - GObjectClass *oclass = G_OBJECT_CLASS (klass); - GParamSpec *param_spec; - - oclass->constructor = do_constructor; - oclass->dispose = do_dispose; - oclass->constructed = do_constructed; - oclass->set_property = do_set_property; - oclass->get_property = do_get_property; - - param_spec = g_param_spec_object ("parent", - "parent", "The parent window", - GTK_TYPE_WINDOW, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (oclass, PROP_PARENT, param_spec); - - g_type_class_add_private (klass, sizeof (EmpathyAccountsDialogPriv)); + GObjectClass *oclass = G_OBJECT_CLASS (klass); + GParamSpec *param_spec; + + oclass->constructor = do_constructor; + oclass->dispose = do_dispose; + oclass->constructed = do_constructed; + oclass->set_property = do_set_property; + oclass->get_property = do_get_property; + + param_spec = g_param_spec_object ("parent", + "parent", "The parent window", + GTK_TYPE_WINDOW, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (oclass, PROP_PARENT, param_spec); + + g_type_class_add_private (klass, sizeof (EmpathyAccountsDialogPriv)); } static void empathy_accounts_dialog_init (EmpathyAccountsDialog *dialog) { - EmpathyAccountsDialogPriv *priv; + EmpathyAccountsDialogPriv *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE ((dialog), - EMPATHY_TYPE_ACCOUNTS_DIALOG, - EmpathyAccountsDialogPriv); - dialog->priv = priv; + priv = G_TYPE_INSTANCE_GET_PRIVATE ((dialog), + EMPATHY_TYPE_ACCOUNTS_DIALOG, + EmpathyAccountsDialogPriv); + dialog->priv = priv; } /* public methods */ GtkWidget * empathy_accounts_dialog_show (GtkWindow *parent, - EmpathyAccount *selected_account) + EmpathyAccount *selected_account) { - EmpathyAccountsDialog *dialog; - EmpathyAccountsDialogPriv *priv; + EmpathyAccountsDialog *dialog; + EmpathyAccountsDialogPriv *priv; - dialog = g_object_new (EMPATHY_TYPE_ACCOUNTS_DIALOG, - "parent", parent, NULL); + dialog = g_object_new (EMPATHY_TYPE_ACCOUNTS_DIALOG, + "parent", parent, NULL); - priv = GET_PRIV (dialog); + priv = GET_PRIV (dialog); - if (selected_account && empathy_connection_managers_is_ready (priv->cms)) { - accounts_dialog_set_selected_account (dialog, selected_account); - } else { - /* save the selection to set it later when the cms - * becomes ready. - */ - priv->initial_selection = selected_account; - } + if (selected_account && empathy_connection_managers_is_ready (priv->cms)) + accounts_dialog_set_selected_account (dialog, selected_account); + else + /* save the selection to set it later when the cms + * becomes ready. + */ + priv->initial_selection = selected_account; - gtk_window_present (GTK_WINDOW (priv->window)); + gtk_window_present (GTK_WINDOW (priv->window)); - return priv->window; + return priv->window; } -- cgit v1.2.3 From 88723038185c9f7b1402153f0a3009ea883fc250 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 25 Jul 2009 18:24:54 +0200 Subject: Even more cleanup + update header --- src/empathy-accounts-dialog.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 339c53b96..78ef4fe75 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1,7 +1,6 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright (C) 2005-2007 Imendio AB - * Copyright (C) 2007-2008 Collabora Ltd. + * Copyright (C) 2007-2009 Collabora Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -20,6 +19,7 @@ * * Authors: Martyn Russell * Xavier Claessens + * Cosimo Cecchi */ #include @@ -119,8 +119,8 @@ static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, #if 0 /* FIXME MC-5 */ -static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog); +static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, + EmpathyAccountsDialog *dialog); #endif static void @@ -172,7 +172,6 @@ get_account_setup_widget (EmpathyAccountSettings *settings) return empathy_account_widget_generic_new (settings); } - static void account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings) @@ -501,7 +500,8 @@ accounts_dialog_name_edited_cb (GtkCellRendererText *renderer, GtkTreeIter iter; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - if (empathy_account_manager_get_connecting_accounts (priv->account_manager) > 0) + if (empathy_account_manager_get_connecting_accounts + (priv->account_manager) > 0) { priv->connecting_id = g_timeout_add (FLASH_TIMEOUT, (GSourceFunc) accounts_dialog_flash_connecting_cb, @@ -1033,7 +1033,8 @@ accounts_dialog_button_create_clicked_cb (GtkWidget *button, { gboolean active; - active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->radiobutton_register)); + active = gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (priv->radiobutton_register)); if (active) empathy_account_settings_set_boolean (settings, "register", TRUE); } @@ -1194,7 +1195,8 @@ accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms, if (priv->initial_selection != NULL) { - accounts_dialog_set_selected_account (dialog, priv->initial_selection); + accounts_dialog_set_selected_account + (dialog, priv->initial_selection); priv->initial_selection = NULL; } } @@ -1316,8 +1318,9 @@ do_constructor (GType type, } else { - retval = G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->constructor - (type, n_props, props); + retval = + G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->constructor + (type, n_props, props); dialog_singleton = EMPATHY_ACCOUNTS_DIALOG (retval); g_object_add_weak_pointer (retval, (gpointer) &dialog_singleton); -- cgit v1.2.3 From 000a7c0ca4dc343b42e628323ddd1ca0f2a08e3f Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Mon, 27 Jul 2009 00:54:23 +0200 Subject: First cut at GObject-ifying EmpathyAccountWidget --- src/empathy-accounts-dialog.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 78ef4fe75..bfdae5c4c 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -137,28 +137,27 @@ accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog, g_free (text); } -typedef GtkWidget *CreateWidget (EmpathyAccountSettings *); - static GtkWidget * get_account_setup_widget (EmpathyAccountSettings *settings) { const gchar *cm = empathy_account_settings_get_cm (settings); const gchar *proto = empathy_account_settings_get_protocol (settings); + + g_print ("cm : %s, proto %s\n", cm, proto); struct { const gchar *cm; const gchar *proto; - CreateWidget *cb; } dialogs[] = { - { "gabble", "jabber", empathy_account_widget_jabber_new}, - { "butterfly", "msn", empathy_account_widget_msn_new}, - { "salut", "local-xmpp", empathy_account_widget_salut_new}, - { "idle", "irc", empathy_account_widget_irc_new}, - { "haze", "icq", empathy_account_widget_icq_new}, - { "haze", "aim", empathy_account_widget_aim_new}, - { "haze", "yahoo", empathy_account_widget_yahoo_new}, - { "haze", "groupwise", empathy_account_widget_groupwise_new}, - { "sofiasip", "sip", empathy_account_widget_sip_new}, - { NULL, NULL, NULL } + { "gabble", "jabber" }, + { "butterfly", "msn" }, + { "salut", "local-xmpp" }, + { "idle", "irc" }, + { "haze", "icq" }, + { "haze", "aim" }, + { "haze", "yahoo" }, + { "haze", "groupwise" }, + { "sofiasip", "sip" }, + { NULL, NULL } }; int i; @@ -166,10 +165,10 @@ get_account_setup_widget (EmpathyAccountSettings *settings) { if (!tp_strdiff (cm, dialogs[i].cm) && !tp_strdiff (proto, dialogs[i].proto)) - return dialogs[i].cb (settings); + return empathy_account_widget_new_for_protocol (dialogs[i].proto, settings); } - return empathy_account_widget_generic_new (settings); + return empathy_account_widget_new_for_protocol ("generic", settings); } static void -- cgit v1.2.3 From 207d7ac4384915a0fd3a65f609a04eeb59cb98e0 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Mon, 27 Jul 2009 01:24:42 +0200 Subject: Remove debug output --- src/empathy-accounts-dialog.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index bfdae5c4c..0cfcd7c48 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -143,7 +143,6 @@ get_account_setup_widget (EmpathyAccountSettings *settings) const gchar *cm = empathy_account_settings_get_cm (settings); const gchar *proto = empathy_account_settings_get_protocol (settings); - g_print ("cm : %s, proto %s\n", cm, proto); struct { const gchar *cm; const gchar *proto; -- cgit v1.2.3 From 10439722fe6985ff89c61e8c7488113e1a52806e Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 29 Jul 2009 22:44:22 +0200 Subject: Rename empathy_account_settings_owns_account() Call it empathy_account_settings_has_account() instead --- src/empathy-accounts-dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 0cfcd7c48..95c3ac146 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -712,7 +712,7 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, COL_ACCOUNT_SETTINGS_POINTER, &settings, -1); - equal = empathy_account_settings_owns_account + equal = empathy_account_settings_has_account (settings, account); g_object_unref (settings); -- cgit v1.2.3 From bf6b5979152190e78ca913c6cfd0b91e204c60fd Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 30 Jul 2009 00:44:36 +0200 Subject: Fix trailing whitespace --- src/empathy-accounts-dialog.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 95c3ac146..7a9dffb79 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -367,7 +367,7 @@ accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer, if (priv->connecting_id) g_source_remove (priv->connecting_id); - + DEBUG ("Editing account name started; stopping flashing"); } @@ -591,7 +591,7 @@ accounts_dialog_model_get_selected_settings (EmpathyAccountsDialog *dialog) if (!gtk_tree_selection_get_selected (selection, &model, &iter)) return NULL; - + gtk_tree_model_get (model, &iter, COL_ACCOUNT_SETTINGS_POINTER, &settings, -1); @@ -738,7 +738,7 @@ accounts_dialog_model_get_selected_account (EmpathyAccountsDialog *dialog) if (!gtk_tree_selection_get_selected (selection, &model, &iter)) return NULL; - + gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); return account; @@ -772,7 +772,7 @@ accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog) if (!gtk_tree_selection_get_selected (selection, &model, &iter)) return FALSE; - + gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); @@ -867,7 +867,7 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, if (!accounts_dialog_get_account_iter (dialog, account, &iter)) gtk_list_store_append (GTK_LIST_STORE (model), &iter); - + settings = empathy_account_settings_new_for_account (account); gtk_list_store_set (GTK_LIST_STORE (model), &iter, @@ -1202,7 +1202,7 @@ accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms, static void accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) -{ +{ GtkBuilder *gui; gchar *filename; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); -- cgit v1.2.3 From c9ef23052d2e5007e6120dcc881d6c382fcf48d3 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 30 Jul 2009 17:35:38 +0200 Subject: Chang the API of AccountManager to have the get lookup the account by name EmpathyAccountManager used to have a _lookup function that looked up accounts by name and a _get function that lookup up accounts by connection. This is confusing, as looking up an account for a connection is less common rename have the _get_account be the same _lookup (but without returning a ref) and add a _get_account_for_connection function lookup by account --- src/empathy-chat-window.c | 4 +--- src/empathy.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 9694a653c..47ef37c42 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1269,7 +1269,7 @@ chat_window_drag_data_received (GtkWidget *widget, strv = g_strsplit (id, "/", 2); account_id = strv[0]; contact_id = strv[1]; - account = empathy_account_manager_lookup (account_manager, account_id); + account = empathy_account_manager_get_account (account_manager, account_id); chat = empathy_chat_window_find_chat (account, contact_id); if (!chat) { @@ -1282,11 +1282,9 @@ chat_window_drag_data_received (GtkWidget *widget, connection, contact_id, NULL, NULL); } - g_object_unref (account); g_strfreev (strv); return; } - g_object_unref (account); g_object_unref (account_manager); g_strfreev (strv); diff --git a/src/empathy.c b/src/empathy.c index 4e824bcb4..956b05e5f 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -113,7 +113,7 @@ dispatch_cb (EmpathyDispatcher *dispatcher, manager = empathy_account_manager_dup_singleton (); connection = empathy_tp_chat_get_connection (tp_chat); - account = empathy_account_manager_get_account (manager, + account = empathy_account_manager_get_account_for_connection (manager, connection); chat = empathy_chat_window_find_chat (account, id); g_object_unref (manager); -- cgit v1.2.3 From 0279ad1b9504f81dbe6773eab9fdbd6ffdbfca3d Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 31 Jul 2009 11:44:35 +0200 Subject: Make protocol icons work also with account == NULL --- src/empathy-accounts-dialog.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 7a9dffb79..974b6dcc4 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -175,6 +175,7 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings) { EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + gchar *icon_name; priv->settings_widget = get_account_setup_widget (settings); @@ -182,14 +183,16 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, priv->settings_widget); gtk_widget_show (priv->settings_widget); + icon_name = empathy_account_settings_get_icon_name (settings); gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_type), - empathy_account_settings_get_icon_name (settings), - GTK_ICON_SIZE_DIALOG); + icon_name, GTK_ICON_SIZE_DIALOG); gtk_widget_set_tooltip_text (priv->image_type, empathy_account_settings_get_protocol (settings)); accounts_dialog_update_name_label (dialog, settings); + + g_free (icon_name); } static void @@ -379,7 +382,7 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, EmpathyAccountsDialog *dialog) { EmpathyAccountSettings *settings; - const gchar *icon_name; + gchar *icon_name; GdkPixbuf *pixbuf; TpConnectionStatus status; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); @@ -392,6 +395,8 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, icon_name = empathy_account_settings_get_icon_name (settings); pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); + g_free (icon_name); + if (pixbuf) { if (status == TP_CONNECTION_STATUS_DISCONNECTED || -- cgit v1.2.3 From af5cee20d84c3ef3ebf31f7e19b4108f9607aa14 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 1 Aug 2009 13:24:42 +0200 Subject: Make sure we always show the main window --- src/empathy-main-window.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index f8e22d91d..d61a05c27 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -1404,6 +1404,8 @@ empathy_main_window_show (void) main_window_update_status (window, window->account_manager); + gtk_widget_show (window->window); + return window->window; } -- cgit v1.2.3 From 9f9890593181c881b09773d7f8e68a402d8ce7fa Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 1 Aug 2009 15:12:42 +0200 Subject: Port to libunique --- src/Makefile.am | 1 - src/bacon-message-connection.c | 412 ----------------------------------------- src/bacon-message-connection.h | 51 ----- src/empathy.c | 151 ++++----------- 4 files changed, 37 insertions(+), 578 deletions(-) delete mode 100644 src/bacon-message-connection.c delete mode 100644 src/bacon-message-connection.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 50d317fbb..01f47d2bb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,7 +49,6 @@ empathy_handwritten_source = \ empathy_SOURCES = \ $(empathy_handwritten_source) \ - bacon-message-connection.c bacon-message-connection.h \ ephy-spinner.c ephy-spinner.h nodist_empathy_SOURCES = $(BUILT_SOURCES) diff --git a/src/bacon-message-connection.c b/src/bacon-message-connection.c deleted file mode 100644 index c9fda4aeb..000000000 --- a/src/bacon-message-connection.c +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Copyright (C) 2003 Bastien Nocera - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Totem project hereby grant permission for non-gpl compatible GStreamer - * plugins to be used and distributed together with GStreamer and Totem. This - * permission are above and beyond the permissions granted by the GPL license - * Totem is covered by. - * - * Monday 7th February 2005: Christian Schaller: Add excemption clause. - * See license_change file for details. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bacon-message-connection.h" - -#ifndef UNIX_PATH_MAX -#define UNIX_PATH_MAX 108 -#endif - -struct BaconMessageConnection { - /* A server accepts connections */ - gboolean is_server; - - /* The socket path itself */ - char *path; - - /* File descriptor of the socket */ - int fd; - /* Channel to watch */ - GIOChannel *chan; - /* Event id returned by g_io_add_watch() */ - int conn_id; - - /* Connections accepted by this connection */ - GSList *accepted_connections; - - /* callback */ - void (*func) (const char *message, gpointer user_data); - gpointer data; -}; - -static gboolean -test_is_socket (const char *path) -{ - struct stat s; - - if (stat (path, &s) == -1) - return FALSE; - - if (S_ISSOCK (s.st_mode)) - return TRUE; - - return FALSE; -} - -static gboolean -is_owned_by_user_and_socket (const char *path) -{ - struct stat s; - - if (stat (path, &s) == -1) - return FALSE; - - if (s.st_uid != geteuid ()) - return FALSE; - - if ((s.st_mode & S_IFSOCK) != S_IFSOCK) - return FALSE; - - return TRUE; -} - -static gboolean server_cb (GIOChannel *source, - GIOCondition condition, gpointer data); - -static gboolean -setup_connection (BaconMessageConnection *conn) -{ - int fdflags; - - g_return_val_if_fail (conn->chan == NULL, FALSE); - - /* Add CLOEXEC flag on the fd to make sure the socket get closed - * if exec is called. */ - fdflags = fcntl (conn->fd, F_GETFD, 0); - if (fdflags >= 0) { - fdflags |= FD_CLOEXEC; - fcntl (conn->fd, F_SETFD, fdflags); - } - - conn->chan = g_io_channel_unix_new (conn->fd); - if (!conn->chan) { - return FALSE; - } - g_io_channel_set_line_term (conn->chan, "\n", 1); - conn->conn_id = g_io_add_watch (conn->chan, G_IO_IN, server_cb, conn); - - return TRUE; -} - -static void -accept_new_connection (BaconMessageConnection *server_conn) -{ - BaconMessageConnection *conn; - int alen; - - g_return_if_fail (server_conn->is_server); - - conn = g_new0 (BaconMessageConnection, 1); - conn->is_server = FALSE; - conn->func = server_conn->func; - conn->data = server_conn->data; - - conn->fd = accept (server_conn->fd, NULL, (guint *)&alen); - - server_conn->accepted_connections = - g_slist_prepend (server_conn->accepted_connections, conn); - - setup_connection (conn); -} - -static gboolean -server_cb (GIOChannel *source, GIOCondition condition, gpointer data) -{ - BaconMessageConnection *conn = (BaconMessageConnection *)data; - char *message, *subs, buf; - int cd, rc, offset; - gboolean finished; - - offset = 0; - if (conn->is_server && conn->fd == g_io_channel_unix_get_fd (source)) { - accept_new_connection (conn); - return TRUE; - } - message = g_malloc (1); - cd = conn->fd; - rc = read (cd, &buf, 1); - while (rc > 0 && buf != '\n') - { - message = g_realloc (message, rc + offset + 1); - message[offset] = buf; - offset = offset + rc; - rc = read (cd, &buf, 1); - } - if (rc <= 0) { - g_io_channel_shutdown (conn->chan, FALSE, NULL); - g_io_channel_unref (conn->chan); - conn->chan = NULL; - close (conn->fd); - conn->fd = -1; - g_free (message); - conn->conn_id = 0; - - return FALSE; - } - message[offset] = '\0'; - - subs = message; - finished = FALSE; - - while (finished == FALSE && *subs != '\0') - { - if (conn->func != NULL) - (*conn->func) (subs, conn->data); - - subs += strlen (subs) + 1; - if (subs - message >= offset) - finished = TRUE; - } - - g_free (message); - - return TRUE; -} - -static char * -find_file_with_pattern (const char *dir, const char *pattern) -{ - GDir *filedir; - char *found_filename; - const char *filename; - GPatternSpec *pat; - - filedir = g_dir_open (dir, 0, NULL); - if (filedir == NULL) - return NULL; - - pat = g_pattern_spec_new (pattern); - if (pat == NULL) - { - g_dir_close (filedir); - return NULL; - } - - found_filename = NULL; - - while ((filename = g_dir_read_name (filedir))) - { - if (g_pattern_match_string (pat, filename)) - { - char *tmp = g_build_filename (dir, filename, NULL); - if (is_owned_by_user_and_socket (tmp)) - found_filename = g_strdup (filename); - g_free (tmp); - } - - if (found_filename != NULL) - break; - } - - g_pattern_spec_free (pat); - g_dir_close (filedir); - - return found_filename; -} - -static char * -socket_filename (const char *prefix) -{ - char *pattern, *newfile, *path, *filename; - const char *tmpdir; - - pattern = g_strdup_printf ("%s.%s.*", prefix, g_get_user_name ()); - tmpdir = g_get_tmp_dir (); - filename = find_file_with_pattern (tmpdir, pattern); - if (filename == NULL) - { - newfile = g_strdup_printf ("%s.%s.%u", prefix, - g_get_user_name (), g_random_int ()); - path = g_build_filename (tmpdir, newfile, NULL); - g_free (newfile); - } else { - path = g_build_filename (tmpdir, filename, NULL); - g_free (filename); - } - - g_free (pattern); - return path; -} - -static gboolean -try_server (BaconMessageConnection *conn) -{ - struct sockaddr_un uaddr; - - uaddr.sun_family = AF_UNIX; - strncpy (uaddr.sun_path, conn->path, - MIN (strlen(conn->path)+1, UNIX_PATH_MAX)); - conn->fd = socket (PF_UNIX, SOCK_STREAM, 0); - if (bind (conn->fd, (struct sockaddr *) &uaddr, sizeof (uaddr)) == -1) - { - conn->fd = -1; - return FALSE; - } - listen (conn->fd, 5); - - return setup_connection (conn); -} - -static gboolean -try_client (BaconMessageConnection *conn) -{ - struct sockaddr_un uaddr; - - uaddr.sun_family = AF_UNIX; - strncpy (uaddr.sun_path, conn->path, - MIN(strlen(conn->path)+1, UNIX_PATH_MAX)); - conn->fd = socket (PF_UNIX, SOCK_STREAM, 0); - if (connect (conn->fd, (struct sockaddr *) &uaddr, - sizeof (uaddr)) == -1) - { - conn->fd = -1; - return FALSE; - } - - return setup_connection (conn); -} - -BaconMessageConnection * -bacon_message_connection_new (const char *prefix) -{ - BaconMessageConnection *conn; - - g_return_val_if_fail (prefix != NULL, NULL); - - conn = g_new0 (BaconMessageConnection, 1); - conn->path = socket_filename (prefix); - - if (test_is_socket (conn->path) == FALSE) - { - if (!try_server (conn)) - { - bacon_message_connection_free (conn); - return NULL; - } - - conn->is_server = TRUE; - return conn; - } - - if (try_client (conn) == FALSE) - { - unlink (conn->path); - try_server (conn); - if (conn->fd == -1) - { - bacon_message_connection_free (conn); - return NULL; - } - - conn->is_server = TRUE; - return conn; - } - - conn->is_server = FALSE; - return conn; -} - -void -bacon_message_connection_free (BaconMessageConnection *conn) -{ - GSList *child_conn; - - g_return_if_fail (conn != NULL); - /* Only servers can accept other connections */ - g_return_if_fail (conn->is_server != FALSE || - conn->accepted_connections == NULL); - - child_conn = conn->accepted_connections; - while (child_conn != NULL) { - bacon_message_connection_free (child_conn->data); - child_conn = g_slist_next (child_conn); - } - g_slist_free (conn->accepted_connections); - - if (conn->conn_id) { - g_source_remove (conn->conn_id); - conn->conn_id = 0; - } - if (conn->chan) { - g_io_channel_shutdown (conn->chan, FALSE, NULL); - g_io_channel_unref (conn->chan); - } - - if (conn->is_server != FALSE) { - unlink (conn->path); - } - if (conn->fd != -1) { - close (conn->fd); - } - - g_free (conn->path); - g_free (conn); -} - -void -bacon_message_connection_set_callback (BaconMessageConnection *conn, - BaconMessageReceivedFunc func, - gpointer user_data) -{ - g_return_if_fail (conn != NULL); - - conn->func = func; - conn->data = user_data; -} - -void -bacon_message_connection_send (BaconMessageConnection *conn, - const char *message) -{ - g_return_if_fail (conn != NULL); - g_return_if_fail (message != NULL); - - g_io_channel_write_chars (conn->chan, message, strlen (message), - NULL, NULL); - g_io_channel_write_chars (conn->chan, "\n", 1, NULL, NULL); - g_io_channel_flush (conn->chan, NULL); -} - -gboolean -bacon_message_connection_get_is_server (BaconMessageConnection *conn) -{ - g_return_val_if_fail (conn != NULL, FALSE); - - return conn->is_server; -} - diff --git a/src/bacon-message-connection.h b/src/bacon-message-connection.h deleted file mode 100644 index db4a91262..000000000 --- a/src/bacon-message-connection.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2003 Bastien Nocera - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Totem project hereby grant permission for non-gpl compatible GStreamer - * plugins to be used and distributed together with GStreamer and Totem. This - * permission are above and beyond the permissions granted by the GPL license - * Totem is covered by. - * - * Monday 7th February 2005: Christian Schaller: Add excemption clause. - * See license_change file for details. - * - */ - -#ifndef BACON_MESSAGE_CONNECTION_H -#define BACON_MESSAGE_CONNECTION_H - -#include - -G_BEGIN_DECLS - -typedef void (*BaconMessageReceivedFunc) (const char *message, - gpointer user_data); - -typedef struct BaconMessageConnection BaconMessageConnection; - -BaconMessageConnection *bacon_message_connection_new (const char *prefix); -void bacon_message_connection_free (BaconMessageConnection *conn); -void bacon_message_connection_set_callback (BaconMessageConnection *conn, - BaconMessageReceivedFunc func, - gpointer user_data); -void bacon_message_connection_send (BaconMessageConnection *conn, - const char *message); -gboolean bacon_message_connection_get_is_server (BaconMessageConnection *conn); - -G_END_DECLS - -#endif /* BACON_MESSAGE_CONNECTION_H */ diff --git a/src/empathy.c b/src/empathy.c index 637470773..3cc494a94 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -30,6 +30,7 @@ #include #include #include +#include #if HAVE_LIBCHAMPLAIN #include @@ -68,7 +69,6 @@ #include "empathy-call-window.h" #include "empathy-chat-window.h" #include "empathy-ft-manager.h" -#include "bacon-message-connection.h" #include "extensions/extensions.h" @@ -77,7 +77,7 @@ #include -static BaconMessageConnection *connection = NULL; +#define COMMAND_ACCOUNTS_DIALOG 1 static void dispatch_cb (EmpathyDispatcher *dispatcher, @@ -403,85 +403,29 @@ migrate_config_to_xdg_dir (void) g_free (old_dir); } -/* The code that handles single-instance and startup notification is - * copied from gedit. - * - * Copyright (C) 2005 - Paolo Maggi - */ -static void -on_bacon_message_received (const char *message, - gpointer data) +static UniqueResponse +unique_app_message_cb (UniqueApp *unique_app, + gint command, + UniqueMessageData *data, + guint timestamp, + gpointer user_data) { - GtkWidget *window = data; - guint32 startup_timestamp; - - g_return_if_fail (message != NULL); + GtkWidget *window = user_data; - DEBUG ("Other instance launched, presenting the main window. message='%s'", - message); + DEBUG ("Other instance launched, presenting the main window. " + "Command=%d, timestamp %u", command, timestamp); - if (strcmp (message, "accounts") == 0) { - /* accounts dialog requested */ + if (command == COMMAND_ACCOUNTS_DIALOG) { empathy_accounts_dialog_show (GTK_WINDOW (window), NULL); } else { - startup_timestamp = atoi (message); - - /* Set the proper interaction time on the window. - * Fall back to roundtripping to the X server when we - * don't have the timestamp, e.g. when launched from - * terminal. We also need to make sure that the window - * has been realized otherwise it will not work. lame. */ - if (startup_timestamp == 0) { - /* Work if launched from the terminal */ - DEBUG ("Using X server timestamp as a fallback"); - - if (!GTK_WIDGET_REALIZED (window)) { - gtk_widget_realize (GTK_WIDGET (window)); - } - - startup_timestamp = gdk_x11_get_server_time (gtk_widget_get_window (window)); - } - - gtk_window_present_with_time (GTK_WINDOW (window), startup_timestamp); + gtk_window_set_screen (GTK_WINDOW (window), + unique_message_data_get_screen (data)); + gtk_window_set_startup_id (GTK_WINDOW (window), + unique_message_data_get_startup_id (data)); + gtk_window_present_with_time (GTK_WINDOW (window), timestamp); } -} - -static guint32 -get_startup_timestamp () -{ - const gchar *startup_id_env; - gchar *startup_id = NULL; - gchar *time_str; - gchar *end; - gulong retval = 0; - - /* we don't unset the env, since startup-notification - * may still need it */ - startup_id_env = g_getenv ("DESKTOP_STARTUP_ID"); - if (startup_id_env == NULL) { - goto out; - } - - startup_id = g_strdup (startup_id_env); - - time_str = g_strrstr (startup_id, "_TIME"); - if (time_str == NULL) { - goto out; - } - - errno = 0; - /* Skip past the "_TIME" part */ - time_str += 5; - - retval = strtoul (time_str, &end, 0); - if (end == time_str || errno != 0) - retval = 0; - - out: - g_free (startup_id); - - return (retval > 0) ? retval : 0; + return UNIQUE_RESPONSE_OK; } static gboolean @@ -579,7 +523,6 @@ account_manager_ready_cb (EmpathyAccountManager *manager, int main (int argc, char *argv[]) { - guint32 startup_timestamp; #if HAVE_GEOCLUE EmpathyLocationManager *location_manager = NULL; #endif @@ -598,6 +541,7 @@ main (int argc, char *argv[]) gboolean accounts_dialog = FALSE; GError *error = NULL; TpDBusDaemon *dbus_daemon; + UniqueApp *unique_app; GOptionEntry options[] = { { "no-connect", 'n', 0, G_OPTION_ARG_NONE, &no_connect, @@ -645,39 +589,20 @@ main (int argc, char *argv[]) g_log_set_default_handler (default_log_handler, NULL); #endif - /* Setting up the bacon connection */ - startup_timestamp = get_startup_timestamp (); - connection = bacon_message_connection_new ("empathy"); - if (connection != NULL) { - if (!bacon_message_connection_get_is_server (connection)) { - gchar *message; - - if (accounts_dialog) { - DEBUG ("Showing accounts dialog from existing Empathy instance"); - - message = g_strdup ("accounts"); - - } else { - - DEBUG ("Activating existing instance"); - - message = g_strdup_printf ("%" G_GUINT32_FORMAT, - startup_timestamp); - } - - bacon_message_connection_send (connection, message); - - /* We never popup a window, so tell startup-notification - * that we are done. */ - gdk_notify_startup_complete (); - - g_free (message); - bacon_message_connection_free (connection); - - return EXIT_SUCCESS; - } - } else { - g_warning ("Cannot create the 'empathy' bacon connection."); + unique_app = unique_app_new_with_commands ("org.gnome.Empathy", + NULL, + "accounts_dialog", + COMMAND_ACCOUNTS_DIALOG, + NULL); + + if (unique_app_is_running (unique_app)) { + unique_app_send_message (unique_app, + accounts_dialog ? + COMMAND_ACCOUNTS_DIALOG : + UNIQUE_ACTIVATE, + NULL); + g_object_unref (unique_app); + return EXIT_SUCCESS; } /* Take well-known name */ @@ -737,12 +662,9 @@ main (int argc, char *argv[]) window = empathy_main_window_show (); icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list); - if (connection) { - /* We se the callback here because we need window */ - bacon_message_connection_set_callback (connection, - on_bacon_message_received, - window); - } + g_signal_connect (unique_app, "message-received", + G_CALLBACK (unique_app_message_cb), + window); /* Handle channels */ dispatcher = empathy_dispatcher_dup_singleton (); @@ -786,6 +708,7 @@ main (int argc, char *argv[]) g_object_unref (location_manager); #endif g_object_unref (ft_factory); + g_object_unref (unique_app); notify_uninit (); -- cgit v1.2.3 From 40ee5f34184be738a4f9f31456480c62a9ad3bb9 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 17 Aug 2009 17:12:23 +0100 Subject: Fix identation --- src/empathy-accounts-dialog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 974b6dcc4..682104d76 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -164,7 +164,8 @@ get_account_setup_widget (EmpathyAccountSettings *settings) { if (!tp_strdiff (cm, dialogs[i].cm) && !tp_strdiff (proto, dialogs[i].proto)) - return empathy_account_widget_new_for_protocol (dialogs[i].proto, settings); + return empathy_account_widget_new_for_protocol (dialogs[i].proto, + settings); } return empathy_account_widget_new_for_protocol ("generic", settings); @@ -717,8 +718,7 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, COL_ACCOUNT_SETTINGS_POINTER, &settings, -1); - equal = empathy_account_settings_has_account - (settings, account); + equal = empathy_account_settings_has_account (settings, account); g_object_unref (settings); if (equal) -- cgit v1.2.3 From d7ad9a427fa8c11bcee8628a0bb5f56602fc84b3 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 17 Aug 2009 17:12:55 +0100 Subject: _new for a signleton needs to return a ref --- src/empathy-accounts-dialog.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 682104d76..87d93c5ae 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1318,6 +1318,7 @@ do_constructor (GType type, if (dialog_singleton) { retval = G_OBJECT (dialog_singleton); + g_object_ref (retval); } else { -- cgit v1.2.3 From 31ef7d012ce3fe7ab4872f4864deaf4230feede1 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 17 Aug 2009 17:54:25 +0100 Subject: Use the remove function account --- src/empathy-accounts-dialog.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 87d93c5ae..98d31b3b9 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1152,8 +1152,7 @@ accounts_dialog_response_cb (GtkWidget *widget, /* FIXME: Warn the user the account is not * complete and is going to be removed. */ - empathy_account_manager_remove - (priv->account_manager, account); + empathy_account_remove_async (account, NULL, NULL); g_object_unref (account); } -- cgit v1.2.3 From 72d258b32eddaae77992e30a127882cbaaab0be0 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Tue, 18 Aug 2009 10:58:59 +0100 Subject: keep a ref on the selected account --- src/empathy-accounts-dialog.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 98d31b3b9..f027eccc0 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1199,6 +1199,7 @@ accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms, { accounts_dialog_set_selected_account (dialog, priv->initial_selection); + g_object_unref (priv->initial_selection); priv->initial_selection = NULL; } } @@ -1304,6 +1305,10 @@ do_dispose (GObject *obj) priv->cms = NULL; } + if (priv->initial_selection != NULL) + g_object_unref (priv->initial_selection); + priv->initial_selection = NULL; + G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->dispose (obj); } @@ -1488,13 +1493,16 @@ empathy_accounts_dialog_show (GtkWindow *parent, priv = GET_PRIV (dialog); - if (selected_account && empathy_connection_managers_is_ready (priv->cms)) - accounts_dialog_set_selected_account (dialog, selected_account); - else - /* save the selection to set it later when the cms - * becomes ready. - */ - priv->initial_selection = selected_account; + if (selected_account) + { + if (empathy_connection_managers_is_ready (priv->cms)) + accounts_dialog_set_selected_account (dialog, selected_account); + else + /* save the selection to set it later when the cms + * becomes ready. + */ + priv->initial_selection = g_object_ref (selected_account); + } gtk_window_present (GTK_WINDOW (priv->window)); -- cgit v1.2.3 From eaac8d0b0724b90e6891ae69c3c8937861b8cdc9 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 19 Aug 2009 12:22:58 +0100 Subject: Don't automagically remove invalid accounts Automagic removal is slightly terrifying, if the user succeeded in creating the account it must have been valid at some point. So leave it there, the UI should indicate that there is a problem with the account so that the user can fix it instead. --- src/empathy-accounts-dialog.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index f027eccc0..f74de13a9 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1135,31 +1135,8 @@ accounts_dialog_response_cb (GtkWidget *widget, gint response, EmpathyAccountsDialog *dialog) { - GList *accounts, *l; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - if (response == GTK_RESPONSE_CLOSE) - { - /* Delete incomplete accounts */ - accounts = empathy_account_manager_dup_accounts - (priv->account_manager); - for (l = accounts; l; l = l->next) - { - EmpathyAccount *account; - - account = l->data; - if (!empathy_account_is_valid (account)) - /* FIXME: Warn the user the account is not - * complete and is going to be removed. - */ - empathy_account_remove_async (account, NULL, NULL); - - g_object_unref (account); - } - g_list_free (accounts); - - gtk_widget_destroy (widget); - } + gtk_widget_destroy (widget); } static void -- cgit v1.2.3 From 6f47d10791dac97495b73200e05122b6406ea74b Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 19 Aug 2009 12:59:06 +0100 Subject: Cache the icon inside EmpathyAccountSettings At some point we should set the Icon property in the account manager, for now just cache it in the settings so we can pass it by reference instead of needing to dup it as that's the API we want to have in the future --- src/empathy-accounts-dialog.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index f74de13a9..913239589 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -192,8 +192,6 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, empathy_account_settings_get_protocol (settings)); accounts_dialog_update_name_label (dialog, settings); - - g_free (icon_name); } static void @@ -396,8 +394,6 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, icon_name = empathy_account_settings_get_icon_name (settings); pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); - g_free (icon_name); - if (pixbuf) { if (status == TP_CONNECTION_STATUS_DISCONNECTED || -- cgit v1.2.3 From 735481c7e2d0d2180d5970b83722452f8aa99ae9 Mon Sep 17 00:00:00 2001 From: Arnaud Maillet Date: Tue, 28 Jul 2009 14:49:26 +0200 Subject: Port empathy-import-dialog to mc5 --- src/empathy-import-dialog.c | 143 +++++++++++++++++++++++++++----------------- src/empathy-import-dialog.h | 7 ++- 2 files changed, 93 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c index 1d0854dd0..a70a6eedd 100644 --- a/src/empathy-import-dialog.c +++ b/src/empathy-import-dialog.c @@ -36,7 +36,7 @@ #include #include #include - +#include #include typedef struct @@ -69,6 +69,8 @@ empathy_import_account_data_new (const gchar *source) data->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) tp_g_value_slice_free); data->source = g_strdup (source); + data->protocol = NULL; + data->connection_manager = NULL; return data; } @@ -78,8 +80,10 @@ empathy_import_account_data_free (EmpathyImportAccountData *data) { if (data == NULL) return; - if (data->profile != NULL) - g_object_unref (data->profile); + if (data->protocol != NULL) + g_free (data->protocol); + if (data->connection_manager != NULL) + g_free (data->connection_manager); if (data->settings != NULL) g_hash_table_destroy (data->settings); if (data->source != NULL) @@ -89,66 +93,60 @@ empathy_import_account_data_free (EmpathyImportAccountData *data) } static void -import_dialog_add_account (EmpathyImportAccountData *data) +import_dialog_create_account_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) { - EmpathyAccountManager *account_manager; + EmpathyImportAccountData *data = (EmpathyImportAccountData *) user_data; EmpathyAccount *account; - GHashTableIter iter; - gpointer key, value; - gchar *display_name; - GValue *username; + GError *error = NULL; - account_manager = empathy_account_manager_dup_singleton (); - account = empathy_account_manager_create_by_profile (account_manager, - data->profile); + account = empathy_account_manager_create_account_finish ( + EMPATHY_ACCOUNT_MANAGER (source), result, &error); - g_object_unref (account_manager); if (account == NULL) { - DEBUG ("Failed to create account"); + DEBUG ("Failed to create account: %s", + error ? error->message : "No error given"); + g_clear_error (&error); + empathy_import_account_data_free (data); return; } - g_hash_table_iter_init (&iter, data->settings); - while (g_hash_table_iter_next (&iter, &key, &value)) - { - const gchar *param = key; - GValue *gvalue = value; + DEBUG ("account created\n"); - switch (G_VALUE_TYPE (gvalue)) - { - case G_TYPE_STRING: - DEBUG ("Set param '%s' to '%s' (string)", - param, g_value_get_string (gvalue)); - empathy_account_set_param_string (account, - param, g_value_get_string (gvalue)); - break; - - case G_TYPE_BOOLEAN: - DEBUG ("Set param '%s' to %s (boolean)", - param, g_value_get_boolean (gvalue) ? "TRUE" : "FALSE"); - empathy_account_set_param_boolean (account, - param, g_value_get_boolean (gvalue)); - break; - - case G_TYPE_INT: - DEBUG ("Set param '%s' to '%i' (integer)", - param, g_value_get_int (gvalue)); - empathy_account_set_param_int (account, - param, g_value_get_int (gvalue)); - break; - } - } + g_object_unref (account); +} + +static void +import_dialog_add_account (EmpathyImportAccountData *data) +{ + EmpathyAccountManager *account_manager; + gchar *display_name; + GHashTable *properties; + GValue *username; + + account_manager = empathy_account_manager_dup_singleton (); + + DEBUG ("connection_manager: %s\n", data->connection_manager); /* Set the display name of the account */ username = g_hash_table_lookup (data->settings, "account"); display_name = g_strdup_printf ("%s (%s)", - mc_profile_get_display_name (data->profile), + data->protocol, g_value_get_string (username)); - empathy_account_set_display_name (account, display_name); + DEBUG ("display name: %s\n", display_name); + + properties = g_hash_table_new (NULL, NULL); + + empathy_account_manager_create_account_async (account_manager, + (const gchar*) data->connection_manager, data->protocol, display_name, + data->settings, properties, import_dialog_create_account_cb, NULL); + + g_hash_table_unref (properties); g_free (display_name); - g_object_unref (account); + g_object_unref (account_manager); } static gboolean @@ -159,18 +157,22 @@ import_dialog_account_id_in_list (GList *accounts, for (l = accounts; l; l = l->next) { - McAccount *account = l->data; - gchar *value = NULL; + EmpathyAccount *account = l->data; + const gchar *account_string; + GValue *value; gboolean result; + const GHashTable *parameters; + + parameters = empathy_account_get_parameters (account); - mc_account_get_param_string (account, "account", &value); + value = g_hash_table_lookup ((GHashTable *) parameters, "account"); if (value == NULL) continue; - result = tp_strdiff (value, account_id); + account_string = g_value_get_string (value); - g_free (value); + result = tp_strdiff (account_string, account_id); if (!result) return TRUE; @@ -179,12 +181,39 @@ import_dialog_account_id_in_list (GList *accounts, return FALSE; } +static gboolean protocol_is_supported (EmpathyImportAccountData *data) +{ + EmpathyConnectionManagers *cm = + empathy_connection_managers_dup_singleton (); + GList *cms = empathy_connection_managers_get_cms (cm); + GList *l; + gboolean proto_is_supported = FALSE; + + for (l = cms; l; l = l->next) + { + TpConnectionManager *tp_cm = l->data; + const gchar *cm_name = tp_connection_manager_get_name (tp_cm); + if (tp_connection_manager_has_protocol (tp_cm, + (const gchar*)data->protocol)) + { + data->connection_manager = g_strdup (cm_name); + proto_is_supported = TRUE; + break; + } + } + + g_object_unref (cm); + + return proto_is_supported; +} + static void import_dialog_add_accounts_to_model (EmpathyImportDialog *dialog) { GtkTreeModel *model; GtkTreeIter iter; GList *l; + EmpathyAccountManager *manager = empathy_account_manager_dup_singleton (); model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); @@ -195,27 +224,33 @@ import_dialog_add_accounts_to_model (EmpathyImportDialog *dialog) gboolean import; GList *accounts; + if (!protocol_is_supported (data)) + continue; + value = g_hash_table_lookup (data->settings, "account"); - accounts = mc_accounts_list_by_profile (data->profile); + accounts = empathy_account_manager_dup_accounts (manager); /* Only set the "Import" cell to be active if there isn't already an * account set up with the same account id. */ import = !import_dialog_account_id_in_list (accounts, g_value_get_string (value)); - mc_accounts_list_free (accounts); + g_list_foreach (accounts, (GFunc) g_object_unref, NULL); + g_list_free (accounts); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_IMPORT, import, - COL_PROTOCOL, mc_profile_get_display_name (data->profile), + COL_PROTOCOL, data->protocol, COL_NAME, g_value_get_string (value), COL_SOURCE, data->source, COL_ACCOUNT_DATA, data, -1); } + + g_object_unref (manager); } static void diff --git a/src/empathy-import-dialog.h b/src/empathy-import-dialog.h index 0e3fd148f..bdd0de732 100644 --- a/src/empathy-import-dialog.h +++ b/src/empathy-import-dialog.h @@ -20,7 +20,6 @@ */ #include -#include #ifndef __EMPATHY_IMPORT_DIALOG_H__ #define __EMPATHY_IMPORT_DIALOG_H__ @@ -31,8 +30,10 @@ typedef struct { /* Table mapping CM param string to a GValue */ GHashTable *settings; - /* The profile to use for this account */ - McProfile *profile; + /* Protocol name */ + gchar *protocol; + /* Connection manager name */ + gchar *connection_manager; /* The name of the account import source */ gchar *source; } EmpathyImportAccountData; -- cgit v1.2.3 From 5e48d35061335282d7cf64e00dcf932dffcdfb54 Mon Sep 17 00:00:00 2001 From: Arnaud Maillet Date: Tue, 28 Jul 2009 14:49:53 +0200 Subject: Port empathy-import-pidgin to mc5 --- src/empathy-import-pidgin.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/empathy-import-pidgin.c b/src/empathy-import-pidgin.c index 935c022ea..5c8221ce7 100644 --- a/src/empathy-import-pidgin.c +++ b/src/empathy-import-pidgin.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -114,8 +115,7 @@ import_dialog_pidgin_parse_setting (EmpathyImportAccountData *data, /* Search for the map corresponding to setting we are parsing */ for (i = 0; i < G_N_ELEMENTS (pidgin_cm_map); i++) { - if (!tp_strdiff (mc_profile_get_protocol_name (data->profile), - pidgin_cm_map[i].protocol) && + if (!tp_strdiff (data->protocol, pidgin_cm_map[i].protocol) && !tp_strdiff (tag_name, pidgin_cm_map[i].pidgin_name)) { item = pidgin_cm_map + i; @@ -199,23 +199,26 @@ empathy_import_pidgin_load (void) if (!tp_strdiff ((gchar *) child->name, PIDGIN_ACCOUNT_TAG_PROTOCOL)) { - gchar *content; + xmlChar *content; const gchar *protocol; - protocol = content = (gchar *) xmlNodeGetContent (child); + content = xmlNodeGetContent (child); + + protocol = (const gchar *) content; if (g_str_has_prefix (protocol, "prpl-")) protocol += 5; - if (!tp_strdiff (protocol, PIDGIN_PROTOCOL_BONJOUR)) - protocol = "salut"; - else if (!tp_strdiff (protocol, PIDGIN_PROTOCOL_NOVELL)) - protocol = "groupwise"; + data->protocol = g_strdup (protocol); + + if (!tp_strdiff (data->protocol, PIDGIN_PROTOCOL_BONJOUR)) + data->protocol = "salut"; + else if (!tp_strdiff (data->protocol, PIDGIN_PROTOCOL_NOVELL)) + data->protocol = "groupwise"; - data->profile = mc_profile_lookup (protocol); - g_free (content); + xmlFree (content); - if (data->profile == NULL) + if (data->protocol == NULL) break; } @@ -240,8 +243,7 @@ empathy_import_pidgin_load (void) username = name; /* Split "username@server" if it is an IRC account */ - if (strstr (name, "@") && !tp_strdiff ( - mc_profile_get_protocol_name (data->profile), "irc")) + if (strstr (name, "@") && !tp_strdiff (data->protocol, "irc")) { nick_server = g_strsplit (name, "@", 2); username = nick_server[0]; @@ -287,12 +289,11 @@ empathy_import_pidgin_load (void) /* If we have the needed settings, add the account data to the list, * otherwise free the data */ - if (data->profile != NULL && g_hash_table_size (data->settings) > 0) + if (data->protocol != NULL && g_hash_table_size (data->settings) > 0) { /* Special-case XMPP: * http://bugzilla.gnome.org/show_bug.cgi?id=579992 */ - if (!tp_strdiff ( - mc_profile_get_protocol_name (data->profile), "jabber")) + if (!tp_strdiff (data->protocol, "jabber")) { if (EMP_STR_EMPTY (tp_asv_get_string (data->settings, "server"))) { -- cgit v1.2.3 From 6da962b47b8a9b6bba3aecf8fda82d1e58d547cf Mon Sep 17 00:00:00 2001 From: Arnaud Maillet Date: Tue, 28 Jul 2009 15:55:28 +0200 Subject: Add empathy-import-dialog and empathy-import-pidgin to the makefile --- src/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 01f47d2bb..d0b86edfc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,6 +39,8 @@ empathy_handwritten_source = \ empathy-chat-window.c empathy-chat-window.h \ empathy-event-manager.c empathy-event-manager.h \ empathy-ft-manager.c empathy-ft-manager.h \ + empathy-import-dialog.c empathy-import-dialog.h \ + empathy-import-pidgin.c empathy-import-pidgin.h \ empathy-main-window.c empathy-main-window.h \ empathy-misc.c empathy-misc.h \ empathy-new-chatroom-dialog.c empathy-new-chatroom-dialog.h \ -- cgit v1.2.3 From f51d76329d1f2994c450aa0c8bf3a37412512581 Mon Sep 17 00:00:00 2001 From: Arnaud Maillet Date: Tue, 28 Jul 2009 15:57:41 +0200 Subject: Instantiate mc5 pidgin account importer in empathy-accounts-dialog --- src/empathy-accounts-dialog.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 913239589..8b896676d 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -45,10 +45,7 @@ #include #include "empathy-accounts-dialog.h" -#if 0 -/* FIXME MC-5 */ #include "empathy-import-dialog.h" -#endif #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT #include @@ -117,11 +114,8 @@ enum { static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings); -#if 0 -/* FIXME MC-5 */ static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog); -#endif static void accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog, @@ -1114,8 +1108,6 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget *button, gtk_widget_destroy (message_dialog); } -#if 0 -/* FIXME MC-5 */ static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) @@ -1124,7 +1116,6 @@ accounts_dialog_button_import_clicked_cb (GtkWidget *button, empathy_import_dialog_show (GTK_WINDOW (priv->window), TRUE); } -#endif static void accounts_dialog_response_cb (GtkWidget *widget, @@ -1214,10 +1205,7 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) "button_back", "clicked", accounts_dialog_button_back_clicked_cb, "button_add", "clicked", accounts_dialog_button_add_clicked_cb, "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb, -#if 0 - /* FIXME MC-5 */ "button_import", "clicked", accounts_dialog_button_import_clicked_cb, -#endif "button_help", "clicked", accounts_dialog_button_help_clicked_cb, NULL); @@ -1400,8 +1388,6 @@ do_constructed (GObject *object) EMPATHY_PREFS_IMPORT_ASKED, &import_asked); -#if 0 - /* FIXME MC-5 */ if (empathy_import_dialog_accounts_to_import ()) { @@ -1417,7 +1403,6 @@ do_constructed (GObject *object) { gtk_widget_set_sensitive (priv->button_import, FALSE); } -#endif } static void -- cgit v1.2.3 From 3245c197d95c326372323addde9f62ca96167a33 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Fri, 21 Aug 2009 18:51:24 +0100 Subject: Fix a small memory leak --- src/empathy-import-pidgin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/empathy-import-pidgin.c b/src/empathy-import-pidgin.c index 5c8221ce7..6a145ff93 100644 --- a/src/empathy-import-pidgin.c +++ b/src/empathy-import-pidgin.c @@ -209,12 +209,12 @@ empathy_import_pidgin_load (void) if (g_str_has_prefix (protocol, "prpl-")) protocol += 5; - data->protocol = g_strdup (protocol); - - if (!tp_strdiff (data->protocol, PIDGIN_PROTOCOL_BONJOUR)) - data->protocol = "salut"; - else if (!tp_strdiff (data->protocol, PIDGIN_PROTOCOL_NOVELL)) - data->protocol = "groupwise"; + if (!tp_strdiff (protocol, PIDGIN_PROTOCOL_BONJOUR)) + data->protocol = g_strdup ("salut"); + else if (!tp_strdiff (protocol, PIDGIN_PROTOCOL_NOVELL)) + data->protocol = g_strdup ("groupwise"); + else + data->protocol = g_strdup (protocol); xmlFree (content); -- cgit v1.2.3 From 74209eb1b8b0cf9df87e66e2e028cae885b39a5f Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 1 Aug 2009 16:54:23 +0200 Subject: Port empathy.c to telepathy-style --- src/empathy.c | 1072 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 546 insertions(+), 526 deletions(-) (limited to 'src') diff --git a/src/empathy.c b/src/empathy.c index 718fe70bf..b80b64be7 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -1,6 +1,5 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2007-2008 Collabora Ltd. + * Copyright (C) 2007-2009 Collabora Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -82,402 +81,424 @@ static void dispatch_cb (EmpathyDispatcher *dispatcher, - EmpathyDispatchOperation *operation, - gpointer user_data) + EmpathyDispatchOperation *operation, + gpointer user_data) { - GQuark channel_type; - - channel_type = empathy_dispatch_operation_get_channel_type_id (operation); - - if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_TEXT) { - EmpathyTpChat *tp_chat; - EmpathyChat *chat = NULL; - const gchar *id; - - tp_chat = EMPATHY_TP_CHAT ( - empathy_dispatch_operation_get_channel_wrapper (operation)); - - id = empathy_tp_chat_get_id (tp_chat); - if (!id) { - EmpathyContact *contact; - - contact = empathy_tp_chat_get_remote_contact (tp_chat); - if (contact) { - id = empathy_contact_get_id (contact); - } - } - - if (id) { - EmpathyAccountManager *manager; - TpConnection *connection; - EmpathyAccount *account; - - manager = empathy_account_manager_dup_singleton (); - connection = empathy_tp_chat_get_connection (tp_chat); - account = empathy_account_manager_get_account_for_connection (manager, - connection); - chat = empathy_chat_window_find_chat (account, id); - g_object_unref (manager); - } - - if (chat) { - empathy_chat_set_tp_chat (chat, tp_chat); - } else { - chat = empathy_chat_new (tp_chat); - } - - empathy_chat_window_present_chat (chat); - - empathy_dispatch_operation_claim (operation); - } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) { - EmpathyCallFactory *factory; - - factory = empathy_call_factory_get (); - empathy_call_factory_claim_channel (factory, operation); - } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER) { - EmpathyFTFactory *factory; - - factory = empathy_ft_factory_dup_singleton (); - - /* if the operation is not incoming, don't claim it, - * as it might have been triggered by another client, and - * we are observing it. - */ - if (empathy_dispatch_operation_is_incoming (operation)) { - empathy_ft_factory_claim_channel (factory, operation); - } - } + GQuark channel_type; + + channel_type = empathy_dispatch_operation_get_channel_type_id (operation); + + if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_TEXT) + { + EmpathyTpChat *tp_chat; + EmpathyChat *chat = NULL; + const gchar *id; + + tp_chat = EMPATHY_TP_CHAT + (empathy_dispatch_operation_get_channel_wrapper (operation)); + + id = empathy_tp_chat_get_id (tp_chat); + if (!id) + { + EmpathyContact *contact; + + contact = empathy_tp_chat_get_remote_contact (tp_chat); + if (contact) + id = empathy_contact_get_id (contact); + } + + if (id) + { + EmpathyAccountManager *manager; + TpConnection *connection; + EmpathyAccount *account; + + manager = empathy_account_manager_dup_singleton (); + connection = empathy_tp_chat_get_connection (tp_chat); + account = empathy_account_manager_get_account_for_connection (manager, + connection); + chat = empathy_chat_window_find_chat (account, id); + g_object_unref (manager); + } + + if (chat) + empathy_chat_set_tp_chat (chat, tp_chat); + else + chat = empathy_chat_new (tp_chat); + + empathy_chat_window_present_chat (chat); + + empathy_dispatch_operation_claim (operation); + } + else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) + { + EmpathyCallFactory *factory; + + factory = empathy_call_factory_get (); + empathy_call_factory_claim_channel (factory, operation); + } + else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER) + { + EmpathyFTFactory *factory; + + factory = empathy_ft_factory_dup_singleton (); + + /* if the operation is not incoming, don't claim it, + * as it might have been triggered by another client, and + * we are observing it. + */ + if (empathy_dispatch_operation_is_incoming (operation)) + empathy_ft_factory_claim_channel (factory, operation); + } } /* Salut account creation */ static gboolean should_create_salut_account (void) { - EmpathyAccountManager *manager; - gboolean salut_created = FALSE; - GList *accounts, *l; + EmpathyAccountManager *manager; + gboolean salut_created = FALSE; + GList *accounts, *l; - /* Check if we already created a salut account */ - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, - &salut_created); + /* Check if we already created a salut account */ + empathy_conf_get_bool (empathy_conf_get (), + EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, + &salut_created); - if (salut_created) - { - DEBUG ("Gconf says we already created a salut account once"); - return FALSE; - } + if (salut_created) + { + DEBUG ("Gconf says we already created a salut account once"); + return FALSE; + } - manager = empathy_account_manager_dup_singleton (); - accounts = empathy_account_manager_dup_accounts (manager); + manager = empathy_account_manager_dup_singleton (); + accounts = empathy_account_manager_dup_accounts (manager); - for (l = accounts; l != NULL; l = g_list_next (l)) { - EmpathyAccount *account = EMPATHY_ACCOUNT (l->data); + for (l = accounts; l != NULL; l = g_list_next (l)) + { + EmpathyAccount *account = EMPATHY_ACCOUNT (l->data); - if (!tp_strdiff (empathy_account_get_protocol (account), "local-xmpp")) - salut_created = TRUE; + if (!tp_strdiff (empathy_account_get_protocol (account), "local-xmpp")) + salut_created = TRUE; - g_object_unref (account); - } + g_object_unref (account); + } - g_object_unref (manager); + g_object_unref (manager); - if (salut_created) - { - DEBUG ("Existing salut account already exists, flagging so in gconf"); - empathy_conf_set_bool (empathy_conf_get (), - EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, - TRUE); - } + if (salut_created) + { + DEBUG ("Existing salut account already exists, flagging so in gconf"); + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, + TRUE); + } - return !salut_created; + return !salut_created; } static void salut_account_created (GObject *source, - GAsyncResult *result, gpointer user_data) + GAsyncResult *result, + gpointer user_data) { - EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source); - EmpathyAccount *account; - GError *error = NULL; - - if (!empathy_account_settings_apply_finish (settings, result, &error)) - { - DEBUG ("Failed to create salut account: %s", error->message); - g_error_free (error); - return; - } - - account = empathy_account_settings_get_account (settings); - - empathy_account_set_enabled (account, TRUE); - empathy_conf_set_bool (empathy_conf_get (), - EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, - TRUE); + EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source); + EmpathyAccount *account; + GError *error = NULL; + + if (!empathy_account_settings_apply_finish (settings, result, &error)) + { + DEBUG ("Failed to create salut account: %s", error->message); + g_error_free (error); + return; + } + + account = empathy_account_settings_get_account (settings); + + empathy_account_set_enabled (account, TRUE); + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, + TRUE); } static void use_conn_notify_cb (EmpathyConf *conf, - const gchar *key, - gpointer user_data) + const gchar *key, + gpointer user_data) { - EmpathyConnectivity *connectivity = user_data; - gboolean use_conn; + EmpathyConnectivity *connectivity = user_data; + gboolean use_conn; - if (empathy_conf_get_bool (conf, key, &use_conn)) { - empathy_connectivity_set_use_conn (connectivity, use_conn); - } + if (empathy_conf_get_bool (conf, key, &use_conn)) + { + empathy_connectivity_set_use_conn (connectivity, use_conn); + } } static void create_salut_account_if_needed (EmpathyConnectionManagers *managers) { - EmpathyAccountSettings *settings; - TpConnectionManager *manager; - const TpConnectionManagerProtocol *protocol; - EBook *book; - EContact *contact; - gchar *nickname = NULL; - gchar *first_name = NULL; - gchar *last_name = NULL; - gchar *email = NULL; - gchar *jid = NULL; - GError *error = NULL; - - - if (!should_create_salut_account ()) - return; - - manager = empathy_connection_managers_get_cm (managers, "salut"); - if (manager == NULL) - { - DEBUG ("Salut not installed, not making a salut account"); - return; - } - - protocol = tp_connection_manager_get_protocol (manager, "local-xmpp"); - if (protocol == NULL) - { - DEBUG ("Salut doesn't support local-xmpp!!"); - return; - } - - DEBUG ("Trying to add a salut account..."); - - /* Get self EContact from EDS */ - if (!e_book_get_self (&contact, &book, &error)) { - DEBUG ("Failed to get self econtact: %s", - error ? error->message : "No error given"); - g_clear_error (&error); - return; - } - - settings = empathy_account_settings_new ("salut", "local-xmpp", - _("People nearby")); - - nickname = e_contact_get (contact, E_CONTACT_NICKNAME); - first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME); - last_name = e_contact_get (contact, E_CONTACT_FAMILY_NAME); - email = e_contact_get (contact, E_CONTACT_EMAIL_1); - jid = e_contact_get (contact, E_CONTACT_IM_JABBER_HOME_1); - - if (!tp_strdiff (nickname, "nickname")) { - g_free (nickname); - nickname = NULL; - } - - DEBUG ("Salut account created:\nnickname=%s\nfirst-name=%s\n" - "last-name=%s\nemail=%s\njid=%s\n", - nickname, first_name, last_name, email, jid); - - empathy_account_settings_set_string (settings, "nickname", nickname ? nickname : ""); - empathy_account_settings_set_string (settings, "first-name", first_name ? first_name : ""); - empathy_account_settings_set_string (settings, "last-name", last_name ? last_name : ""); - empathy_account_settings_set_string (settings, "email", email ? email : ""); - empathy_account_settings_set_string (settings, "jid", jid ? jid : ""); - - empathy_account_settings_apply_async (settings, - salut_account_created, NULL); - - g_free (nickname); - g_free (first_name); - g_free (last_name); - g_free (email); - g_free (jid); - g_object_unref (settings); - g_object_unref (contact); - g_object_unref (book); + EmpathyAccountSettings *settings; + TpConnectionManager *manager; + const TpConnectionManagerProtocol *protocol; + EBook *book; + EContact *contact; + gchar *nickname = NULL; + gchar *first_name = NULL; + gchar *last_name = NULL; + gchar *email = NULL; + gchar *jid = NULL; + GError *error = NULL; + + + if (!should_create_salut_account ()) + return; + + manager = empathy_connection_managers_get_cm (managers, "salut"); + if (manager == NULL) + { + DEBUG ("Salut not installed, not making a salut account"); + return; + } + + protocol = tp_connection_manager_get_protocol (manager, "local-xmpp"); + if (protocol == NULL) + { + DEBUG ("Salut doesn't support local-xmpp!!"); + return; + } + + DEBUG ("Trying to add a salut account..."); + + /* Get self EContact from EDS */ + if (!e_book_get_self (&contact, &book, &error)) + { + DEBUG ("Failed to get self econtact: %s", + error ? error->message : "No error given"); + g_clear_error (&error); + return; + } + + settings = empathy_account_settings_new ("salut", "local-xmpp", + _("People nearby")); + + nickname = e_contact_get (contact, E_CONTACT_NICKNAME); + first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME); + last_name = e_contact_get (contact, E_CONTACT_FAMILY_NAME); + email = e_contact_get (contact, E_CONTACT_EMAIL_1); + jid = e_contact_get (contact, E_CONTACT_IM_JABBER_HOME_1); + + if (!tp_strdiff (nickname, "nickname")) + { + g_free (nickname); + nickname = NULL; + } + + DEBUG ("Salut account created:\nnickname=%s\nfirst-name=%s\n" + "last-name=%s\nemail=%s\njid=%s\n", + nickname, first_name, last_name, email, jid); + + empathy_account_settings_set_string (settings, + "nickname", nickname ? nickname : ""); + empathy_account_settings_set_string (settings, + "first-name", first_name ? first_name : ""); + empathy_account_settings_set_string (settings, + "last-name", last_name ? last_name : ""); + empathy_account_settings_set_string (settings, "email", email ? email : ""); + empathy_account_settings_set_string (settings, "jid", jid ? jid : ""); + + empathy_account_settings_apply_async (settings, + salut_account_created, NULL); + + g_free (nickname); + g_free (first_name); + g_free (last_name); + g_free (email); + g_free (jid); + g_object_unref (settings); + g_object_unref (contact); + g_object_unref (book); } static void connection_managers_ready_cb (EmpathyConnectionManagers *managers, - GParamSpec *spec, gpointer user_data) + GParamSpec *spec, + gpointer user_data) { - if (empathy_connection_managers_is_ready (managers)) - { - create_salut_account_if_needed (managers); - g_object_unref (managers); - managers = NULL; - } + if (empathy_connection_managers_is_ready (managers)) + { + create_salut_account_if_needed (managers); + g_object_unref (managers); + managers = NULL; + } } static void create_salut_account (void) { - EmpathyConnectionManagers *managers; - - if (!should_create_salut_account ()) - return; - - managers = empathy_connection_managers_dup_singleton (); - - if (empathy_connection_managers_is_ready (managers)) - { - create_salut_account_if_needed (managers); - g_object_unref (managers); - } - else - { - g_signal_connect (managers, "notify::ready", - G_CALLBACK (connection_managers_ready_cb), NULL); - } + EmpathyConnectionManagers *managers; + + if (!should_create_salut_account ()) + return; + + managers = empathy_connection_managers_dup_singleton (); + + if (empathy_connection_managers_is_ready (managers)) + { + create_salut_account_if_needed (managers); + g_object_unref (managers); + } + else + { + g_signal_connect (managers, "notify::ready", + G_CALLBACK (connection_managers_ready_cb), NULL); + } } static void migrate_config_to_xdg_dir (void) { - gchar *xdg_dir, *old_dir, *xdg_filename, *old_filename; - int i; - GFile *xdg_file, *old_file; - static const gchar* filenames[] = { - "geometry.ini", - "irc-networks.xml", - "chatrooms.xml", - "contact-groups.xml", - "status-presets.xml", - "accels.txt", - NULL - }; - - xdg_dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL); - if (g_file_test (xdg_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - /* xdg config dir already exists */ - g_free (xdg_dir); - return; - } - - old_dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); - if (!g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - /* old config dir didn't exist */ - g_free (xdg_dir); - g_free (old_dir); - return; - } - - if (g_mkdir_with_parents (xdg_dir, (S_IRUSR | S_IWUSR | S_IXUSR)) == -1) { - DEBUG ("Failed to create configuration directory; aborting migration"); - g_free (xdg_dir); - g_free (old_dir); - return; - } - - for (i = 0; filenames[i]; i++) { - old_filename = g_build_filename (old_dir, filenames[i], NULL); - if (!g_file_test (old_filename, G_FILE_TEST_EXISTS)) { - g_free (old_filename); - continue; - } - xdg_filename = g_build_filename (xdg_dir, filenames[i], NULL); - old_file = g_file_new_for_path (old_filename); - xdg_file = g_file_new_for_path (xdg_filename); - if (!g_file_move (old_file, xdg_file, G_FILE_COPY_NONE, - NULL, NULL, NULL, NULL)) { - DEBUG ("Failed to migrate %s", filenames[i]); - } - g_free (old_filename); - g_free (xdg_filename); - g_object_unref (old_file); - g_object_unref (xdg_file); - } - - g_free (xdg_dir); - g_free (old_dir); + gchar *xdg_dir, *old_dir, *xdg_filename, *old_filename; + int i; + GFile *xdg_file, *old_file; + static const gchar* filenames[] = { + "geometry.ini", + "irc-networks.xml", + "chatrooms.xml", + "contact-groups.xml", + "status-presets.xml", + "accels.txt", + NULL + }; + + xdg_dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL); + if (g_file_test (xdg_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) + { + /* xdg config dir already exists */ + g_free (xdg_dir); + return; + } + + old_dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); + if (!g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) + { + /* old config dir didn't exist */ + g_free (xdg_dir); + g_free (old_dir); + return; + } + + if (g_mkdir_with_parents (xdg_dir, (S_IRUSR | S_IWUSR | S_IXUSR)) == -1) + { + DEBUG ("Failed to create configuration directory; aborting migration"); + g_free (xdg_dir); + g_free (old_dir); + return; + } + + for (i = 0; filenames[i]; i++) + { + old_filename = g_build_filename (old_dir, filenames[i], NULL); + if (!g_file_test (old_filename, G_FILE_TEST_EXISTS)) + { + g_free (old_filename); + continue; + } + xdg_filename = g_build_filename (xdg_dir, filenames[i], NULL); + old_file = g_file_new_for_path (old_filename); + xdg_file = g_file_new_for_path (xdg_filename); + + if (!g_file_move (old_file, xdg_file, G_FILE_COPY_NONE, + NULL, NULL, NULL, NULL)) + DEBUG ("Failed to migrate %s", filenames[i]); + + g_free (old_filename); + g_free (xdg_filename); + g_object_unref (old_file); + g_object_unref (xdg_file); + } + + g_free (xdg_dir); + g_free (old_dir); } static UniqueResponse unique_app_message_cb (UniqueApp *unique_app, - gint command, - UniqueMessageData *data, - guint timestamp, - gpointer user_data) + gint command, + UniqueMessageData *data, + guint timestamp, + gpointer user_data) { - GtkWidget *window = user_data; - - DEBUG ("Other instance launched, presenting the main window. " - "Command=%d, timestamp %u", command, timestamp); - - if (command == COMMAND_ACCOUNTS_DIALOG) { - empathy_accounts_dialog_show (GTK_WINDOW (window), NULL); - } else { - gtk_window_set_screen (GTK_WINDOW (window), - unique_message_data_get_screen (data)); - gtk_window_set_startup_id (GTK_WINDOW (window), - unique_message_data_get_startup_id (data)); - gtk_window_present_with_time (GTK_WINDOW (window), timestamp); - } - - return UNIQUE_RESPONSE_OK; + GtkWidget *window = user_data; + + DEBUG ("Other instance launched, presenting the main window. " + "Command=%d, timestamp %u", command, timestamp); + + if (command == COMMAND_ACCOUNTS_DIALOG) + { + empathy_accounts_dialog_show (GTK_WINDOW (window), NULL); + } + else + { + gtk_window_set_screen (GTK_WINDOW (window), + unique_message_data_get_screen (data)); + gtk_window_set_startup_id (GTK_WINDOW (window), + unique_message_data_get_startup_id (data)); + gtk_window_present_with_time (GTK_WINDOW (window), timestamp); + } + + return UNIQUE_RESPONSE_OK; } static gboolean show_version_cb (const char *option_name, - const char *value, - gpointer data, - GError **error) + const char *value, + gpointer data, + GError **error) { - g_print ("%s\n", PACKAGE_STRING); + g_print ("%s\n", PACKAGE_STRING); - exit (EXIT_SUCCESS); + exit (EXIT_SUCCESS); - return FALSE; + return FALSE; } static void new_incoming_transfer_cb (EmpathyFTFactory *factory, - EmpathyFTHandler *handler, - GError *error, - gpointer user_data) + EmpathyFTHandler *handler, + GError *error, + gpointer user_data) { - if (error) { - empathy_ft_manager_display_error (handler, error); - } else { - empathy_receive_file_with_file_chooser (handler); - } + if (error) + empathy_ft_manager_display_error (handler, error); + else + empathy_receive_file_with_file_chooser (handler); } static void new_ft_handler_cb (EmpathyFTFactory *factory, - EmpathyFTHandler *handler, - GError *error, - gpointer user_data) + EmpathyFTHandler *handler, + GError *error, + gpointer user_data) { - if (error) { - empathy_ft_manager_display_error (handler, error); - } else { - empathy_ft_manager_add_handler (handler); - } + if (error) + empathy_ft_manager_display_error (handler, error); + else + empathy_ft_manager_add_handler (handler); - g_object_unref (handler); + g_object_unref (handler); } static void -new_call_handler_cb (EmpathyCallFactory *factory, EmpathyCallHandler *handler, - gboolean outgoing, gpointer user_data) +new_call_handler_cb (EmpathyCallFactory *factory, + EmpathyCallHandler *handler, + gboolean outgoing, + gpointer user_data) { - EmpathyCallWindow *window; + EmpathyCallWindow *window; - window = empathy_call_window_new (handler); - gtk_widget_show (GTK_WIDGET (window)); + window = empathy_call_window_new (handler); + gtk_widget_show (GTK_WIDGET (window)); } #ifdef ENABLE_DEBUG @@ -487,237 +508,236 @@ default_log_handler (const gchar *log_domain, const gchar *message, gpointer user_data) { - g_log_default_handler (log_domain, log_level, message, NULL); - - /* G_LOG_DOMAIN = "empathy". No need to send empathy messages to the - * debugger as they already have in empathy_debug. */ - if (log_level != G_LOG_LEVEL_DEBUG - || tp_strdiff (log_domain, G_LOG_DOMAIN)) { - EmpathyDebugger *dbg; - GTimeVal now; - - dbg = empathy_debugger_get_singleton (); - g_get_current_time (&now); - - empathy_debugger_add_message (dbg, &now, log_domain, - log_level, message); - } + g_log_default_handler (log_domain, log_level, message, NULL); + + /* G_LOG_DOMAIN = "empathy". No need to send empathy messages to the + * debugger as they already have in empathy_debug. */ + if (log_level != G_LOG_LEVEL_DEBUG + || tp_strdiff (log_domain, G_LOG_DOMAIN)) + { + EmpathyDebugger *dbg; + GTimeVal now; + + dbg = empathy_debugger_get_singleton (); + g_get_current_time (&now); + + empathy_debugger_add_message (dbg, &now, log_domain, + log_level, message); + } } #endif /* ENABLE_DEBUG */ static void account_manager_ready_cb (EmpathyAccountManager *manager, - GParamSpec *spec, - gpointer user_data) + GParamSpec *spec, + gpointer user_data) { - if (!empathy_account_manager_is_ready (manager)) - return; - - if (empathy_account_manager_get_count (manager) == 0) - { - empathy_accounts_dialog_show (GTK_WINDOW (empathy_main_window_get ()), - NULL); - } - create_salut_account (); + if (!empathy_account_manager_is_ready (manager)) + return; + + if (empathy_account_manager_get_count (manager) == 0) + empathy_accounts_dialog_show (GTK_WINDOW (empathy_main_window_get ()), + NULL); + + create_salut_account (); } int main (int argc, char *argv[]) { #if HAVE_GEOCLUE - EmpathyLocationManager *location_manager = NULL; + EmpathyLocationManager *location_manager = NULL; #endif - EmpathyStatusIcon *icon; - EmpathyDispatcher *dispatcher; - EmpathyAccountManager *account_manager; - EmpathyLogManager *log_manager; - EmpathyChatroomManager *chatroom_manager; - EmpathyCallFactory *call_factory; - EmpathyFTFactory *ft_factory; - GtkWidget *window; - EmpathyIdle *idle; - EmpathyConnectivity *connectivity; - gboolean autoconnect = TRUE; - gboolean no_connect = FALSE; - gboolean hide_contact_list = FALSE; - gboolean accounts_dialog = FALSE; - GError *error = NULL; - TpDBusDaemon *dbus_daemon; - UniqueApp *unique_app; - GOptionEntry options[] = { - { "no-connect", 'n', - 0, G_OPTION_ARG_NONE, &no_connect, - N_("Don't connect on startup"), - NULL }, - { "hide-contact-list", 'h', - 0, G_OPTION_ARG_NONE, &hide_contact_list, - N_("Don't show the contact list on startup"), - NULL }, - { "accounts", 'a', - 0, G_OPTION_ARG_NONE, &accounts_dialog, - N_("Show the accounts dialog"), - NULL }, - { "version", 'v', - G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_cb, NULL, NULL }, - { NULL } - }; - - /* Init */ - g_thread_init (NULL); - empathy_init (); - - if (!gtk_init_with_args (&argc, &argv, - N_("- Empathy IM Client"), - options, GETTEXT_PACKAGE, &error)) { - g_warning ("Error in empathy init: %s", error->message); - return EXIT_FAILURE; - } - - empathy_gtk_init (); - g_set_application_name (_(PACKAGE_NAME)); - g_setenv ("PULSE_PROP_media.role", "phone", TRUE); - - gst_init (&argc, &argv); + EmpathyStatusIcon *icon; + EmpathyDispatcher *dispatcher; + EmpathyAccountManager *account_manager; + EmpathyLogManager *log_manager; + EmpathyChatroomManager *chatroom_manager; + EmpathyCallFactory *call_factory; + EmpathyFTFactory *ft_factory; + GtkWidget *window; + EmpathyIdle *idle; + EmpathyConnectivity *connectivity; + gboolean autoconnect = TRUE; + gboolean no_connect = FALSE; + gboolean hide_contact_list = FALSE; + gboolean accounts_dialog = FALSE; + GError *error = NULL; + TpDBusDaemon *dbus_daemon; + UniqueApp *unique_app; + + GOptionEntry options[] = { + { "no-connect", 'n', + 0, G_OPTION_ARG_NONE, &no_connect, + N_("Don't connect on startup"), + NULL }, + { "hide-contact-list", 'h', + 0, G_OPTION_ARG_NONE, &hide_contact_list, + N_("Don't show the contact list on startup"), + NULL }, + { "accounts", 'a', + 0, G_OPTION_ARG_NONE, &accounts_dialog, + N_("Show the accounts dialog"), + NULL }, + { "version", 'v', + G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_cb, + NULL, NULL }, + { NULL } + }; + + /* Init */ + g_thread_init (NULL); + empathy_init (); + + if (!gtk_init_with_args (&argc, &argv, N_("- Empathy IM Client"), + options, GETTEXT_PACKAGE, &error)) + { + g_warning ("Error in empathy init: %s", error->message); + return EXIT_FAILURE; + } + + empathy_gtk_init (); + g_set_application_name (_(PACKAGE_NAME)); + g_setenv ("PULSE_PROP_media.role", "phone", TRUE); + + gst_init (&argc, &argv); #if HAVE_LIBCHAMPLAIN - gtk_clutter_init (&argc, &argv); + gtk_clutter_init (&argc, &argv); #endif - gtk_window_set_default_icon_name ("empathy"); - textdomain (GETTEXT_PACKAGE); + gtk_window_set_default_icon_name ("empathy"); + textdomain (GETTEXT_PACKAGE); #ifdef ENABLE_DEBUG - /* Set up debugger */ - g_log_set_default_handler (default_log_handler, NULL); + /* Set up debugger */ + g_log_set_default_handler (default_log_handler, NULL); #endif - unique_app = unique_app_new_with_commands ("org.gnome.Empathy", - NULL, - "accounts_dialog", - COMMAND_ACCOUNTS_DIALOG, - NULL); - - if (unique_app_is_running (unique_app)) { - unique_app_send_message (unique_app, - accounts_dialog ? - COMMAND_ACCOUNTS_DIALOG : - UNIQUE_ACTIVATE, - NULL); - g_object_unref (unique_app); - return EXIT_SUCCESS; - } - - /* Take well-known name */ - dbus_daemon = tp_dbus_daemon_dup (&error); - if (error == NULL) { - if (!tp_dbus_daemon_request_name (dbus_daemon, - "org.gnome.Empathy", - TRUE, &error)) { - DEBUG ("Failed to request well-known name: %s", - error ? error->message : "no message"); - g_clear_error (&error); - } - g_object_unref (dbus_daemon); - } else { - DEBUG ("Failed to dup dbus daemon: %s", - error ? error->message : "no message"); - g_clear_error (&error); - } - - if (accounts_dialog) { - GtkWidget *dialog; - - dialog = empathy_accounts_dialog_show (NULL, NULL); - g_signal_connect (dialog, "destroy", - G_CALLBACK (gtk_main_quit), - NULL); - - gtk_main (); - return 0; - } - - /* Setting up Idle */ - idle = empathy_idle_dup_singleton (); - empathy_idle_set_auto_away (idle, TRUE); - - /* Setting up Connectivity */ - connectivity = empathy_connectivity_dup_singleton (); - use_conn_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_CONN, - connectivity); - empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_CONN, - use_conn_notify_cb, connectivity); - - /* Autoconnect */ - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_AUTOCONNECT, - &autoconnect); - if (autoconnect && ! no_connect && - tp_connection_presence_type_cmp_availability (empathy_idle_get_state - (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) { - empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE); - } - - /* account management */ - account_manager = empathy_account_manager_dup_singleton (); - g_signal_connect (account_manager, "notify::ready", - G_CALLBACK (account_manager_ready_cb), NULL); - - migrate_config_to_xdg_dir (); - - /* Setting up UI */ - window = empathy_main_window_show (); - icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list); - - g_signal_connect (unique_app, "message-received", - G_CALLBACK (unique_app_message_cb), - window); - - /* Handle channels */ - dispatcher = empathy_dispatcher_dup_singleton (); - g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL); - - /* Logging */ - log_manager = empathy_log_manager_dup_singleton (); - empathy_log_manager_observe (log_manager, dispatcher); - - chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL); - empathy_chatroom_manager_observe (chatroom_manager, dispatcher); - - notify_init (_(PACKAGE_NAME)); - /* Create the call factory */ - call_factory = empathy_call_factory_initialise (); - g_signal_connect (G_OBJECT (call_factory), "new-call-handler", - G_CALLBACK (new_call_handler_cb), NULL); - /* Create the FT factory */ - ft_factory = empathy_ft_factory_dup_singleton (); - g_signal_connect (ft_factory, "new-ft-handler", - G_CALLBACK (new_ft_handler_cb), NULL); - g_signal_connect (ft_factory, "new-incoming-transfer", - G_CALLBACK (new_incoming_transfer_cb), NULL); - - /* Location mananger */ + unique_app = unique_app_new_with_commands ("org.gnome.Empathy", + NULL, "accounts_dialog", COMMAND_ACCOUNTS_DIALOG, NULL); + + if (unique_app_is_running (unique_app)) + { + unique_app_send_message (unique_app, accounts_dialog ? + COMMAND_ACCOUNTS_DIALOG : UNIQUE_ACTIVATE, NULL); + + g_object_unref (unique_app); + return EXIT_SUCCESS; + } + + /* Take well-known name */ + dbus_daemon = tp_dbus_daemon_dup (&error); + if (error == NULL) + { + if (!tp_dbus_daemon_request_name (dbus_daemon, + "org.gnome.Empathy", TRUE, &error)) + { + DEBUG ("Failed to request well-known name: %s", + error ? error->message : "no message"); + g_clear_error (&error); + } + g_object_unref (dbus_daemon); + } + else + { + DEBUG ("Failed to dup dbus daemon: %s", + error ? error->message : "no message"); + g_clear_error (&error); + } + + if (accounts_dialog) + { + GtkWidget *dialog; + + dialog = empathy_accounts_dialog_show (NULL, NULL); + g_signal_connect (dialog, "destroy", + G_CALLBACK (gtk_main_quit), NULL); + + gtk_main (); + return 0; + } + + /* Setting up Idle */ + idle = empathy_idle_dup_singleton (); + empathy_idle_set_auto_away (idle, TRUE); + + /* Setting up Connectivity */ + connectivity = empathy_connectivity_dup_singleton (); + use_conn_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_CONN, + connectivity); + empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_CONN, + use_conn_notify_cb, connectivity); + + /* Autoconnect */ + empathy_conf_get_bool (empathy_conf_get (), + EMPATHY_PREFS_AUTOCONNECT, &autoconnect); + if (autoconnect && !no_connect && + tp_connection_presence_type_cmp_availability + (empathy_idle_get_state (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) + <= 0) + empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE); + + /* account management */ + account_manager = empathy_account_manager_dup_singleton (); + g_signal_connect (account_manager, "notify::ready", + G_CALLBACK (account_manager_ready_cb), NULL); + + migrate_config_to_xdg_dir (); + + /* Setting up UI */ + window = empathy_main_window_show (); + icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list); + + g_signal_connect (unique_app, "message-received", + G_CALLBACK (unique_app_message_cb), window); + + /* Handle channels */ + dispatcher = empathy_dispatcher_dup_singleton (); + g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL); + + /* Logging */ + log_manager = empathy_log_manager_dup_singleton (); + empathy_log_manager_observe (log_manager, dispatcher); + + chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL); + empathy_chatroom_manager_observe (chatroom_manager, dispatcher); + + notify_init (_(PACKAGE_NAME)); + /* Create the call factory */ + call_factory = empathy_call_factory_initialise (); + g_signal_connect (G_OBJECT (call_factory), "new-call-handler", + G_CALLBACK (new_call_handler_cb), NULL); + /* Create the FT factory */ + ft_factory = empathy_ft_factory_dup_singleton (); + g_signal_connect (ft_factory, "new-ft-handler", + G_CALLBACK (new_ft_handler_cb), NULL); + g_signal_connect (ft_factory, "new-incoming-transfer", + G_CALLBACK (new_incoming_transfer_cb), NULL); + + /* Location mananger */ #if HAVE_GEOCLUE - location_manager = empathy_location_manager_dup_singleton (); + location_manager = empathy_location_manager_dup_singleton (); #endif - gtk_main (); + gtk_main (); - empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE); + empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE); - g_object_unref (idle); - g_object_unref (connectivity); - g_object_unref (icon); - g_object_unref (account_manager); - g_object_unref (log_manager); - g_object_unref (dispatcher); - g_object_unref (chatroom_manager); + g_object_unref (idle); + g_object_unref (connectivity); + g_object_unref (icon); + g_object_unref (account_manager); + g_object_unref (log_manager); + g_object_unref (dispatcher); + g_object_unref (chatroom_manager); #if HAVE_GEOCLUE - g_object_unref (location_manager); + g_object_unref (location_manager); #endif - g_object_unref (ft_factory); - g_object_unref (unique_app); + g_object_unref (ft_factory); + g_object_unref (unique_app); - notify_uninit (); + notify_uninit (); - return EXIT_SUCCESS; + return EXIT_SUCCESS; } -- cgit v1.2.3 From 8bccbdc3d107c019ef858d0ad15c769c31028731 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 1 Aug 2009 17:00:30 +0200 Subject: Skeleton of EmpathyAccountAssistant --- src/empathy-account-assistant.c | 43 ++++++++++++++++++++++++++++++ src/empathy-account-assistant.h | 59 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 src/empathy-account-assistant.c create mode 100644 src/empathy-account-assistant.h (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c new file mode 100644 index 000000000..d264df367 --- /dev/null +++ b/src/empathy-account-assistant.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Cosimo Cecchi + */ + +/* empathy-account-assistant.c */ + +#include "empathy-account-assistant.h" + +G_DEFINE_TYPE (EmpathyAccountAssistant, empathy_account_assistant, + GTK_TYPE_ASSISTANT) + + +static void +empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) +{ +} + +static void +empathy_account_assistant_init (EmpathyAccountAssistant *self) +{ +} + +EmpathyAccountAssistant* +empathy_account_assistant_new (void) +{ + return g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT, NULL); +} diff --git a/src/empathy-account-assistant.h b/src/empathy-account-assistant.h new file mode 100644 index 000000000..03e99e265 --- /dev/null +++ b/src/empathy-account-assistant.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Cosimo Cecchi + */ + +/* empathy-account-assistant.h */ + +#ifndef __EMPATHY_ACCOUNT_ASSISTANT_H__ +#define __EMPATHY_ACCOUNT_ASSISTANT_H__ + +#include + +G_BEGIN_DECLS + +#define EMPATHY_TYPE_ACCOUNT_ASSISTANT empathy_account_assistant_get_type() +#define EMPATHY_ACCOUNT_ASSISTANT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistant)) +#define EMPATHY_ACCOUNT_ASSISTANT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistantClass)) +#define EMPATHY_IS_ACCOUNT_ASSISTANT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT)) +#define EMPATHY_IS_ACCOUNT_ASSISTANT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_ACCOUNT_ASSISTANT)) +#define EMPATHY_ACCOUNT_ASSISTANT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistantClass)) + +typedef struct { + GtkAssistant parent; + + /* private */ + gpointer priv; +} EmpathyAccountAssistant; + +typedef struct { + GtkAssistantClass parent_class; +} EmpathyAccountAssistantClass; + +GType empathy_account_assistant_get_type (void); + +EmpathyAccountAssistant* empathy_account_assistant_new (void); + +G_END_DECLS + +#endif /* __EMPATHY_ACCOUNT_ASSISTANT_H__ */ -- cgit v1.2.3 From a1382ef236e65efb2443268d3ed406229e747381 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 1 Aug 2009 17:33:32 +0200 Subject: Add a first page to the assistant --- src/Makefile.am | 1 + src/empathy-account-assistant.c | 32 ++++++++++++++++++++++++++++++++ src/empathy-account-assistant.h | 1 + 3 files changed, 34 insertions(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index d0b86edfc..9ac6b9bb3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,6 +31,7 @@ BUILT_SOURCES= \ empathy_handwritten_source = \ empathy.c \ empathy-about-dialog.c empathy-about-dialog.h \ + empathy-account-assistant.c empathy-account-assistant.h \ empathy-accounts-dialog.c empathy-accounts-dialog.h \ empathy-call-window.c empathy-call-window.h \ empathy-call-window-fullscreen.c empathy-call-window-fullscreen.h \ diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index d264df367..461949892 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -20,20 +20,52 @@ /* empathy-account-assistant.c */ +#include + #include "empathy-account-assistant.h" G_DEFINE_TYPE (EmpathyAccountAssistant, empathy_account_assistant, GTK_TYPE_ASSISTANT) +static GtkWidget * +account_assistant_build_introduction_page (void) +{ + GtkWidget *main_vbox, *hbox_1, *w; + + main_vbox = gtk_vbox_new (FALSE, 12); + gtk_widget_show (main_vbox); + + hbox_1 = gtk_hbox_new (FALSE, 12); + gtk_box_pack_start (GTK_BOX (main_vbox), hbox_1, TRUE, TRUE, 6); + gtk_widget_show (hbox_1); + + w = gtk_label_new (_("With Empathy you can chat with people online nearby " + "and with friends and colleagues who use Google Talk, AIM, " + "Windows Live and many other chat programs. With a microphone " + "or a webcam you can also have audio or video calls.")); + gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 6); + gtk_widget_show (w); + + w = gtk_image_new_from_icon_name ("empathy", GTK_ICON_SIZE_DIALOG); + gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 6); + gtk_widget_show (w); + + return main_vbox; +} static void empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) { + } static void empathy_account_assistant_init (EmpathyAccountAssistant *self) { + GtkWidget *page; + + page = account_assistant_build_introduction_page (); + gtk_assistant_append_page (GTK_ASSISTANT (self), page); } EmpathyAccountAssistant* diff --git a/src/empathy-account-assistant.h b/src/empathy-account-assistant.h index 03e99e265..64711e72f 100644 --- a/src/empathy-account-assistant.h +++ b/src/empathy-account-assistant.h @@ -24,6 +24,7 @@ #define __EMPATHY_ACCOUNT_ASSISTANT_H__ #include +#include G_BEGIN_DECLS -- cgit v1.2.3 From 73a995007e5a417b0e1e0ebf13bdcfdf4dae7c7c Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 1 Aug 2009 19:02:52 +0200 Subject: Implement first page in the assistant --- src/Makefile.am | 1 - src/empathy-account-assistant.c | 75 ----------------------------------------- src/empathy-account-assistant.h | 60 --------------------------------- 3 files changed, 136 deletions(-) delete mode 100644 src/empathy-account-assistant.c delete mode 100644 src/empathy-account-assistant.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 9ac6b9bb3..d0b86edfc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,7 +31,6 @@ BUILT_SOURCES= \ empathy_handwritten_source = \ empathy.c \ empathy-about-dialog.c empathy-about-dialog.h \ - empathy-account-assistant.c empathy-account-assistant.h \ empathy-accounts-dialog.c empathy-accounts-dialog.h \ empathy-call-window.c empathy-call-window.h \ empathy-call-window-fullscreen.c empathy-call-window-fullscreen.h \ diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c deleted file mode 100644 index 461949892..000000000 --- a/src/empathy-account-assistant.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2009 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Cosimo Cecchi - */ - -/* empathy-account-assistant.c */ - -#include - -#include "empathy-account-assistant.h" - -G_DEFINE_TYPE (EmpathyAccountAssistant, empathy_account_assistant, - GTK_TYPE_ASSISTANT) - -static GtkWidget * -account_assistant_build_introduction_page (void) -{ - GtkWidget *main_vbox, *hbox_1, *w; - - main_vbox = gtk_vbox_new (FALSE, 12); - gtk_widget_show (main_vbox); - - hbox_1 = gtk_hbox_new (FALSE, 12); - gtk_box_pack_start (GTK_BOX (main_vbox), hbox_1, TRUE, TRUE, 6); - gtk_widget_show (hbox_1); - - w = gtk_label_new (_("With Empathy you can chat with people online nearby " - "and with friends and colleagues who use Google Talk, AIM, " - "Windows Live and many other chat programs. With a microphone " - "or a webcam you can also have audio or video calls.")); - gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 6); - gtk_widget_show (w); - - w = gtk_image_new_from_icon_name ("empathy", GTK_ICON_SIZE_DIALOG); - gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 6); - gtk_widget_show (w); - - return main_vbox; -} - -static void -empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) -{ - -} - -static void -empathy_account_assistant_init (EmpathyAccountAssistant *self) -{ - GtkWidget *page; - - page = account_assistant_build_introduction_page (); - gtk_assistant_append_page (GTK_ASSISTANT (self), page); -} - -EmpathyAccountAssistant* -empathy_account_assistant_new (void) -{ - return g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT, NULL); -} diff --git a/src/empathy-account-assistant.h b/src/empathy-account-assistant.h deleted file mode 100644 index 64711e72f..000000000 --- a/src/empathy-account-assistant.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2009 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Cosimo Cecchi - */ - -/* empathy-account-assistant.h */ - -#ifndef __EMPATHY_ACCOUNT_ASSISTANT_H__ -#define __EMPATHY_ACCOUNT_ASSISTANT_H__ - -#include -#include - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_ACCOUNT_ASSISTANT empathy_account_assistant_get_type() -#define EMPATHY_ACCOUNT_ASSISTANT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistant)) -#define EMPATHY_ACCOUNT_ASSISTANT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistantClass)) -#define EMPATHY_IS_ACCOUNT_ASSISTANT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT)) -#define EMPATHY_IS_ACCOUNT_ASSISTANT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_ACCOUNT_ASSISTANT)) -#define EMPATHY_ACCOUNT_ASSISTANT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistantClass)) - -typedef struct { - GtkAssistant parent; - - /* private */ - gpointer priv; -} EmpathyAccountAssistant; - -typedef struct { - GtkAssistantClass parent_class; -} EmpathyAccountAssistantClass; - -GType empathy_account_assistant_get_type (void); - -EmpathyAccountAssistant* empathy_account_assistant_new (void); - -G_END_DECLS - -#endif /* __EMPATHY_ACCOUNT_ASSISTANT_H__ */ -- cgit v1.2.3 From 3ac8eb4e2f6909d6c54718d6910b156359e10b42 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 1 Aug 2009 19:11:33 +0200 Subject: Move back the account assistant to src/ --- src/Makefile.am | 1 + src/empathy-account-assistant.c | 116 ++++++++++++++++++++++++++++++++++++++++ src/empathy-account-assistant.h | 60 +++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 src/empathy-account-assistant.c create mode 100644 src/empathy-account-assistant.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index d0b86edfc..9ac6b9bb3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,6 +31,7 @@ BUILT_SOURCES= \ empathy_handwritten_source = \ empathy.c \ empathy-about-dialog.c empathy-about-dialog.h \ + empathy-account-assistant.c empathy-account-assistant.h \ empathy-accounts-dialog.c empathy-accounts-dialog.h \ empathy-call-window.c empathy-call-window.h \ empathy-call-window-fullscreen.c empathy-call-window-fullscreen.h \ diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c new file mode 100644 index 000000000..6d3c27aa2 --- /dev/null +++ b/src/empathy-account-assistant.c @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2009 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Cosimo Cecchi + */ + +/* empathy-account-assistant.c */ + +#include + +#include "empathy-account-assistant.h" +#include + +G_DEFINE_TYPE (EmpathyAccountAssistant, empathy_account_assistant, + GTK_TYPE_ASSISTANT) + +static GtkWidget * +account_assistant_build_introduction_page (void) +{ + GtkWidget *main_vbox, *hbox_1, *w, *radio, *vbox_1; + GdkPixbuf *pix; + + main_vbox = gtk_vbox_new (FALSE, 12); + gtk_widget_show (main_vbox); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); + + hbox_1 = gtk_hbox_new (FALSE, 12); + gtk_box_pack_start (GTK_BOX (main_vbox), hbox_1, TRUE, TRUE, 0); + gtk_widget_show (hbox_1); + + w = gtk_label_new (_("With Empathy you can chat with people \nonline nearby " + "and with friends and colleagues \nwho use Google Talk, AIM, " + "Windows Live \nand many other chat programs. With a microphone \n" + "or a webcam you can also have audio or video calls.")); + gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 0); + gtk_widget_show (w); + + pix = empathy_pixbuf_from_icon_name_sized ("empathy", 96); + w = gtk_image_new_from_pixbuf (pix); + gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 6); + gtk_widget_show (w); + + g_object_unref (pix); + + w = gtk_label_new (_("Do you have an account you've been using with another " + "chat program?")); + gtk_misc_set_alignment (GTK_MISC (w), 0, 0); + gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + + w = gtk_alignment_new (0, 0, 0, 0); + gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0); + gtk_box_pack_start (GTK_BOX (main_vbox), w, TRUE, TRUE, 0); + gtk_widget_show (w); + + vbox_1 = gtk_vbox_new (FALSE, 6); + gtk_container_add (GTK_CONTAINER (w), vbox_1); + gtk_widget_show (vbox_1); + + radio = gtk_radio_button_new_with_label (NULL, _("Yes, import my account details from ")); + gtk_box_pack_start (GTK_BOX (vbox_1), radio, TRUE, TRUE, 0); + gtk_widget_show (radio); + + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("Yes, I'll enter my account details now")); + gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); + gtk_widget_show (w); + + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("No, I want a new account")); + gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); + gtk_widget_show (w); + + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("No, I just want to see people online nearby for now")); + gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); + gtk_widget_show (w); + + return main_vbox; +} + +static void +empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) +{ + +} + +static void +empathy_account_assistant_init (EmpathyAccountAssistant *self) +{ + GtkWidget *page; + + page = account_assistant_build_introduction_page (); + gtk_assistant_append_page (GTK_ASSISTANT (self), page); + gtk_assistant_set_page_title (GTK_ASSISTANT (self), page, _("Welcome to Empathy")); + gtk_assistant_set_page_type (GTK_ASSISTANT (self), page, GTK_ASSISTANT_PAGE_INTRO); + gtk_assistant_set_page_complete (GTK_ASSISTANT (self), page, TRUE); +} + +GtkWidget * +empathy_account_assistant_new (void) +{ + return g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT, NULL); +} diff --git a/src/empathy-account-assistant.h b/src/empathy-account-assistant.h new file mode 100644 index 000000000..38a96f8f0 --- /dev/null +++ b/src/empathy-account-assistant.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Cosimo Cecchi + */ + +/* empathy-account-assistant.h */ + +#ifndef __EMPATHY_ACCOUNT_ASSISTANT_H__ +#define __EMPATHY_ACCOUNT_ASSISTANT_H__ + +#include +#include + +G_BEGIN_DECLS + +#define EMPATHY_TYPE_ACCOUNT_ASSISTANT empathy_account_assistant_get_type() +#define EMPATHY_ACCOUNT_ASSISTANT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistant)) +#define EMPATHY_ACCOUNT_ASSISTANT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistantClass)) +#define EMPATHY_IS_ACCOUNT_ASSISTANT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT)) +#define EMPATHY_IS_ACCOUNT_ASSISTANT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_ACCOUNT_ASSISTANT)) +#define EMPATHY_ACCOUNT_ASSISTANT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistantClass)) + +typedef struct { + GtkAssistant parent; + + /* private */ + gpointer priv; +} EmpathyAccountAssistant; + +typedef struct { + GtkAssistantClass parent_class; +} EmpathyAccountAssistantClass; + +GType empathy_account_assistant_get_type (void); + +GtkWidget *empathy_account_assistant_new (void); + +G_END_DECLS + +#endif /* __EMPATHY_ACCOUNT_ASSISTANT_H__ */ -- cgit v1.2.3 From 01e526b8b694869c81996f9e817cc3e3a559c161 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Mon, 3 Aug 2009 10:34:48 +0200 Subject: Fix style --- src/empathy-account-assistant.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 6d3c27aa2..4c23ca8b0 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -72,19 +72,23 @@ account_assistant_build_introduction_page (void) gtk_container_add (GTK_CONTAINER (w), vbox_1); gtk_widget_show (vbox_1); - radio = gtk_radio_button_new_with_label (NULL, _("Yes, import my account details from ")); + radio = gtk_radio_button_new_with_label (NULL, + _("Yes, import my account details from ")); gtk_box_pack_start (GTK_BOX (vbox_1), radio, TRUE, TRUE, 0); gtk_widget_show (radio); - w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("Yes, I'll enter my account details now")); + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), + _("Yes, I'll enter my account details now")); gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); gtk_widget_show (w); - w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("No, I want a new account")); + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), + _("No, I want a new account")); gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); gtk_widget_show (w); - w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("No, I just want to see people online nearby for now")); + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), + _("No, I just want to see people online nearby for now")); gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); gtk_widget_show (w); @@ -102,10 +106,13 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) { GtkWidget *page; + /* first page */ page = account_assistant_build_introduction_page (); gtk_assistant_append_page (GTK_ASSISTANT (self), page); - gtk_assistant_set_page_title (GTK_ASSISTANT (self), page, _("Welcome to Empathy")); - gtk_assistant_set_page_type (GTK_ASSISTANT (self), page, GTK_ASSISTANT_PAGE_INTRO); + gtk_assistant_set_page_title (GTK_ASSISTANT (self), page, + _("Welcome to Empathy")); + gtk_assistant_set_page_type (GTK_ASSISTANT (self), page, + GTK_ASSISTANT_PAGE_INTRO); gtk_assistant_set_page_complete (GTK_ASSISTANT (self), page, TRUE); } -- cgit v1.2.3 From 91feedc5c6b02468fc029f83157445a9c6d8b7d4 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Mon, 3 Aug 2009 11:32:05 +0200 Subject: Style fixes --- src/empathy-account-assistant.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.h b/src/empathy-account-assistant.h index 38a96f8f0..82b14e312 100644 --- a/src/empathy-account-assistant.h +++ b/src/empathy-account-assistant.h @@ -30,15 +30,18 @@ G_BEGIN_DECLS #define EMPATHY_TYPE_ACCOUNT_ASSISTANT empathy_account_assistant_get_type() #define EMPATHY_ACCOUNT_ASSISTANT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistant)) + (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT,\ + EmpathyAccountAssistant)) #define EMPATHY_ACCOUNT_ASSISTANT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistantClass)) + (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_ACCOUNT_ASSISTANT,\ + EmpathyAccountAssistantClass)) #define EMPATHY_IS_ACCOUNT_ASSISTANT(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT)) #define EMPATHY_IS_ACCOUNT_ASSISTANT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_ACCOUNT_ASSISTANT)) #define EMPATHY_ACCOUNT_ASSISTANT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistantClass)) + (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNT_ASSISTANT,\ + EmpathyAccountAssistantClass)) typedef struct { GtkAssistant parent; -- cgit v1.2.3 From 63b3a10e4b442ef9865885f590f3d251ac006f04 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Mon, 3 Aug 2009 11:32:19 +0200 Subject: Add private struct and responses to first page --- src/empathy-account-assistant.c | 62 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 4c23ca8b0..5b7535bd3 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -23,13 +23,43 @@ #include #include "empathy-account-assistant.h" + +#include + #include G_DEFINE_TYPE (EmpathyAccountAssistant, empathy_account_assistant, GTK_TYPE_ASSISTANT) +#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountAssistant) + +typedef enum { + RESPONSE_IMPORT = 1, + RESPONSE_ENTER_ACCOUNT = 2, + RESPONSE_CREATE_ACCOUNT = 3, + RESPONSE_SALUT_ONLY = 4 +} FirstPageResponse; + +typedef struct { + FirstPageResponse first_resp; +} EmpathyAccountAssistantPriv; + +static void +account_assistant_radio_choice_toggled_cb (GtkToggleButton *button, + EmpathyAccountAssistant *self) +{ + FirstPageResponse response; + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + + response = GPOINTER_TO_INT (g_object_get_data + (G_OBJECT (button), "response")); + + g_print ("choice %d toggled\n", response); + priv->first_resp = response; +} + static GtkWidget * -account_assistant_build_introduction_page (void) +account_assistant_build_introduction_page (EmpathyAccountAssistant *self) { GtkWidget *main_vbox, *hbox_1, *w, *radio, *vbox_1; GdkPixbuf *pix; @@ -72,42 +102,68 @@ account_assistant_build_introduction_page (void) gtk_container_add (GTK_CONTAINER (w), vbox_1); gtk_widget_show (vbox_1); + /* TODO: this will have to be updated when kutio's branch have landed */ radio = gtk_radio_button_new_with_label (NULL, _("Yes, import my account details from ")); gtk_box_pack_start (GTK_BOX (vbox_1), radio, TRUE, TRUE, 0); + g_object_set_data (G_OBJECT (radio), "response", + GINT_TO_POINTER (RESPONSE_IMPORT)); gtk_widget_show (radio); + g_signal_connect (radio, "clicked", + G_CALLBACK (account_assistant_radio_choice_toggled_cb), self); + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("Yes, I'll enter my account details now")); gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); + g_object_set_data (G_OBJECT (w), "response", + GINT_TO_POINTER (RESPONSE_ENTER_ACCOUNT)); gtk_widget_show (w); + g_signal_connect (w, "clicked", + G_CALLBACK (account_assistant_radio_choice_toggled_cb), self); + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("No, I want a new account")); gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); + g_object_set_data (G_OBJECT (w), "response", + GINT_TO_POINTER (RESPONSE_CREATE_ACCOUNT)); gtk_widget_show (w); + g_signal_connect (w, "clicked", + G_CALLBACK (account_assistant_radio_choice_toggled_cb), self); + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("No, I just want to see people online nearby for now")); gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); + g_object_set_data (G_OBJECT (w), "response", + GINT_TO_POINTER (RESPONSE_SALUT_ONLY)); gtk_widget_show (w); + g_signal_connect (w, "clicked", + G_CALLBACK (account_assistant_radio_choice_toggled_cb), self); + return main_vbox; } static void empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) { - + g_type_class_add_private (klass, sizeof (EmpathyAccountAssistantPriv)); } static void empathy_account_assistant_init (EmpathyAccountAssistant *self) { + EmpathyAccountAssistantPriv *priv; GtkWidget *page; + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_ACCOUNT_ASSISTANT, + EmpathyAccountAssistantPriv); + self->priv = priv; + /* first page */ - page = account_assistant_build_introduction_page (); + page = account_assistant_build_introduction_page (self); gtk_assistant_append_page (GTK_ASSISTANT (self), page); gtk_assistant_set_page_title (GTK_ASSISTANT (self), page, _("Welcome to Empathy")); -- cgit v1.2.3 From 7f784aadcfcadc05128b783a4e8d5f8499887b9d Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Tue, 4 Aug 2009 02:40:04 +0200 Subject: Add the details page to the assistant Also, add a sketched version of the other pages --- src/empathy-account-assistant.c | 170 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 165 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 5b7535bd3..0586daaf0 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -24,8 +24,11 @@ #include "empathy-account-assistant.h" +#include #include +#include +#include #include G_DEFINE_TYPE (EmpathyAccountAssistant, empathy_account_assistant, @@ -42,8 +45,27 @@ typedef enum { typedef struct { FirstPageResponse first_resp; + + GtkWidget *add_existing_page; } EmpathyAccountAssistantPriv; +static gint +account_assistant_page_forward_func (gint current_page, + gpointer user_data) +{ + EmpathyAccountAssistant *self = user_data; + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + gint retval; + + retval = current_page; + + if (current_page == 0) + retval = priv->first_resp; + + g_print ("retval = %d\n", retval); + return retval; +} + static void account_assistant_radio_choice_toggled_cb (GtkToggleButton *button, EmpathyAccountAssistant *self) @@ -146,6 +168,117 @@ account_assistant_build_introduction_page (EmpathyAccountAssistant *self) return main_vbox; } +static GtkWidget * +account_assistant_build_import_page (EmpathyAccountAssistant *self) +{ + /* TODO: import page */ + GtkWidget *main_vbox, *w; + + main_vbox = gtk_vbox_new (FALSE, 12); + w = gtk_label_new ("Import your accounts!"); + gtk_widget_show (w); + gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 6); + + gtk_widget_show (main_vbox); + + return main_vbox; +} + +static gboolean +account_assistant_chooser_enter_details_filter_func ( + TpConnectionManager *cm, + TpConnectionManagerProtocol *protocol, + gpointer user_data) +{ + /* TODO */ + return TRUE; +} + +static void +account_assistant_protocol_changed_cb (GtkComboBox *chooser, + EmpathyAccountAssistant *self) +{ + TpConnectionManager *cm; + TpConnectionManagerProtocol *proto; + EmpathyAccountSettings *settings; + EmpathyAccountAssistantPriv *priv; + char *str; + GtkWidget *account_widget; + + priv = GET_PRIV (self); + + cm = empathy_protocol_chooser_dup_selected ( + EMPATHY_PROTOCOL_CHOOSER (chooser), &proto); + + if (cm == NULL || proto == NULL) + /* we are not ready yet */ + return; + + /* Create account */ + /* To translator: %s is the protocol name */ + str = g_strdup_printf (_("New %s account"), proto->name); + + settings = empathy_account_settings_new (cm->name, proto->name, str); + account_widget = empathy_account_widget_simple_new_for_protocol + (proto->name, settings); + + gtk_box_pack_start (GTK_BOX (priv->add_existing_page), account_widget, FALSE, + FALSE, 0); + gtk_widget_show (account_widget); + + g_free (str); +} + +static GtkWidget * +account_assistant_build_enter_details_page (EmpathyAccountAssistant *self) +{ + GtkWidget *main_vbox, *w, *chooser; + + main_vbox = gtk_vbox_new (FALSE, 12); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); + gtk_widget_show (main_vbox); + + w = gtk_label_new (_("What kind of chat account do you have?")); + gtk_misc_set_alignment (GTK_MISC (w), 0, 0); + gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); + + w = gtk_alignment_new (0, 0, 0, 0); + gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0); + gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + + chooser = empathy_protocol_chooser_new (); + empathy_protocol_chooser_set_visible (EMPATHY_PROTOCOL_CHOOSER (chooser), + account_assistant_chooser_enter_details_filter_func, self); + gtk_container_add (GTK_CONTAINER (w), chooser); + gtk_widget_show (chooser); + + g_signal_connect (chooser, "changed", + G_CALLBACK (account_assistant_protocol_changed_cb), self); + + /* trigger show the first account widget */ + account_assistant_protocol_changed_cb (GTK_COMBO_BOX (chooser), self); + + return main_vbox; +} + +static GtkWidget * +account_assistant_build_create_account_page (EmpathyAccountAssistant *self) +{ + GtkWidget *main_vbox, *w; + + main_vbox = gtk_vbox_new (FALSE, 12); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); + gtk_widget_show (main_vbox); + + w = gtk_label_new (_("What kind of chat account do you want to create?")); + gtk_misc_set_alignment (GTK_MISC (w), 0, 0); + gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + + return main_vbox; +} + static void empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) { @@ -156,20 +289,47 @@ static void empathy_account_assistant_init (EmpathyAccountAssistant *self) { EmpathyAccountAssistantPriv *priv; + GtkAssistant *assistant = GTK_ASSISTANT (self); GtkWidget *page; priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_ACCOUNT_ASSISTANT, EmpathyAccountAssistantPriv); self->priv = priv; - /* first page */ + gtk_assistant_set_forward_page_func (assistant, + account_assistant_page_forward_func, self, NULL); + + /* first page (introduction) */ page = account_assistant_build_introduction_page (self); - gtk_assistant_append_page (GTK_ASSISTANT (self), page); - gtk_assistant_set_page_title (GTK_ASSISTANT (self), page, + gtk_assistant_append_page (assistant, page); + gtk_assistant_set_page_title (assistant, page, _("Welcome to Empathy")); - gtk_assistant_set_page_type (GTK_ASSISTANT (self), page, + gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_INTRO); - gtk_assistant_set_page_complete (GTK_ASSISTANT (self), page, TRUE); + gtk_assistant_set_page_complete (assistant, page, TRUE); + + /* set a default answer */ + priv->first_resp = RESPONSE_IMPORT; + + /* second page (import accounts) */ + page = account_assistant_build_import_page (self); + gtk_assistant_append_page (assistant, page); + gtk_assistant_set_page_title (assistant, page, + _("Import your existing accounts")); + gtk_assistant_set_page_complete (assistant, page, TRUE); + + /* third page (enter account details) */ + page = account_assistant_build_enter_details_page (self); + gtk_assistant_append_page (assistant, page); + gtk_assistant_set_page_title (assistant, page, + _("Enter your account details")); + priv->add_existing_page = page; + + /* fourth page (create a new account) */ + page = account_assistant_build_create_account_page (self); + gtk_assistant_append_page (assistant, page); + gtk_assistant_set_page_title (assistant, page, + _("Enter the details of the new account")); } GtkWidget * -- cgit v1.2.3 From b69cd1fb3e9c4f2ffe87e1be5e165cc168cc60c9 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Tue, 4 Aug 2009 11:46:24 +0200 Subject: Update label layout and add an "apply" logic --- src/empathy-account-assistant.c | 66 +++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 0586daaf0..7a5f176cd 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -47,6 +47,8 @@ typedef struct { FirstPageResponse first_resp; GtkWidget *add_existing_page; + GtkWidget *current_account_widget; + EmpathyAccountWidget *current_widget_object; } EmpathyAccountAssistantPriv; static gint @@ -94,23 +96,25 @@ account_assistant_build_introduction_page (EmpathyAccountAssistant *self) gtk_box_pack_start (GTK_BOX (main_vbox), hbox_1, TRUE, TRUE, 0); gtk_widget_show (hbox_1); - w = gtk_label_new (_("With Empathy you can chat with people \nonline nearby " - "and with friends and colleagues \nwho use Google Talk, AIM, " - "Windows Live \nand many other chat programs. With a microphone \n" - "or a webcam you can also have audio or video calls.")); + w = gtk_label_new ( + _("With Empathy you can chat with people\n" + "online nearby and with friends and colleagues\n" + "who use Google Talk, AIM, Windows Live\n" + "and many other chat programs. With a microphone\n" + "or a webcam you can also have audio or video calls.")); gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5); gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 0); gtk_widget_show (w); - pix = empathy_pixbuf_from_icon_name_sized ("empathy", 96); + pix = empathy_pixbuf_from_icon_name_sized ("empathy", 80); w = gtk_image_new_from_pixbuf (pix); gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 6); gtk_widget_show (w); g_object_unref (pix); - w = gtk_label_new (_("Do you have an account you've been using with another " - "chat program?")); + w = gtk_label_new (_("Do you have an account you've been using " + "with another\nchat program?")); gtk_misc_set_alignment (GTK_MISC (w), 0, 0); gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); gtk_widget_show (w); @@ -194,6 +198,17 @@ account_assistant_chooser_enter_details_filter_func ( return TRUE; } +static void +account_assistant_handle_apply_cb (EmpathyAccountWidget *widget_object, + gboolean is_valid, + EmpathyAccountAssistant *self) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + + gtk_assistant_set_page_complete (GTK_ASSISTANT (self), + priv->add_existing_page, is_valid); +} + static void account_assistant_protocol_changed_cb (GtkComboBox *chooser, EmpathyAccountAssistant *self) @@ -204,6 +219,7 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser, EmpathyAccountAssistantPriv *priv; char *str; GtkWidget *account_widget; + EmpathyAccountWidget *widget_object = NULL; priv = GET_PRIV (self); @@ -220,7 +236,20 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser, settings = empathy_account_settings_new (cm->name, proto->name, str); account_widget = empathy_account_widget_simple_new_for_protocol - (proto->name, settings); + (proto->name, settings, &widget_object); + + if (priv->current_account_widget != NULL) + { + g_signal_handlers_disconnect_by_func (priv->current_widget_object, + account_assistant_handle_apply_cb, self); + gtk_widget_destroy (priv->current_account_widget); + } + + priv->current_account_widget = account_widget; + priv->current_widget_object = widget_object; + + g_signal_connect (priv->current_widget_object, "handle-apply", + G_CALLBACK (account_assistant_handle_apply_cb), self); gtk_box_pack_start (GTK_BOX (priv->add_existing_page), account_widget, FALSE, FALSE, 0); @@ -232,7 +261,8 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser, static GtkWidget * account_assistant_build_enter_details_page (EmpathyAccountAssistant *self) { - GtkWidget *main_vbox, *w, *chooser; + GtkWidget *main_vbox, *w, *chooser, *hbox; + PangoAttrList *list; main_vbox = gtk_vbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); @@ -259,6 +289,23 @@ account_assistant_build_enter_details_page (EmpathyAccountAssistant *self) /* trigger show the first account widget */ account_assistant_protocol_changed_cb (GTK_COMBO_BOX (chooser), self); + hbox = gtk_hbox_new (FALSE, 6); + gtk_box_pack_end (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + w = gtk_image_new_from_icon_name ("gtk-dialog-info", GTK_ICON_SIZE_BUTTON); + gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + + w = gtk_label_new (_("If you have other accounts to set up, you can do " + "that at any time\nfrom the Edit menu.")); + gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); + list = pango_attr_list_new (); + pango_attr_list_insert (list, pango_attr_scale_new (PANGO_SCALE_SMALL)); + gtk_label_set_attributes (GTK_LABEL (w), list); + gtk_widget_show (w); + pango_attr_list_unref (list); + return main_vbox; } @@ -323,6 +370,7 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) gtk_assistant_append_page (assistant, page); gtk_assistant_set_page_title (assistant, page, _("Enter your account details")); + gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM); priv->add_existing_page = page; /* fourth page (create a new account) */ -- cgit v1.2.3 From c037c417937a5a77a8c8bc168103cb3c5a19a659 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Tue, 4 Aug 2009 15:22:36 +0200 Subject: Filter out IRC and local-xmpp in the wizard --- src/empathy-account-assistant.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 7a5f176cd..b7c5b28ed 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -21,6 +21,7 @@ /* empathy-account-assistant.c */ #include +#include #include "empathy-account-assistant.h" @@ -194,7 +195,10 @@ account_assistant_chooser_enter_details_filter_func ( TpConnectionManagerProtocol *protocol, gpointer user_data) { - /* TODO */ + if (!tp_strdiff (protocol->name, "local-xmpp") || + !tp_strdiff (protocol->name, "irc")) + return FALSE; + return TRUE; } -- cgit v1.2.3 From 877ca07d5b79400863997df5c31180feec7103db Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Tue, 4 Aug 2009 20:01:30 +0200 Subject: Unify the enter and create page. Refactor a lot the surrounding code. Missing piece: adapting labels for the EmpathyAccountWidget in case of creation vs. entering details. --- src/empathy-account-assistant.c | 319 ++++++++++++++++++++++++++-------------- 1 file changed, 205 insertions(+), 114 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index b7c5b28ed..5fd125816 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -44,14 +44,197 @@ typedef enum { RESPONSE_SALUT_ONLY = 4 } FirstPageResponse; +enum { + PAGE_INTRO = 0, + PAGE_IMPORT = 1, + PAGE_ENTER_CREATE = 2, + PAGE_SALUT_ONLY = 3 +}; + typedef struct { FirstPageResponse first_resp; - GtkWidget *add_existing_page; + /* enter or create page */ + GtkWidget *enter_or_create_page; GtkWidget *current_account_widget; EmpathyAccountWidget *current_widget_object; + GtkWidget *first_label; + GtkWidget *second_label; + GtkWidget *chooser; + EmpathyAccountSettings *settings; } EmpathyAccountAssistantPriv; +static void +account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + + if (priv->settings == NULL) + return; + + empathy_account_settings_apply_async (priv->settings, NULL, NULL); +} + +static void +account_assistant_apply_cb (GtkAssistant *assistant, + gpointer user_data) +{ + EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant); + gint current_page; + + current_page = gtk_assistant_get_current_page (assistant); + + if (current_page == RESPONSE_ENTER_ACCOUNT) + account_assistant_apply_account_and_finish (self); +} + +static void +account_assistant_handle_apply_cb (EmpathyAccountWidget *widget_object, + gboolean is_valid, + EmpathyAccountAssistant *self) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + + gtk_assistant_set_page_complete (GTK_ASSISTANT (self), + priv->enter_or_create_page, is_valid); +} + +static void +account_assistant_protocol_changed_cb (GtkComboBox *chooser, + EmpathyAccountAssistant *self) +{ + TpConnectionManager *cm; + TpConnectionManagerProtocol *proto; + EmpathyAccountSettings *settings; + EmpathyAccountAssistantPriv *priv; + char *str; + GtkWidget *account_widget; + EmpathyAccountWidget *widget_object = NULL; + + priv = GET_PRIV (self); + + cm = empathy_protocol_chooser_dup_selected ( + EMPATHY_PROTOCOL_CHOOSER (chooser), &proto); + + if (cm == NULL || proto == NULL) + /* we are not ready yet */ + return; + + /* Create account */ + /* To translator: %s is the protocol name */ + str = g_strdup_printf (_("New %s account"), proto->name); + + settings = empathy_account_settings_new (cm->name, proto->name, str); + account_widget = empathy_account_widget_simple_new_for_protocol + (proto->name, settings, &widget_object); + + if (priv->current_account_widget != NULL) + { + g_signal_handlers_disconnect_by_func (priv->current_widget_object, + account_assistant_handle_apply_cb, self); + gtk_widget_destroy (priv->current_account_widget); + } + + priv->current_account_widget = account_widget; + priv->current_widget_object = widget_object; + priv->settings = settings; + + g_signal_connect (priv->current_widget_object, "handle-apply", + G_CALLBACK (account_assistant_handle_apply_cb), self); + + gtk_box_pack_start (GTK_BOX (priv->enter_or_create_page), account_widget, + FALSE, FALSE, 0); + gtk_widget_show (account_widget); + + g_free (str); +} + +static gboolean +account_assistant_chooser_enter_details_filter_func ( + TpConnectionManager *cm, + TpConnectionManagerProtocol *protocol, + gpointer user_data) +{ + if (!tp_strdiff (protocol->name, "local-xmpp") || + !tp_strdiff (protocol->name, "irc")) + return FALSE; + + return TRUE; +} + +static gboolean +account_assistant_chooser_create_account_filter_func ( + TpConnectionManager *cm, + TpConnectionManagerProtocol *protocol, + gpointer user_data) +{ + return tp_connection_manager_protocol_can_register (protocol); +} + +static void +account_assistant_finish_enter_or_create_page (EmpathyAccountAssistant *self, + gboolean is_enter) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + + if (is_enter) + { + gtk_label_set_label (GTK_LABEL (priv->first_label), + _("What kind of chat account do you have?")); + gtk_label_set_label (GTK_LABEL (priv->second_label), + _("If you have other accounts to set up, you can do " + "that at any time\nfrom the Edit menu.")); + empathy_protocol_chooser_set_visible ( + EMPATHY_PROTOCOL_CHOOSER (priv->chooser), + account_assistant_chooser_enter_details_filter_func, self); + + gtk_assistant_set_page_title (GTK_ASSISTANT (self), + priv->enter_or_create_page, _("Enter your account details")); + } + else + { + gtk_label_set_label (GTK_LABEL (priv->first_label), + _("What kind of chat account do you want to create?")); + gtk_label_set_label (GTK_LABEL (priv->second_label), + _("You can register other accounts, or setup\n" + "an existing one at any time from the Edit menu.")); + empathy_protocol_chooser_set_visible ( + EMPATHY_PROTOCOL_CHOOSER (priv->chooser), + account_assistant_chooser_create_account_filter_func, self); + + gtk_assistant_set_page_title (GTK_ASSISTANT (self), + priv->enter_or_create_page, + _("Enter the details for the new account")); + } + + g_signal_connect (priv->chooser, "changed", + G_CALLBACK (account_assistant_protocol_changed_cb), self); + + /* trigger show the first account widget */ + account_assistant_protocol_changed_cb (GTK_COMBO_BOX (priv->chooser), self); +} + +static void +account_assistant_prepare_cb (GtkAssistant *assistant, + GtkWidget *current_page, + gpointer user_data) +{ + EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant); + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + gint current_idx; + + current_idx = gtk_assistant_get_current_page (assistant); + + g_print ("prepare, current idx = %d\n", current_idx); + + if (current_idx == PAGE_ENTER_CREATE) + { + account_assistant_finish_enter_or_create_page (self, + priv->first_resp == RESPONSE_ENTER_ACCOUNT ? + TRUE : FALSE); + } +} + static gint account_assistant_page_forward_func (gint current_page, gpointer user_data) @@ -63,7 +246,11 @@ account_assistant_page_forward_func (gint current_page, retval = current_page; if (current_page == 0) - retval = priv->first_resp; + { + if (priv->first_resp == RESPONSE_ENTER_ACCOUNT || + priv->first_resp == RESPONSE_CREATE_ACCOUNT) + retval = PAGE_ENTER_CREATE; + } g_print ("retval = %d\n", retval); return retval; @@ -189,82 +376,11 @@ account_assistant_build_import_page (EmpathyAccountAssistant *self) return main_vbox; } -static gboolean -account_assistant_chooser_enter_details_filter_func ( - TpConnectionManager *cm, - TpConnectionManagerProtocol *protocol, - gpointer user_data) -{ - if (!tp_strdiff (protocol->name, "local-xmpp") || - !tp_strdiff (protocol->name, "irc")) - return FALSE; - - return TRUE; -} - -static void -account_assistant_handle_apply_cb (EmpathyAccountWidget *widget_object, - gboolean is_valid, - EmpathyAccountAssistant *self) -{ - EmpathyAccountAssistantPriv *priv = GET_PRIV (self); - - gtk_assistant_set_page_complete (GTK_ASSISTANT (self), - priv->add_existing_page, is_valid); -} - -static void -account_assistant_protocol_changed_cb (GtkComboBox *chooser, - EmpathyAccountAssistant *self) -{ - TpConnectionManager *cm; - TpConnectionManagerProtocol *proto; - EmpathyAccountSettings *settings; - EmpathyAccountAssistantPriv *priv; - char *str; - GtkWidget *account_widget; - EmpathyAccountWidget *widget_object = NULL; - - priv = GET_PRIV (self); - - cm = empathy_protocol_chooser_dup_selected ( - EMPATHY_PROTOCOL_CHOOSER (chooser), &proto); - - if (cm == NULL || proto == NULL) - /* we are not ready yet */ - return; - - /* Create account */ - /* To translator: %s is the protocol name */ - str = g_strdup_printf (_("New %s account"), proto->name); - - settings = empathy_account_settings_new (cm->name, proto->name, str); - account_widget = empathy_account_widget_simple_new_for_protocol - (proto->name, settings, &widget_object); - - if (priv->current_account_widget != NULL) - { - g_signal_handlers_disconnect_by_func (priv->current_widget_object, - account_assistant_handle_apply_cb, self); - gtk_widget_destroy (priv->current_account_widget); - } - - priv->current_account_widget = account_widget; - priv->current_widget_object = widget_object; - - g_signal_connect (priv->current_widget_object, "handle-apply", - G_CALLBACK (account_assistant_handle_apply_cb), self); - - gtk_box_pack_start (GTK_BOX (priv->add_existing_page), account_widget, FALSE, - FALSE, 0); - gtk_widget_show (account_widget); - - g_free (str); -} - static GtkWidget * -account_assistant_build_enter_details_page (EmpathyAccountAssistant *self) +account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self, + gboolean is_enter) { + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); GtkWidget *main_vbox, *w, *chooser, *hbox; PangoAttrList *list; @@ -272,9 +388,11 @@ account_assistant_build_enter_details_page (EmpathyAccountAssistant *self) gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); gtk_widget_show (main_vbox); - w = gtk_label_new (_("What kind of chat account do you have?")); + w = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (w), 0, 0); gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + priv->first_label = w; w = gtk_alignment_new (0, 0, 0, 0); gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0); @@ -282,16 +400,9 @@ account_assistant_build_enter_details_page (EmpathyAccountAssistant *self) gtk_widget_show (w); chooser = empathy_protocol_chooser_new (); - empathy_protocol_chooser_set_visible (EMPATHY_PROTOCOL_CHOOSER (chooser), - account_assistant_chooser_enter_details_filter_func, self); gtk_container_add (GTK_CONTAINER (w), chooser); gtk_widget_show (chooser); - - g_signal_connect (chooser, "changed", - G_CALLBACK (account_assistant_protocol_changed_cb), self); - - /* trigger show the first account widget */ - account_assistant_protocol_changed_cb (GTK_COMBO_BOX (chooser), self); + priv->chooser = chooser; hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_end (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); @@ -301,35 +412,18 @@ account_assistant_build_enter_details_page (EmpathyAccountAssistant *self) gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); gtk_widget_show (w); - w = gtk_label_new (_("If you have other accounts to set up, you can do " - "that at any time\nfrom the Edit menu.")); + w = gtk_label_new (NULL); gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); list = pango_attr_list_new (); pango_attr_list_insert (list, pango_attr_scale_new (PANGO_SCALE_SMALL)); gtk_label_set_attributes (GTK_LABEL (w), list); gtk_widget_show (w); + priv->second_label = w; pango_attr_list_unref (list); return main_vbox; } -static GtkWidget * -account_assistant_build_create_account_page (EmpathyAccountAssistant *self) -{ - GtkWidget *main_vbox, *w; - - main_vbox = gtk_vbox_new (FALSE, 12); - gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); - gtk_widget_show (main_vbox); - - w = gtk_label_new (_("What kind of chat account do you want to create?")); - gtk_misc_set_alignment (GTK_MISC (w), 0, 0); - gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - return main_vbox; -} - static void empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) { @@ -350,6 +444,11 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) gtk_assistant_set_forward_page_func (assistant, account_assistant_page_forward_func, self, NULL); + g_signal_connect (self, "apply", + G_CALLBACK (account_assistant_apply_cb), NULL); + g_signal_connect (self, "prepare", + G_CALLBACK (account_assistant_prepare_cb), NULL); + /* first page (introduction) */ page = account_assistant_build_introduction_page (self); gtk_assistant_append_page (assistant, page); @@ -370,18 +469,10 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) gtk_assistant_set_page_complete (assistant, page, TRUE); /* third page (enter account details) */ - page = account_assistant_build_enter_details_page (self); + page = account_assistant_build_enter_or_create_page (self, TRUE); gtk_assistant_append_page (assistant, page); - gtk_assistant_set_page_title (assistant, page, - _("Enter your account details")); gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM); - priv->add_existing_page = page; - - /* fourth page (create a new account) */ - page = account_assistant_build_create_account_page (self); - gtk_assistant_append_page (assistant, page); - gtk_assistant_set_page_title (assistant, page, - _("Enter the details of the new account")); + priv->enter_or_create_page = page; } GtkWidget * -- cgit v1.2.3 From 3962f6f8d1680b6a304577dbc1ed366c33f6b206 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 5 Aug 2009 12:02:39 +0200 Subject: Change labels when creating an account --- src/empathy-account-assistant.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 5fd125816..91ba26b68 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -125,6 +125,10 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser, str = g_strdup_printf (_("New %s account"), proto->name); settings = empathy_account_settings_new (cm->name, proto->name, str); + + if (priv->first_resp == RESPONSE_CREATE_ACCOUNT) + empathy_account_settings_set_boolean (settings, "register", TRUE); + account_widget = empathy_account_widget_simple_new_for_protocol (proto->name, settings, &widget_object); -- cgit v1.2.3 From 06c242f4125d7a48667b069ac53902894cbcdf10 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 5 Aug 2009 12:06:29 +0200 Subject: Unref settings when changing the protocol --- src/empathy-account-assistant.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 91ba26b68..852ea4534 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -141,6 +141,10 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser, priv->current_account_widget = account_widget; priv->current_widget_object = widget_object; + + if (priv->settings != NULL) + g_object_unref (priv->settings); + priv->settings = settings; g_signal_connect (priv->current_widget_object, "handle-apply", -- cgit v1.2.3 From bca9fa60a556e96dbad090afcfd407dab7a4532d Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 5 Aug 2009 16:38:55 +0200 Subject: Add a parent window property to the assistant --- src/empathy-account-assistant.c | 71 +++++++++++++++++++++++++++++++++++++++-- src/empathy-account-assistant.h | 2 +- src/empathy.c | 10 ++++-- 3 files changed, 78 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 852ea4534..e92826688 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -51,6 +51,10 @@ enum { PAGE_SALUT_ONLY = 3 }; +enum { + PROP_PARENT = 1 +}; + typedef struct { FirstPageResponse first_resp; @@ -432,9 +436,71 @@ account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self, return main_vbox; } +static void +do_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (object); + + switch (property_id) + { + case PROP_PARENT: + g_value_set_object (value, priv->parent_window); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +do_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (object); + + switch (property_id) + { + case PROP_PARENT: + priv->parent_window = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +do_constructed (GObject *object) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (object); + + /* set us as transient for the parent window if any */ + if (priv->parent_window) + gtk_window_set_transient_for (GTK_WINDOW (object), + priv->parent_window); + + gtk_window_set_type_hint (GTK_WINDOW (object), GDK_WINDOW_TYPE_HINT_DIALOG); +} + static void empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) { + GObjectClass *oclass = G_OBJECT_CLASS (klass); + GParamSpec *param_spec; + + oclass->get_property = do_get_property; + oclass->set_property = do_set_property; + oclass->constructed = do_constructed; + + param_spec = g_param_spec_object ("parent-window", + "parent-window", "The parent window", + GTK_TYPE_WINDOW, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (oclass, PROP_PARENT, param_spec); + g_type_class_add_private (klass, sizeof (EmpathyAccountAssistantPriv)); } @@ -484,7 +550,8 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) } GtkWidget * -empathy_account_assistant_new (void) +empathy_account_assistant_new (GtkWindow *window) { - return g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT, NULL); + return g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT, "parent-window", + window, NULL); } diff --git a/src/empathy-account-assistant.h b/src/empathy-account-assistant.h index 82b14e312..857460201 100644 --- a/src/empathy-account-assistant.h +++ b/src/empathy-account-assistant.h @@ -56,7 +56,7 @@ typedef struct { GType empathy_account_assistant_get_type (void); -GtkWidget *empathy_account_assistant_new (void); +GtkWidget *empathy_account_assistant_new (GtkWindow *parent); G_END_DECLS diff --git a/src/empathy.c b/src/empathy.c index b80b64be7..acfdcb13e 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -63,6 +63,7 @@ #include #include +#include "empathy-account-assistant.h" #include "empathy-accounts-dialog.h" #include "empathy-main-window.h" #include "empathy-status-icon.h" @@ -532,12 +533,17 @@ account_manager_ready_cb (EmpathyAccountManager *manager, GParamSpec *spec, gpointer user_data) { + GtkWidget *assistant; + if (!empathy_account_manager_is_ready (manager)) return; if (empathy_account_manager_get_count (manager) == 0) - empathy_accounts_dialog_show (GTK_WINDOW (empathy_main_window_get ()), - NULL); + { + assistant = empathy_account_assistant_new ( + GTK_WINDOW (empathy_main_window_get ())); + gtk_window_present (GTK_WINDOW (assistant)); + } create_salut_account (); } -- cgit v1.2.3 From ce3eb60be50a9571bde936eccecc800ee54080f1 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 5 Aug 2009 16:39:20 +0200 Subject: Report back errors (right now just on stdout) --- src/empathy-account-assistant.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index e92826688..567ddc67b 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -66,8 +66,24 @@ typedef struct { GtkWidget *second_label; GtkWidget *chooser; EmpathyAccountSettings *settings; + + GtkWindow *parent_window; } EmpathyAccountAssistantPriv; +static void +account_assistant_apply_account_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + GError *error = NULL; + + empathy_account_settings_apply_finish (EMPATHY_ACCOUNT_SETTINGS (source), + result, &error); + + if (error != NULL) + g_print ("error applying %s\n", error->message); +} + static void account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self) { @@ -76,7 +92,8 @@ account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self) if (priv->settings == NULL) return; - empathy_account_settings_apply_async (priv->settings, NULL, NULL); + empathy_account_settings_apply_async (priv->settings, + account_assistant_apply_account_cb, self); } static void -- cgit v1.2.3 From 84fbdb813bbb7f29aceedbd7293dcb10c499d660 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 5 Aug 2009 16:39:47 +0200 Subject: Don't forward anymore after the end --- src/empathy-account-assistant.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 567ddc67b..4c7062b9d 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -281,6 +281,12 @@ account_assistant_page_forward_func (gint current_page, retval = PAGE_ENTER_CREATE; } + if (current_page == PAGE_ENTER_CREATE) + { + /* don't forward anymore */ + retval = -1; + } + g_print ("retval = %d\n", retval); return retval; } -- cgit v1.2.3 From 9aafbf8e9f92b270036f61622ece41461342a279 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 5 Aug 2009 16:39:57 +0200 Subject: Fix long lines --- src/empathy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/empathy.c b/src/empathy.c index acfdcb13e..15672c8df 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -116,8 +116,8 @@ dispatch_cb (EmpathyDispatcher *dispatcher, manager = empathy_account_manager_dup_singleton (); connection = empathy_tp_chat_get_connection (tp_chat); - account = empathy_account_manager_get_account_for_connection (manager, - connection); + account = empathy_account_manager_get_account_for_connection ( + manager, connection); chat = empathy_chat_window_find_chat (account, id); g_object_unref (manager); } @@ -380,7 +380,8 @@ migrate_config_to_xdg_dir (void) return; } - old_dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); + old_dir = g_build_filename (g_get_home_dir (), ".gnome2", + PACKAGE_NAME, NULL); if (!g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { /* old config dir didn't exist */ -- cgit v1.2.3 From b264035637b60c6fc09839f2a58f2bc16f573113 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 6 Aug 2009 15:39:00 +0200 Subject: Report errors during creation --- src/empathy-account-assistant.c | 118 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 4c7062b9d..dc83330a0 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -70,18 +70,134 @@ typedef struct { GtkWindow *parent_window; } EmpathyAccountAssistantPriv; +static GtkWidget * +account_assistant_build_error_page (EmpathyAccountAssistant *self, + GError *error, gint page_num) +{ + GtkWidget *main_vbox, *w, *hbox; + GString *str; + char *message; + PangoAttrList *list; + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + + main_vbox = gtk_vbox_new (FALSE, 12); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); + gtk_widget_show (main_vbox); + + hbox = gtk_hbox_new (FALSE, 12); + gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + w = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR, + GTK_ICON_SIZE_DIALOG); + gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + + /* translators: this is followed by the "while ..." strings some lines + * down this file. + */ + str = g_string_new (_("There has been an error\n")); + + if (page_num == PAGE_IMPORT) + /* translators: this follows the "There has been an error " string */ + str = g_string_append (str, _("while importing the accounts.")); + else if (page_num == PAGE_ENTER_CREATE && + priv->first_resp == RESPONSE_ENTER_ACCOUNT) + /* translators: this follows the "There has been an error " string */ + str = g_string_append (str, _("while parsing the account details.")); + else if (page_num == PAGE_ENTER_CREATE && + priv->first_resp == RESPONSE_CREATE_ACCOUNT) + /* translators: this follows the "There has been an error " string */ + str = g_string_append (str, _("while creating the account.")); + + message = g_string_free (str, FALSE); + + w = gtk_label_new (message); + gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); + list = pango_attr_list_new (); + pango_attr_list_insert (list, pango_attr_scale_new (PANGO_SCALE_LARGE)); + pango_attr_list_insert (list, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); + gtk_label_set_attributes (GTK_LABEL (w), list); + gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5); + gtk_widget_show (w); + + g_free (message); + pango_attr_list_unref (list); + + message = g_markup_printf_escaped + (_("The error message was: %s"), + error->message); + w = gtk_label_new (message); + gtk_label_set_use_markup (GTK_LABEL (w), TRUE); + gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5); + gtk_widget_show (w); + + w = gtk_label_new (_("You can either go back and try to enter your " + "accounts' details\nagain or quit this wizard and add accounts " + "later from the Edit menu.")); + gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 6); + gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5); + gtk_widget_show (w); + + return main_vbox; +} + +static void +account_assistant_back_button_clicked_cb (GtkButton *button, + EmpathyAccountAssistant *self) +{ + gint page_num; + + page_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), + "page-num")); + gtk_assistant_remove_action_widget (GTK_ASSISTANT (self), + GTK_WIDGET (button)); + gtk_assistant_set_current_page (GTK_ASSISTANT (self), page_num); +} + +static void +account_assistant_present_error_page (EmpathyAccountAssistant *self, + GError *error, gint page_num) +{ + GtkWidget *error_page, *back_button; + gint num; + + error_page = account_assistant_build_error_page (self, error, + page_num); + num = gtk_assistant_append_page (GTK_ASSISTANT (self), error_page); + gtk_assistant_set_page_title (GTK_ASSISTANT (self), error_page, + _("An error occurred")); + gtk_assistant_set_page_type (GTK_ASSISTANT (self), error_page, + GTK_ASSISTANT_PAGE_SUMMARY); + + back_button = gtk_button_new_from_stock (GTK_STOCK_GO_BACK); + gtk_assistant_add_action_widget (GTK_ASSISTANT (self), back_button); + g_object_set_data (G_OBJECT (back_button), + "page-num", GINT_TO_POINTER (page_num)); + g_signal_connect (back_button, "clicked", + G_CALLBACK (account_assistant_back_button_clicked_cb), self); + gtk_widget_show (back_button); + + gtk_assistant_set_current_page (GTK_ASSISTANT (self), num); +} + static void account_assistant_apply_account_cb (GObject *source, GAsyncResult *result, gpointer user_data) { GError *error = NULL; + EmpathyAccountAssistant *self = user_data; empathy_account_settings_apply_finish (EMPATHY_ACCOUNT_SETTINGS (source), result, &error); if (error != NULL) - g_print ("error applying %s\n", error->message); + { + account_assistant_present_error_page (self, error, PAGE_ENTER_CREATE); + g_error_free (error); + } } static void -- cgit v1.2.3 From f9cbc778a336d3a891d67914d289841222fb679b Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 6 Aug 2009 19:19:49 +0200 Subject: Implement dispose --- src/empathy-account-assistant.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index dc83330a0..5bcd602e7 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -68,6 +68,8 @@ typedef struct { EmpathyAccountSettings *settings; GtkWindow *parent_window; + + gboolean dispose_run; } EmpathyAccountAssistantPriv; static GtkWidget * @@ -624,6 +626,26 @@ do_constructed (GObject *object) gtk_window_set_type_hint (GTK_WINDOW (object), GDK_WINDOW_TYPE_HINT_DIALOG); } +static void +do_dispose (GObject *obj) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (obj); + + if (priv->dispose_run) + return; + + priv->dispose_run = TRUE; + + if (priv->settings != NULL) + { + g_object_unref (priv->settings); + priv->settings = NULL; + } + + if (G_OBJECT_CLASS (empathy_account_assistant_parent_class)->dispose != NULL) + G_OBJECT_CLASS (empathy_account_assistant_parent_class)->dispose (obj); +} + static void empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) { @@ -633,6 +655,7 @@ empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) oclass->get_property = do_get_property; oclass->set_property = do_set_property; oclass->constructed = do_constructed; + oclass->dispose = do_dispose; param_spec = g_param_spec_object ("parent-window", "parent-window", "The parent window", -- cgit v1.2.3 From 1d0f90da95786ef6143460ed7234156ec9c46936 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 6 Aug 2009 19:19:56 +0200 Subject: Enable newly created accounts --- src/empathy-account-assistant.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 5bcd602e7..9291cd30c 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -191,15 +191,21 @@ account_assistant_apply_account_cb (GObject *source, { GError *error = NULL; EmpathyAccountAssistant *self = user_data; + EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source); + EmpathyAccount *account; - empathy_account_settings_apply_finish (EMPATHY_ACCOUNT_SETTINGS (source), - result, &error); + empathy_account_settings_apply_finish (settings, result, &error); if (error != NULL) { account_assistant_present_error_page (self, error, PAGE_ENTER_CREATE); g_error_free (error); + return; } + + /* enable the newly created account */ + account = empathy_account_settings_get_account (settings); + empathy_account_set_enabled (account, TRUE); } static void -- cgit v1.2.3 From 2cfd3d52a13089bd00c863a2ff2a721ec04190b5 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 6 Aug 2009 19:20:28 +0200 Subject: Add a comment over the window type hint --- src/empathy-account-assistant.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 9291cd30c..91d90c83c 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -629,6 +629,7 @@ do_constructed (GObject *object) gtk_window_set_transient_for (GTK_WINDOW (object), priv->parent_window); + /* set the dialog hint, so this will be centered over the parent window */ gtk_window_set_type_hint (GTK_WINDOW (object), GDK_WINDOW_TYPE_HINT_DIALOG); } -- cgit v1.2.3 From a4f73e80b9f3015356fd0ee7d33fc0c7a8a21c8c Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 6 Aug 2009 19:55:36 +0200 Subject: Implement close and cancel; Also, move to implementing GTK+ signals rather than connecting --- src/empathy-account-assistant.c | 101 ++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 91d90c83c..4e9044fdf 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -220,19 +220,6 @@ account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self) account_assistant_apply_account_cb, self); } -static void -account_assistant_apply_cb (GtkAssistant *assistant, - gpointer user_data) -{ - EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant); - gint current_page; - - current_page = gtk_assistant_get_current_page (assistant); - - if (current_page == RESPONSE_ENTER_ACCOUNT) - account_assistant_apply_account_and_finish (self); -} - static void account_assistant_handle_apply_cb (EmpathyAccountWidget *widget_object, gboolean is_valid, @@ -367,27 +354,6 @@ account_assistant_finish_enter_or_create_page (EmpathyAccountAssistant *self, account_assistant_protocol_changed_cb (GTK_COMBO_BOX (priv->chooser), self); } -static void -account_assistant_prepare_cb (GtkAssistant *assistant, - GtkWidget *current_page, - gpointer user_data) -{ - EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant); - EmpathyAccountAssistantPriv *priv = GET_PRIV (self); - gint current_idx; - - current_idx = gtk_assistant_get_current_page (assistant); - - g_print ("prepare, current idx = %d\n", current_idx); - - if (current_idx == PAGE_ENTER_CREATE) - { - account_assistant_finish_enter_or_create_page (self, - priv->first_resp == RESPONSE_ENTER_ACCOUNT ? - TRUE : FALSE); - } -} - static gint account_assistant_page_forward_func (gint current_page, gpointer user_data) @@ -421,12 +387,22 @@ account_assistant_radio_choice_toggled_cb (GtkToggleButton *button, { FirstPageResponse response; EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + GtkWidget *intro_page; response = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "response")); - g_print ("choice %d toggled\n", response); priv->first_resp = response; + + intro_page = gtk_assistant_get_nth_page (GTK_ASSISTANT (self), + PAGE_INTRO); + + if (response == RESPONSE_SALUT_ONLY) + gtk_assistant_set_page_type (GTK_ASSISTANT (self), intro_page, + GTK_ASSISTANT_PAGE_SUMMARY); + else + gtk_assistant_set_page_type (GTK_ASSISTANT (self), intro_page, + GTK_ASSISTANT_PAGE_INTRO); } static GtkWidget * @@ -583,6 +559,50 @@ account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self, return main_vbox; } +static void +impl_signal_apply (GtkAssistant *assistant) +{ + EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant); + gint current_page; + + current_page = gtk_assistant_get_current_page (assistant); + + if (current_page == RESPONSE_ENTER_ACCOUNT) + account_assistant_apply_account_and_finish (self); +} + +static void +impl_signal_close (GtkAssistant *assistant) +{ + gtk_widget_destroy (GTK_WIDGET (assistant)); +} + +static void +impl_signal_cancel (GtkAssistant *assistant) +{ + gtk_widget_destroy (GTK_WIDGET (assistant)); +} + +static void +impl_signal_prepare (GtkAssistant *assistant, + GtkWidget *current_page) +{ + EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant); + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + gint current_idx; + + current_idx = gtk_assistant_get_current_page (assistant); + + g_print ("prepare, current idx = %d\n", current_idx); + + if (current_idx == PAGE_ENTER_CREATE) + { + account_assistant_finish_enter_or_create_page (self, + priv->first_resp == RESPONSE_ENTER_ACCOUNT ? + TRUE : FALSE); + } +} + static void do_get_property (GObject *object, guint property_id, @@ -657,6 +677,7 @@ static void empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) { GObjectClass *oclass = G_OBJECT_CLASS (klass); + GtkAssistantClass *gtkclass = GTK_ASSISTANT_CLASS (klass); GParamSpec *param_spec; oclass->get_property = do_get_property; @@ -664,6 +685,11 @@ empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) oclass->constructed = do_constructed; oclass->dispose = do_dispose; + gtkclass->apply = impl_signal_apply; + gtkclass->prepare = impl_signal_prepare; + gtkclass->close = impl_signal_close; + gtkclass->cancel = impl_signal_cancel; + param_spec = g_param_spec_object ("parent-window", "parent-window", "The parent window", GTK_TYPE_WINDOW, @@ -687,11 +713,6 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) gtk_assistant_set_forward_page_func (assistant, account_assistant_page_forward_func, self, NULL); - g_signal_connect (self, "apply", - G_CALLBACK (account_assistant_apply_cb), NULL); - g_signal_connect (self, "prepare", - G_CALLBACK (account_assistant_prepare_cb), NULL); - /* first page (introduction) */ page = account_assistant_build_introduction_page (self); gtk_assistant_append_page (assistant, page); -- cgit v1.2.3 From 85883a63be4daae817ed194ba6fa014266d27c09 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 6 Aug 2009 21:13:31 +0200 Subject: Port to new API --- src/empathy-accounts-dialog.c | 2 +- src/empathy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 8b896676d..391c42b6d 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -446,7 +446,7 @@ accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer, return; enabled = empathy_account_is_enabled (account); - empathy_account_set_enabled (account, !enabled); + empathy_account_set_enabled_async (account, !enabled, NULL, NULL); DEBUG ("%s account %s", enabled ? "Disabled" : "Enable", empathy_account_get_display_name (account)); diff --git a/src/empathy.c b/src/empathy.c index 15672c8df..650129ebb 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -216,7 +216,7 @@ salut_account_created (GObject *source, account = empathy_account_settings_get_account (settings); - empathy_account_set_enabled (account, TRUE); + empathy_account_set_enabled_async (account, TRUE, NULL, NULL); empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, TRUE); -- cgit v1.2.3 From b047c404615a4137ced83c40d214f1092fbc733b Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 6 Aug 2009 21:17:16 +0200 Subject: Emit the close signal only after we are done with the async machinery. --- src/empathy-account-assistant.c | 53 ++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 4e9044fdf..f5ef3c7f5 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -66,6 +66,7 @@ typedef struct { GtkWidget *second_label; GtkWidget *chooser; EmpathyAccountSettings *settings; + gboolean is_creating; GtkWindow *parent_window; @@ -184,6 +185,26 @@ account_assistant_present_error_page (EmpathyAccountAssistant *self, gtk_assistant_set_current_page (GTK_ASSISTANT (self), num); } +static void +account_assistant_account_enabled_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + GError *error = NULL; + EmpathyAccountAssistant *self = user_data; + + empathy_account_set_enabled_finish (EMPATHY_ACCOUNT (source), + result, &error); + + if (error) + { + g_warning ("Error enabling an account: %s", error->message); + g_error_free (error); + } + + g_signal_emit_by_name (self, "close"); +} + static void account_assistant_apply_account_cb (GObject *source, GAsyncResult *result, @@ -191,11 +212,14 @@ account_assistant_apply_account_cb (GObject *source, { GError *error = NULL; EmpathyAccountAssistant *self = user_data; + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source); EmpathyAccount *account; empathy_account_settings_apply_finish (settings, result, &error); + priv->is_creating = FALSE; + if (error != NULL) { account_assistant_present_error_page (self, error, PAGE_ENTER_CREATE); @@ -205,7 +229,8 @@ account_assistant_apply_account_cb (GObject *source, /* enable the newly created account */ account = empathy_account_settings_get_account (settings); - empathy_account_set_enabled (account, TRUE); + empathy_account_set_enabled_async (account, TRUE, + account_assistant_account_enabled_cb, self); } static void @@ -216,6 +241,8 @@ account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self) if (priv->settings == NULL) return; + priv->is_creating = TRUE; + empathy_account_settings_apply_async (priv->settings, account_assistant_apply_account_cb, self); } @@ -559,24 +586,32 @@ account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self, return main_vbox; } +static void +account_assistant_close_cb (GtkAssistant *assistant, + gpointer user_data) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (assistant); + + if (priv->is_creating) + return; + + gtk_widget_destroy (GTK_WIDGET (assistant)); +} + static void impl_signal_apply (GtkAssistant *assistant) { EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant); + // EmpathyAccountAssistantPriv *priv = GET_PRIV (self); gint current_page; + g_print ("apply!!\n"); current_page = gtk_assistant_get_current_page (assistant); if (current_page == RESPONSE_ENTER_ACCOUNT) account_assistant_apply_account_and_finish (self); } -static void -impl_signal_close (GtkAssistant *assistant) -{ - gtk_widget_destroy (GTK_WIDGET (assistant)); -} - static void impl_signal_cancel (GtkAssistant *assistant) { @@ -687,7 +722,6 @@ empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass) gtkclass->apply = impl_signal_apply; gtkclass->prepare = impl_signal_prepare; - gtkclass->close = impl_signal_close; gtkclass->cancel = impl_signal_cancel; param_spec = g_param_spec_object ("parent-window", @@ -710,6 +744,9 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) EmpathyAccountAssistantPriv); self->priv = priv; + g_signal_connect (self, "close", + G_CALLBACK (account_assistant_close_cb), NULL); + gtk_assistant_set_forward_page_func (assistant, account_assistant_page_forward_func, self, NULL); -- cgit v1.2.3 From 1ca4a9ee58260df26a03bc6565867b7958333f4c Mon Sep 17 00:00:00 2001 From: Arnaud Maillet Date: Tue, 28 Jul 2009 15:07:53 +0200 Subject: Remove the hardcode --- src/empathy-accounts-dialog.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 391c42b6d..3532e97f4 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -134,34 +134,24 @@ accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog, static GtkWidget * get_account_setup_widget (EmpathyAccountSettings *settings) { - const gchar *cm = empathy_account_settings_get_cm (settings); const gchar *proto = empathy_account_settings_get_protocol (settings); + EmpathyConnectionManagers *cm = + empathy_connection_managers_dup_singleton (); + GList *cms = empathy_connection_managers_get_cms (cm); + GList *l; - struct { - const gchar *cm; - const gchar *proto; - } dialogs[] = { - { "gabble", "jabber" }, - { "butterfly", "msn" }, - { "salut", "local-xmpp" }, - { "idle", "irc" }, - { "haze", "icq" }, - { "haze", "aim" }, - { "haze", "yahoo" }, - { "haze", "groupwise" }, - { "sofiasip", "sip" }, - { NULL, NULL } - }; - int i; - - for (i = 0; dialogs[i].cm != NULL; i++) + for (l = cms; l; l = l->next) { - if (!tp_strdiff (cm, dialogs[i].cm) - && !tp_strdiff (proto, dialogs[i].proto)) - return empathy_account_widget_new_for_protocol (dialogs[i].proto, - settings); + TpConnectionManager *tp_cm = l->data; + if (tp_connection_manager_has_protocol (tp_cm, proto)) + { + g_object_unref (cm); + return empathy_account_widget_new_for_protocol + (proto, settings); + } } + g_object_unref (cm); return empathy_account_widget_new_for_protocol ("generic", settings); } -- cgit v1.2.3 From 2f019885754917e5130b35d167cadb4c5ca966d5 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 7 Aug 2009 17:21:56 +0200 Subject: Split EmpathyImportDialog and EmpathyImportWidget Also, take this as a chance to GObject-ify everything. --- src/empathy-import-dialog.c | 493 ++++++++++++++----------------------------- src/empathy-import-dialog.h | 39 +++- src/empathy-import-dialog.ui | 78 ++----- src/empathy-import-widget.c | 464 ++++++++++++++++++++++++++++++++++++++++ src/empathy-import-widget.h | 68 ++++++ 5 files changed, 739 insertions(+), 403 deletions(-) create mode 100644 src/empathy-import-widget.c create mode 100644 src/empathy-import-widget.h (limited to 'src') diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c index a70a6eedd..4866b81c5 100644 --- a/src/empathy-import-dialog.c +++ b/src/empathy-import-dialog.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2008-2009 Collabora Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -17,7 +17,8 @@ * Boston, MA 02110-1301 USA * * Authors: Jonny Lamb - * */ + * Cosimo Cecchi + */ #include @@ -31,6 +32,7 @@ #include "empathy-import-dialog.h" #include "empathy-import-pidgin.h" +#include "empathy-import-widget.h" #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include @@ -39,25 +41,22 @@ #include #include -typedef struct -{ - GtkWidget *window; - GtkWidget *treeview; - GtkWidget *button_ok; - GtkWidget *button_cancel; - GList *accounts; -} EmpathyImportDialog; - -enum -{ - COL_IMPORT = 0, - COL_PROTOCOL, - COL_NAME, - COL_SOURCE, - COL_ACCOUNT_DATA, - COL_COUNT +enum { + PROP_PARENT = 1, + PROP_SHOW_WARNING }; +typedef struct { + GtkWindow *parent_window; + + EmpathyImportWidget *iw; + + gboolean show_warning; +} EmpathyImportDialogPriv; + +G_DEFINE_TYPE (EmpathyImportDialog, empathy_import_dialog, GTK_TYPE_DIALOG) +#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyImportDialog) + EmpathyImportAccountData * empathy_import_account_data_new (const gchar *source) { @@ -92,377 +91,193 @@ empathy_import_account_data_free (EmpathyImportAccountData *data) g_slice_free (EmpathyImportAccountData, data); } -static void -import_dialog_create_account_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) +gboolean +empathy_import_dialog_accounts_to_import (void) { - EmpathyImportAccountData *data = (EmpathyImportAccountData *) user_data; - EmpathyAccount *account; - GError *error = NULL; - - account = empathy_account_manager_create_account_finish ( - EMPATHY_ACCOUNT_MANAGER (source), result, &error); - - if (account == NULL) - { - DEBUG ("Failed to create account: %s", - error ? error->message : "No error given"); - g_clear_error (&error); - empathy_import_account_data_free (data); - return; - } - - DEBUG ("account created\n"); - - g_object_unref (account); + return empathy_import_pidgin_accounts_to_import (); } static void -import_dialog_add_account (EmpathyImportAccountData *data) +import_dialog_add_import_widget (EmpathyImportDialog *self) { - EmpathyAccountManager *account_manager; - gchar *display_name; - GHashTable *properties; - GValue *username; - - account_manager = empathy_account_manager_dup_singleton (); - - DEBUG ("connection_manager: %s\n", data->connection_manager); - - /* Set the display name of the account */ - username = g_hash_table_lookup (data->settings, "account"); - display_name = g_strdup_printf ("%s (%s)", - data->protocol, - g_value_get_string (username)); - - DEBUG ("display name: %s\n", display_name); - - properties = g_hash_table_new (NULL, NULL); - - empathy_account_manager_create_account_async (account_manager, - (const gchar*) data->connection_manager, data->protocol, display_name, - data->settings, properties, import_dialog_create_account_cb, NULL); - - g_hash_table_unref (properties); - g_free (display_name); - g_object_unref (account_manager); + EmpathyImportWidget *iw; + EmpathyImportDialogPriv *priv = GET_PRIV (self); + GtkWidget *widget, *area; + + area = gtk_dialog_get_content_area (GTK_DIALOG (self)); + + iw = empathy_import_widget_new (); + widget = empathy_import_widget_get_widget (iw); + gtk_box_pack_start (GTK_BOX (area), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + priv->iw = iw; + + gtk_dialog_add_buttons (GTK_DIALOG (self), GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); } -static gboolean -import_dialog_account_id_in_list (GList *accounts, - const gchar *account_id) +static void +import_dialog_show_warning_message (EmpathyImportDialog *self) { - GList *l; + GtkWidget *hbox, *vbox, *w; - for (l = accounts; l; l = l->next) - { - EmpathyAccount *account = l->data; - const gchar *account_string; - GValue *value; - gboolean result; - const GHashTable *parameters; + vbox = gtk_vbox_new (FALSE, 12); + hbox = gtk_hbox_new (FALSE, 12); - parameters = empathy_account_get_parameters (account); + w = gtk_label_new (_("No accounts to import could be found. Empathy " + "currently only supports importing accounts from Pidgin.")); + gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); + gtk_label_set_selectable (GTK_LABEL (w), TRUE); + gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); + gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - value = g_hash_table_lookup ((GHashTable *) parameters, "account"); + w = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, + GTK_ICON_SIZE_DIALOG); + gtk_misc_set_alignment (GTK_MISC (w), 0.5, 0.0); + gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - if (value == NULL) - continue; + gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); - account_string = g_value_get_string (value); + w = gtk_dialog_get_content_area (GTK_DIALOG (self)); + gtk_box_pack_start (GTK_BOX (w), hbox, FALSE, FALSE, 0); - result = tp_strdiff (account_string, account_id); + gtk_box_set_spacing (GTK_BOX (w), 14); /* 14 + 2 * 5 = 24 */ - if (!result) - return TRUE; - } + gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CLOSE, + GTK_RESPONSE_CLOSE); - return FALSE; + gtk_widget_show_all (w); } -static gboolean protocol_is_supported (EmpathyImportAccountData *data) +static void +impl_signal_response (GtkDialog *dialog, + gint response_id) { - EmpathyConnectionManagers *cm = - empathy_connection_managers_dup_singleton (); - GList *cms = empathy_connection_managers_get_cms (cm); - GList *l; - gboolean proto_is_supported = FALSE; + EmpathyImportDialogPriv *priv = GET_PRIV (dialog); - for (l = cms; l; l = l->next) - { - TpConnectionManager *tp_cm = l->data; - const gchar *cm_name = tp_connection_manager_get_name (tp_cm); - if (tp_connection_manager_has_protocol (tp_cm, - (const gchar*)data->protocol)) - { - data->connection_manager = g_strdup (cm_name); - proto_is_supported = TRUE; - break; - } - } - - g_object_unref (cm); + if (response_id == GTK_RESPONSE_OK) + empathy_import_widget_add_selected_accounts (priv->iw); - return proto_is_supported; + gtk_widget_destroy (GTK_WIDGET (dialog)); } static void -import_dialog_add_accounts_to_model (EmpathyImportDialog *dialog) +do_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - GtkTreeModel *model; - GtkTreeIter iter; - GList *l; - EmpathyAccountManager *manager = empathy_account_manager_dup_singleton (); + EmpathyImportDialogPriv *priv = GET_PRIV (object); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); - - for (l = dialog->accounts; l; l = l->next) + switch (property_id) { - GValue *value; - EmpathyImportAccountData *data = l->data; - gboolean import; - GList *accounts; - - if (!protocol_is_supported (data)) - continue; - - value = g_hash_table_lookup (data->settings, "account"); - - accounts = empathy_account_manager_dup_accounts (manager); - - /* Only set the "Import" cell to be active if there isn't already an - * account set up with the same account id. */ - import = !import_dialog_account_id_in_list (accounts, - g_value_get_string (value)); - - g_list_foreach (accounts, (GFunc) g_object_unref, NULL); - g_list_free (accounts); - - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_IMPORT, import, - COL_PROTOCOL, data->protocol, - COL_NAME, g_value_get_string (value), - COL_SOURCE, data->source, - COL_ACCOUNT_DATA, data, - -1); + case PROP_PARENT: + g_value_set_object (value, priv->parent_window); + break; + case PROP_SHOW_WARNING: + g_value_set_boolean (value, priv->show_warning); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } - - g_object_unref (manager); -} - -static void -import_dialog_cell_toggled_cb (GtkCellRendererToggle *cell_renderer, - const gchar *path_str, - EmpathyImportDialog *dialog) -{ - GtkTreeModel *model; - GtkTreeIter iter; - GtkTreePath *path; - - path = gtk_tree_path_new_from_string (path_str); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); - - gtk_tree_model_get_iter (model, &iter, path); - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_IMPORT, !gtk_cell_renderer_toggle_get_active (cell_renderer), - -1); - - gtk_tree_path_free (path); } static void -import_dialog_set_up_account_list (EmpathyImportDialog *dialog) -{ - GtkListStore *store; - GtkTreeView *view; - GtkTreeViewColumn *column; - GtkCellRenderer *cell; - - store = gtk_list_store_new (COL_COUNT, G_TYPE_BOOLEAN, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - - gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview), - GTK_TREE_MODEL (store)); - - g_object_unref (store); - - view = GTK_TREE_VIEW (dialog->treeview); - gtk_tree_view_set_headers_visible (view, TRUE); - - /* Import column */ - cell = gtk_cell_renderer_toggle_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - /* Translators: this is the header of a treeview column */ - _("Import"), cell, - "active", COL_IMPORT, - NULL); - - g_signal_connect (cell, "toggled", - G_CALLBACK (import_dialog_cell_toggled_cb), dialog); - - /* Protocol column */ - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Protocol")); - gtk_tree_view_column_set_expand (column, TRUE); - gtk_tree_view_append_column (view, column); - - cell = gtk_cell_renderer_text_new (); - g_object_set (cell, - "editable", FALSE, - NULL); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, "text", COL_PROTOCOL); - - /* Account column */ - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Account")); - gtk_tree_view_column_set_expand (column, TRUE); - gtk_tree_view_append_column (view, column); - - cell = gtk_cell_renderer_text_new (); - g_object_set (cell, - "editable", FALSE, - NULL); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME); - - /* Source column */ - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Source")); - gtk_tree_view_column_set_expand (column, TRUE); - gtk_tree_view_append_column (view, column); - - cell = gtk_cell_renderer_text_new (); - g_object_set (cell, - "editable", FALSE, - NULL); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, "text", COL_SOURCE); - - import_dialog_add_accounts_to_model (dialog); -} - -static gboolean -import_dialog_tree_model_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) +do_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { - gboolean to_import; - EmpathyImportAccountData *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; -} + EmpathyImportDialogPriv *priv = GET_PRIV (object); -static void -import_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathyImportDialog *dialog) -{ - if (response == GTK_RESPONSE_OK) + switch (property_id) { - GtkTreeModel *model; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); - gtk_tree_model_foreach (model, import_dialog_tree_model_foreach, dialog); + case PROP_PARENT: + priv->parent_window = g_value_get_object (value); + break; + case PROP_SHOW_WARNING: + priv->show_warning = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } - - gtk_widget_destroy (dialog->window); } static void -import_dialog_destroy_cb (GtkWidget *widget, - EmpathyImportDialog *dialog) +do_constructed (GObject *obj) { - g_list_foreach (dialog->accounts, (GFunc) empathy_import_account_data_free, - NULL); - g_list_free (dialog->accounts); - g_slice_free (EmpathyImportDialog, dialog); -} + EmpathyImportDialog *self = EMPATHY_IMPORT_DIALOG (obj); + EmpathyImportDialogPriv *priv = GET_PRIV (self); + gboolean have_accounts; -gboolean -empathy_import_dialog_accounts_to_import (void) -{ - return empathy_import_pidgin_accounts_to_import (); -} + have_accounts = empathy_import_dialog_accounts_to_import (); -void -empathy_import_dialog_show (GtkWindow *parent, - gboolean warning) -{ - static EmpathyImportDialog *dialog = NULL; - GtkBuilder *gui; - gchar *filename; - GList *accounts = NULL; - - /* This window is a singleton. If it already exist, present it */ - if (dialog) - { - gtk_window_present (GTK_WINDOW (dialog->window)); - return; - } - - /* Load all accounts from all supported applications */ - accounts = g_list_concat (accounts, empathy_import_pidgin_load ()); - - /* Check if we have accounts to import before creating the window */ - if (!accounts) + if (!have_accounts) { - GtkWidget *message; - - if (warning) + if (priv->show_warning) { - message = gtk_message_dialog_new (parent, - GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, - _("No accounts to import could be found. Empathy currently only " - "supports importing accounts from Pidgin.")); - - gtk_dialog_run (GTK_DIALOG (message)); - gtk_widget_destroy (message); + import_dialog_show_warning_message (self); } else DEBUG ("No accounts to import; closing dialog silently."); - - return; + } + else + { + import_dialog_add_import_widget (self); } - /* 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.ui", "src"); - gui = empathy_builder_get_file (filename, - "import_dialog", &dialog->window, - "treeview", &dialog->treeview, - NULL); - - empathy_builder_connect (gui, dialog, - "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); + if (priv->parent_window) + gtk_window_set_transient_for (GTK_WINDOW (self), priv->parent_window); +} - g_free (filename); - g_object_unref (gui); +static void +empathy_import_dialog_init (EmpathyImportDialog *self) +{ + EmpathyImportDialogPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + EMPATHY_TYPE_IMPORT_DIALOG, EmpathyImportDialogPriv); - if (parent) - gtk_window_set_transient_for (GTK_WINDOW (dialog->window), parent); + self->priv = priv; - import_dialog_set_up_account_list (dialog); + gtk_container_set_border_width (GTK_CONTAINER (self), 5); + gtk_window_set_title (GTK_WINDOW (self), _("Import Accounts")); + gtk_window_set_modal (GTK_WINDOW (self), TRUE); + gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE); +} - gtk_widget_show (dialog->window); +static void +empathy_import_dialog_class_init (EmpathyImportDialogClass *klass) +{ + GObjectClass *oclass = G_OBJECT_CLASS (klass); + GtkDialogClass *gtkclass = GTK_DIALOG_CLASS (klass); + GParamSpec *param_spec; + + oclass->constructed = do_constructed; + oclass->get_property = do_get_property; + oclass->set_property = do_set_property; + + gtkclass->response = impl_signal_response; + + param_spec = g_param_spec_object ("parent-window", + "parent-window", "The parent window", + GTK_TYPE_WINDOW, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (oclass, PROP_PARENT, param_spec); + + param_spec = g_param_spec_boolean ("show-warning", + "show-warning", "Whether a warning should be shown when there are no " + "sources for importing accounts.", + FALSE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (oclass, PROP_SHOW_WARNING, param_spec); + + g_type_class_add_private (klass, sizeof (EmpathyImportDialogPriv)); } +GtkWidget * +empathy_import_dialog_new (GtkWindow *parent, + gboolean warning) +{ + return g_object_new (EMPATHY_TYPE_IMPORT_DIALOG, "parent-window", + parent, "show-warning", warning, NULL); +} diff --git a/src/empathy-import-dialog.h b/src/empathy-import-dialog.h index bdd0de732..14ab33b47 100644 --- a/src/empathy-import-dialog.h +++ b/src/empathy-import-dialog.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2008-2009 Collabora Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -17,6 +17,7 @@ * Boston, MA 02110-1301 USA * * Authors: Jonny Lamb + * Cosimo Cecchi */ #include @@ -26,6 +27,21 @@ G_BEGIN_DECLS +#define EMPATHY_TYPE_IMPORT_DIALOG empathy_import_dialog_get_type() +#define EMPATHY_IMPORT_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_IMPORT_DIALOG,\ + EmpathyImportDialog)) +#define EMPATHY_IMPORT_DIALOG_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_IMPORT_DIALOG,\ + EmpathyImportDialogClass)) +#define EMPATHY_IS_IMPORT_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_IMPORT_DIALOG)) +#define EMPATHY_IS_IMPORT_DIALOG_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_IMPORT_DIALOG)) +#define EMPATHY_IMPORT_DIALOG_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_IMPORT_DIALOG,\ + EmpathyImportDialogClass)) + typedef struct { /* Table mapping CM param string to a GValue */ @@ -38,10 +54,27 @@ typedef struct gchar *source; } EmpathyImportAccountData; -EmpathyImportAccountData *empathy_import_account_data_new (const gchar *source); +typedef struct { + GtkDialog parent; + + /* private */ + gpointer priv; +} EmpathyImportDialog; + +typedef struct { + GtkDialogClass parent_class; +} EmpathyImportDialogClass; + +GType empathy_import_dialog_get_type (void); + +GtkWidget* empathy_import_dialog_new (GtkWindow *parent_window, + gboolean show_warning); + +EmpathyImportAccountData *empathy_import_account_data_new ( + const gchar *source); void empathy_import_account_data_free (EmpathyImportAccountData *data); + gboolean empathy_import_dialog_accounts_to_import (void); -void empathy_import_dialog_show (GtkWindow *parent, gboolean warning); G_END_DECLS diff --git a/src/empathy-import-dialog.ui b/src/empathy-import-dialog.ui index 38ba434e4..ce7a56a74 100644 --- a/src/empathy-import-dialog.ui +++ b/src/empathy-import-dialog.ui @@ -1,73 +1,29 @@ - - - 5 - Import Accounts - True - GTK_WIN_POS_CENTER_ON_PARENT - GDK_WINDOW_TYPE_HINT_DIALOG - False - - + + + + True + 2 + + True - 2 + True + never + automatic + in - + + 200 True True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - - - 200 - True - True - False - - + False - - 1 - - - - - True - GTK_BUTTONBOX_END - - - True - True - True - gtk-cancel - True - - - - - True - True - True - gtk-ok - True - - - 1 - - - - - False - GTK_PACK_END - + + 1 + - - button_cancel - button_ok - diff --git a/src/empathy-import-widget.c b/src/empathy-import-widget.c new file mode 100644 index 000000000..d276c03e5 --- /dev/null +++ b/src/empathy-import-widget.c @@ -0,0 +1,464 @@ +/* + * Copyright (C) 2008-2009 Collabora Ltd. + * + * This program 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 2 of the + * License, or (at your option) any later version. + * + * This program 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, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: Jonny Lamb + * Cosimo Cecchi + */ + +/* empathy-import-widget.c */ + +#include "empathy-import-dialog.h" +#include "empathy-import-widget.h" +#include "empathy-import-pidgin.h" + +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include +#include +#include +#include +#include + +#include + +#include + +#include + +G_DEFINE_TYPE (EmpathyImportWidget, empathy_import_widget, G_TYPE_OBJECT) + +#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyImportWidget) + +enum +{ + COL_IMPORT = 0, + COL_PROTOCOL, + COL_NAME, + COL_SOURCE, + COL_ACCOUNT_DATA, + COL_COUNT +}; + +typedef struct { + GtkWidget *vbox; + GtkWidget *treeview; + + GList *accounts; + + EmpathyConnectionManagers *cms; + + gboolean dispose_run; +} EmpathyImportWidgetPriv; + +static gboolean +import_widget_account_id_in_list (GList *accounts, + const gchar *account_id) +{ + GList *l; + + for (l = accounts; l; l = l->next) + { + EmpathyAccount *account = l->data; + const gchar *account_string; + GValue *value; + gboolean result; + const GHashTable *parameters; + + parameters = empathy_account_get_parameters (account); + + value = g_hash_table_lookup ((GHashTable *)parameters, "account"); + + if (value == NULL) + continue; + + account_string = g_value_get_string (value); + + result = tp_strdiff (account_string, account_id); + + if (!result) + return TRUE; + } + + return FALSE; +} + +static gboolean +protocol_is_supported (EmpathyImportWidget *self, + EmpathyImportAccountData *data) +{ + EmpathyImportWidgetPriv *priv = GET_PRIV (self); + GList *cms = empathy_connection_managers_get_cms (priv->cms); + GList *l; + gboolean proto_is_supported = FALSE; + + for (l = cms; l; l = l->next) + { + TpConnectionManager *tp_cm = l->data; + const gchar *cm_name = tp_connection_manager_get_name (tp_cm); + if (tp_connection_manager_has_protocol (tp_cm, + (const gchar*) data->protocol)) + { + data->connection_manager = g_strdup (cm_name); + proto_is_supported = TRUE; + break; + } + } + + return proto_is_supported; +} + +static void +import_widget_add_accounts_to_model (EmpathyImportWidget *self) +{ + GtkTreeModel *model; + GtkTreeIter iter; + GList *l; + EmpathyImportWidgetPriv *priv = GET_PRIV (self); + EmpathyAccountManager *manager = empathy_account_manager_dup_singleton (); + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + + for (l = priv->accounts; l; l = l->next) + { + GValue *value; + EmpathyImportAccountData *data = l->data; + gboolean import; + GList *accounts; + + if (!protocol_is_supported (self, data)) + continue; + + value = g_hash_table_lookup (data->settings, "account"); + + accounts = empathy_account_manager_dup_accounts (manager); + + /* Only set the "Import" cell to be active if there isn't already an + * account set up with the same account id. */ + import = !import_widget_account_id_in_list (accounts, + g_value_get_string (value)); + + g_list_foreach (accounts, (GFunc) g_object_unref, NULL); + g_list_free (accounts); + + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_IMPORT, import, + COL_PROTOCOL, data->protocol, + COL_NAME, g_value_get_string (value), + COL_SOURCE, data->source, + COL_ACCOUNT_DATA, data, + -1); + } + + g_object_unref (manager); +} + +static void +import_widget_create_account_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyAccount *account; + GError *error = NULL; + EmpathyImportWidget *self = user_data; + + account = empathy_account_manager_create_account_finish ( + EMPATHY_ACCOUNT_MANAGER (source), result, &error); + + if (account == NULL) + { + DEBUG ("Failed to create account: %s", + error ? error->message : "No error given"); + g_clear_error (&error); + return; + } + + DEBUG ("account created\n"); + + g_object_unref (self); +} + +static void +import_widget_add_account (EmpathyImportWidget *self, + EmpathyImportAccountData *data) +{ + EmpathyAccountManager *account_manager; + gchar *display_name; + GHashTable *properties; + GValue *username; + + account_manager = empathy_account_manager_dup_singleton (); + + DEBUG ("connection_manager: %s\n", data->connection_manager); + + /* Set the display name of the account */ + username = g_hash_table_lookup (data->settings, "account"); + display_name = g_strdup_printf ("%s (%s)", + data->protocol, + g_value_get_string (username)); + + DEBUG ("display name: %s\n", display_name); + + properties = g_hash_table_new (NULL, NULL); + + empathy_account_manager_create_account_async (account_manager, + (const gchar*) data->connection_manager, data->protocol, display_name, + data->settings, properties, import_widget_create_account_cb, + g_object_ref (self)); + + g_hash_table_unref (properties); + g_free (display_name); + g_object_unref (account_manager); +} + +static gboolean +import_widget_tree_model_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data) +{ + gboolean to_import; + EmpathyImportAccountData *data; + EmpathyImportWidget *self = user_data; + + gtk_tree_model_get (model, iter, + COL_IMPORT, &to_import, + COL_ACCOUNT_DATA, &data, + -1); + + if (to_import) + import_widget_add_account (self, data); + + return FALSE; +} + +static void +import_widget_cell_toggled_cb (GtkCellRendererToggle *cell_renderer, + const gchar *path_str, + EmpathyImportWidget *self) +{ + GtkTreeModel *model; + GtkTreeIter iter; + GtkTreePath *path; + EmpathyImportWidgetPriv *priv = GET_PRIV (self); + + path = gtk_tree_path_new_from_string (path_str); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + + gtk_tree_model_get_iter (model, &iter, path); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_IMPORT, !gtk_cell_renderer_toggle_get_active (cell_renderer), + -1); + + gtk_tree_path_free (path); +} + +static void +import_widget_set_up_account_list (EmpathyImportWidget *self) +{ + EmpathyImportWidgetPriv *priv = GET_PRIV (self); + GtkListStore *store; + GtkTreeView *view; + GtkTreeViewColumn *column; + GtkCellRenderer *cell; + + store = gtk_list_store_new (COL_COUNT, G_TYPE_BOOLEAN, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); + + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), + GTK_TREE_MODEL (store)); + + g_object_unref (store); + + view = GTK_TREE_VIEW (priv->treeview); + gtk_tree_view_set_headers_visible (view, TRUE); + + /* Import column */ + cell = gtk_cell_renderer_toggle_new (); + gtk_tree_view_insert_column_with_attributes (view, -1, + /* Translators: this is the header of a treeview column */ + _("Import"), cell, + "active", COL_IMPORT, + NULL); + + g_signal_connect (cell, "toggled", + G_CALLBACK (import_widget_cell_toggled_cb), self); + + /* Protocol column */ + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_title (column, _("Protocol")); + gtk_tree_view_column_set_expand (column, TRUE); + gtk_tree_view_append_column (view, column); + + cell = gtk_cell_renderer_text_new (); + g_object_set (cell, "editable", FALSE, NULL); + gtk_tree_view_column_pack_start (column, cell, TRUE); + gtk_tree_view_column_add_attribute (column, cell, "text", COL_PROTOCOL); + + /* Account column */ + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_title (column, _("Account")); + gtk_tree_view_column_set_expand (column, TRUE); + gtk_tree_view_append_column (view, column); + + cell = gtk_cell_renderer_text_new (); + g_object_set (cell, "editable", FALSE, NULL); + gtk_tree_view_column_pack_start (column, cell, TRUE); + gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME); + + /* Source column */ + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_title (column, _("Source")); + gtk_tree_view_column_set_expand (column, TRUE); + gtk_tree_view_append_column (view, column); + + cell = gtk_cell_renderer_text_new (); + g_object_set (cell, "editable", FALSE, NULL); + gtk_tree_view_column_pack_start (column, cell, TRUE); + gtk_tree_view_column_add_attribute (column, cell, "text", COL_SOURCE); + + import_widget_add_accounts_to_model (self); +} + +static void +import_widget_cms_ready_cb (EmpathyConnectionManagers *cms, + GParamSpec *pspec, + EmpathyImportWidget *self) +{ + if (empathy_connection_managers_is_ready (cms)) + import_widget_set_up_account_list (self); +} + +static void +import_widget_destroy_cb (GtkWidget *w, + EmpathyImportWidget *self) +{ + g_object_unref (self); +} + +static void +do_finalize (GObject *obj) +{ + EmpathyImportWidgetPriv *priv = GET_PRIV (obj); + + g_list_foreach (priv->accounts, (GFunc) empathy_import_account_data_free, + NULL); + g_list_free (priv->accounts); + + if (G_OBJECT_CLASS (empathy_import_widget_parent_class)->finalize != NULL) + G_OBJECT_CLASS (empathy_import_widget_parent_class)->finalize (obj); +} + +static void +do_dispose (GObject *obj) +{ + EmpathyImportWidgetPriv *priv = GET_PRIV (obj); + + if (priv->dispose_run) + return; + + priv->dispose_run = TRUE; + + if (priv->cms != NULL) + { + g_object_unref (priv->cms); + priv->cms = NULL; + } + + if (G_OBJECT_CLASS (empathy_import_widget_parent_class)->dispose != NULL) + G_OBJECT_CLASS (empathy_import_widget_parent_class)->dispose (obj); +} + +static void +do_constructed (GObject *obj) +{ + EmpathyImportWidget *self = EMPATHY_IMPORT_WIDGET (obj); + EmpathyImportWidgetPriv *priv = GET_PRIV (self); + GtkBuilder *gui; + gchar *filename; + + filename = empathy_file_lookup ("empathy-import-dialog.ui", "src"); + gui = empathy_builder_get_file (filename, + "widget_vbox", &priv->vbox, + "treeview", &priv->treeview, + NULL); + + g_free (filename); + empathy_builder_unref_and_keep_widget (gui, priv->vbox); + + g_signal_connect (priv->vbox, "destroy", + G_CALLBACK (import_widget_destroy_cb), self); + + if (empathy_connection_managers_is_ready (priv->cms)) + import_widget_set_up_account_list (self); + else + g_signal_connect (priv->cms, "notify::ready", + G_CALLBACK (import_widget_cms_ready_cb), self); +} + +static void +empathy_import_widget_class_init (EmpathyImportWidgetClass *klass) +{ + GObjectClass *oclass = G_OBJECT_CLASS (klass); + + oclass->constructed = do_constructed; + oclass->finalize = do_finalize; + oclass->dispose = do_dispose; + + g_type_class_add_private (klass, sizeof (EmpathyImportWidgetPriv)); +} + +static void +empathy_import_widget_init (EmpathyImportWidget *self) +{ + EmpathyImportWidgetPriv *priv = + G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_IMPORT_WIDGET, + EmpathyImportWidgetPriv); + + self->priv = priv; + + /* Load all accounts from all supported applications */ + priv->accounts = empathy_import_pidgin_load (); + + priv->cms = empathy_connection_managers_dup_singleton (); +} + +EmpathyImportWidget * +empathy_import_widget_new (void) +{ + return g_object_new (EMPATHY_TYPE_IMPORT_WIDGET, NULL); +} + +GtkWidget * +empathy_import_widget_get_widget (EmpathyImportWidget *self) +{ + EmpathyImportWidgetPriv *priv = GET_PRIV (self); + + return priv->vbox; +} + +void +empathy_import_widget_add_selected_accounts (EmpathyImportWidget *self) +{ + GtkTreeModel *model; + EmpathyImportWidgetPriv *priv = GET_PRIV (self); + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + gtk_tree_model_foreach (model, import_widget_tree_model_foreach, self); +} diff --git a/src/empathy-import-widget.h b/src/empathy-import-widget.h new file mode 100644 index 000000000..8af953d79 --- /dev/null +++ b/src/empathy-import-widget.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2008-2009 Collabora Ltd. + * + * This program 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 2 of the + * License, or (at your option) any later version. + * + * This program 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, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: Jonny Lamb + * Cosimo Cecchi + */ + +/* empathy-import-widget.h */ + +#ifndef __EMPATHY_IMPORT_WIDGET_H__ +#define __EMPATHY_IMPORT_WIDGET_H__ + +#include + +G_BEGIN_DECLS + +#define EMPATHY_TYPE_IMPORT_WIDGET empathy_import_widget_get_type() +#define EMPATHY_IMPORT_WIDGET(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_IMPORT_WIDGET,\ + EmpathyImportWidget)) +#define EMPATHY_IMPORT_WIDGET_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_IMPORT_WIDGET,\ + EmpathyImportWidgetClass)) +#define EMPATHY_IS_IMPORT_WIDGET(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_IMPORT_WIDGET)) +#define EMPATHY_IS_IMPORT_WIDGET_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_IMPORT_WIDGET)) +#define EMPATHY_IMPORT_WIDGET_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_IMPORT_WIDGET,\ + EmpathyImportWidgetClass)) + +typedef struct { + GObject parent; + + /* private */ + gpointer priv; +} EmpathyImportWidget; + +typedef struct { + GObjectClass parent_class; +} EmpathyImportWidgetClass; + +GType empathy_import_widget_get_type (void); + +EmpathyImportWidget* empathy_import_widget_new (void); + +GtkWidget * empathy_import_widget_get_widget (EmpathyImportWidget *self); + +void empathy_import_widget_add_selected_accounts (EmpathyImportWidget *self); + +G_END_DECLS + +#endif /* __EMPATHY_IMPORT_WIDGET_H__ */ -- cgit v1.2.3 From a7e5be33b8ff0bf0cdeaf4672d967e14f80c54eb Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 7 Aug 2009 17:22:55 +0200 Subject: Add the new files to the Makefile.am --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 9ac6b9bb3..5d3bee501 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,6 +41,7 @@ empathy_handwritten_source = \ empathy-event-manager.c empathy-event-manager.h \ empathy-ft-manager.c empathy-ft-manager.h \ empathy-import-dialog.c empathy-import-dialog.h \ + empathy-import-widget.c empathy-import-widget.h \ empathy-import-pidgin.c empathy-import-pidgin.h \ empathy-main-window.c empathy-main-window.h \ empathy-misc.c empathy-misc.h \ -- cgit v1.2.3 From 72ade92677b8c069b2933b76c64e340222a31254 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 7 Aug 2009 17:23:24 +0200 Subject: Adapt to the new API --- src/empathy-accounts-dialog.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 3532e97f4..785d20ae0 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1103,8 +1103,10 @@ accounts_dialog_button_import_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + GtkWidget *import_dialog; - empathy_import_dialog_show (GTK_WINDOW (priv->window), TRUE); + import_dialog = empathy_import_dialog_new (GTK_WINDOW (priv->window), TRUE); + gtk_widget_show (import_dialog); } static void @@ -1383,10 +1385,13 @@ do_constructed (GObject *object) if (!import_asked) { + GtkWidget *import_dialog; + empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_IMPORT_ASKED, TRUE); - empathy_import_dialog_show (GTK_WINDOW (priv->window), + import_dialog = empathy_import_dialog_new (GTK_WINDOW (priv->window), FALSE); + gtk_widget_show (import_dialog); } } else -- cgit v1.2.3 From 5f31f7e68a4d8e132aa9c1d0c6305e1546368666 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 7 Aug 2009 17:24:06 +0200 Subject: Hook the import UI in the assistant --- src/empathy-account-assistant.c | 92 +++++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index f5ef3c7f5..0b30bb807 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -24,6 +24,8 @@ #include #include "empathy-account-assistant.h" +#include "empathy-import-dialog.h" +#include "empathy-import-widget.h" #include #include @@ -68,6 +70,9 @@ typedef struct { EmpathyAccountSettings *settings; gboolean is_creating; + /* import page */ + EmpathyImportWidget *iw; + GtkWindow *parent_window; gboolean dispose_run; @@ -396,15 +401,17 @@ account_assistant_page_forward_func (gint current_page, if (priv->first_resp == RESPONSE_ENTER_ACCOUNT || priv->first_resp == RESPONSE_CREATE_ACCOUNT) retval = PAGE_ENTER_CREATE; + if (priv->first_resp == RESPONSE_IMPORT) + retval = PAGE_IMPORT; } - if (current_page == PAGE_ENTER_CREATE) + if (current_page == PAGE_ENTER_CREATE || + current_page == PAGE_IMPORT) { /* don't forward anymore */ retval = -1; } - g_print ("retval = %d\n", retval); return retval; } @@ -435,8 +442,10 @@ account_assistant_radio_choice_toggled_cb (GtkToggleButton *button, static GtkWidget * account_assistant_build_introduction_page (EmpathyAccountAssistant *self) { - GtkWidget *main_vbox, *hbox_1, *w, *radio, *vbox_1; + GtkWidget *main_vbox, *hbox_1, *w, *vbox_1; + GtkWidget *radio = NULL; GdkPixbuf *pix; + const gchar *str; main_vbox = gtk_vbox_new (FALSE, 12); gtk_widget_show (main_vbox); @@ -474,23 +483,46 @@ account_assistant_build_introduction_page (EmpathyAccountAssistant *self) gtk_box_pack_start (GTK_BOX (main_vbox), w, TRUE, TRUE, 0); gtk_widget_show (w); - vbox_1 = gtk_vbox_new (FALSE, 6); + vbox_1 = gtk_vbox_new (TRUE, 0); gtk_container_add (GTK_CONTAINER (w), vbox_1); gtk_widget_show (vbox_1); - /* TODO: this will have to be updated when kutio's branch have landed */ - radio = gtk_radio_button_new_with_label (NULL, - _("Yes, import my account details from ")); - gtk_box_pack_start (GTK_BOX (vbox_1), radio, TRUE, TRUE, 0); - g_object_set_data (G_OBJECT (radio), "response", - GINT_TO_POINTER (RESPONSE_IMPORT)); - gtk_widget_show (radio); + if (empathy_import_dialog_accounts_to_import ()) + { + hbox_1 = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox_1), hbox_1, TRUE, TRUE, 0); + gtk_widget_show (hbox_1); + + radio = gtk_radio_button_new_with_label (NULL, + _("Yes, import my account details from ")); + gtk_box_pack_start (GTK_BOX (hbox_1), radio, TRUE, TRUE, 0); + g_object_set_data (G_OBJECT (radio), "response", + GINT_TO_POINTER (RESPONSE_IMPORT)); + gtk_widget_show (radio); + + w = gtk_combo_box_new_text (); + gtk_combo_box_append_text (GTK_COMBO_BOX (w), "Pidgin"); + gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 0); + gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0); + gtk_widget_show (w); + + g_signal_connect (radio, "clicked", + G_CALLBACK (account_assistant_radio_choice_toggled_cb), self); + } - g_signal_connect (radio, "clicked", - G_CALLBACK (account_assistant_radio_choice_toggled_cb), self); + str = _("Yes, I'll enter my account details now"); + + if (radio == NULL) + { + radio = gtk_radio_button_new_with_label (NULL, str); + w = radio; + } + else + { + w = gtk_radio_button_new_with_label_from_widget ( + GTK_RADIO_BUTTON (radio), str); + } - w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), - _("Yes, I'll enter my account details now")); gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0); g_object_set_data (G_OBJECT (w), "response", GINT_TO_POINTER (RESPONSE_ENTER_ACCOUNT)); @@ -525,14 +557,29 @@ account_assistant_build_introduction_page (EmpathyAccountAssistant *self) static GtkWidget * account_assistant_build_import_page (EmpathyAccountAssistant *self) { - /* TODO: import page */ - GtkWidget *main_vbox, *w; + GtkWidget *main_vbox, *w, *import; + EmpathyImportWidget *iw; + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); main_vbox = gtk_vbox_new (FALSE, 12); - w = gtk_label_new ("Import your accounts!"); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); + w = gtk_label_new (_("Select the accounts you want to import:")); + gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_widget_show (w); gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 6); + w = gtk_alignment_new (0, 0, 0, 0); + gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0); + gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + + iw = empathy_import_widget_new (); + import = empathy_import_widget_get_widget (iw); + gtk_container_add (GTK_CONTAINER (w), import); + gtk_widget_show (import); + + priv->iw = iw; + gtk_widget_show (main_vbox); return main_vbox; @@ -602,14 +649,16 @@ static void impl_signal_apply (GtkAssistant *assistant) { EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant); - // EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); gint current_page; - g_print ("apply!!\n"); current_page = gtk_assistant_get_current_page (assistant); if (current_page == RESPONSE_ENTER_ACCOUNT) account_assistant_apply_account_and_finish (self); + + if (current_page == RESPONSE_IMPORT) + empathy_import_widget_add_selected_accounts (priv->iw); } static void @@ -628,8 +677,6 @@ impl_signal_prepare (GtkAssistant *assistant, current_idx = gtk_assistant_get_current_page (assistant); - g_print ("prepare, current idx = %d\n", current_idx); - if (current_idx == PAGE_ENTER_CREATE) { account_assistant_finish_enter_or_create_page (self, @@ -768,6 +815,7 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) gtk_assistant_set_page_title (assistant, page, _("Import your existing accounts")); gtk_assistant_set_page_complete (assistant, page, TRUE); + gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM); /* third page (enter account details) */ page = account_assistant_build_enter_or_create_page (self, TRUE); -- cgit v1.2.3 From 34f824dd1b1642afab7474d32b53e65074a5495c Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 7 Aug 2009 21:06:49 +0200 Subject: Don't hardcode new lines --- src/empathy-account-assistant.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 0b30bb807..0b32b3a94 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -104,7 +104,7 @@ account_assistant_build_error_page (EmpathyAccountAssistant *self, /* translators: this is followed by the "while ..." strings some lines * down this file. */ - str = g_string_new (_("There has been an error\n")); + str = g_string_new (_("There has been an error ")); if (page_num == PAGE_IMPORT) /* translators: this follows the "There has been an error " string */ @@ -127,6 +127,7 @@ account_assistant_build_error_page (EmpathyAccountAssistant *self, pango_attr_list_insert (list, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); gtk_label_set_attributes (GTK_LABEL (w), list); gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5); + gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_widget_show (w); g_free (message); @@ -142,10 +143,11 @@ account_assistant_build_error_page (EmpathyAccountAssistant *self, gtk_widget_show (w); w = gtk_label_new (_("You can either go back and try to enter your " - "accounts' details\nagain or quit this wizard and add accounts " + "accounts' details again or quit this wizard and add accounts " "later from the Edit menu.")); gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 6); gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5); + gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_widget_show (w); return main_vbox; @@ -355,7 +357,7 @@ account_assistant_finish_enter_or_create_page (EmpathyAccountAssistant *self, _("What kind of chat account do you have?")); gtk_label_set_label (GTK_LABEL (priv->second_label), _("If you have other accounts to set up, you can do " - "that at any time\nfrom the Edit menu.")); + "that at any time from the Edit menu.")); empathy_protocol_chooser_set_visible ( EMPATHY_PROTOCOL_CHOOSER (priv->chooser), account_assistant_chooser_enter_details_filter_func, self); @@ -368,7 +370,7 @@ account_assistant_finish_enter_or_create_page (EmpathyAccountAssistant *self, gtk_label_set_label (GTK_LABEL (priv->first_label), _("What kind of chat account do you want to create?")); gtk_label_set_label (GTK_LABEL (priv->second_label), - _("You can register other accounts, or setup\n" + _("You can register other accounts, or setup " "an existing one at any time from the Edit menu.")); empathy_protocol_chooser_set_visible ( EMPATHY_PROTOCOL_CHOOSER (priv->chooser), @@ -456,25 +458,27 @@ account_assistant_build_introduction_page (EmpathyAccountAssistant *self) gtk_widget_show (hbox_1); w = gtk_label_new ( - _("With Empathy you can chat with people\n" - "online nearby and with friends and colleagues\n" - "who use Google Talk, AIM, Windows Live\n" - "and many other chat programs. With a microphone\n" + _("With Empathy you can chat with people " + "online nearby and with friends and colleagues " + "who use Google Talk, AIM, Windows Live " + "and many other chat programs. With a microphone " "or a webcam you can also have audio or video calls.")); gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 0); + gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); + gtk_box_pack_start (GTK_BOX (hbox_1), w, FALSE, FALSE, 0); gtk_widget_show (w); pix = empathy_pixbuf_from_icon_name_sized ("empathy", 80); w = gtk_image_new_from_pixbuf (pix); - gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 6); + gtk_box_pack_start (GTK_BOX (hbox_1), w, FALSE, FALSE, 6); gtk_widget_show (w); g_object_unref (pix); w = gtk_label_new (_("Do you have an account you've been using " - "with another\nchat program?")); + "with another chat program?")); gtk_misc_set_alignment (GTK_MISC (w), 0, 0); + gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); gtk_widget_show (w); @@ -626,6 +630,8 @@ account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self, list = pango_attr_list_new (); pango_attr_list_insert (list, pango_attr_scale_new (PANGO_SCALE_SMALL)); gtk_label_set_attributes (GTK_LABEL (w), list); + gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); + gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_widget_show (w); priv->second_label = w; pango_attr_list_unref (list); -- cgit v1.2.3 From 7bbf2dfc7a29041ab5efeb1683fab7d213d480df Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 7 Aug 2009 21:08:12 +0200 Subject: The assistant should not be resizable --- src/empathy-account-assistant.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 0b32b3a94..34c505613 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -828,6 +828,8 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) gtk_assistant_append_page (assistant, page); gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM); priv->enter_or_create_page = page; + + gtk_window_set_resizable (GTK_WINDOW (self), FALSE); } GtkWidget * -- cgit v1.2.3 From 350ed3dbdba49253b6a94c8066c45ae81e95bed1 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sun, 9 Aug 2009 17:15:51 +0200 Subject: Remove useless includes --- src/empathy-account-assistant.c | 1 + src/empathy-import-dialog.c | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 34c505613..55a322e24 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -22,6 +22,7 @@ #include #include +#include #include "empathy-account-assistant.h" #include "empathy-import-dialog.h" diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c index 4866b81c5..1a5f0a25c 100644 --- a/src/empathy-import-dialog.c +++ b/src/empathy-import-dialog.c @@ -22,8 +22,6 @@ #include -#include - #include #include #include @@ -37,8 +35,6 @@ #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include #include -#include -#include #include enum { -- cgit v1.2.3 From 0e5397ae0e6cc3d75f8e9db19ca872cf28cf41be Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sun, 9 Aug 2009 17:48:57 +0200 Subject: Make the import system more future-proof Split the utilities from the widget and the dialog; we now have an enum for supported applications, with a special value which means "all applications", which is the only one which triggers showing the "Source" column in EmpathyImportWidget. We need this to avoid being redundant in the EmpathyAccountAssistant, as we already choose there the application from which to import. --- src/Makefile.am | 1 + src/empathy-account-assistant.c | 7 ++-- src/empathy-accounts-dialog.c | 3 +- src/empathy-import-dialog.c | 44 +--------------------- src/empathy-import-dialog.h | 18 --------- src/empathy-import-pidgin.c | 2 +- src/empathy-import-utils.c | 76 ++++++++++++++++++++++++++++++++++++++ src/empathy-import-utils.h | 56 ++++++++++++++++++++++++++++ src/empathy-import-widget.c | 82 +++++++++++++++++++++++++++++++++-------- src/empathy-import-widget.h | 4 +- 10 files changed, 212 insertions(+), 81 deletions(-) create mode 100644 src/empathy-import-utils.c create mode 100644 src/empathy-import-utils.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 5d3bee501..3641835f7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,6 +43,7 @@ empathy_handwritten_source = \ empathy-import-dialog.c empathy-import-dialog.h \ empathy-import-widget.c empathy-import-widget.h \ empathy-import-pidgin.c empathy-import-pidgin.h \ + empathy-import-utils.c empathy-import-utils.h \ empathy-main-window.c empathy-main-window.h \ empathy-misc.c empathy-misc.h \ empathy-new-chatroom-dialog.c empathy-new-chatroom-dialog.h \ diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 55a322e24..ab42bbd4f 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -25,8 +25,8 @@ #include #include "empathy-account-assistant.h" -#include "empathy-import-dialog.h" #include "empathy-import-widget.h" +#include "empathy-import-utils.h" #include #include @@ -492,7 +492,7 @@ account_assistant_build_introduction_page (EmpathyAccountAssistant *self) gtk_container_add (GTK_CONTAINER (w), vbox_1); gtk_widget_show (vbox_1); - if (empathy_import_dialog_accounts_to_import ()) + if (empathy_import_accounts_to_import ()) { hbox_1 = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox_1), hbox_1, TRUE, TRUE, 0); @@ -578,7 +578,8 @@ account_assistant_build_import_page (EmpathyAccountAssistant *self) gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0); gtk_widget_show (w); - iw = empathy_import_widget_new (); + /* NOTE: this is hardcoded as we support pidgin only */ + iw = empathy_import_widget_new (EMPATHY_IMPORT_APPLICATION_PIDGIN); import = empathy_import_widget_get_widget (iw); gtk_container_add (GTK_CONTAINER (w), import); gtk_widget_show (import); diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 785d20ae0..e985befc8 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -46,6 +46,7 @@ #include "empathy-accounts-dialog.h" #include "empathy-import-dialog.h" +#include "empathy-import-utils.h" #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT #include @@ -1380,7 +1381,7 @@ do_constructed (GObject *object) EMPATHY_PREFS_IMPORT_ASKED, &import_asked); - if (empathy_import_dialog_accounts_to_import ()) + if (empathy_import_accounts_to_import ()) { if (!import_asked) diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c index 1a5f0a25c..7ca0285b1 100644 --- a/src/empathy-import-dialog.c +++ b/src/empathy-import-dialog.c @@ -53,46 +53,6 @@ typedef struct { G_DEFINE_TYPE (EmpathyImportDialog, empathy_import_dialog, GTK_TYPE_DIALOG) #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyImportDialog) -EmpathyImportAccountData * -empathy_import_account_data_new (const gchar *source) -{ - EmpathyImportAccountData *data; - - g_return_val_if_fail (!EMP_STR_EMPTY (source), NULL); - - data = g_slice_new0 (EmpathyImportAccountData); - data->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, - (GDestroyNotify) tp_g_value_slice_free); - data->source = g_strdup (source); - data->protocol = NULL; - data->connection_manager = NULL; - - return data; -} - -void -empathy_import_account_data_free (EmpathyImportAccountData *data) -{ - if (data == NULL) - return; - if (data->protocol != NULL) - g_free (data->protocol); - if (data->connection_manager != NULL) - g_free (data->connection_manager); - if (data->settings != NULL) - g_hash_table_destroy (data->settings); - if (data->source != NULL) - g_free (data->source); - - g_slice_free (EmpathyImportAccountData, data); -} - -gboolean -empathy_import_dialog_accounts_to_import (void) -{ - return empathy_import_pidgin_accounts_to_import (); -} - static void import_dialog_add_import_widget (EmpathyImportDialog *self) { @@ -102,7 +62,7 @@ import_dialog_add_import_widget (EmpathyImportDialog *self) area = gtk_dialog_get_content_area (GTK_DIALOG (self)); - iw = empathy_import_widget_new (); + iw = empathy_import_widget_new (EMPATHY_IMPORT_APPLICATION_ALL); widget = empathy_import_widget_get_widget (iw); gtk_box_pack_start (GTK_BOX (area), widget, FALSE, FALSE, 0); gtk_widget_show (widget); @@ -207,7 +167,7 @@ do_constructed (GObject *obj) EmpathyImportDialogPriv *priv = GET_PRIV (self); gboolean have_accounts; - have_accounts = empathy_import_dialog_accounts_to_import (); + have_accounts = empathy_import_accounts_to_import (); if (!have_accounts) { diff --git a/src/empathy-import-dialog.h b/src/empathy-import-dialog.h index 14ab33b47..0e9d225c4 100644 --- a/src/empathy-import-dialog.h +++ b/src/empathy-import-dialog.h @@ -42,18 +42,6 @@ G_BEGIN_DECLS (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_IMPORT_DIALOG,\ EmpathyImportDialogClass)) -typedef struct -{ - /* Table mapping CM param string to a GValue */ - GHashTable *settings; - /* Protocol name */ - gchar *protocol; - /* Connection manager name */ - gchar *connection_manager; - /* The name of the account import source */ - gchar *source; -} EmpathyImportAccountData; - typedef struct { GtkDialog parent; @@ -70,12 +58,6 @@ GType empathy_import_dialog_get_type (void); GtkWidget* empathy_import_dialog_new (GtkWindow *parent_window, gboolean show_warning); -EmpathyImportAccountData *empathy_import_account_data_new ( - const gchar *source); -void empathy_import_account_data_free (EmpathyImportAccountData *data); - -gboolean empathy_import_dialog_accounts_to_import (void); - G_END_DECLS #endif /* __EMPATHY_IMPORT_DIALOG_H__ */ diff --git a/src/empathy-import-pidgin.c b/src/empathy-import-pidgin.c index 6a145ff93..23b1d84f5 100644 --- a/src/empathy-import-pidgin.c +++ b/src/empathy-import-pidgin.c @@ -32,7 +32,7 @@ #include #include -#include "empathy-import-dialog.h" +#include "empathy-import-utils.h" #include "empathy-import-pidgin.h" #define DEBUG_FLAG EMPATHY_DEBUG_OTHER diff --git a/src/empathy-import-utils.c b/src/empathy-import-utils.c new file mode 100644 index 000000000..f84b20609 --- /dev/null +++ b/src/empathy-import-utils.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2009 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Jonny Lamb + * Cosimo Cecchi + */ + +#include + +#include + +#include "empathy-import-utils.h" +#include "empathy-import-pidgin.h" + +EmpathyImportAccountData * +empathy_import_account_data_new (const gchar *source) +{ + EmpathyImportAccountData *data; + + g_return_val_if_fail (!EMP_STR_EMPTY (source), NULL); + + data = g_slice_new0 (EmpathyImportAccountData); + data->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, + (GDestroyNotify) tp_g_value_slice_free); + data->source = g_strdup (source); + data->protocol = NULL; + data->connection_manager = NULL; + + return data; +} + +void +empathy_import_account_data_free (EmpathyImportAccountData *data) +{ + if (data == NULL) + return; + if (data->protocol != NULL) + g_free (data->protocol); + if (data->connection_manager != NULL) + g_free (data->connection_manager); + if (data->settings != NULL) + g_hash_table_destroy (data->settings); + if (data->source != NULL) + g_free (data->source); + + g_slice_free (EmpathyImportAccountData, data); +} + +gboolean +empathy_import_accounts_to_import (void) +{ + return empathy_import_pidgin_accounts_to_import (); +} + +GList * +empathy_import_accounts_load (EmpathyImportApplication id) +{ + if (id == EMPATHY_IMPORT_APPLICATION_PIDGIN) + return empathy_import_pidgin_load (); + + return empathy_import_pidgin_load (); +} diff --git a/src/empathy-import-utils.h b/src/empathy-import-utils.h new file mode 100644 index 000000000..8c971a04d --- /dev/null +++ b/src/empathy-import-utils.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Jonny Lamb + * Cosimo Cecchi + */ + +#ifndef __EMPATHY_IMPORT_UTILS_H__ +#define __EMPATHY_IMPORT_UTILS_H__ + +#include + +G_BEGIN_DECLS + +typedef struct +{ + /* Table mapping CM param string to a GValue */ + GHashTable *settings; + /* Protocol name */ + gchar *protocol; + /* Connection manager name */ + gchar *connection_manager; + /* The name of the account import source */ + gchar *source; +} EmpathyImportAccountData; + +typedef enum { + EMPATHY_IMPORT_APPLICATION_ALL = 0, + EMPATHY_IMPORT_APPLICATION_PIDGIN, + EMPATHY_IMPORT_APPLICATION_INVALID +} EmpathyImportApplication; + +EmpathyImportAccountData *empathy_import_account_data_new ( + const gchar *source); +void empathy_import_account_data_free (EmpathyImportAccountData *data); + +gboolean empathy_import_accounts_to_import (void); +GList *empathy_import_accounts_load (EmpathyImportApplication id); + +G_END_DECLS + +#endif /* __EMPATHY_IMPORT_UTILS_H__ */ diff --git a/src/empathy-import-widget.c b/src/empathy-import-widget.c index d276c03e5..03117350c 100644 --- a/src/empathy-import-widget.c +++ b/src/empathy-import-widget.c @@ -53,11 +53,16 @@ enum COL_COUNT }; +enum { + PROP_APPLICATION_ID = 1 +}; + typedef struct { GtkWidget *vbox; GtkWidget *treeview; GList *accounts; + EmpathyImportApplication app_id; EmpathyConnectionManagers *cms; @@ -322,16 +327,19 @@ import_widget_set_up_account_list (EmpathyImportWidget *self) gtk_tree_view_column_pack_start (column, cell, TRUE); gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME); - /* Source column */ - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Source")); - gtk_tree_view_column_set_expand (column, TRUE); - gtk_tree_view_append_column (view, column); - - cell = gtk_cell_renderer_text_new (); - g_object_set (cell, "editable", FALSE, NULL); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, "text", COL_SOURCE); + if (priv->app_id == EMPATHY_IMPORT_APPLICATION_ALL) + { + /* Source column */ + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_title (column, _("Source")); + gtk_tree_view_column_set_expand (column, TRUE); + gtk_tree_view_append_column (view, column); + + cell = gtk_cell_renderer_text_new (); + g_object_set (cell, "editable", FALSE, NULL); + gtk_tree_view_column_pack_start (column, cell, TRUE); + gtk_tree_view_column_add_attribute (column, cell, "text", COL_SOURCE); + } import_widget_add_accounts_to_model (self); } @@ -352,6 +360,42 @@ import_widget_destroy_cb (GtkWidget *w, g_object_unref (self); } +static void +do_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + EmpathyImportWidgetPriv *priv = GET_PRIV (object); + + switch (property_id) + { + case PROP_APPLICATION_ID: + g_value_set_int (value, priv->app_id); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +do_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + EmpathyImportWidgetPriv *priv = GET_PRIV (object); + + switch (property_id) + { + case PROP_APPLICATION_ID: + priv->app_id = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + static void do_finalize (GObject *obj) { @@ -393,6 +437,8 @@ do_constructed (GObject *obj) GtkBuilder *gui; gchar *filename; + priv->accounts = empathy_import_accounts_load (priv->app_id); + filename = empathy_file_lookup ("empathy-import-dialog.ui", "src"); gui = empathy_builder_get_file (filename, "widget_vbox", &priv->vbox, @@ -416,10 +462,19 @@ static void empathy_import_widget_class_init (EmpathyImportWidgetClass *klass) { GObjectClass *oclass = G_OBJECT_CLASS (klass); + GParamSpec *param_spec; oclass->constructed = do_constructed; oclass->finalize = do_finalize; oclass->dispose = do_dispose; + oclass->set_property = do_set_property; + oclass->get_property = do_get_property; + + param_spec = g_param_spec_int ("application-id", + "application-id", "The application id to import from", + 0, EMPATHY_IMPORT_APPLICATION_INVALID, EMPATHY_IMPORT_APPLICATION_ALL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (oclass, PROP_APPLICATION_ID, param_spec); g_type_class_add_private (klass, sizeof (EmpathyImportWidgetPriv)); } @@ -433,16 +488,13 @@ empathy_import_widget_init (EmpathyImportWidget *self) self->priv = priv; - /* Load all accounts from all supported applications */ - priv->accounts = empathy_import_pidgin_load (); - priv->cms = empathy_connection_managers_dup_singleton (); } EmpathyImportWidget * -empathy_import_widget_new (void) +empathy_import_widget_new (EmpathyImportApplication id) { - return g_object_new (EMPATHY_TYPE_IMPORT_WIDGET, NULL); + return g_object_new (EMPATHY_TYPE_IMPORT_WIDGET, "application-id", id, NULL); } GtkWidget * diff --git a/src/empathy-import-widget.h b/src/empathy-import-widget.h index 8af953d79..48f2e1d48 100644 --- a/src/empathy-import-widget.h +++ b/src/empathy-import-widget.h @@ -27,6 +27,8 @@ #include +#include "empathy-import-utils.h" + G_BEGIN_DECLS #define EMPATHY_TYPE_IMPORT_WIDGET empathy_import_widget_get_type() @@ -57,7 +59,7 @@ typedef struct { GType empathy_import_widget_get_type (void); -EmpathyImportWidget* empathy_import_widget_new (void); +EmpathyImportWidget* empathy_import_widget_new (EmpathyImportApplication id); GtkWidget * empathy_import_widget_get_widget (EmpathyImportWidget *self); -- cgit v1.2.3 From 165945e35293556ba6d133f5f90a7251de8d8e4b Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Tue, 11 Aug 2009 17:48:59 +0200 Subject: Enable entering more than an account from the wizard. --- src/empathy-account-assistant.c | 167 +++++++++++++++++++++++++++++++--------- 1 file changed, 131 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index ab42bbd4f..613ba4b8c 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -47,11 +47,15 @@ typedef enum { RESPONSE_SALUT_ONLY = 4 } FirstPageResponse; +typedef enum { + RESPONSE_CREATE_AGAIN = 1, + RESPONSE_CREATE_STOP = 2 +} CreateEnterPageResponse; + enum { PAGE_INTRO = 0, PAGE_IMPORT = 1, PAGE_ENTER_CREATE = 2, - PAGE_SALUT_ONLY = 3 }; enum { @@ -60,6 +64,8 @@ enum { typedef struct { FirstPageResponse first_resp; + CreateEnterPageResponse create_enter_resp; + gboolean enter_create_forward; /* enter or create page */ GtkWidget *enter_or_create_page; @@ -68,6 +74,7 @@ typedef struct { GtkWidget *first_label; GtkWidget *second_label; GtkWidget *chooser; + GtkWidget *create_again_radio; EmpathyAccountSettings *settings; gboolean is_creating; @@ -79,6 +86,12 @@ typedef struct { gboolean dispose_run; } EmpathyAccountAssistantPriv; +static GtkWidget * account_assistant_build_enter_or_create_page ( + EmpathyAccountAssistant *self); +static void account_assistant_finish_enter_or_create_page ( + EmpathyAccountAssistant *self, + gboolean is_enter); + static GtkWidget * account_assistant_build_error_page (EmpathyAccountAssistant *self, GError *error, gint page_num) @@ -110,11 +123,11 @@ account_assistant_build_error_page (EmpathyAccountAssistant *self, if (page_num == PAGE_IMPORT) /* translators: this follows the "There has been an error " string */ str = g_string_append (str, _("while importing the accounts.")); - else if (page_num == PAGE_ENTER_CREATE && + else if (page_num >= PAGE_ENTER_CREATE && priv->first_resp == RESPONSE_ENTER_ACCOUNT) /* translators: this follows the "There has been an error " string */ str = g_string_append (str, _("while parsing the account details.")); - else if (page_num == PAGE_ENTER_CREATE && + else if (page_num >= PAGE_ENTER_CREATE && priv->first_resp == RESPONSE_CREATE_ACCOUNT) /* translators: this follows the "There has been an error " string */ str = g_string_append (str, _("while creating the account.")); @@ -193,6 +206,26 @@ account_assistant_present_error_page (EmpathyAccountAssistant *self, gtk_assistant_set_current_page (GTK_ASSISTANT (self), num); } +static void +account_assistant_reset_enter_create_page (EmpathyAccountAssistant *self) +{ + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + GtkWidget *page; + gint idx; + + page = account_assistant_build_enter_or_create_page (self); + idx = gtk_assistant_append_page (GTK_ASSISTANT (self), page); + gtk_assistant_set_page_type (GTK_ASSISTANT (self), page, + GTK_ASSISTANT_PAGE_CONFIRM); + priv->enter_or_create_page = page; + + gtk_assistant_set_current_page (GTK_ASSISTANT (self), idx); + + account_assistant_finish_enter_or_create_page (self, + priv->first_resp == RESPONSE_ENTER_ACCOUNT ? + TRUE : FALSE); +} + static void account_assistant_account_enabled_cb (GObject *source, GAsyncResult *result, @@ -200,6 +233,7 @@ account_assistant_account_enabled_cb (GObject *source, { GError *error = NULL; EmpathyAccountAssistant *self = user_data; + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); empathy_account_set_enabled_finish (EMPATHY_ACCOUNT (source), result, &error); @@ -210,7 +244,10 @@ account_assistant_account_enabled_cb (GObject *source, g_error_free (error); } - g_signal_emit_by_name (self, "close"); + if (priv->create_enter_resp == RESPONSE_CREATE_STOP) + g_signal_emit_by_name (self, "close"); + else + account_assistant_reset_enter_create_page (self); } static void @@ -230,7 +267,8 @@ account_assistant_apply_account_cb (GObject *source, if (error != NULL) { - account_assistant_present_error_page (self, error, PAGE_ENTER_CREATE); + account_assistant_present_error_page (self, error, + gtk_assistant_get_current_page (GTK_ASSISTANT (self))); g_error_free (error); return; } @@ -356,9 +394,12 @@ account_assistant_finish_enter_or_create_page (EmpathyAccountAssistant *self, { gtk_label_set_label (GTK_LABEL (priv->first_label), _("What kind of chat account do you have?")); - gtk_label_set_label (GTK_LABEL (priv->second_label), + /* gtk_label_set_label (GTK_LABEL (priv->second_label), _("If you have other accounts to set up, you can do " "that at any time from the Edit menu.")); + */ + gtk_label_set_label (GTK_LABEL (priv->second_label), + _("Do you have any other chat accounts you want to set up?")); empathy_protocol_chooser_set_visible ( EMPATHY_PROTOCOL_CHOOSER (priv->chooser), account_assistant_chooser_enter_details_filter_func, self); @@ -370,9 +411,12 @@ account_assistant_finish_enter_or_create_page (EmpathyAccountAssistant *self, { gtk_label_set_label (GTK_LABEL (priv->first_label), _("What kind of chat account do you want to create?")); - gtk_label_set_label (GTK_LABEL (priv->second_label), + /* gtk_label_set_label (GTK_LABEL (priv->second_label), _("You can register other accounts, or setup " "an existing one at any time from the Edit menu.")); + */ + gtk_label_set_label (GTK_LABEL (priv->second_label), + _("Do you want to create other chat accounts?")); empathy_protocol_chooser_set_visible ( EMPATHY_PROTOCOL_CHOOSER (priv->chooser), account_assistant_chooser_create_account_filter_func, self); @@ -399,7 +443,7 @@ account_assistant_page_forward_func (gint current_page, retval = current_page; - if (current_page == 0) + if (current_page == PAGE_INTRO) { if (priv->first_resp == RESPONSE_ENTER_ACCOUNT || priv->first_resp == RESPONSE_CREATE_ACCOUNT) @@ -408,11 +452,16 @@ account_assistant_page_forward_func (gint current_page, retval = PAGE_IMPORT; } - if (current_page == PAGE_ENTER_CREATE || - current_page == PAGE_IMPORT) + if (current_page == PAGE_IMPORT || + current_page >= PAGE_ENTER_CREATE) + /* don't forward anymore */ + retval = -1; + + if (current_page >= PAGE_ENTER_CREATE && + priv->create_enter_resp == RESPONSE_CREATE_AGAIN) { - /* don't forward anymore */ - retval = -1; + priv->enter_create_forward = TRUE; + retval = current_page; } return retval; @@ -591,13 +640,29 @@ account_assistant_build_import_page (EmpathyAccountAssistant *self) return main_vbox; } +static void +account_assistant_radio_create_again_clicked_cb (GtkButton *button, + EmpathyAccountAssistant *self) +{ + CreateEnterPageResponse response; + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); + + response = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), + "response")); + + priv->create_enter_resp = response; + + gtk_assistant_set_page_type (GTK_ASSISTANT (self), + priv->enter_or_create_page, + (response == RESPONSE_CREATE_AGAIN) ? + GTK_ASSISTANT_PAGE_CONTENT : GTK_ASSISTANT_PAGE_CONFIRM); +} + static GtkWidget * -account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self, - gboolean is_enter) +account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self) { EmpathyAccountAssistantPriv *priv = GET_PRIV (self); - GtkWidget *main_vbox, *w, *chooser, *hbox; - PangoAttrList *list; + GtkWidget *main_vbox, *w, *chooser, *vbox, *hbox, *radio; main_vbox = gtk_vbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); @@ -619,24 +684,46 @@ account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self, gtk_widget_show (chooser); priv->chooser = chooser; - hbox = gtk_hbox_new (FALSE, 6); - gtk_box_pack_end (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - w = gtk_image_new_from_icon_name ("gtk-dialog-info", GTK_ICON_SIZE_BUTTON); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); + vbox = gtk_vbox_new (FALSE, 6); + gtk_box_pack_end (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); + gtk_widget_show (vbox); w = gtk_label_new (NULL); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - list = pango_attr_list_new (); - pango_attr_list_insert (list, pango_attr_scale_new (PANGO_SCALE_SMALL)); - gtk_label_set_attributes (GTK_LABEL (w), list); + gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_widget_show (w); priv->second_label = w; - pango_attr_list_unref (list); + + w = gtk_alignment_new (0, 0, 0, 0); + gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0); + gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + + hbox = gtk_hbox_new (FALSE, 6); + gtk_container_add (GTK_CONTAINER (w), hbox); + gtk_widget_show (hbox); + + radio = gtk_radio_button_new_with_label (NULL, _("Yes")); + gtk_box_pack_start (GTK_BOX (hbox), radio, FALSE, FALSE, 0); + g_object_set_data (G_OBJECT (radio), "response", + GINT_TO_POINTER (RESPONSE_CREATE_AGAIN)); + gtk_widget_show (radio); + + w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), + _("No, that's all for now")); + gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); + g_object_set_data (G_OBJECT (w), "response", + GINT_TO_POINTER (RESPONSE_CREATE_STOP)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE); + priv->create_enter_resp = RESPONSE_CREATE_STOP; + priv->create_again_radio = w; + gtk_widget_show (w); + + g_signal_connect (w, "clicked", + G_CALLBACK (account_assistant_radio_create_again_clicked_cb), self); + g_signal_connect (radio, "clicked", + G_CALLBACK (account_assistant_radio_create_again_clicked_cb), self); return main_vbox; } @@ -662,10 +749,10 @@ impl_signal_apply (GtkAssistant *assistant) current_page = gtk_assistant_get_current_page (assistant); - if (current_page == RESPONSE_ENTER_ACCOUNT) + if (current_page >= PAGE_ENTER_CREATE) account_assistant_apply_account_and_finish (self); - if (current_page == RESPONSE_IMPORT) + if (current_page == PAGE_IMPORT) empathy_import_widget_add_selected_accounts (priv->iw); } @@ -684,12 +771,20 @@ impl_signal_prepare (GtkAssistant *assistant, gint current_idx; current_idx = gtk_assistant_get_current_page (assistant); - - if (current_idx == PAGE_ENTER_CREATE) + + if (current_idx >= PAGE_ENTER_CREATE) { - account_assistant_finish_enter_or_create_page (self, - priv->first_resp == RESPONSE_ENTER_ACCOUNT ? - TRUE : FALSE); + if (!priv->enter_create_forward) + { + account_assistant_finish_enter_or_create_page (self, + priv->first_resp == RESPONSE_ENTER_ACCOUNT ? + TRUE : FALSE); + } + else + { + priv->enter_create_forward = FALSE; + account_assistant_apply_account_and_finish (self); + } } } @@ -826,7 +921,7 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM); /* third page (enter account details) */ - page = account_assistant_build_enter_or_create_page (self, TRUE); + page = account_assistant_build_enter_or_create_page (self); gtk_assistant_append_page (assistant, page); gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM); priv->enter_or_create_page = page; -- cgit v1.2.3 From adc79c5d0574f548cfe2b89cb0e04d74a5d1e40e Mon Sep 17 00:00:00 2001 From: Jonathan Tellier Date: Thu, 13 Aug 2009 08:56:02 -0400 Subject: First part of an overhaul of the accounts dialog --- src/empathy-account-assistant.c | 5 +- src/empathy-accounts-dialog.c | 416 ++++++++++++++++++++-------------------- src/empathy-accounts-dialog.ui | 137 +++++-------- 3 files changed, 267 insertions(+), 291 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 613ba4b8c..8b803a9b6 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -334,8 +334,9 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser, if (priv->first_resp == RESPONSE_CREATE_ACCOUNT) empathy_account_settings_set_boolean (settings, "register", TRUE); - account_widget = empathy_account_widget_simple_new_for_protocol - (proto->name, settings, &widget_object); + widget_object = empathy_account_widget_new_for_protocol (proto->name, + settings, TRUE); + account_widget = empathy_account_widget_get_widget (widget_object); if (priv->current_account_widget != NULL) { diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index e985befc8..30a7f72a8 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -20,6 +20,7 @@ * Authors: Martyn Russell * Xavier Claessens * Cosimo Cecchi + * Jonathan Tellier */ #include @@ -42,7 +43,9 @@ #include #include #include +#include #include +#include #include "empathy-accounts-dialog.h" #include "empathy-import-dialog.h" @@ -70,8 +73,6 @@ typedef struct { GtkWidget *treeview; GtkWidget *button_add; - GtkWidget *button_remove; - GtkWidget *button_import; GtkWidget *frame_new_account; GtkWidget *combobox_protocol; @@ -100,7 +101,6 @@ typedef struct { } EmpathyAccountsDialogPriv; enum { - COL_ENABLED, COL_NAME, COL_STATUS, COL_ACCOUNT_POINTER, @@ -112,28 +112,86 @@ enum { PROP_PARENT = 1 }; -static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, +static EmpathyAccountSettings * accounts_dialog_model_get_selected_settings ( + EmpathyAccountsDialog *dialog); + +static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog); + +static void accounts_dialog_update (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings); -static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog); +static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings); static void accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog, - EmpathyAccountSettings *settings) + const gchar *display_name) { gchar *text; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - text = g_markup_printf_escaped ("%s", - empathy_account_settings_get_display_name (settings)); + text = g_markup_printf_escaped ("%s", display_name); gtk_label_set_markup (GTK_LABEL (priv->label_name), text); g_free (text); } +static void +empathy_account_dialog_widget_cancelled_cb (EmpathyAccountWidget *widget_object, + EmpathyAccountsDialog *dialog) +{ + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + EmpathyAccountSettings *settings; + EmpathyAccount *account; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + view = GTK_TREE_VIEW (priv->treeview); + selection = gtk_tree_view_get_selection (view); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return; + + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_SETTINGS_POINTER, &settings, + COL_ACCOUNT_POINTER, &account, -1); + + empathy_account_settings_discard_changes (settings); + + if (account == NULL) + { + /* We were creating an account. We remove the selected row */ + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); + } + else + { + /* We were modifying an account. We discard the changes by reloading the + * settings and the UI. */ + accounts_dialog_update_settings (dialog, settings); + g_object_unref (account); + } + + if (settings != NULL) + g_object_unref (settings); +} + +static void +empathy_account_dialog_account_created_cb (EmpathyAccountWidget *widget_object, + EmpathyAccountsDialog *dialog) +{ + EmpathyAccountSettings *settings = + accounts_dialog_model_get_selected_settings (dialog); + accounts_dialog_update_settings (dialog, settings); + + if (settings) + g_object_unref (settings); +} + static GtkWidget * -get_account_setup_widget (EmpathyAccountSettings *settings) +get_account_setup_widget (EmpathyAccountSettings *settings, + EmpathyAccountWidget **widget_object) { const gchar *proto = empathy_account_settings_get_protocol (settings); EmpathyConnectionManagers *cm = @@ -147,23 +205,31 @@ get_account_setup_widget (EmpathyAccountSettings *settings) if (tp_connection_manager_has_protocol (tp_cm, proto)) { g_object_unref (cm); - return empathy_account_widget_new_for_protocol - (proto, settings); + *widget_object = empathy_account_widget_new_for_protocol (proto, + settings, FALSE); + return empathy_account_widget_get_widget (*widget_object); } } g_object_unref (cm); - return empathy_account_widget_new_for_protocol ("generic", settings); + *widget_object = empathy_account_widget_new_for_protocol ("generic", settings, + FALSE); + return empathy_account_widget_get_widget (*widget_object); } static void account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings) { + EmpathyAccountWidget *widget_object = NULL; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); gchar *icon_name; - priv->settings_widget = get_account_setup_widget (settings); + priv->settings_widget = get_account_setup_widget (settings, &widget_object); + g_signal_connect (widget_object, "account-created", + G_CALLBACK (empathy_account_dialog_account_created_cb), dialog); + g_signal_connect (widget_object, "cancelled", + G_CALLBACK (empathy_account_dialog_widget_cancelled_cb), dialog); gtk_container_add (GTK_CONTAINER (priv->alignment_settings), priv->settings_widget); @@ -176,7 +242,10 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, gtk_widget_set_tooltip_text (priv->image_type, empathy_account_settings_get_protocol (settings)); - accounts_dialog_update_name_label (dialog, settings); + accounts_dialog_update_name_label (dialog, + empathy_account_settings_get_display_name(settings)); + + g_free (icon_name); } static void @@ -241,17 +310,13 @@ accounts_dialog_button_add_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { GtkTreeView *view; - GtkTreeSelection *selection; GtkTreeModel *model; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); view = GTK_TREE_VIEW (priv->treeview); model = gtk_tree_view_get_model (view); - selection = gtk_tree_view_get_selection (view); - gtk_tree_selection_unselect_all (selection); gtk_widget_set_sensitive (priv->button_add, FALSE); - gtk_widget_set_sensitive (priv->button_remove, FALSE); gtk_widget_hide (priv->vbox_details); gtk_widget_hide (priv->frame_no_protocol); gtk_widget_show (priv->frame_new_account); @@ -300,7 +365,7 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, if (empathy_connection_managers_get_cms_num (priv->cms) > 0) { /* We have no account configured but we have some - * profiles instsalled. The user obviously wants to add + * profiles installed. The user obviously wants to add * an account. Click on the Add button for him. */ accounts_dialog_button_add_clicked_cb (priv->button_add, dialog); @@ -312,7 +377,6 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, gtk_widget_hide (priv->frame_new_account); gtk_widget_show (priv->frame_no_protocol); gtk_widget_set_sensitive (priv->button_add, FALSE); - gtk_widget_set_sensitive (priv->button_remove, FALSE); return; } @@ -322,7 +386,6 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, gtk_widget_hide (priv->frame_no_protocol); gtk_widget_show (priv->vbox_details); gtk_widget_set_sensitive (priv->button_add, TRUE); - gtk_widget_set_sensitive (priv->button_remove, TRUE); if (priv->settings_widget) { @@ -413,38 +476,6 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, g_object_unref (pixbuf); } -static void -accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer, - gchar *path, - EmpathyAccountsDialog *dialog) -{ - EmpathyAccount *account; - GtkTreeModel *model; - GtkTreePath *treepath; - GtkTreeIter iter; - gboolean enabled; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); - treepath = gtk_tree_path_new_from_string (path); - gtk_tree_model_get_iter (model, &iter, treepath); - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_POINTER, &account, - -1); - gtk_tree_path_free (treepath); - - if (account == NULL) - return; - - enabled = empathy_account_is_enabled (account); - empathy_account_set_enabled_async (account, !enabled, NULL, NULL); - - DEBUG ("%s account %s", enabled ? "Disabled" : "Enable", - empathy_account_get_display_name (account)); - - g_object_unref (account); -} - static gboolean accounts_dialog_row_changed_foreach (GtkTreeModel *model, GtkTreePath *path, @@ -506,9 +537,102 @@ accounts_dialog_name_edited_cb (GtkCellRendererText *renderer, empathy_account_settings_set_display_name_async (settings, new_text, NULL, NULL); + g_object_set (settings, "display-name-overridden", TRUE, NULL); g_object_unref (settings); } +static void +accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog, + gint response_id, + gpointer user_data) +{ + EmpathyAccount *account; + GtkTreeModel *model; + GtkTreeIter iter; + GtkTreeSelection *selection; + EmpathyAccountsDialog *account_dialog = EMPATHY_ACCOUNTS_DIALOG (user_data); + EmpathyAccountsDialogPriv *priv = GET_PRIV (account_dialog); + + if (response_id == GTK_RESPONSE_YES) + { + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return; + + gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); + + if (account != NULL) + { + empathy_account_remove_async (account, NULL, NULL); + g_object_unref (account); + } + + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); + accounts_dialog_model_select_first (account_dialog); + } + + gtk_widget_destroy (GTK_WIDGET (message_dialog)); +} + +static void +accounts_dialog_view_delete_activated_cb (EmpathyCellRendererActivatable *cell, + const gchar *path_string, + EmpathyAccountsDialog *dialog) +{ + EmpathyAccount *account; + GtkTreeModel *model; + GtkTreeIter iter; + GtkWidget *message_dialog; + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + + if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string)) + return; + + gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); + + if (account == NULL || !empathy_account_is_valid (account)) + { + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); + accounts_dialog_model_select_first (dialog); + return; + } + + message_dialog = gtk_message_dialog_new + (GTK_WINDOW (priv->window), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + _("You are about to remove your %s account!\n" + "Are you sure you want to proceed?"), + empathy_account_get_display_name (account)); + + gtk_message_dialog_format_secondary_text + (GTK_MESSAGE_DIALOG (message_dialog), + _("Any associated conversations and chat rooms will NOT be " + "removed if you decide to proceed.\n" + "\n" + "Should you decide to add the account back at a later time, " + "they will still be available.")); + + gtk_dialog_add_button (GTK_DIALOG (message_dialog), + GTK_STOCK_CANCEL, + GTK_RESPONSE_NO); + gtk_dialog_add_button (GTK_DIALOG (message_dialog), + GTK_STOCK_REMOVE, + GTK_RESPONSE_YES); + + g_signal_connect (message_dialog, "response", + G_CALLBACK (accounts_dialog_delete_account_response_cb), dialog); + + gtk_widget_show (message_dialog); + + if (account != NULL) + g_object_unref (account); +} + static void accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) { @@ -518,22 +642,11 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); view = GTK_TREE_VIEW (priv->treeview); - gtk_tree_view_set_headers_visible (view, TRUE); - - /* Enabled column */ - cell = gtk_cell_renderer_toggle_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - _("Enabled"), - cell, - "active", COL_ENABLED, - NULL); - g_signal_connect (cell, "toggled", - G_CALLBACK (accounts_dialog_enable_toggled_cb), - dialog); + gtk_tree_view_set_headers_visible (view, FALSE); /* Account column */ column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Accounts")); + //gtk_tree_view_column_set_title (column, _("Accounts")); gtk_tree_view_column_set_expand (column, TRUE); gtk_tree_view_append_column (view, column); @@ -561,6 +674,17 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) g_signal_connect (cell, "editing-started", G_CALLBACK (accounts_dialog_name_editing_started_cb), dialog); + + /* Delete column */ + cell = empathy_cell_renderer_activatable_new (); + gtk_tree_view_column_pack_start (column, cell, FALSE); + g_object_set (cell, + "icon-name", GTK_STOCK_DELETE, + NULL); + + g_signal_connect (cell, "path-activated", + G_CALLBACK (accounts_dialog_view_delete_activated_cb), + dialog); } static EmpathyAccountSettings * @@ -589,6 +713,7 @@ static void accounts_dialog_model_selection_changed (GtkTreeSelection *selection, EmpathyAccountsDialog *dialog) { +// EmpathyAccountsDialogPriv priv = GET_PRIV (dialog); EmpathyAccountSettings *settings; GtkTreeModel *model; GtkTreeIter iter; @@ -597,6 +722,10 @@ accounts_dialog_model_selection_changed (GtkTreeSelection *selection, is_selection = gtk_tree_selection_get_selected (selection, &model, &iter); settings = accounts_dialog_model_get_selected_settings (dialog); + + if (settings != NULL) + empathy_account_settings_discard_changes (settings); + accounts_dialog_update_settings (dialog, settings); if (settings) @@ -611,7 +740,6 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog) EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); store = gtk_list_store_new (COL_COUNT, - G_TYPE_BOOLEAN, /* enabled */ G_TYPE_STRING, /* name */ G_TYPE_UINT, /* status */ EMPATHY_TYPE_ACCOUNT, /* account */ @@ -709,27 +837,6 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, return FALSE; } -static EmpathyAccount * -accounts_dialog_model_get_selected_account (EmpathyAccountsDialog *dialog) -{ - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - EmpathyAccount *account; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - view = GTK_TREE_VIEW (priv->treeview); - selection = gtk_tree_view_get_selection (view); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return NULL; - - gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); - - return account; -} - static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings) @@ -742,33 +849,6 @@ accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, if (accounts_dialog_get_settings_iter (dialog, settings, &iter)) gtk_tree_selection_select_iter (selection, &iter); } - -static gboolean -accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog) -{ - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - EmpathyAccount *account; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - view = GTK_TREE_VIEW (priv->treeview); - selection = gtk_tree_view_get_selection (view); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return FALSE; - - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_POINTER, &account, - -1); - - if (account != NULL) - empathy_account_remove_async (account, NULL, NULL); - - return gtk_list_store_remove (GTK_LIST_STORE (model), &iter); -} - static void accounts_dialog_add (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings) @@ -784,7 +864,6 @@ accounts_dialog_add (EmpathyAccountsDialog *dialog, gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ENABLED, FALSE, COL_NAME, name, COL_STATUS, TP_CONNECTION_STATUS_DISCONNECTED, COL_ACCOUNT_SETTINGS_POINTER, settings, @@ -857,7 +936,6 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, settings = empathy_account_settings_new_for_account (account); gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ENABLED, enabled, COL_NAME, name, COL_STATUS, status, COL_ACCOUNT_POINTER, account, @@ -871,7 +949,7 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, TP_CONNECTION_STATUS_DISCONNECTED, dialog); - g_object_unref (settings); + //g_object_unref (settings); } static void @@ -898,7 +976,6 @@ accounts_dialog_update (EmpathyAccountsDialog *dialog, accounts_dialog_get_settings_iter (dialog, settings, &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ENABLED, enabled, COL_NAME, name, COL_STATUS, status, COL_ACCOUNT_POINTER, account, @@ -934,7 +1011,6 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog, gboolean enabled) { GtkTreeModel *model; - GtkTreeIter iter; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); /* Update the status in the model */ @@ -943,11 +1019,6 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog, DEBUG ("Account %s is now %s", empathy_account_get_display_name (account), enabled ? "enabled" : "disabled"); - - if (accounts_dialog_get_account_iter (dialog, account, &iter)) - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ENABLED, enabled, - -1); } static void @@ -989,7 +1060,14 @@ accounts_dialog_account_changed_cb (EmpathyAccountManager *manager, selected_settings = accounts_dialog_model_get_selected_settings (dialog); if (settings == selected_settings) - accounts_dialog_update_name_label (dialog, settings); + accounts_dialog_update_name_label (dialog, + empathy_account_settings_get_display_name(settings)); + + if (settings) + g_object_unref (settings); + + if (selected_settings) + g_object_unref (selected_settings); } static void @@ -1037,7 +1115,10 @@ accounts_dialog_button_back_clicked_cb (GtkWidget *button, EmpathyAccountSettings *settings; settings = accounts_dialog_model_get_selected_settings (dialog); - accounts_dialog_update (dialog, settings); + accounts_dialog_update_settings (dialog, settings); + + if (settings) + g_object_unref (settings); } static void @@ -1047,69 +1128,6 @@ accounts_dialog_button_help_clicked_cb (GtkWidget *button, empathy_url_show (button, "ghelp:empathy?empathy-create-account"); } -static void -accounts_dialog_button_remove_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) -{ - EmpathyAccount *account; - GtkWidget *message_dialog; - gint res; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - - account = accounts_dialog_model_get_selected_account (dialog); - - if (account == NULL || !empathy_account_is_valid (account)) - { - accounts_dialog_model_remove_selected (dialog); - accounts_dialog_model_select_first (dialog); - return; - } - message_dialog = gtk_message_dialog_new - (GTK_WINDOW (priv->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - _("You are about to remove your %s account!\n" - "Are you sure you want to proceed?"), - empathy_account_get_display_name (account)); - - gtk_message_dialog_format_secondary_text - (GTK_MESSAGE_DIALOG (message_dialog), - _("Any associated conversations and chat rooms will NOT be " - "removed if you decide to proceed.\n" - "\n" - "Should you decide to add the account back at a later time, " - "they will still be available.")); - - gtk_dialog_add_button (GTK_DIALOG (message_dialog), - GTK_STOCK_CANCEL, - GTK_RESPONSE_NO); - gtk_dialog_add_button (GTK_DIALOG (message_dialog), - GTK_STOCK_REMOVE, - GTK_RESPONSE_YES); - - gtk_widget_show (message_dialog); - res = gtk_dialog_run (GTK_DIALOG (message_dialog)); - - if (res == GTK_RESPONSE_YES) - { - accounts_dialog_model_remove_selected (dialog); - accounts_dialog_model_select_first (dialog); - } - gtk_widget_destroy (message_dialog); -} - -static void -accounts_dialog_button_import_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) -{ - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - GtkWidget *import_dialog; - - import_dialog = empathy_import_dialog_new (GTK_WINDOW (priv->window), TRUE); - gtk_widget_show (import_dialog); -} - static void accounts_dialog_response_cb (GtkWidget *widget, gint response, @@ -1186,8 +1204,6 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) "image_type", &priv->image_type, "label_name", &priv->label_name, "button_add", &priv->button_add, - "button_remove", &priv->button_remove, - "button_import", &priv->button_import, NULL); g_free (filename); @@ -1197,15 +1213,13 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) "button_create", "clicked", accounts_dialog_button_create_clicked_cb, "button_back", "clicked", accounts_dialog_button_back_clicked_cb, "button_add", "clicked", accounts_dialog_button_add_clicked_cb, - "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb, - "button_import", "clicked", accounts_dialog_button_import_clicked_cb, "button_help", "clicked", accounts_dialog_button_help_clicked_cb, NULL); g_object_unref (gui); priv->combobox_protocol = empathy_protocol_chooser_new (); - gtk_box_pack_end (GTK_BOX (priv->hbox_type), + gtk_box_pack_start (GTK_BOX (priv->hbox_type), priv->combobox_protocol, TRUE, TRUE, 0); gtk_widget_show (priv->combobox_protocol); @@ -1386,19 +1400,15 @@ do_constructed (GObject *object) if (!import_asked) { - GtkWidget *import_dialog; - + GtkWidget *import_dialog; + empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_IMPORT_ASKED, TRUE); import_dialog = empathy_import_dialog_new (GTK_WINDOW (priv->window), FALSE); - gtk_widget_show (import_dialog); + gtk_widget_show (import_dialog); } } - else - { - gtk_widget_set_sensitive (priv->button_import, FALSE); - } } static void diff --git a/src/empathy-accounts-dialog.ui b/src/empathy-accounts-dialog.ui index 7c899a3cb..edd8f20a4 100644 --- a/src/empathy-accounts-dialog.ui +++ b/src/empathy-accounts-dialog.ui @@ -2,10 +2,6 @@ - - gtk-add - 4 - 5 Accounts @@ -46,62 +42,18 @@ - + + _Add... True - 6 - True - - - True - 6 - True - - - True - True - False - add_image - _Add... - True - - - 0 - - - - - gtk-remove - True - True - False - True - - - 1 - - - - - False - False - 0 - - - - - Import Accounts... - True - True - False - - - 1 - - + True + True + add_image + True False - 1 + False + 2 @@ -128,11 +80,11 @@ True True Gmail + True - + - True 0 @@ -205,29 +157,6 @@ True 12 - - - True - 6 - - - True - Type: - - - False - False - 0 - - - - - - - - 0 - - True @@ -347,12 +276,45 @@ - + True - Add Account - - - + + + True + Add new + + + + + + 5 + 0 + + + + + True + 6 + + + + + + True + account + + + False + False + end + 0 + + + + + 1 + + @@ -454,4 +416,7 @@ button_close + + gtk-add + -- cgit v1.2.3 From 17ae7af66b0baa2b898445dee8e79a670e588891 Mon Sep 17 00:00:00 2001 From: Jonathan Tellier Date: Fri, 21 Aug 2009 15:11:32 -0400 Subject: Fix errors revealed by make check - Added missing files in po/POTFILES.in - Fixed style --- src/empathy-account-assistant.c | 10 +++++----- src/empathy-accounts-dialog.c | 4 ++-- src/empathy-import-dialog.c | 4 ++-- src/empathy-import-widget.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 8b803a9b6..e375aa72e 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -390,7 +390,7 @@ account_assistant_finish_enter_or_create_page (EmpathyAccountAssistant *self, gboolean is_enter) { EmpathyAccountAssistantPriv *priv = GET_PRIV (self); - + if (is_enter) { gtk_label_set_label (GTK_LABEL (priv->first_label), @@ -426,10 +426,10 @@ account_assistant_finish_enter_or_create_page (EmpathyAccountAssistant *self, priv->enter_or_create_page, _("Enter the details for the new account")); } - + g_signal_connect (priv->chooser, "changed", G_CALLBACK (account_assistant_protocol_changed_cb), self); - + /* trigger show the first account widget */ account_assistant_protocol_changed_cb (GTK_COMBO_BOX (priv->chooser), self); } @@ -568,7 +568,7 @@ account_assistant_build_introduction_page (EmpathyAccountAssistant *self) str = _("Yes, I'll enter my account details now"); if (radio == NULL) - { + { radio = gtk_radio_button_new_with_label (NULL, str); w = radio; } @@ -772,7 +772,7 @@ impl_signal_prepare (GtkAssistant *assistant, gint current_idx; current_idx = gtk_assistant_get_current_page (assistant); - + if (current_idx >= PAGE_ENTER_CREATE) { if (!priv->enter_create_forward) diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 30a7f72a8..43acfbcf9 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -243,7 +243,7 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, empathy_account_settings_get_protocol (settings)); accounts_dialog_update_name_label (dialog, - empathy_account_settings_get_display_name(settings)); + empathy_account_settings_get_display_name (settings)); g_free (icon_name); } @@ -1061,7 +1061,7 @@ accounts_dialog_account_changed_cb (EmpathyAccountManager *manager, if (settings == selected_settings) accounts_dialog_update_name_label (dialog, - empathy_account_settings_get_display_name(settings)); + empathy_account_settings_get_display_name (settings)); if (settings) g_object_unref (settings); diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c index 7ca0285b1..94c6fd765 100644 --- a/src/empathy-import-dialog.c +++ b/src/empathy-import-dialog.c @@ -61,14 +61,14 @@ import_dialog_add_import_widget (EmpathyImportDialog *self) GtkWidget *widget, *area; area = gtk_dialog_get_content_area (GTK_DIALOG (self)); - + iw = empathy_import_widget_new (EMPATHY_IMPORT_APPLICATION_ALL); widget = empathy_import_widget_get_widget (iw); gtk_box_pack_start (GTK_BOX (area), widget, FALSE, FALSE, 0); gtk_widget_show (widget); priv->iw = iw; - + gtk_dialog_add_buttons (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); } diff --git a/src/empathy-import-widget.c b/src/empathy-import-widget.c index 03117350c..17f196229 100644 --- a/src/empathy-import-widget.c +++ b/src/empathy-import-widget.c @@ -85,7 +85,7 @@ import_widget_account_id_in_list (GList *accounts, parameters = empathy_account_get_parameters (account); - value = g_hash_table_lookup ((GHashTable *)parameters, "account"); + value = g_hash_table_lookup ((GHashTable *) parameters, "account"); if (value == NULL) continue; @@ -438,7 +438,7 @@ do_constructed (GObject *obj) gchar *filename; priv->accounts = empathy_import_accounts_load (priv->app_id); - + filename = empathy_file_lookup ("empathy-import-dialog.ui", "src"); gui = empathy_builder_get_file (filename, "widget_vbox", &priv->vbox, -- cgit v1.2.3 From d2b306d115c9c7b46da2e2018e061aa38e6397bf Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sat, 22 Aug 2009 16:04:26 +0100 Subject: Don't free the icon name that we don't own --- src/empathy-accounts-dialog.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 43acfbcf9..408feaad3 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -244,8 +244,6 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, accounts_dialog_update_name_label (dialog, empathy_account_settings_get_display_name (settings)); - - g_free (icon_name); } static void -- cgit v1.2.3 From bd062af39b10bb87d86b9561001f4ab9184e037d Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sat, 22 Aug 2009 17:21:09 +0100 Subject: Don't leak a ref to EmpathyAccountSettings --- src/empathy-accounts-dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 408feaad3..ad96ba921 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -947,7 +947,7 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, TP_CONNECTION_STATUS_DISCONNECTED, dialog); - //g_object_unref (settings); + g_object_unref (settings); } static void -- cgit v1.2.3 From b72ead7076cd2ba308d32f0ae42fc50efc82bd51 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sat, 22 Aug 2009 17:22:23 +0100 Subject: Remove dead code and fix some coding style issues --- src/empathy-accounts-dialog.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index ad96ba921..40f46e49e 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -644,7 +644,6 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) /* Account column */ column = gtk_tree_view_column_new (); - //gtk_tree_view_column_set_title (column, _("Accounts")); gtk_tree_view_column_set_expand (column, TRUE); gtk_tree_view_append_column (view, column); @@ -711,7 +710,6 @@ static void accounts_dialog_model_selection_changed (GtkTreeSelection *selection, EmpathyAccountsDialog *dialog) { -// EmpathyAccountsDialogPriv priv = GET_PRIV (dialog); EmpathyAccountSettings *settings; GtkTreeModel *model; GtkTreeIter iter; @@ -726,7 +724,7 @@ accounts_dialog_model_selection_changed (GtkTreeSelection *selection, accounts_dialog_update_settings (dialog, settings); - if (settings) + if (settings != NULL) g_object_unref (settings); } -- cgit v1.2.3 From fe39c811b7ef600c0262b905683f3a8966311129 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sat, 22 Aug 2009 18:20:53 +0100 Subject: Clean up the dialog a bit --- src/empathy-accounts-dialog.ui | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.ui b/src/empathy-accounts-dialog.ui index edd8f20a4..cd98415d7 100644 --- a/src/empathy-accounts-dialog.ui +++ b/src/empathy-accounts-dialog.ui @@ -6,6 +6,7 @@ 5 Accounts accounts + 640 dialog False @@ -111,28 +112,12 @@ - + True - 0 - none + 6 + 20 - - True - 6 - 20 - - - - - - - - True - Settings - - - - + -- cgit v1.2.3 From 45a6ac022bc86f649bb49f909f95b9311eec57c9 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sat, 22 Aug 2009 19:43:38 +0100 Subject: Use the right default answer if we're not importing accounts --- src/empathy-account-assistant.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index e375aa72e..d8aa46f1d 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -495,6 +495,7 @@ account_assistant_radio_choice_toggled_cb (GtkToggleButton *button, static GtkWidget * account_assistant_build_introduction_page (EmpathyAccountAssistant *self) { + EmpathyAccountAssistantPriv *priv = GET_PRIV (self); GtkWidget *main_vbox, *hbox_1, *w, *vbox_1; GtkWidget *radio = NULL; GdkPixbuf *pix; @@ -563,6 +564,11 @@ account_assistant_build_introduction_page (EmpathyAccountAssistant *self) g_signal_connect (radio, "clicked", G_CALLBACK (account_assistant_radio_choice_toggled_cb), self); + priv->first_resp = RESPONSE_IMPORT; + } + else + { + priv->first_resp = RESPONSE_ENTER_ACCOUNT; } str = _("Yes, I'll enter my account details now"); @@ -910,9 +916,6 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self) GTK_ASSISTANT_PAGE_INTRO); gtk_assistant_set_page_complete (assistant, page, TRUE); - /* set a default answer */ - priv->first_resp = RESPONSE_IMPORT; - /* second page (import accounts) */ page = account_assistant_build_import_page (self); gtk_assistant_append_page (assistant, page); -- cgit v1.2.3 From 1173e9d086df6304f2436edf0d8cc6c1540414f9 Mon Sep 17 00:00:00 2001 From: Arnaud Maillet Date: Sat, 22 Aug 2009 14:52:15 +0200 Subject: Add empathy-import-mc4-accounts files --- src/empathy-import-mc4-accounts.c | 555 ++++++++++++++++++++++++++++++++++++++ src/empathy-import-mc4-accounts.h | 31 +++ 2 files changed, 586 insertions(+) create mode 100644 src/empathy-import-mc4-accounts.c create mode 100644 src/empathy-import-mc4-accounts.h (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c new file mode 100644 index 000000000..0dbadd6ee --- /dev/null +++ b/src/empathy-import-mc4-accounts.c @@ -0,0 +1,555 @@ +/* + * Copyright (C) 2008 Collabora Ltd. + * + * This program 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 2 of the + * License, or (at your option) any later version. + * + * This program 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, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: Arnaud Maillet + */ + +#include +#include +#include +#include +#include +#include + +#include "empathy-import-mc4-accounts.h" + +#define DEBUG_FLAG EMPATHY_DEBUG_IMPORT_MC4_ACCOUNTS +#include + +#define MC_ACCOUNTS_GCONF_BASE "/apps/telepathy/mc/accounts" +#define IMPORT_MC4_ACCOUNTS "/apps/empathy/accounts/import_mc4_accounts" + +typedef struct +{ + gchar *profile; + gchar *protocol; +} ProfileProtocolMapItem; + +static ProfileProtocolMapItem profile_protocol_map[] = +{ + { "aim", "aim" }, + { "ekiga", "sip" }, + { "fwd", "sip" }, + { "gadugadu", "gadugadu" }, + { "groupwise", "groupwise" }, + { "gtalk", "jabber" }, + { "icq", "icq" }, + { "irc", "irc" }, + { "jabber", "jabber" }, + { "msn-haze", "msn" }, + { "msn", "msn" }, + { "qq", "qq" }, + { "salut", "local-xmpp" }, + { "sametime", "sametime" }, + { "sipphone", "sip" }, + { "sofiasip", "sip" }, + { "yahoo", "yahoo" }, +}; + +typedef struct +{ + gchar *connection_manager; + gchar *protocol; + gchar *display_name; + gchar *param_account; + gchar *param_server; + gboolean enabled; + GHashTable *parameters; +} AccountData; + +static void +_account_data_free (AccountData *account) +{ + if (account->connection_manager != NULL) + { + g_free (account->connection_manager); + account->connection_manager = NULL; + } + + if (account->protocol != NULL) + { + g_free (account->protocol); + account->protocol = NULL; + } + + if (account->display_name != NULL) + { + g_free (account->display_name); + account->display_name = NULL; + } + + if (account->param_account != NULL) + { + g_free (account->param_account); + account->param_account = NULL; + } + + if (account->param_server != NULL) + { + g_free (account->param_server); + account->param_server = NULL; + } + + if (account->parameters != NULL) + { + g_hash_table_destroy (account->parameters); + account->parameters = NULL; + } + + g_slice_free (AccountData, account); +} + +static gchar * +_account_name_from_key (const gchar *key) +{ + guint base_len = strlen (MC_ACCOUNTS_GCONF_BASE); + const gchar *base, *slash; + + g_assert (key == strstr (key, MC_ACCOUNTS_GCONF_BASE)); + g_assert (strlen (key) > base_len + 1); + + base = key + base_len + 1; + slash = strchr (base, '/'); + + if (slash == NULL) + return g_strdup (base); + else + return g_strndup (base, slash - base); +} + +static gchar * +_param_name_from_key (const gchar *key) +{ + const gchar *base, *slash; + gchar *account_name; + + account_name = _account_name_from_key (key); + base = strstr (key, account_name); + slash = strchr (base, '/'); + g_free (account_name); + + return g_strdup (slash+1); +} + +static void +_normalize_display_name (AccountData *account) +{ + + if (account->display_name != NULL) + return; + + if (!tp_strdiff (account->protocol, "local-xmpp")) + { + account->display_name = g_strdup ("Nearby People"); + } + + else if (!tp_strdiff (account->protocol, "irc")) + { + + if (account->display_name != NULL) + { + g_free (account->display_name); + account->display_name = NULL; + } + + account->display_name = g_strdup_printf + ("%s on %s", account->param_account, account->param_server); + + } + + else if (account->display_name == NULL) + { + + if (account->param_account != NULL) + account->display_name = g_strdup + ((const gchar *) account->param_account); + else + account->display_name = g_strdup + ("No display name"); + + } +} + +static gboolean +_protocol_is_supported (AccountData *data) +{ + EmpathyConnectionManagers *cm = + empathy_connection_managers_dup_singleton (); + GList *cms = empathy_connection_managers_get_cms (cm); + GList *l; + gboolean proto_is_supported = FALSE; + + for (l = cms; l; l = l->next) + { + TpConnectionManager *tp_cm = l->data; + const gchar *cm_name = tp_connection_manager_get_name (tp_cm); + if (tp_connection_manager_has_protocol (tp_cm, + (const gchar*)data->protocol)) + { + data->connection_manager = g_strdup (cm_name); + proto_is_supported = TRUE; + break; + } + } + + g_object_unref (cm); + + return proto_is_supported; +} + +static void +_create_account_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + AccountData *data = (AccountData*) user_data; + EmpathyAccount *account; + GError *error = NULL; + + account = empathy_account_manager_create_account_finish ( + EMPATHY_ACCOUNT_MANAGER (source), result, &error); + + if (account == NULL) + { + DEBUG ("Failed to create account: %s", + error ? error->message : "No error given"); + g_clear_error (&error); + _account_data_free (data); + return; + } + + DEBUG ("account created\n"); + empathy_account_set_enabled (account, data->enabled); + + g_object_unref (account); + _account_data_free (data); +} + +static void +_recurse_account (GSList *entries, AccountData *account) +{ + GSList *tmp; + + for (tmp = entries; tmp != NULL; tmp = tmp->next) + { + + GConfEntry *entry; + gchar *param; + GConfValue *value; + + entry = (GConfEntry*) tmp->data; + param = _param_name_from_key (gconf_entry_get_key (entry)); + + if (!tp_strdiff (param, "profile")) + { + const gchar *profile; + gint i; + value = gconf_entry_get_value (entry); + profile = gconf_value_get_string (value); + + DEBUG ("profile: %s\n", profile); + + for (i = 0; i < G_N_ELEMENTS (profile_protocol_map); i++) + { + if (!tp_strdiff (profile, profile_protocol_map[i].profile)) + { + account->protocol = g_strdup + (profile_protocol_map[i].protocol); + break; + } + } + } + + else if (!tp_strdiff (param, "enabled")) + { + value = gconf_entry_get_value (entry); + account->enabled = gconf_value_get_bool (value); + } + + else if (!tp_strdiff (param, "display_name")) + { + value = gconf_entry_get_value (entry); + account->display_name = g_strdup (gconf_value_get_string (value)); + } + + else if (!tp_strdiff (param, "param-account")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + account->param_account = g_strdup (gconf_value_get_string (value)); + + my_g_value = tp_g_value_slice_new (G_TYPE_STRING); + g_value_set_string (my_g_value, account->param_account); + g_hash_table_insert (account->parameters, "account", my_g_value); + + } + + else if (!tp_strdiff (param, "param-server")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + account->param_account = g_strdup (gconf_value_get_string (value)); + + my_g_value = tp_g_value_slice_new (G_TYPE_STRING); + g_value_set_string (my_g_value, account->param_account); + g_hash_table_insert (account->parameters, "server", my_g_value); + + } + + else if (!tp_strdiff (param, "param-port")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + my_g_value = tp_g_value_slice_new (G_TYPE_UINT); + g_value_set_uint (my_g_value, gconf_value_get_int (value)); + g_hash_table_insert (account->parameters, "password", my_g_value);; + + } + + + else if (!tp_strdiff (param, "param-password")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + my_g_value = tp_g_value_slice_new (G_TYPE_STRING); + g_value_set_string (my_g_value, gconf_value_get_string (value)); + g_hash_table_insert (account->parameters, "password", my_g_value); + + } + + else if (!tp_strdiff (param, "param-require-encryption")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + my_g_value = tp_g_value_slice_new (G_TYPE_BOOLEAN); + g_value_set_boolean (my_g_value, gconf_value_get_bool (value)); + g_hash_table_insert (account->parameters, "require-encryption", my_g_value); + + } + + else if (!tp_strdiff (param, "param-register")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + my_g_value = tp_g_value_slice_new (G_TYPE_BOOLEAN); + g_value_set_boolean (my_g_value, gconf_value_get_bool (value)); + g_hash_table_insert (account->parameters, "require-register", my_g_value); + + } + + else if (!tp_strdiff (param, "param-ident")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + my_g_value = tp_g_value_slice_new (G_TYPE_STRING); + g_value_set_string (my_g_value, gconf_value_get_string (value)); + g_hash_table_insert (account->parameters, "ident", my_g_value); + + } + + else if (!tp_strdiff (param, "param-fullname")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + my_g_value = tp_g_value_slice_new (G_TYPE_STRING); + g_value_set_string (my_g_value, gconf_value_get_string (value)); + g_hash_table_insert (account->parameters, "fullname", my_g_value); + + } + + else if (!tp_strdiff (param, "param-stun-server")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + my_g_value = tp_g_value_slice_new (G_TYPE_STRING); + g_value_set_string (my_g_value, gconf_value_get_string (value)); + g_hash_table_insert (account->parameters, "stun-server", my_g_value); + + } + + else if (!tp_strdiff (param, "param-stun-port")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + my_g_value = tp_g_value_slice_new (G_TYPE_UINT); + g_value_set_uint (my_g_value, gconf_value_get_int (value)); + g_hash_table_insert (account->parameters, "stun-port", my_g_value);; + + } + + else if (!tp_strdiff (param, "param-keepalive-interval")) + { + + GValue *my_g_value; + + value = gconf_entry_get_value (entry); + my_g_value = tp_g_value_slice_new (G_TYPE_UINT); + g_value_set_uint (my_g_value, gconf_value_get_int (value)); + g_hash_table_insert (account->parameters, "keepalive-interval", my_g_value);; + + } + + g_free (param); + gconf_entry_unref (entry); + + } + + _normalize_display_name (account); +} + +void empathy_import_mc4_accounts (void) +{ + GConfClient *client; + GError *error = NULL; + GSList *dir, *dirs, *entries; + gboolean import_mc4_accounts; + + client = gconf_client_get_default (); + + import_mc4_accounts = gconf_client_get_bool (client, + IMPORT_MC4_ACCOUNTS, &error); + + if (error != NULL) + { + DEBUG ("Failed to get import_mc4_accounts key: %s\n", error->message); + g_clear_error (&error); + g_object_unref (client); + return; + } + + if (!import_mc4_accounts) + { + g_object_unref (client); + return; + } + + DEBUG ("MC 4 accounts are going to be imported\n"); + + dirs = gconf_client_all_dirs (client, MC_ACCOUNTS_GCONF_BASE, &error); + + if (error != NULL) + { + DEBUG ("Failed to get mc_accounts_gconf_base dirs: %s\n", + error->message); + g_clear_error (&error); + g_object_unref (client); + return; + } + + for (dir = dirs; NULL != dir; dir = dir->next) + { + gchar *account_name = _account_name_from_key (dir->data); + AccountData *account; + + account = g_slice_new0 (AccountData); + + account->connection_manager = NULL; + account->protocol = NULL; + account->enabled = FALSE; + account->display_name = NULL; + account->param_account = NULL; + account->param_server = NULL; + account->parameters = g_hash_table_new_full (g_str_hash, g_str_equal, + NULL, (GDestroyNotify) tp_g_value_slice_free); + + DEBUG ("name : %s\n", account_name); + + entries = gconf_client_all_entries (client, dir->data, &error); + + if (error != NULL) + { + + DEBUG ("Failed to get all entries: %s\n", error->message); + g_clear_error (&error); + + } + else + { + _recurse_account (entries, account); + } + + if (_protocol_is_supported (account)) + { + EmpathyAccountManager *account_manager; + GHashTable *properties; + + account_manager = empathy_account_manager_dup_singleton (); + + properties = g_hash_table_new (NULL, NULL); + + DEBUG ("account cm: %s", account->connection_manager); + DEBUG ("account protocol: %s", account->protocol); + DEBUG ("account display_name: %s", account->display_name); + DEBUG ("account param_account: %s", account->param_account); + DEBUG ("account param_server: %s", account->param_server); + DEBUG ("enabled: %d", account->enabled); + tp_asv_dump (account->parameters); + + empathy_account_manager_create_account_async (account_manager, + (const gchar*) account->connection_manager, + (const gchar*) account->protocol, account->display_name, + account->parameters, properties, + _create_account_cb, account); + + g_hash_table_unref (properties); + g_object_unref (account_manager); + } + else + { + DEBUG ("protocol of this account is not supported\n"); + _account_data_free (account); + } + + g_slist_free (entries); + g_free (account_name); + g_free (dir->data); + + } + + gconf_client_set_bool (client, + IMPORT_MC4_ACCOUNTS, FALSE, &error); + + if (error != NULL) + { + DEBUG ("Failed to set import_mc4_accounts key: %s\n", error->message); + g_clear_error (&error); + } + + g_slist_free (dirs); + g_object_unref (client); +} \ No newline at end of file diff --git a/src/empathy-import-mc4-accounts.h b/src/empathy-import-mc4-accounts.h new file mode 100644 index 000000000..fcc5118cf --- /dev/null +++ b/src/empathy-import-mc4-accounts.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2008 Collabora Ltd. + * + * This program 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 2 of the + * License, or (at your option) any later version. + * + * This program 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, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: Arnaud Maillet + */ + +#ifndef __EMPATHY_IMPORT_MC4_ACCOUNTS_H__ +#define __EMPATHY_IMPORT_MC4_ACCOUNTS_H__ + +G_BEGIN_DECLS + +void empathy_import_mc4_accounts (void); + +G_END_DECLS + +#endif /* __EMPATHY_IMPORT_MC4_ACCOUNTS_H__ */ \ No newline at end of file -- cgit v1.2.3 From 5b34b46eb22ab9b178144959a23ca99d5b20f3ac Mon Sep 17 00:00:00 2001 From: Arnaud Maillet Date: Sat, 22 Aug 2009 14:54:49 +0200 Subject: Add the mc4 account importer files in the makefile --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 3641835f7..6896c03f3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,6 +39,7 @@ empathy_handwritten_source = \ empathy-debug-dialog.c empathy-debug-dialog.h \ empathy-chat-window.c empathy-chat-window.h \ empathy-event-manager.c empathy-event-manager.h \ + empathy-import-mc4-accounts.c empathy-import-mc4-accounts.h \ empathy-ft-manager.c empathy-ft-manager.h \ empathy-import-dialog.c empathy-import-dialog.h \ empathy-import-widget.c empathy-import-widget.h \ -- cgit v1.2.3 From 53077973f94837e583296a2d4c93db84317e1913 Mon Sep 17 00:00:00 2001 From: Arnaud Maillet Date: Sat, 22 Aug 2009 14:55:49 +0200 Subject: Instantiate the mc4 account importer in empathy.c --- src/empathy.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/empathy.c b/src/empathy.c index 650129ebb..a80d39684 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -70,6 +70,7 @@ #include "empathy-call-window.h" #include "empathy-chat-window.h" #include "empathy-ft-manager.h" +#include "empathy-import-mc4-accounts.h" #include "extensions/extensions.h" @@ -328,6 +329,7 @@ connection_managers_ready_cb (EmpathyConnectionManagers *managers, { if (empathy_connection_managers_is_ready (managers)) { + empathy_import_mc4_accounts (); create_salut_account_if_needed (managers); g_object_unref (managers); managers = NULL; -- cgit v1.2.3 From b466c826795481a46c47f74773689633d9bb0b6c Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 14:55:17 +0100 Subject: Use new async enable api --- src/empathy-import-mc4-accounts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 0dbadd6ee..13f81e4e2 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -234,7 +234,7 @@ _create_account_cb (GObject *source, } DEBUG ("account created\n"); - empathy_account_set_enabled (account, data->enabled); + empathy_account_set_enabled_async (account, data->enabled, NULL, NULL); g_object_unref (account); _account_data_free (data); -- cgit v1.2.3 From 8781e7c615d1f233a530cff66cfe47aa54fddd2f Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 14:55:53 +0100 Subject: Don't unref the account object as we don't own it --- src/empathy-import-mc4-accounts.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 13f81e4e2..86e2b1a3b 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -236,7 +236,6 @@ _create_account_cb (GObject *source, DEBUG ("account created\n"); empathy_account_set_enabled_async (account, data->enabled, NULL, NULL); - g_object_unref (account); _account_data_free (data); } -- cgit v1.2.3 From 4b5fa08436333e571186c991496549be520f21eb Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 14:57:32 +0100 Subject: Make the gconf entry be false by default --- src/empathy-import-mc4-accounts.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 86e2b1a3b..4ce8d4e80 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -32,7 +32,7 @@ #include #define MC_ACCOUNTS_GCONF_BASE "/apps/telepathy/mc/accounts" -#define IMPORT_MC4_ACCOUNTS "/apps/empathy/accounts/import_mc4_accounts" +#define IMPORTED_MC4_ACCOUNTS "/apps/empathy/accounts/imported_mc4_accounts" typedef struct { @@ -436,12 +436,12 @@ void empathy_import_mc4_accounts (void) GConfClient *client; GError *error = NULL; GSList *dir, *dirs, *entries; - gboolean import_mc4_accounts; + gboolean imported_mc4_accounts; client = gconf_client_get_default (); - import_mc4_accounts = gconf_client_get_bool (client, - IMPORT_MC4_ACCOUNTS, &error); + imported_mc4_accounts = gconf_client_get_bool (client, + IMPORTED_MC4_ACCOUNTS, &error); if (error != NULL) { @@ -451,8 +451,9 @@ void empathy_import_mc4_accounts (void) return; } - if (!import_mc4_accounts) + if (imported_mc4_accounts) { + DEBUG ("Mc4 accounts already imported"); g_object_unref (client); return; } @@ -541,7 +542,7 @@ void empathy_import_mc4_accounts (void) } gconf_client_set_bool (client, - IMPORT_MC4_ACCOUNTS, FALSE, &error); + IMPORTED_MC4_ACCOUNTS, TRUE, &error); if (error != NULL) { @@ -551,4 +552,4 @@ void empathy_import_mc4_accounts (void) g_slist_free (dirs); g_object_unref (client); -} \ No newline at end of file +} -- cgit v1.2.3 From 9498d6a67a0085d0bab3e49cd11288daa6474771 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 15:00:28 +0100 Subject: Use g_str_has_prefix convenience function for clarity --- src/empathy-import-mc4-accounts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 4ce8d4e80..8fa8d5845 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -19,6 +19,7 @@ * Authors: Arnaud Maillet */ +#include #include #include #include @@ -120,7 +121,7 @@ _account_name_from_key (const gchar *key) guint base_len = strlen (MC_ACCOUNTS_GCONF_BASE); const gchar *base, *slash; - g_assert (key == strstr (key, MC_ACCOUNTS_GCONF_BASE)); + g_assert (g_str_has_prefix (key, MC_ACCOUNTS_GCONF_BASE)); g_assert (strlen (key) > base_len + 1); base = key + base_len + 1; -- cgit v1.2.3 From 95cddd4f98544e4526a08cc25e5dd3fce0ed2a33 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 17:51:58 +0100 Subject: Overhaul the importer slightly --- src/empathy-import-mc4-accounts.c | 516 +++++++++++++------------------------- src/empathy-import-mc4-accounts.h | 6 +- 2 files changed, 179 insertions(+), 343 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 8fa8d5845..eea3b7f18 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -22,9 +22,12 @@ #include #include #include +#include #include #include +#include #include +#include #include #include "empathy-import-mc4-accounts.h" @@ -43,78 +46,15 @@ typedef struct static ProfileProtocolMapItem profile_protocol_map[] = { - { "aim", "aim" }, { "ekiga", "sip" }, { "fwd", "sip" }, - { "gadugadu", "gadugadu" }, - { "groupwise", "groupwise" }, { "gtalk", "jabber" }, - { "icq", "icq" }, - { "irc", "irc" }, - { "jabber", "jabber" }, { "msn-haze", "msn" }, - { "msn", "msn" }, - { "qq", "qq" }, { "salut", "local-xmpp" }, - { "sametime", "sametime" }, { "sipphone", "sip" }, { "sofiasip", "sip" }, - { "yahoo", "yahoo" }, }; -typedef struct -{ - gchar *connection_manager; - gchar *protocol; - gchar *display_name; - gchar *param_account; - gchar *param_server; - gboolean enabled; - GHashTable *parameters; -} AccountData; - -static void -_account_data_free (AccountData *account) -{ - if (account->connection_manager != NULL) - { - g_free (account->connection_manager); - account->connection_manager = NULL; - } - - if (account->protocol != NULL) - { - g_free (account->protocol); - account->protocol = NULL; - } - - if (account->display_name != NULL) - { - g_free (account->display_name); - account->display_name = NULL; - } - - if (account->param_account != NULL) - { - g_free (account->param_account); - account->param_account = NULL; - } - - if (account->param_server != NULL) - { - g_free (account->param_server); - account->param_server = NULL; - } - - if (account->parameters != NULL) - { - g_hash_table_destroy (account->parameters); - account->parameters = NULL; - } - - g_slice_free (AccountData, account); -} - static gchar * _account_name_from_key (const gchar *key) { @@ -147,70 +87,47 @@ _param_name_from_key (const gchar *key) return g_strdup (slash+1); } -static void -_normalize_display_name (AccountData *account) +static gchar * +_create_default_display_name (const gchar *protocol) { + if (!tp_strdiff (protocol, "local-xmpp")) + return g_strdup (_("People Nearby")); - if (account->display_name != NULL) - return; - - if (!tp_strdiff (account->protocol, "local-xmpp")) - { - account->display_name = g_strdup ("Nearby People"); - } - - else if (!tp_strdiff (account->protocol, "irc")) - { - - if (account->display_name != NULL) - { - g_free (account->display_name); - account->display_name = NULL; - } - - account->display_name = g_strdup_printf - ("%s on %s", account->param_account, account->param_server); - - } - - else if (account->display_name == NULL) - { - - if (account->param_account != NULL) - account->display_name = g_strdup - ((const gchar *) account->param_account); - else - account->display_name = g_strdup - ("No display name"); - - } + return g_strdup_printf ("%s account", protocol); } -static gboolean -_protocol_is_supported (AccountData *data) +static const gchar * +_get_manager_for_protocol (EmpathyConnectionManagers *managers, + const gchar *protocol) { - EmpathyConnectionManagers *cm = - empathy_connection_managers_dup_singleton (); - GList *cms = empathy_connection_managers_get_cms (cm); + GList *cms = empathy_connection_managers_get_cms (managers); GList *l; - gboolean proto_is_supported = FALSE; + TpConnectionManager *haze = NULL; + TpConnectionManager *cm = NULL; for (l = cms; l; l = l->next) { TpConnectionManager *tp_cm = l->data; - const gchar *cm_name = tp_connection_manager_get_name (tp_cm); - if (tp_connection_manager_has_protocol (tp_cm, - (const gchar*)data->protocol)) + + /* Only use haze if no other cm provides this account */ + if (!tp_strdiff (tp_connection_manager_get_name (tp_cm), "haze")) { - data->connection_manager = g_strdup (cm_name); - proto_is_supported = TRUE; - break; + haze = tp_cm; + continue; + } + + if (tp_connection_manager_has_protocol (tp_cm, protocol)) + { + cm = tp_cm; + goto out; } } - g_object_unref (cm); + if (haze != NULL && tp_connection_manager_has_protocol (haze, protocol)) + return tp_connection_manager_get_name (haze); - return proto_is_supported; +out: + return cm != NULL ? tp_connection_manager_get_name (cm) : NULL; } static void @@ -218,227 +135,208 @@ _create_account_cb (GObject *source, GAsyncResult *result, gpointer user_data) { - AccountData *data = (AccountData*) user_data; EmpathyAccount *account; GError *error = NULL; - account = empathy_account_manager_create_account_finish ( - EMPATHY_ACCOUNT_MANAGER (source), result, &error); - - if (account == NULL) + if (!empathy_account_settings_apply_finish ( + EMPATHY_ACCOUNT_SETTINGS (source), result, &error)) { DEBUG ("Failed to create account: %s", error ? error->message : "No error given"); - g_clear_error (&error); - _account_data_free (data); - return; + g_error_free (error); + goto out; } DEBUG ("account created\n"); - empathy_account_set_enabled_async (account, data->enabled, NULL, NULL); + account = empathy_account_settings_get_account ( + EMPATHY_ACCOUNT_SETTINGS (source)); + empathy_account_set_enabled_async (account, + GPOINTER_TO_INT (user_data), NULL, NULL); - _account_data_free (data); +out: + g_object_unref (source); } -static void -_recurse_account (GSList *entries, AccountData *account) +static gchar * +_get_protocol_from_profile (const gchar *profile) { - GSList *tmp; + gint i; - for (tmp = entries; tmp != NULL; tmp = tmp->next) - { + DEBUG ("profile: %s\n", profile); - GConfEntry *entry; - gchar *param; - GConfValue *value; + for (i = 0; i < G_N_ELEMENTS (profile_protocol_map); i++) + if (!tp_strdiff (profile, profile_protocol_map[i].profile)) + return g_strdup (profile_protocol_map[i].protocol); - entry = (GConfEntry*) tmp->data; - param = _param_name_from_key (gconf_entry_get_key (entry)); - - if (!tp_strdiff (param, "profile")) - { - const gchar *profile; - gint i; - value = gconf_entry_get_value (entry); - profile = gconf_value_get_string (value); - - DEBUG ("profile: %s\n", profile); - - for (i = 0; i < G_N_ELEMENTS (profile_protocol_map); i++) - { - if (!tp_strdiff (profile, profile_protocol_map[i].profile)) - { - account->protocol = g_strdup - (profile_protocol_map[i].protocol); - break; - } - } - } - - else if (!tp_strdiff (param, "enabled")) - { - value = gconf_entry_get_value (entry); - account->enabled = gconf_value_get_bool (value); - } - - else if (!tp_strdiff (param, "display_name")) - { - value = gconf_entry_get_value (entry); - account->display_name = g_strdup (gconf_value_get_string (value)); - } - - else if (!tp_strdiff (param, "param-account")) - { - - GValue *my_g_value; - - value = gconf_entry_get_value (entry); - account->param_account = g_strdup (gconf_value_get_string (value)); - - my_g_value = tp_g_value_slice_new (G_TYPE_STRING); - g_value_set_string (my_g_value, account->param_account); - g_hash_table_insert (account->parameters, "account", my_g_value); - - } - - else if (!tp_strdiff (param, "param-server")) - { - - GValue *my_g_value; - - value = gconf_entry_get_value (entry); - account->param_account = g_strdup (gconf_value_get_string (value)); + return g_strdup (profile); +} - my_g_value = tp_g_value_slice_new (G_TYPE_STRING); - g_value_set_string (my_g_value, account->param_account); - g_hash_table_insert (account->parameters, "server", my_g_value); +static void +_handle_entry (EmpathyAccountSettings *settings, + const gchar *key, + GConfEntry *entry) +{ + const gchar *signature; - } + signature = empathy_account_settings_get_dbus_signature (settings, key); + if (signature == NULL) + { + DEBUG ("Parameter %s is unknown", signature); + return; + } - else if (!tp_strdiff (param, "param-port")) + switch ((int)*signature) + { + case DBUS_TYPE_INT16: + case DBUS_TYPE_INT32: { - - GValue *my_g_value; - - value = gconf_entry_get_value (entry); - my_g_value = tp_g_value_slice_new (G_TYPE_UINT); - g_value_set_uint (my_g_value, gconf_value_get_int (value)); - g_hash_table_insert (account->parameters, "password", my_g_value);; - + gint v = gconf_value_get_int (gconf_entry_get_value (entry)); + empathy_account_settings_set_int32 (settings, key, v); + break; } - - - else if (!tp_strdiff (param, "param-password")) + case DBUS_TYPE_UINT16: + case DBUS_TYPE_UINT32: { - - GValue *my_g_value; - - value = gconf_entry_get_value (entry); - my_g_value = tp_g_value_slice_new (G_TYPE_STRING); - g_value_set_string (my_g_value, gconf_value_get_string (value)); - g_hash_table_insert (account->parameters, "password", my_g_value); - + gint v = gconf_value_get_int (gconf_entry_get_value (entry)); + empathy_account_settings_set_uint32 (settings, key, v); + break; } - - else if (!tp_strdiff (param, "param-require-encryption")) + case DBUS_TYPE_STRING: { + const gchar *v = gconf_value_get_string ( + gconf_entry_get_value (entry)); - GValue *my_g_value; - - value = gconf_entry_get_value (entry); - my_g_value = tp_g_value_slice_new (G_TYPE_BOOLEAN); - g_value_set_boolean (my_g_value, gconf_value_get_bool (value)); - g_hash_table_insert (account->parameters, "require-encryption", my_g_value); - + empathy_account_settings_set_string (settings, key, v); + break; } - - else if (!tp_strdiff (param, "param-register")) + case DBUS_TYPE_BOOLEAN: { + gboolean v = gconf_value_get_bool ( + gconf_entry_get_value (entry)); - GValue *my_g_value; - - value = gconf_entry_get_value (entry); - my_g_value = tp_g_value_slice_new (G_TYPE_BOOLEAN); - g_value_set_boolean (my_g_value, gconf_value_get_bool (value)); - g_hash_table_insert (account->parameters, "require-register", my_g_value); - + empathy_account_settings_set_boolean (settings, key, v); + break; } + default: + DEBUG ("Unsupported type in signature: %s", signature); + } +} - else if (!tp_strdiff (param, "param-ident")) - { +static void +_recurse_account (GSList *entries, EmpathyAccountSettings *settings) +{ + GSList *tmp; - GValue *my_g_value; + for (tmp = entries; tmp != NULL; tmp = tmp->next) + { - value = gconf_entry_get_value (entry); - my_g_value = tp_g_value_slice_new (G_TYPE_STRING); - g_value_set_string (my_g_value, gconf_value_get_string (value)); - g_hash_table_insert (account->parameters, "ident", my_g_value); + GConfEntry *entry; + gchar *param; - } + entry = (GConfEntry*) tmp->data; + param = _param_name_from_key (gconf_entry_get_key (entry)); - else if (!tp_strdiff (param, "param-fullname")) + if (g_str_has_prefix (param, "param-")) { - - GValue *my_g_value; - - value = gconf_entry_get_value (entry); - my_g_value = tp_g_value_slice_new (G_TYPE_STRING); - g_value_set_string (my_g_value, gconf_value_get_string (value)); - g_hash_table_insert (account->parameters, "fullname", my_g_value); - + _handle_entry (settings, param + strlen ("param-"), entry); } - else if (!tp_strdiff (param, "param-stun-server")) - { - - GValue *my_g_value; + g_free (param); + gconf_entry_unref (entry); + } +} - value = gconf_entry_get_value (entry); - my_g_value = tp_g_value_slice_new (G_TYPE_STRING); - g_value_set_string (my_g_value, gconf_value_get_string (value)); - g_hash_table_insert (account->parameters, "stun-server", my_g_value); +static void +import_one_account (const char *path, + EmpathyConnectionManagers *managers, + GConfClient *client) +{ + gchar *account_name = _account_name_from_key (path); + EmpathyAccountSettings *settings; + GError *error = NULL; + GSList *entries = NULL; + gchar *profile = NULL; + gchar *protocol = NULL; + const gchar *manager; + gchar *display_name; + gchar *key; + gboolean enabled = FALSE; - } + DEBUG ("Starting import of %s (%s)", path, account_name); - else if (!tp_strdiff (param, "param-stun-port")) - { + key = g_strdup_printf ("%s/profile", path); + profile = gconf_client_get_string (client, key, NULL); + g_free (key); - GValue *my_g_value; + if (profile == NULL) + { + DEBUG ("Account is missing a profile entry\n"); + goto failed; + } - value = gconf_entry_get_value (entry); - my_g_value = tp_g_value_slice_new (G_TYPE_UINT); - g_value_set_uint (my_g_value, gconf_value_get_int (value)); - g_hash_table_insert (account->parameters, "stun-port", my_g_value);; + protocol = _get_protocol_from_profile (profile); + manager = _get_manager_for_protocol (managers, protocol); + if (manager == NULL) + { + DEBUG ("No manager available for this protocol %s", protocol); + goto failed; + } - } + key = g_strdup_printf ("%s/display_name", path); + display_name = gconf_client_get_string (client, key, NULL); + g_free (key); - else if (!tp_strdiff (param, "param-keepalive-interval")) - { + if (display_name == NULL) + display_name = _create_default_display_name (protocol); - GValue *my_g_value; + settings = empathy_account_settings_new (manager, protocol, display_name); + g_free (display_name); - value = gconf_entry_get_value (entry); - my_g_value = tp_g_value_slice_new (G_TYPE_UINT); - g_value_set_uint (my_g_value, gconf_value_get_int (value)); - g_hash_table_insert (account->parameters, "keepalive-interval", my_g_value);; + /* Bit of a hack, as we know EmpathyConnectionManagers is ready the + * EmpathyAccountSettings should be ready right away as well */ + g_assert (empathy_account_settings_is_ready (settings)); - } + entries = gconf_client_all_entries (client, path, &error); - g_free (param); - gconf_entry_unref (entry); + if (entries == NULL) + { + DEBUG ("Failed to get all entries: %s\n", error->message); + g_error_free (error); + goto failed; } - _normalize_display_name (account); + _recurse_account (entries, settings); + + key = g_strdup_printf ("%s/enabled", path); + enabled = gconf_client_get_bool (client, key, NULL); + g_free (key); + empathy_account_settings_apply_async (settings, + _create_account_cb, GINT_TO_POINTER (enabled)); +out: + g_free (protocol); + g_free (profile); + g_slist_free (entries); + g_free (account_name); + return; + +failed: + DEBUG ("Failed to import %s", path); + if (settings != NULL) + g_object_unref (settings); + goto out; } -void empathy_import_mc4_accounts (void) +void +empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) { GConfClient *client; GError *error = NULL; - GSList *dir, *dirs, *entries; + GSList *dir, *dirs; gboolean imported_mc4_accounts; + g_return_if_fail (empathy_connection_managers_is_ready (managers)); + client = gconf_client_get_default (); imported_mc4_accounts = gconf_client_get_bool (client, @@ -474,73 +372,10 @@ void empathy_import_mc4_accounts (void) for (dir = dirs; NULL != dir; dir = dir->next) { - gchar *account_name = _account_name_from_key (dir->data); - AccountData *account; - - account = g_slice_new0 (AccountData); - - account->connection_manager = NULL; - account->protocol = NULL; - account->enabled = FALSE; - account->display_name = NULL; - account->param_account = NULL; - account->param_server = NULL; - account->parameters = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, (GDestroyNotify) tp_g_value_slice_free); - - DEBUG ("name : %s\n", account_name); - - entries = gconf_client_all_entries (client, dir->data, &error); - - if (error != NULL) - { - - DEBUG ("Failed to get all entries: %s\n", error->message); - g_clear_error (&error); - - } - else - { - _recurse_account (entries, account); - } - - if (_protocol_is_supported (account)) - { - EmpathyAccountManager *account_manager; - GHashTable *properties; - - account_manager = empathy_account_manager_dup_singleton (); - - properties = g_hash_table_new (NULL, NULL); - - DEBUG ("account cm: %s", account->connection_manager); - DEBUG ("account protocol: %s", account->protocol); - DEBUG ("account display_name: %s", account->display_name); - DEBUG ("account param_account: %s", account->param_account); - DEBUG ("account param_server: %s", account->param_server); - DEBUG ("enabled: %d", account->enabled); - tp_asv_dump (account->parameters); - - empathy_account_manager_create_account_async (account_manager, - (const gchar*) account->connection_manager, - (const gchar*) account->protocol, account->display_name, - account->parameters, properties, - _create_account_cb, account); - - g_hash_table_unref (properties); - g_object_unref (account_manager); - } - else - { - DEBUG ("protocol of this account is not supported\n"); - _account_data_free (account); - } - - g_slist_free (entries); - g_free (account_name); + import_one_account ((gchar *)dir->data, managers, client); g_free (dir->data); - } + g_slist_free (dirs); gconf_client_set_bool (client, IMPORTED_MC4_ACCOUNTS, TRUE, &error); @@ -551,6 +386,5 @@ void empathy_import_mc4_accounts (void) g_clear_error (&error); } - g_slist_free (dirs); g_object_unref (client); } diff --git a/src/empathy-import-mc4-accounts.h b/src/empathy-import-mc4-accounts.h index fcc5118cf..e5392db67 100644 --- a/src/empathy-import-mc4-accounts.h +++ b/src/empathy-import-mc4-accounts.h @@ -24,8 +24,10 @@ G_BEGIN_DECLS -void empathy_import_mc4_accounts (void); +#include + +void empathy_import_mc4_accounts (EmpathyConnectionManagers *managers); G_END_DECLS -#endif /* __EMPATHY_IMPORT_MC4_ACCOUNTS_H__ */ \ No newline at end of file +#endif /* __EMPATHY_IMPORT_MC4_ACCOUNTS_H__ */ -- cgit v1.2.3 From f4cd87f5aba95e2c20cb4af10f9de8e1d62b3702 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 18:16:24 +0100 Subject: Grab passwords from the keyring if needed --- src/empathy-import-mc4-accounts.c | 47 ++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index eea3b7f18..614c5cbe3 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -172,7 +173,35 @@ _get_protocol_from_profile (const gchar *profile) } static void -_handle_entry (EmpathyAccountSettings *settings, +_set_password_from_keyring (EmpathyAccountSettings *settings, + const gchar *account_name, const gchar *key) +{ + GnomeKeyringResult res; + gchar *password; + GnomeKeyringPasswordSchema keyring_schema = { + GNOME_KEYRING_ITEM_GENERIC_SECRET, + { + { "account", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, + { "param", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, + { NULL, 0 } + } + }; + + res = gnome_keyring_find_password_sync (&keyring_schema, + &password, + "account", account_name, + "param", key, + NULL); + + if (res == GNOME_KEYRING_RESULT_OK) + { + empathy_account_settings_set_string (settings, key, password); + gnome_keyring_free_password (password); + } +} + +static void +_handle_entry (EmpathyAccountSettings *settings, const gchar *account_name, const gchar *key, GConfEntry *entry) { @@ -206,7 +235,13 @@ _handle_entry (EmpathyAccountSettings *settings, const gchar *v = gconf_value_get_string ( gconf_entry_get_value (entry)); - empathy_account_settings_set_string (settings, key, v); + /* MC 4 would put password in the keyring and leave the password in + * gconf keyring */ + + if (!tp_strdiff (key, "password") && !tp_strdiff (v, "keyring")) + _set_password_from_keyring (settings, account_name, key); + else + empathy_account_settings_set_string (settings, key, v); break; } case DBUS_TYPE_BOOLEAN: @@ -223,7 +258,8 @@ _handle_entry (EmpathyAccountSettings *settings, } static void -_recurse_account (GSList *entries, EmpathyAccountSettings *settings) +_recurse_account (GSList *entries, EmpathyAccountSettings *settings, + const gchar *account_name) { GSList *tmp; @@ -238,7 +274,8 @@ _recurse_account (GSList *entries, EmpathyAccountSettings *settings) if (g_str_has_prefix (param, "param-")) { - _handle_entry (settings, param + strlen ("param-"), entry); + _handle_entry (settings, account_name, param + strlen ("param-"), + entry); } g_free (param); @@ -306,7 +343,7 @@ import_one_account (const char *path, goto failed; } - _recurse_account (entries, settings); + _recurse_account (entries, settings, account_name); key = g_strdup_printf ("%s/enabled", path); enabled = gconf_client_get_bool (client, key, NULL); -- cgit v1.2.3 From afd7de0052654752aa60edc8dddfd628eaa49ce6 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 18:24:46 +0100 Subject: Return TRUE if we imported any mc4 accounts --- src/empathy-import-mc4-accounts.c | 30 +++++++++++++++++++----------- src/empathy-import-mc4-accounts.h | 2 +- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 614c5cbe3..5425b35cd 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -283,7 +283,7 @@ _recurse_account (GSList *entries, EmpathyAccountSettings *settings, } } -static void +static gboolean import_one_account (const char *path, EmpathyConnectionManagers *managers, GConfClient *client) @@ -298,6 +298,7 @@ import_one_account (const char *path, gchar *display_name; gchar *key; gboolean enabled = FALSE; + gboolean ret = FALSE; DEBUG ("Starting import of %s (%s)", path, account_name); @@ -350,12 +351,15 @@ import_one_account (const char *path, g_free (key); empathy_account_settings_apply_async (settings, _create_account_cb, GINT_TO_POINTER (enabled)); + ret = TRUE; + out: g_free (protocol); g_free (profile); g_slist_free (entries); g_free (account_name); - return; + + return ret; failed: DEBUG ("Failed to import %s", path); @@ -364,15 +368,17 @@ failed: goto out; } -void +gboolean empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) { GConfClient *client; GError *error = NULL; - GSList *dir, *dirs; + GSList *dir, *dirs = NULL; gboolean imported_mc4_accounts; + gboolean imported = FALSE; - g_return_if_fail (empathy_connection_managers_is_ready (managers)); + g_return_val_if_fail (empathy_connection_managers_is_ready (managers), + FALSE); client = gconf_client_get_default (); @@ -384,14 +390,13 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) DEBUG ("Failed to get import_mc4_accounts key: %s\n", error->message); g_clear_error (&error); g_object_unref (client); - return; + goto out; } if (imported_mc4_accounts) { DEBUG ("Mc4 accounts already imported"); - g_object_unref (client); - return; + goto out; } DEBUG ("MC 4 accounts are going to be imported\n"); @@ -404,15 +409,15 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) error->message); g_clear_error (&error); g_object_unref (client); - return; + goto out; } for (dir = dirs; NULL != dir; dir = dir->next) { - import_one_account ((gchar *)dir->data, managers, client); + if (import_one_account ((gchar *)dir->data, managers, client)) + imported = TRUE; g_free (dir->data); } - g_slist_free (dirs); gconf_client_set_bool (client, IMPORTED_MC4_ACCOUNTS, TRUE, &error); @@ -423,5 +428,8 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) g_clear_error (&error); } +out: + g_slist_free (dirs); g_object_unref (client); + return imported; } diff --git a/src/empathy-import-mc4-accounts.h b/src/empathy-import-mc4-accounts.h index e5392db67..c30b4e505 100644 --- a/src/empathy-import-mc4-accounts.h +++ b/src/empathy-import-mc4-accounts.h @@ -26,7 +26,7 @@ G_BEGIN_DECLS #include -void empathy_import_mc4_accounts (EmpathyConnectionManagers *managers); +gboolean empathy_import_mc4_accounts (EmpathyConnectionManagers *managers); G_END_DECLS -- cgit v1.2.3 From 9d3432812718541748315d119b22960c190a2ffd Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 18:45:13 +0100 Subject: Add api to ask if we have importer our mc4 accounts --- src/empathy-import-mc4-accounts.c | 14 ++++++++++++++ src/empathy-import-mc4-accounts.h | 1 + 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 5425b35cd..27dd94956 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -368,6 +368,20 @@ failed: goto out; } +gboolean +empathy_import_mc4_has_imported (void) +{ + GConfClient *client; + gboolean ret; + + client = gconf_client_get_default (); + + ret = gconf_client_get_bool (client, IMPORTED_MC4_ACCOUNTS, NULL); + g_object_unref (client); + + return ret; +} + gboolean empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) { diff --git a/src/empathy-import-mc4-accounts.h b/src/empathy-import-mc4-accounts.h index c30b4e505..98fb86916 100644 --- a/src/empathy-import-mc4-accounts.h +++ b/src/empathy-import-mc4-accounts.h @@ -27,6 +27,7 @@ G_BEGIN_DECLS #include gboolean empathy_import_mc4_accounts (EmpathyConnectionManagers *managers); +gboolean empathy_import_mc4_has_imported (void); G_END_DECLS -- cgit v1.2.3 From 3cdcb21a13d11a2026d242c242704b0581a7b475 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 18:52:17 +0100 Subject: Fix debug strings, don't unref the gconf client twice --- src/empathy-import-mc4-accounts.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 27dd94956..312b5a2fc 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -402,14 +402,13 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) if (error != NULL) { DEBUG ("Failed to get import_mc4_accounts key: %s\n", error->message); - g_clear_error (&error); - g_object_unref (client); + g_error_free (error); goto out; } if (imported_mc4_accounts) { - DEBUG ("Mc4 accounts already imported"); + DEBUG ("Mc4 accounts previously imported"); goto out; } @@ -419,7 +418,7 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) if (error != NULL) { - DEBUG ("Failed to get mc_accounts_gconf_base dirs: %s\n", + DEBUG ("Failed to get MC4 account dirs: %s\n", error->message); g_clear_error (&error); g_object_unref (client); -- cgit v1.2.3 From 97ce0c3a078943c1c25ad8e2411482ffc9edc8c8 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 18:53:33 +0100 Subject: Always set the mc4 imported gconf key --- src/empathy-import-mc4-accounts.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 312b5a2fc..6f2a02c83 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -432,16 +432,9 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) g_free (dir->data); } - gconf_client_set_bool (client, - IMPORTED_MC4_ACCOUNTS, TRUE, &error); - - if (error != NULL) - { - DEBUG ("Failed to set import_mc4_accounts key: %s\n", error->message); - g_clear_error (&error); - } - out: + gconf_client_set_bool (client, IMPORTED_MC4_ACCOUNTS, TRUE, NULL); + g_slist_free (dirs); g_object_unref (client); return imported; -- cgit v1.2.3 From 96ae3367ff3aca2ef4c33e7e1f4790c7d5cc6fe3 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 18:55:54 +0100 Subject: Refactor the startup sequence a bit On initial start the following should happen: * If we haven't tried to import mc4 accounts, do so * If there were no mc4 accounts imported and there are no accounts defined show the account creation assistant. * If we haven't created a salut account, do so --- src/empathy.c | 67 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/empathy.c b/src/empathy.c index a80d39684..38fd56c54 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -323,39 +323,41 @@ create_salut_account_if_needed (EmpathyConnectionManagers *managers) } static void -connection_managers_ready_cb (EmpathyConnectionManagers *managers, - GParamSpec *spec, - gpointer user_data) +maybe_show_account_assistant (void) { - if (empathy_connection_managers_is_ready (managers)) + EmpathyAccountManager *manager; + manager = empathy_account_manager_dup_singleton (); + + if (empathy_account_manager_get_count (manager) == 0) { - empathy_import_mc4_accounts (); - create_salut_account_if_needed (managers); - g_object_unref (managers); - managers = NULL; + GtkWidget * assistant = empathy_account_assistant_new ( + GTK_WINDOW (empathy_main_window_get ())); + gtk_window_present (GTK_WINDOW (assistant)); } } -static void -create_salut_account (void) +static gboolean +check_connection_managers_ready (EmpathyConnectionManagers *managers) { - EmpathyConnectionManagers *managers; - - if (!should_create_salut_account ()) - return; - - managers = empathy_connection_managers_dup_singleton (); - if (empathy_connection_managers_is_ready (managers)) { + if (!empathy_import_mc4_accounts (managers)) + maybe_show_account_assistant (); + create_salut_account_if_needed (managers); g_object_unref (managers); + managers = NULL; + return TRUE; } - else - { - g_signal_connect (managers, "notify::ready", - G_CALLBACK (connection_managers_ready_cb), NULL); - } + return FALSE; +} + +static void +connection_managers_ready_cb (EmpathyConnectionManagers *managers, + GParamSpec *spec, + gpointer user_data) +{ + check_connection_managers_ready (managers); } static void @@ -536,19 +538,24 @@ account_manager_ready_cb (EmpathyAccountManager *manager, GParamSpec *spec, gpointer user_data) { - GtkWidget *assistant; - if (!empathy_account_manager_is_ready (manager)) return; - if (empathy_account_manager_get_count (manager) == 0) + if (should_create_salut_account () || !empathy_import_mc4_has_imported ()) { - assistant = empathy_account_assistant_new ( - GTK_WINDOW (empathy_main_window_get ())); - gtk_window_present (GTK_WINDOW (assistant)); - } + EmpathyConnectionManagers *managers; + managers = empathy_connection_managers_dup_singleton (); - create_salut_account (); + if (!check_connection_managers_ready (managers)) + { + g_signal_connect (managers, "notify::ready", + G_CALLBACK (connection_managers_ready_cb), NULL); + } + } + else + { + maybe_show_account_assistant (); + } } int -- cgit v1.2.3 From 35d058ac2d105c9c77aa378e4dc4a9e7abae8597 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 22:43:14 +0100 Subject: Move the logs to the new location after creating the account --- src/empathy-import-mc4-accounts.c | 96 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 6f2a02c83..df4668720 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,11 @@ static ProfileProtocolMapItem profile_protocol_map[] = { "sofiasip", "sip" }, }; +typedef struct { + gchar *account_name; + gboolean enable; +} Misc; + static gchar * _account_name_from_key (const gchar *key) { @@ -131,6 +137,76 @@ out: return cm != NULL ? tp_connection_manager_get_name (cm) : NULL; } +static void +_move_contents (const gchar *old, const gchar *new) +{ + GDir *source; + const gchar *f; + int ret; + + ret = g_mkdir_with_parents (new, 0777); + if (ret == -1) + return; + + source = g_dir_open (old, 0, NULL); + if (source == NULL) + return; + + while ((f = g_dir_read_name (source)) != NULL) + { + gchar *old_path; + gchar *new_path; + + old_path = g_build_path (G_DIR_SEPARATOR_S, old, f, NULL); + new_path = g_build_path (G_DIR_SEPARATOR_S, new, f, NULL); + + if (g_file_test (old_path, G_FILE_TEST_IS_DIR)) + { + _move_contents (old_path, new_path); + } + else + { + GFile *f_old, *f_new; + + f_old = g_file_new_for_path (old_path); + f_new = g_file_new_for_path (new_path); + + g_file_move (f_old, f_new, G_FILE_COPY_NONE, + NULL, NULL, NULL, NULL); + + g_object_unref (f_old); + g_object_unref (f_new); + } + + g_free (old_path); + g_free (new_path); + } + + g_dir_close (source); +} + +static void +_move_logs (EmpathyAccount *account, const gchar *account_name) +{ + gchar *old_path, *new_path, *escaped; + const gchar *name; + + name = empathy_account_get_unique_name (account); + if (g_str_has_prefix (name, TP_ACCOUNT_OBJECT_PATH_BASE)) + name += strlen (TP_ACCOUNT_OBJECT_PATH_BASE); + + escaped = g_strdelimit (g_strdup (name), "/", '_'); + new_path = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), + PACKAGE_NAME, "logs", escaped, NULL); + g_free (escaped); + + old_path = g_build_path (G_DIR_SEPARATOR_S, + g_get_home_dir (), + ".gnome2", PACKAGE_NAME, "logs", account_name, NULL); + + _move_contents (old_path, new_path); +} + static void _create_account_cb (GObject *source, GAsyncResult *result, @@ -138,6 +214,7 @@ _create_account_cb (GObject *source, { EmpathyAccount *account; GError *error = NULL; + Misc *misc = (Misc *)user_data; if (!empathy_account_settings_apply_finish ( EMPATHY_ACCOUNT_SETTINGS (source), result, &error)) @@ -151,8 +228,14 @@ _create_account_cb (GObject *source, DEBUG ("account created\n"); account = empathy_account_settings_get_account ( EMPATHY_ACCOUNT_SETTINGS (source)); + + _move_logs (account, misc->account_name); + empathy_account_set_enabled_async (account, - GPOINTER_TO_INT (user_data), NULL, NULL); + misc->enable, NULL, NULL); + + g_free (misc->account_name); + g_slice_free (Misc, misc); out: g_object_unref (source); @@ -299,6 +382,7 @@ import_one_account (const char *path, gchar *key; gboolean enabled = FALSE; gboolean ret = FALSE; + Misc *misc; DEBUG ("Starting import of %s (%s)", path, account_name); @@ -338,7 +422,6 @@ import_one_account (const char *path, if (entries == NULL) { - DEBUG ("Failed to get all entries: %s\n", error->message); g_error_free (error); goto failed; @@ -349,20 +432,25 @@ import_one_account (const char *path, key = g_strdup_printf ("%s/enabled", path); enabled = gconf_client_get_bool (client, key, NULL); g_free (key); + + misc = g_slice_new (Misc); + misc->account_name = account_name; + misc->enable = enabled; + empathy_account_settings_apply_async (settings, - _create_account_cb, GINT_TO_POINTER (enabled)); + _create_account_cb, misc); ret = TRUE; out: g_free (protocol); g_free (profile); g_slist_free (entries); - g_free (account_name); return ret; failed: DEBUG ("Failed to import %s", path); + g_free (account_name); if (settings != NULL) g_object_unref (settings); goto out; -- cgit v1.2.3 From 6d77d369532c3806c8bba9ab2374d7b795657c0d Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 22:50:36 +0100 Subject: Fix some broken english --- src/empathy-import-mc4-accounts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index df4668720..c9a0bf238 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -116,7 +116,7 @@ _get_manager_for_protocol (EmpathyConnectionManagers *managers, { TpConnectionManager *tp_cm = l->data; - /* Only use haze if no other cm provides this account */ + /* Only use haze if no other cm provides this protocol */ if (!tp_strdiff (tp_connection_manager_get_name (tp_cm), "haze")) { haze = tp_cm; -- cgit v1.2.3 From 93e0d79fad604f7b0494f738f65cd5c6c46ecc8c Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 22:51:02 +0100 Subject: Fix copyright date --- src/empathy-import-mc4-accounts.c | 2 +- src/empathy-import-mc4-accounts.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index c9a0bf238..53063d6c2 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2009 Collabora Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/src/empathy-import-mc4-accounts.h b/src/empathy-import-mc4-accounts.h index 98fb86916..0a30fdff7 100644 --- a/src/empathy-import-mc4-accounts.h +++ b/src/empathy-import-mc4-accounts.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2009 Collabora Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as -- cgit v1.2.3 From 81ad518058d0ae188c1dc229c55d6c8f71f84dbe Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 22:51:32 +0100 Subject: Fix use after free --- src/empathy-import-mc4-accounts.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 53063d6c2..602cfc1f9 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -85,13 +85,16 @@ _param_name_from_key (const gchar *key) { const gchar *base, *slash; gchar *account_name; + gchar *ret; account_name = _account_name_from_key (key); base = strstr (key, account_name); slash = strchr (base, '/'); + + ret = g_strdup (slash+1); g_free (account_name); - return g_strdup (slash+1); + return ret; } static gchar * -- cgit v1.2.3 From 05deeddf094d51dfdfc6133850f40e3e1d5591ca Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 22:51:52 +0100 Subject: Put string up for translation --- src/empathy-import-mc4-accounts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index 602cfc1f9..c4ceb2f4b 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -103,7 +103,7 @@ _create_default_display_name (const gchar *protocol) if (!tp_strdiff (protocol, "local-xmpp")) return g_strdup (_("People Nearby")); - return g_strdup_printf ("%s account", protocol); + return g_strdup_printf (_("%s account"), protocol); } static const gchar * -- cgit v1.2.3 From 74bba154cc8476d831140e27148d4897633e2d18 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 23 Aug 2009 22:52:40 +0100 Subject: When empathy_account_settings_apply_finish returns false the error is always set --- src/empathy-import-mc4-accounts.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index c4ceb2f4b..a7a08ea84 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -222,8 +222,7 @@ _create_account_cb (GObject *source, if (!empathy_account_settings_apply_finish ( EMPATHY_ACCOUNT_SETTINGS (source), result, &error)) { - DEBUG ("Failed to create account: %s", - error ? error->message : "No error given"); + DEBUG ("Failed to create account: %s", error->message); g_error_free (error); goto out; } -- cgit v1.2.3 From f421f61bb5e2ef7e8067b5874e0230961be389d5 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 24 Aug 2009 11:35:00 +0100 Subject: Fix several coding style issues --- src/empathy-import-mc4-accounts.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index a7a08ea84..968293bd2 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -217,7 +217,7 @@ _create_account_cb (GObject *source, { EmpathyAccount *account; GError *error = NULL; - Misc *misc = (Misc *)user_data; + Misc *misc = (Misc *) user_data; if (!empathy_account_settings_apply_finish ( EMPATHY_ACCOUNT_SETTINGS (source), result, &error)) @@ -354,7 +354,7 @@ _recurse_account (GSList *entries, EmpathyAccountSettings *settings, GConfEntry *entry; gchar *param; - entry = (GConfEntry*) tmp->data; + entry = (GConfEntry *) tmp->data; param = _param_name_from_key (gconf_entry_get_key (entry)); if (g_str_has_prefix (param, "param-")) @@ -517,7 +517,7 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers) for (dir = dirs; NULL != dir; dir = dir->next) { - if (import_one_account ((gchar *)dir->data, managers, client)) + if (import_one_account ((gchar *) dir->data, managers, client)) imported = TRUE; g_free (dir->data); } -- cgit v1.2.3 From cdf5ef7743814ca18104d5dba1a04e79a3554d0e Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 24 Aug 2009 12:01:52 +0100 Subject: empathy-accounts-dialog: remove the hardcoded Gmail label --- src/empathy-accounts-dialog.ui | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.ui b/src/empathy-accounts-dialog.ui index cd98415d7..e5226b270 100644 --- a/src/empathy-accounts-dialog.ui +++ b/src/empathy-accounts-dialog.ui @@ -80,7 +80,6 @@ True True - Gmail True -- cgit v1.2.3