[gnome-control-center] color: Add a popup menu for advanced users that want to set the system default



commit 24b2d2534ef97ff13004500e62cbc8cfb58548f8
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jun 21 13:25:32 2011 +0100

    color: Add a popup menu for advanced users that want to set the system default
    
    A menu popup was the best thing we could find after discussing it on
    If anybody has any better ideas then please shout / send patches.
    
    To show the menu, press the context menu key on the keyboard.

 panels/color/cc-color-panel.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/panels/color/cc-color-panel.c b/panels/color/cc-color-panel.c
index 9ca6e75..d7c8866 100644
--- a/panels/color/cc-color-panel.c
+++ b/panels/color/cc-color-panel.c
@@ -143,6 +143,36 @@ out:
     g_object_unref (profile);
 }
 
+static void
+gcm_prefs_treeview_popup_menu (CcColorPanel *prefs, GtkWidget *treeview)
+{
+  GtkWidget *menu, *menuitem;
+
+  menu = gtk_menu_new ();
+
+  /* TRANSLATORS: this is when the profile should be set for all users */
+  menuitem = gtk_menu_item_new_with_label (_("Set for all users"));
+  g_signal_connect (menuitem, "activate",
+                    G_CALLBACK (gcm_prefs_default_cb),
+                    prefs);
+
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+  gtk_widget_show_all (menu);
+
+  /* Note: gdk_event_get_time() accepts a NULL argument */
+  gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0,
+                  gdk_event_get_time (NULL));
+}
+
+static gboolean
+gcm_prefs_treeview_popup_menu_cb (GtkWidget *treeview, CcColorPanel *prefs)
+{
+  if (prefs->priv->current_device == NULL)
+    return FALSE;
+  gcm_prefs_treeview_popup_menu (prefs, treeview);
+  return TRUE; /* we handled this */
+}
+
 static GFile *
 gcm_prefs_file_chooser_get_icc_profile (CcColorPanel *prefs)
 {
@@ -2125,6 +2155,9 @@ cc_color_panel_init (CcColorPanel *prefs)
   g_signal_connect (GTK_TREE_VIEW (widget), "row-activated",
                     G_CALLBACK (gcm_prefs_treeview_row_activated_cb),
                     prefs);
+  g_signal_connect (GTK_TREE_VIEW (widget), "popup-menu",
+                    G_CALLBACK (gcm_prefs_treeview_popup_menu_cb),
+                    prefs);
 
   /* add columns to the tree view */
   gcm_prefs_add_devices_columns (prefs, GTK_TREE_VIEW (widget));



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