[gnome-control-center] Add a lockbutton to the toolbar



commit e5072232eee59afb923a270e7d9d5fb786caa7d0
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 20 21:27:09 2011 -0400

    Add a lockbutton to the toolbar
    
    And populate it from the get_permission method added earlier.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=650292

 shell/gnome-control-center.c |   30 +++++++++++++++++++++++++++++-
 shell/shell.ui               |   26 +++++++++++++++++++-------
 2 files changed, 48 insertions(+), 8 deletions(-)
---
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index b577bf0..4ffaf92 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -60,6 +60,7 @@ struct _GnomeControlCenterPrivate
   GtkWidget  *scrolled_window;
   GtkWidget  *window;
   GtkWidget  *search_entry;
+  GtkWidget  *lock_button;
 
   GMenuTree  *menu_tree;
   GtkListStore *store;
@@ -129,6 +130,9 @@ activate_panel (GnomeControlCenter *shell,
           /* create the panel plugin */
           panel = g_object_new (panel_type, "shell", shell, NULL);
 
+          gtk_lock_button_set_permission (GTK_LOCK_BUTTON (priv->lock_button),
+                                          cc_panel_get_permission (CC_PANEL (panel)));
+
           box = gtk_alignment_new (0, 0, 1, 1);
           gtk_alignment_set_padding (GTK_ALIGNMENT (box), 6, 6, 6, 6);
 
@@ -176,6 +180,8 @@ shell_show_overview_page (GnomeControlCenterPrivate *priv)
   priv->filter_string = g_strdup ("");
   gtk_entry_set_text (GTK_ENTRY (priv->search_entry), "");
 
+  gtk_lock_button_set_permission (GTK_LOCK_BUTTON (priv->lock_button), NULL);
+
   /* reset window title and icon */
   gtk_window_set_title (GTK_WINDOW (priv->window), priv->default_window_title);
   gtk_window_set_default_icon_name (priv->default_window_icon);
@@ -528,7 +534,6 @@ setup_search (GnomeControlCenter *shell)
   search_scrolled = W (priv->builder, "search-scrolled-window");
   gtk_container_add (GTK_CONTAINER (search_scrolled), search_view);
 
-
   /* add the custom renderer */
   priv->search_renderer = (GtkCellRenderer*) shell_search_renderer_new ();
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (search_view),
@@ -558,6 +563,26 @@ setup_search (GnomeControlCenter *shell)
 }
 
 static void
+permission_changed_cb (GtkWidget *button, GParamSpec *pspec, gpointer data)
+{
+  if (gtk_lock_button_get_permission (GTK_LOCK_BUTTON (button)) != NULL)
+    gtk_widget_show (button);
+  else
+    gtk_widget_hide (button);
+}
+
+static void
+setup_lock (GnomeControlCenter *shell)
+{
+  GnomeControlCenterPrivate *priv = shell->priv;
+
+  priv->lock_button = W (priv->builder, "lock-button");
+
+  g_signal_connect (priv->lock_button, "notify::permission",
+                    G_CALLBACK (permission_changed_cb), NULL);
+}
+
+static void
 maybe_add_category_view (GnomeControlCenter *shell,
                          const char         *name)
 {
@@ -713,6 +738,7 @@ notebook_switch_page_cb (GtkNotebook               *book,
     {
       gtk_widget_hide (W (priv->builder, "home-button"));
       gtk_widget_show (W (priv->builder, "search-entry"));
+      gtk_widget_hide (W (priv->builder, "lock-button"));
     }
   else
     {
@@ -1067,6 +1093,8 @@ gnome_control_center_init (GnomeControlCenter *self)
   /* setup search functionality */
   setup_search (self);
 
+  setup_lock (self);
+
   /* store default window title and name */
   priv->default_window_title = g_strdup (gtk_window_get_title (GTK_WINDOW (priv->window)));
   priv->default_window_icon = g_strdup (gtk_window_get_icon_name (GTK_WINDOW (priv->window)));
diff --git a/shell/shell.ui b/shell/shell.ui
index 7bb627d..5575769 100644
--- a/shell/shell.ui
+++ b/shell/shell.ui
@@ -52,14 +52,26 @@
                             <property name="xalign">1</property>
                             <property name="xscale">0</property>
                             <child>
-                              <object class="GtkEntry" id="search-entry">
-                                <property name="width_request">210</property>
+                              <object class="GtkBox" id="topright">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="invisible_char">&#x25CF;</property>
-                                <property name="secondary-icon-name">edit-find-symbolic</property>
-                                <property name="secondary-icon-activatable">False</property>
-                                <property name="secondary-icon-sensitive">False</property>
+                                <property name="orientation">horizontal</property>
+                                <child>
+                                  <object class="GtkEntry" id="search-entry">
+                                    <property name="width_request">210</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">&#x25CF;</property>
+                                    <property name="secondary-icon-name">edit-find-symbolic</property>
+                                    <property name="secondary-icon-activatable">False</property>
+                                    <property name="secondary-icon-sensitive">False</property>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkLockButton" id="lock-button">
+                                    <property name="visible">False</property>
+                                    <property name="no_show_all">True</property>
+                                  </object>
+                                </child>
                               </object>
                             </child>
                           </object>



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