[empathy] account-dialog: add 'Rename' item to the context menu



commit 7e7a112250b3b22190f8e50f5e34d2cafb60da49
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Mar 30 14:37:27 2012 +0200

    account-dialog: add 'Rename' item to the context menu
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673159

 src/empathy-accounts-dialog.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 8a08c4a..b146f38 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -1733,6 +1733,30 @@ accounts_dialog_treeview_enabled_cb (GtkMenuItem *item,
   enable_and_connect_account (account, !enabled);
 }
 
+static void
+accounts_dialog_treeview_rename_cb (GtkMenuItem *item,
+    EmpathyAccountsDialog *self)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (self);
+  GtkTreePath *path;
+  GtkTreeIter iter;
+  GtkTreeSelection *selection;
+  GtkTreeModel *model;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+    return;
+  path = gtk_tree_model_get_path (model, &iter);
+
+  g_object_set (G_OBJECT (priv->name_renderer), "editable", TRUE, NULL);
+
+  gtk_widget_grab_focus (GTK_WIDGET (priv->treeview));
+  gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path,
+      gtk_tree_view_get_column (GTK_TREE_VIEW (priv->treeview), 0), TRUE);
+
+  gtk_tree_path_free (path);
+}
+
 static gboolean
 accounts_dialog_treeview_button_press_event_cb (GtkTreeView *view,
     GdkEventButton *event,
@@ -1790,6 +1814,15 @@ accounts_dialog_treeview_button_press_event_cb (GtkTreeView *view,
 
   gtk_widget_show (item);
 
+  /* Menu item: Rename */
+  item = gtk_menu_item_new_with_mnemonic (_("Rename"));
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+  tp_g_signal_connect_object (item, "activate",
+      G_CALLBACK (accounts_dialog_treeview_rename_cb), dialog, 0);
+
+  gtk_widget_show (item);
+
   /* FIXME: Add here presence items, to be able to set per-account presence */
 
   /* Popup menu */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]