]> git.0d.be Git - empathy.git/commitdiff
Click on the treeview to edit the name of an account. Fixes bug #459166.
authorXavier Claessens <xclaesse@gmail.com>
Thu, 2 Aug 2007 19:25:13 +0000 (19:25 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Thu, 2 Aug 2007 19:25:13 +0000 (19:25 +0000)
2007-08-02 Xavier Claessens  <xclaesse@gmail.com>

* libempathy-gtk/empathy-accounts-dialog.glade:
* libempathy-gtk/empathy-accounts-dialog.c: Click on the treeview to
edit the name of an account. Fixes bug #459166.

svn path=/trunk/; revision=229

ChangeLog
libempathy-gtk/empathy-accounts-dialog.c
libempathy-gtk/empathy-accounts-dialog.glade

index 213e057d398c0df15ee34b338c4c683d8b588ea2..62e08355eb2817bafd342bf7c58eca45f92ab64d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-08-02 Xavier Claessens  <xclaesse@gmail.com>
+
+       * libempathy-gtk/empathy-accounts-dialog.glade:
+       * libempathy-gtk/empathy-accounts-dialog.c: Click on the treeview to
+       edit the name of an account. Fixes bug #459166.
+
 2007-08-02 Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy-gtk/empathy-account-widget-jabber.c: Do not try to guess
index 151922e270c621b94241c7e04dab016dfc44dc07..ca637651c4f0146c0ce22fc68428423c8b5fc2e2 100644 (file)
@@ -70,8 +70,7 @@ typedef struct {
 
        GtkWidget        *frame_new_account;
        GtkWidget        *combobox_profile;
-       GtkWidget        *entry_name;
-       GtkWidget        *table_new_account;
+       GtkWidget        *hbox_type;
        GtkWidget        *button_create;
        GtkWidget        *button_back;
 
@@ -131,8 +130,6 @@ static void       accounts_dialog_status_changed_cb         (MissionControl
                                                             TelepathyConnectionStatusReason  reason,
                                                             const gchar                     *unique_name,
                                                             EmpathyAccountsDialog            *dialog);
-static void       accounts_dialog_entry_name_changed_cb     (GtkWidget                       *widget,
-                                                            EmpathyAccountsDialog            *dialog);
 static void       accounts_dialog_button_create_clicked_cb  (GtkWidget                       *button,
                                                             EmpathyAccountsDialog            *dialog);
 static void       accounts_dialog_button_back_clicked_cb    (GtkWidget                       *button,
@@ -350,6 +347,32 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog)
        g_object_unref (store);
 }
 
+static void
+accounts_dialog_name_edited_cb (GtkCellRendererText   *renderer,
+                               gchar                 *path,
+                               gchar                 *new_text,
+                               EmpathyAccountsDialog *dialog)
+{
+       McAccount    *account;
+       GtkTreeModel *model;
+       GtkTreePath  *treepath;
+       GtkTreeIter   iter;
+
+       model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->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_list_store_set (GTK_LIST_STORE (model), &iter,
+                           COL_NAME, new_text,
+                           -1);
+       gtk_tree_path_free (treepath);
+
+       mc_account_set_display_name (account, new_text);
+       g_object_unref (account);
+}
+
 static void
 accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
 {
@@ -373,11 +396,17 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
                                                 NULL);
 
        cell = gtk_cell_renderer_text_new ();
-       g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+       g_object_set (cell,
+                     "ellipsize", PANGO_ELLIPSIZE_END,
+                     "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);
 
        gtk_tree_view_column_set_expand (column, TRUE);
        gtk_tree_view_append_column (view, column);
@@ -750,16 +779,6 @@ accounts_dialog_status_changed_cb (MissionControl                  *mc,
        gtk_widget_show (dialog->window);
 }
 
-static void          
-accounts_dialog_entry_name_changed_cb (GtkWidget             *widget,
-                                      EmpathyAccountsDialog  *dialog)
-{
-       const gchar *str;
-       
-       str = gtk_entry_get_text (GTK_ENTRY (widget));
-       gtk_widget_set_sensitive (dialog->button_create, !G_STR_EMPTY (str));
-}
-
 static void
 accounts_dialog_button_create_clicked_cb (GtkWidget             *button,
                                          EmpathyAccountsDialog  *dialog)
@@ -778,7 +797,7 @@ accounts_dialog_button_create_clicked_cb (GtkWidget             *button,
        /* Create account */
        account = mc_account_create (profile);
 
-       str = gtk_entry_get_text (GTK_ENTRY (dialog->entry_name));
+       str = mc_account_get_unique_name (account);
        mc_account_set_display_name (account, str);
 
        accounts_dialog_add_account (dialog, account);
@@ -826,8 +845,7 @@ accounts_dialog_button_add_clicked_cb (GtkWidget            *button,
        gtk_widget_show (dialog->frame_new_account);
 
        gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_profile), 0);
-       gtk_entry_set_text (GTK_ENTRY (dialog->entry_name), "");
-       gtk_widget_grab_focus (dialog->entry_name);
+       gtk_widget_grab_focus (dialog->combobox_profile);
 }
 
 static void
@@ -976,8 +994,7 @@ empathy_accounts_dialog_show (GtkWindow *parent)
                                       "dialog-action_area", &bbox,
                                       "treeview", &dialog->treeview,
                                       "frame_new_account", &dialog->frame_new_account,
-                                      "entry_name", &dialog->entry_name,
-                                      "table_new_account", &dialog->table_new_account,
+                                      "hbox_type", &dialog->hbox_type,
                                       "button_create", &dialog->button_create,
                                       "button_back", &dialog->button_back,
                                       "image_type", &dialog->image_type,
@@ -993,7 +1010,6 @@ empathy_accounts_dialog_show (GtkWindow *parent)
                              "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,
-                             "entry_name", "changed", accounts_dialog_entry_name_changed_cb,
                              "treeview", "row-activated", accounts_dialog_treeview_row_activated_cb,
                              "button_connect", "clicked", accounts_dialog_button_connect_clicked_cb,
                              "button_add", "clicked", accounts_dialog_button_add_clicked_cb,
@@ -1006,10 +1022,9 @@ empathy_accounts_dialog_show (GtkWindow *parent)
 
        /* Create profile chooser */
        dialog->combobox_profile = empathy_profile_chooser_new ();
-       gtk_table_attach_defaults (GTK_TABLE (dialog->table_new_account),
-                                  dialog->combobox_profile,
-                                  1, 2,
-                                  0, 1);
+       gtk_box_pack_end (GTK_BOX (dialog->hbox_type),
+                         dialog->combobox_profile,
+                         TRUE, TRUE, 0);
        gtk_widget_show (dialog->combobox_profile);
 
        /* Set up signalling */
index a61b57bd79708823c6b702be452d9887916eb1af..e2a8493e50fd6aedf28f6874af5e84d2ebf1b2d5 100644 (file)
                          <property name="spacing">12</property>
 
                          <child>
-                           <widget class="GtkTable" id="table_new_account">
+                           <widget class="GtkHBox" id="hbox_type">
                              <property name="visible">True</property>
-                             <property name="n_rows">2</property>
-                             <property name="n_columns">2</property>
                              <property name="homogeneous">False</property>
-                             <property name="row_spacing">6</property>
-                             <property name="column_spacing">6</property>
-
-                             <child>
-                               <widget class="GtkLabel" id="label640">
-                                 <property name="visible">True</property>
-                                 <property name="label" translatable="yes">_Type:</property>
-                                 <property name="use_underline">True</property>
-                                 <property name="use_markup">False</property>
-                                 <property name="justify">GTK_JUSTIFY_LEFT</property>
-                                 <property name="wrap">False</property>
-                                 <property name="selectable">False</property>
-                                 <property name="xalign">0</property>
-                                 <property name="yalign">0.5</property>
-                                 <property name="xpad">0</property>
-                                 <property name="ypad">0</property>
-                                 <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-                                 <property name="width_chars">-1</property>
-                                 <property name="single_line_mode">False</property>
-                                 <property name="angle">0</property>
-                               </widget>
-                               <packing>
-                                 <property name="left_attach">0</property>
-                                 <property name="right_attach">1</property>
-                                 <property name="top_attach">0</property>
-                                 <property name="bottom_attach">1</property>
-                                 <property name="x_options"></property>
-                                 <property name="y_options"></property>
-                               </packing>
-                             </child>
+                             <property name="spacing">6</property>
 
                              <child>
-                               <widget class="GtkLabel" id="label638">
+                               <widget class="GtkLabel" id="label645">
                                  <property name="visible">True</property>
-                                 <property name="label" translatable="yes">_Name:</property>
-                                 <property name="use_underline">True</property>
+                                 <property name="label" translatable="yes">Type:</property>
+                                 <property name="use_underline">False</property>
                                  <property name="use_markup">False</property>
                                  <property name="justify">GTK_JUSTIFY_LEFT</property>
                                  <property name="wrap">False</property>
                                  <property name="selectable">False</property>
-                                 <property name="xalign">0</property>
+                                 <property name="xalign">0.5</property>
                                  <property name="yalign">0.5</property>
                                  <property name="xpad">0</property>
                                  <property name="ypad">0</property>
-                                 <property name="mnemonic_widget">entry_name</property>
                                  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
                                  <property name="width_chars">-1</property>
                                  <property name="single_line_mode">False</property>
                                  <property name="angle">0</property>
                                </widget>
                                <packing>
-                                 <property name="left_attach">0</property>
-                                 <property name="right_attach">1</property>
-                                 <property name="top_attach">1</property>
-                                 <property name="bottom_attach">2</property>
-                                 <property name="x_options"></property>
-                                 <property name="y_options"></property>
+                                 <property name="padding">0</property>
+                                 <property name="expand">False</property>
+                                 <property name="fill">False</property>
                                </packing>
                              </child>
 
                              <child>
-                               <widget class="GtkEntry" id="entry_name">
-                                 <property name="visible">True</property>
-                                 <property name="tooltip" translatable="yes">A unique name for this account to identify it personally to you.</property>
-                                 <property name="can_focus">True</property>
-                                 <property name="editable">True</property>
-                                 <property name="visibility">True</property>
-                                 <property name="max_length">0</property>
-                                 <property name="text" translatable="yes"></property>
-                                 <property name="has_frame">True</property>
-                                 <property name="invisible_char">*</property>
-                                 <property name="activates_default">False</property>
-                               </widget>
-                               <packing>
-                                 <property name="left_attach">1</property>
-                                 <property name="right_attach">2</property>
-                                 <property name="top_attach">1</property>
-                                 <property name="bottom_attach">2</property>
-                                 <property name="y_options"></property>
-                               </packing>
+                               <placeholder/>
                              </child>
                            </widget>
                            <packing>
                              <child>
                                <widget class="GtkButton" id="button_create">
                                  <property name="visible">True</property>
-                                 <property name="sensitive">False</property>
                                  <property name="can_focus">True</property>
                                  <property name="relief">GTK_RELIEF_NORMAL</property>
                                  <property name="focus_on_click">True</property>