[gnome-control-center] shell: Remove the lock button from the shell



commit c0f41daff0bcd6a1c243562cfcbd7408455e12d3
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Oct 12 09:57:17 2018 +1300

    shell: Remove the lock button from the shell
    
    Only the date time panel used it, all other panels add their own shell using
    cc_shell_embed_widget_in_header which was added after the date time panel was
    written. Update the date time panel to use this method.

 panels/datetime/cc-datetime-panel.c | 18 ++++++++++++------
 panels/datetime/datetime.ui         |  4 ++++
 shell/cc-panel.c                    | 11 -----------
 shell/cc-panel.h                    |  1 -
 shell/cc-window.c                   |  5 -----
 shell/cc-window.ui                  |  9 ---------
 6 files changed, 16 insertions(+), 32 deletions(-)
---
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 593815288..6a70928fb 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -103,6 +103,7 @@ struct _CcDateTimePanel
   GtkWidget *h_spinbutton;
   GtkWidget *listbox1;
   GtkWidget *listbox2;
+  GtkLockButton *lock_button;
   GtkWidget *m_spinbutton;
   GtkWidget *month_combobox;
   GtkListStore *month_liststore;
@@ -167,11 +168,14 @@ cc_date_time_panel_dispose (GObject *object)
   G_OBJECT_CLASS (cc_date_time_panel_parent_class)->dispose (object);
 }
 
-static GPermission *
-cc_date_time_panel_get_permission (CcPanel *panel)
+static void
+cc_date_time_panel_constructed (GObject *object)
 {
-  CcDateTimePanel *self = CC_DATE_TIME_PANEL (panel);
-  return self->permission;
+  CcDateTimePanel *self = CC_DATE_TIME_PANEL (object);
+
+  G_OBJECT_CLASS (cc_date_time_panel_parent_class)->constructed (object);
+
+  cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)), GTK_WIDGET (self->lock_button));
 }
 
 static const char *
@@ -1113,10 +1117,10 @@ cc_date_time_panel_class_init (CcDateTimePanelClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
 
+  object_class->constructed = cc_date_time_panel_constructed;
   object_class->dispose = cc_date_time_panel_dispose;
 
-  panel_class->get_permission = cc_date_time_panel_get_permission;
-  panel_class->get_help_uri   = cc_date_time_panel_get_help_uri;
+  panel_class->get_help_uri = cc_date_time_panel_get_help_uri;
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/datetime/datetime.ui");
 
@@ -1135,6 +1139,7 @@ cc_date_time_panel_class_init (CcDateTimePanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, h_spinbutton);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, listbox1);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, listbox2);
+  gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, lock_button);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, m_spinbutton);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, month_liststore);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, network_time_switch);
@@ -1222,6 +1227,7 @@ cc_date_time_panel_init (CcDateTimePanel *self)
       g_warning ("Your system does not have the '%s' PolicyKit files installed. Please check your 
installation",
                  DATETIME_PERMISSION);
     }
+  gtk_lock_button_set_permission (GTK_LOCK_BUTTON (self->lock_button), self->permission);
 
   self->location_settings = g_settings_new (LOCATION_SETTINGS);
   g_signal_connect (self->location_settings, "changed",
diff --git a/panels/datetime/datetime.ui b/panels/datetime/datetime.ui
index 8270c5990..5bdb24874 100644
--- a/panels/datetime/datetime.ui
+++ b/panels/datetime/datetime.ui
@@ -1,6 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.10 -->
+  <object class="GtkLockButton" id="lock_button">
+    <property name="visible">True</property>
+    <property name="can_focus">True</property>
+  </object>
   <object class="GtkListStore" id="city_liststore">
     <columns>
       <!-- column-name city-human-readable -->
diff --git a/shell/cc-panel.c b/shell/cc-panel.c
index 1fd13fa23..687bfa702 100644
--- a/shell/cc-panel.c
+++ b/shell/cc-panel.c
@@ -252,17 +252,6 @@ cc_panel_get_shell (CcPanel *panel)
   return priv->shell;
 }
 
-GPermission *
-cc_panel_get_permission (CcPanel *panel)
-{
-  CcPanelClass *class = CC_PANEL_GET_CLASS (panel);
-
-  if (class->get_permission)
-    return class->get_permission (panel);
-
-  return NULL;
-}
-
 const char *
 cc_panel_get_help_uri (CcPanel *panel)
 {
diff --git a/shell/cc-panel.h b/shell/cc-panel.h
index 5c705a4aa..a76f18a45 100644
--- a/shell/cc-panel.h
+++ b/shell/cc-panel.h
@@ -79,7 +79,6 @@ struct _CcPanelClass
   /*< private >*/
   GtkBinClass parent_class;
 
-  GPermission * (* get_permission) (CcPanel *panel);
   const char  * (* get_help_uri)   (CcPanel *panel);
 
   GtkWidget *   (* get_title_widget) (CcPanel *panel);
diff --git a/shell/cc-window.c b/shell/cc-window.c
index ad84d5273..3bda5456f 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -64,7 +64,6 @@ struct _CcWindow
   GtkWidget  *search_button;
   GtkWidget  *search_bar;
   GtkWidget  *search_entry;
-  GtkWidget  *lock_button;
   GtkWidget  *development_warning_dialog;
   GtkWidget  *current_panel;
   char       *current_panel_id;
@@ -185,9 +184,6 @@ activate_panel (CcWindow          *self,
   cc_shell_set_active_panel (CC_SHELL (self), CC_PANEL (self->current_panel));
   gtk_widget_show (self->current_panel);
 
-  gtk_lock_button_set_permission (GTK_LOCK_BUTTON (self->lock_button),
-                                  cc_panel_get_permission (CC_PANEL (self->current_panel)));
-
   gtk_stack_add_named (GTK_STACK (self->stack), self->current_panel, id);
 
   /* switch to the new panel */
@@ -836,7 +832,6 @@ cc_window_class_init (CcWindowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcWindow, header_box);
   gtk_widget_class_bind_template_child (widget_class, CcWindow, header_sizegroup);
   gtk_widget_class_bind_template_child (widget_class, CcWindow, list_scrolled);
-  gtk_widget_class_bind_template_child (widget_class, CcWindow, lock_button);
   gtk_widget_class_bind_template_child (widget_class, CcWindow, panel_headerbar);
   gtk_widget_class_bind_template_child (widget_class, CcWindow, panel_list);
   gtk_widget_class_bind_template_child (widget_class, CcWindow, previous_button);
diff --git a/shell/cc-window.ui b/shell/cc-window.ui
index e5cec5053..d67e77a42 100644
--- a/shell/cc-window.ui
+++ b/shell/cc-window.ui
@@ -211,14 +211,6 @@
               <object class="GtkBox" id="top_right_box">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <child>
-                  <object class="GtkLockButton" id="lock_button">
-                    <property name="can_focus">True</property>
-                    <style>
-                      <class name="text-button" />
-                    </style>
-                  </object>
-                </child>
               </object>
               <packing>
                 <property name="pack_type">end</property>
@@ -232,7 +224,6 @@
   <object class="GtkSizeGroup" id="header_sizegroup">
     <property name="mode">vertical</property>
     <widgets>
-      <widget name="lock_button"/>
       <widget name="search_button"/>
       <widget name="previous_button"/>
     </widgets>


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