diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-12-23 01:46:43 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-12-26 02:06:48 +0800 |
commit | 153800e9804c5d032e5c8c6e1b15c3090e3c349a (patch) | |
tree | 45c27147a281b03283f1f818e7943d173b68a891 /src | |
parent | a748e3cf4d08a94a674b4f675dc3a0457ab7c4e9 (diff) | |
download | gsoc2013-empathy-153800e9804c5d032e5c8c6e1b15c3090e3c349a.tar gsoc2013-empathy-153800e9804c5d032e5c8c6e1b15c3090e3c349a.tar.gz gsoc2013-empathy-153800e9804c5d032e5c8c6e1b15c3090e3c349a.tar.bz2 gsoc2013-empathy-153800e9804c5d032e5c8c6e1b15c3090e3c349a.tar.lz gsoc2013-empathy-153800e9804c5d032e5c8c6e1b15c3090e3c349a.tar.xz gsoc2013-empathy-153800e9804c5d032e5c8c6e1b15c3090e3c349a.tar.zst gsoc2013-empathy-153800e9804c5d032e5c8c6e1b15c3090e3c349a.zip |
Remove the protocol selection screen when adding a new account
Instead, display the protocol chooser on the top of the account widget
(#599182).
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-accounts-dialog.c | 162 | ||||
-rw-r--r-- | src/empathy-accounts-dialog.ui | 157 |
2 files changed, 92 insertions, 227 deletions
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 08adadcbb..2c6ab617a 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -91,11 +91,8 @@ typedef struct { GtkWidget *button_add; GtkWidget *button_import; - GtkWidget *frame_new_account; GtkWidget *combobox_protocol; - GtkWidget *hbox_type; - GtkWidget *button_create; - GtkWidget *button_back; + GtkWidget *hbox_protocol; GtkWidget *image_type; GtkWidget *label_name; @@ -158,6 +155,12 @@ static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog); static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings); +static void accounts_dialog_add (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings); + +static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, + EmpathyAccountSettings *settings); + static void accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog, const gchar *display_name) @@ -475,52 +478,81 @@ accounts_dialog_has_pending_change (EmpathyAccountsDialog *dialog, } static void -accounts_dialog_protocol_changed_cb (GtkWidget *widget, - EmpathyAccountsDialog *dialog) +accounts_dialog_setup_ui_to_add_account (EmpathyAccountsDialog *dialog) { + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + EmpathyAccountSettings *settings; + gchar *str; + const gchar *display_name; TpConnectionManager *cm; TpConnectionManagerProtocol *proto; gboolean is_gtalk; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); cm = empathy_protocol_chooser_dup_selected ( EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto, &is_gtalk); - if (cm == NULL) return; - if (proto == NULL) - { - g_object_unref (cm); - return; - } + display_name = empathy_protocol_name_to_display_name ( + is_gtalk ? "gtalk" : proto->name); + + if (display_name == NULL) + display_name = proto->name; + + /* Create account */ + /* To translator: %s is the name of the protocol, such as "Google Talk" or + * "Yahoo!" + */ + str = g_strdup_printf (_("New %s account"), display_name); + settings = empathy_account_settings_new (cm->name, proto->name, str); + g_free (str); + + if (is_gtalk) + empathy_account_settings_set_icon_name_async (settings, "im-google-talk", + NULL, NULL); + + accounts_dialog_add (dialog, settings); + accounts_dialog_model_set_selected (dialog, settings); + + gtk_widget_show_all (priv->hbox_protocol); + + g_object_unref (settings); g_object_unref (cm); } static void -accounts_dialog_setup_ui_to_add_account (EmpathyAccountsDialog *dialog) +accounts_dialog_protocol_changed_cb (GtkWidget *widget, + EmpathyAccountsDialog *dialog) { - GtkTreeView *view; - GtkTreeModel *model; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + gboolean creating; - view = GTK_TREE_VIEW (priv->treeview); - model = gtk_tree_view_get_model (view); + /* The "changed" signal is fired during the initiation of the + * EmpathyProtocolChooser while populating the widget. Such signals should + * be ignored so we check if we are actually creating a new account. */ + if (priv->setting_widget_object == NULL) + return; - gtk_widget_set_sensitive (priv->button_add, FALSE); - gtk_widget_hide (priv->vbox_details); - gtk_widget_hide (priv->frame_no_protocol); - gtk_widget_show (priv->frame_new_account); + g_object_get (priv->setting_widget_object, + "creating-account", &creating, NULL); + if (!creating) + return; - /* 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); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); - gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox_protocol), 0); - gtk_widget_grab_focus (priv->combobox_protocol); + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return; + + /* We are creating a new widget to replace the current one, don't ask + * confirmation to the user. */ + priv->force_change_row = TRUE; + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); + + accounts_dialog_setup_ui_to_add_account (dialog); } static void @@ -670,7 +702,6 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, /* 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); return; @@ -678,10 +709,10 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog, /* 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_hide (priv->hbox_protocol); if (priv->settings_widget) { @@ -1459,60 +1490,6 @@ accounts_dialog_account_enabled_cb (TpAccountManager *manager, } static void -accounts_dialog_button_create_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) -{ - EmpathyAccountSettings *settings; - gchar *str; - const gchar *display_name; - TpConnectionManager *cm; - TpConnectionManagerProtocol *proto; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - gboolean is_gtalk; - - cm = empathy_protocol_chooser_dup_selected ( - EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto, &is_gtalk); - - display_name = empathy_protocol_name_to_display_name ( - is_gtalk ? "gtalk" : proto->name); - - if (display_name == NULL) - display_name = proto->name; - - /* Create account */ - /* To translator: %s is the name of the protocol, such as "Google Talk" or - * "Yahoo!" - */ - str = g_strdup_printf (_("New %s account"), display_name); - settings = empathy_account_settings_new (cm->name, proto->name, str); - - g_free (str); - - if (is_gtalk) - empathy_account_settings_set_icon_name_async (settings, "im-google-talk", - NULL, NULL); - - accounts_dialog_add (dialog, settings); - accounts_dialog_model_set_selected (dialog, settings); - - g_object_unref (settings); - g_object_unref (cm); -} - -static void -accounts_dialog_button_back_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) -{ - EmpathyAccountSettings *settings; - - settings = accounts_dialog_model_get_selected_settings (dialog); - accounts_dialog_update_settings (dialog, settings); - - if (settings) - g_object_unref (settings); -} - -static void accounts_dialog_button_help_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { @@ -1701,14 +1678,11 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) "alignment_settings", &priv->alignment_settings, "alignment_infobar", &priv->alignment_infobar, "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, "image_type", &priv->image_type, "label_name", &priv->label_name, "button_add", &priv->button_add, "button_import", &priv->button_import, + "hbox_protocol", &priv->hbox_protocol, NULL); g_free (filename); @@ -1716,8 +1690,6 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) "accounts_dialog", "response", accounts_dialog_response_cb, "accounts_dialog", "destroy", accounts_dialog_destroy_cb, "accounts_dialog", "delete-event", accounts_dialog_delete_event_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_help", "clicked", accounts_dialog_button_help_clicked_cb, "button_import", "clicked", accounts_dialog_button_import_clicked_cb, @@ -1728,17 +1700,11 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) #ifdef HAVE_MOBLIN action_area = gtk_dialog_get_action_area (GTK_DIALOG (priv->window)); gtk_widget_hide (action_area); - - /* Translators: this is used only when built on a moblin platform */ - gtk_button_set_label (GTK_BUTTON (priv->button_create), _("_Next")); - gtk_button_set_use_underline (GTK_BUTTON (priv->button_create), TRUE); #endif priv->combobox_protocol = empathy_protocol_chooser_new (); - gtk_box_pack_start (GTK_BOX (priv->hbox_type), - priv->combobox_protocol, + gtk_box_pack_start (GTK_BOX (priv->hbox_protocol), 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); diff --git a/src/empathy-accounts-dialog.ui b/src/empathy-accounts-dialog.ui index 58234a6a0..55bfa79f4 100644 --- a/src/empathy-accounts-dialog.ui +++ b/src/empathy-accounts-dialog.ui @@ -91,6 +91,31 @@ <property name="visible">True</property> <property name="spacing">18</property> <child> + <object class="GtkHBox" id="hbox_protocol"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label_protocol"> + <property name="visible">True</property> + <property name="label" translatable="yes">Protocol:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> <object class="GtkVBox" id="vbox_details"> <property name="visible">True</property> <property name="spacing">18</property> @@ -159,135 +184,6 @@ </child> </object> <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkFrame" id="frame_new_account"> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkAlignment" id="alignment29"> - <property name="visible">True</property> - <property name="top_padding">6</property> - <property name="left_padding">20</property> - <child> - <object class="GtkHBox" id="hbox181"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <object class="GtkButton" id="button_back"> - <property name="label">gtk-cancel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">end</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="button_create"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <object class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <child> - <object class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <object class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-new</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Cr_eate</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> - </object> - </child> - </object> - </child> - <child type="label"> - <object class="GtkHBox" id="hbox_add_account"> - <property name="visible">True</property> - <child> - <object class="GtkLabel" id="label643"> - <property name="visible">True</property> - <property name="label" translatable="yes">Add new</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="padding">5</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkHBox" id="hbox_type"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <placeholder/> - </child> - <child> - <object class="GtkLabel" id="label645"> - <property name="visible">True</property> - <property name="label" translatable="yes">account</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> <property name="position">1</property> </packing> </child> @@ -325,6 +221,9 @@ <property name="position">2</property> </packing> </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="position">1</property> |