[gnome-control-center/wip/privacy-swarm: 5/14] shell: Add a new privacy section



commit 49be3e3e707a6b91a99465f61e5671f62f0c0de4
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Dec 11 14:15:48 2018 -0500

    shell: Add a new privacy section
    
    This will be filled out in the next commits.
    
    Probably doesn't build because it includes all the type funcs.

 shell/cc-panel-list.c   | 75 ++++++++++++++++++++++++++++++++++++++-----------
 shell/cc-panel-list.h   |  1 +
 shell/cc-panel-list.ui  | 69 +++++++++++++++++++++++++++++++++++++++++++++
 shell/cc-panel-loader.c | 16 +++++++++++
 shell/cc-shell-model.h  |  1 +
 shell/cc-window.c       |  4 +++
 6 files changed, 150 insertions(+), 16 deletions(-)
---
diff --git a/shell/cc-panel-list.c b/shell/cc-panel-list.c
index 3319eed2d..15792be02 100644
--- a/shell/cc-panel-list.c
+++ b/shell/cc-panel-list.c
@@ -44,6 +44,7 @@ struct _CcPanelList
 
   GtkWidget          *details_listbox;
   GtkWidget          *devices_listbox;
+  GtkWidget          *privacy_listbox;
   GtkWidget          *main_listbox;
   GtkWidget          *search_listbox;
 
@@ -54,6 +55,7 @@ struct _CcPanelList
 
   GtkListBoxRow      *details_row;
   GtkListBoxRow      *devices_row;
+  GtkListBoxRow      *privacy_row;
 
   GtkWidget          *empty_search_placeholder;
 
@@ -104,6 +106,9 @@ get_widget_from_view (CcPanelList     *self,
     case CC_PANEL_LIST_DEVICES:
       return self->devices_listbox;
 
+    case CC_PANEL_LIST_PRIVACY:
+      return self->privacy_listbox;
+
     case CC_PANEL_LIST_SEARCH:
       return self->search_listbox;
 
@@ -130,6 +135,10 @@ get_listbox_from_category (CcPanelList     *self,
       return self->details_listbox;
       break;
 
+    case CC_CATEGORY_PRIVACY:
+      return self->privacy_listbox;
+      break;
+
     default:
       return self->main_listbox;
       break;
@@ -171,6 +180,9 @@ get_view_from_listbox (CcPanelList *self,
   if (listbox == self->devices_listbox)
     return CC_PANEL_LIST_DEVICES;
 
+  if (listbox == self->privacy_listbox)
+    return CC_PANEL_LIST_PRIVACY;
+
   return CC_PANEL_LIST_SEARCH;
 }
 
@@ -392,6 +404,15 @@ static const gchar * const panel_order[] = {
   "power",
   "network",
 
+  /* Privacy page */
+  "location",
+  "camera",
+  "microphone",
+  "usage",
+  "lock",
+  "diagnostics",
+  "trash",
+ 
   /* Devices page */
   "display",
   "keyboard",
@@ -429,21 +450,22 @@ sort_function (GtkListBoxRow *a,
                GtkListBoxRow *b,
                gpointer       user_data)
 {
-  CcPanelList *self;
+  CcPanelList *self = CC_PANEL_LIST (user_data);
   RowData *a_data, *b_data;
+  GtkListBoxRow *special[3] = { self->privacy_row, self->devices_row, self->details_row };
+  int ai = -1;
+  int bi = -1;
+  int i;
 
-  self = CC_PANEL_LIST (user_data);
-
-  /* Handle the Devices and the Details rows */
-  if (a == self->details_row && b == self->devices_row)
-    return 1;
-  if (a == self->devices_row && b == self->details_row)
-    return -1;
-  if (a == self->details_row || a == self->devices_row)
-    return 1;
-  if (b == self->details_row || b == self->devices_row)
-    return -1;
-
+  for (i = 0; i < 3; i++)
+    {
+      if (a == special[i]) ai = i;
+      if (b == special[i]) bi = i;
+    }
+ 
+  if (ai >= 0 || bi >= 0)
+    return ai - bi; 
+  
   /*
    * We can only retrieve the data after assuring that none
    * of the rows are Devices and Details.
@@ -523,7 +545,7 @@ header_func (GtkListBoxRow *row,
     return;
 
   /* The Details row always have the separator */
-  if (row == self->details_row)
+  if (row == self->details_row || row == self->devices_row)
     {
       GtkWidget *separator;
 
@@ -537,9 +559,10 @@ header_func (GtkListBoxRow *row,
     {
       RowData *row_data, *before_data;
 
-      if (row == self->devices_row ||
+      if (row == self->privacy_row ||
           before == self->details_row ||
-          before == self->devices_row)
+          before == self->devices_row ||
+          before == self->privacy_row)
         {
           return;
         }
@@ -578,6 +601,12 @@ row_activated_cb (GtkWidget     *listbox,
 {
   RowData *data;
 
+  if (row == self->privacy_row)
+    {
+      switch_to_view (self, CC_PANEL_LIST_PRIVACY);
+      goto out;
+    }
+
   /* Details */
   if (row == self->details_row)
     {
@@ -606,6 +635,9 @@ row_activated_cb (GtkWidget     *listbox,
 
       if (listbox != self->devices_listbox)
         gtk_list_box_unselect_all (GTK_LIST_BOX (self->devices_listbox));
+
+      if (listbox != self->privacy_listbox)
+        gtk_list_box_unselect_all (GTK_LIST_BOX (self->privacy_listbox));
     }
 
   /*
@@ -655,6 +687,8 @@ search_row_activated_cb (GtkWidget     *listbox,
     real_listbox = self->details_listbox;
   else if (data->category == CC_CATEGORY_DEVICES)
     real_listbox = self->devices_listbox;
+  else if (data->category == CC_CATEGORY_PRIVACY)
+    real_listbox = self->privacy_listbox;
   else
     real_listbox = self->main_listbox;
 
@@ -827,6 +861,8 @@ cc_panel_list_class_init (CcPanelListClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcPanelList, details_row);
   gtk_widget_class_bind_template_child (widget_class, CcPanelList, devices_listbox);
   gtk_widget_class_bind_template_child (widget_class, CcPanelList, devices_row);
+  gtk_widget_class_bind_template_child (widget_class, CcPanelList, privacy_listbox);
+  gtk_widget_class_bind_template_child (widget_class, CcPanelList, privacy_row);
   gtk_widget_class_bind_template_child (widget_class, CcPanelList, empty_search_placeholder);
   gtk_widget_class_bind_template_child (widget_class, CcPanelList, main_listbox);
   gtk_widget_class_bind_template_child (widget_class, CcPanelList, search_listbox);
@@ -849,6 +885,11 @@ cc_panel_list_init (CcPanelList *self)
                               self,
                               NULL);
 
+  gtk_list_box_set_sort_func (GTK_LIST_BOX (self->privacy_listbox),
+                              sort_function,
+                              self,
+                              NULL);
+
   gtk_list_box_set_sort_func (GTK_LIST_BOX (self->details_listbox),
                               sort_function,
                               self,
@@ -1015,6 +1056,8 @@ cc_panel_list_add_panel (CcPanelList        *self,
     gtk_widget_show (GTK_WIDGET (self->devices_row));
   else if (category == CC_CATEGORY_DETAILS)
     gtk_widget_show (GTK_WIDGET (self->details_row));
+  else if (category == CC_CATEGORY_PRIVACY)
+    gtk_widget_show (GTK_WIDGET (self->privacy_row));
 }
 
 /**
diff --git a/shell/cc-panel-list.h b/shell/cc-panel-list.h
index 525734ea5..c2172e999 100644
--- a/shell/cc-panel-list.h
+++ b/shell/cc-panel-list.h
@@ -33,6 +33,7 @@ typedef enum
   CC_PANEL_LIST_MAIN,
   CC_PANEL_LIST_DETAILS,
   CC_PANEL_LIST_DEVICES,
+  CC_PANEL_LIST_PRIVACY,
   CC_PANEL_LIST_WIDGET,
   CC_PANEL_LIST_SEARCH
 } CcPanelListView;
diff --git a/shell/cc-panel-list.ui b/shell/cc-panel-list.ui
index 3064a179e..837199cc9 100644
--- a/shell/cc-panel-list.ui
+++ b/shell/cc-panel-list.ui
@@ -12,6 +12,64 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <signal name="row-activated" handler="row_activated_cb" object="CcPanelList" swapped="no" />
+        <child>
+          <object class="GtkListBoxRow" id="privacy_row">
+            <property name="visible">False</property>
+            <property name="can_focus">True</property>
+            <child>
+              <object class="GtkBox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">12</property>
+                <property name="spacing">12</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">preferences-system-privacy-symbolic</property>
+                    <style>
+                      <class name="sidebar-icon" />
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="label" translatable="yes">Privacy</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">go-next-symbolic</property>
+                    <style>
+                      <class name="sidebar-icon" />
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
         <child>
           <object class="GtkListBoxRow" id="devices_row">
             <property name="visible">False</property>
@@ -133,6 +191,17 @@
         <property name="name">main</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkListBox" id="privacy_listbox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <signal name="row-activated" handler="row_activated_cb" object="CcPanelList" swapped="no" />
+      </object>
+      <packing>
+        <property name="name">privacy</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
     <child>
       <object class="GtkListBox" id="devices_listbox">
         <property name="visible">True</property>
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index 5eeb44e60..5aa52f59d 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -65,6 +65,13 @@ extern GType cc_user_panel_get_type (void);
 #ifdef BUILD_WACOM
 extern GType cc_wacom_panel_get_type (void);
 #endif /* BUILD_WACOM */
+extern GType cc_location_panel_get_type (void);
+extern GType cc_camera_panel_get_type (void);
+extern GType cc_microphone_panel_get_type (void);
+extern GType cc_usage_panel_get_type (void);
+extern GType cc_lock_panel_get_type (void);
+extern GType cc_diagnostics_panel_get_type (void);
+extern GType cc_trash_panel_get_type (void);
 
 /* Static init functions */
 #ifdef BUILD_NETWORK
@@ -89,13 +96,18 @@ static CcPanelLoaderVtable default_panels[] =
 #ifdef BUILD_BLUETOOTH
   PANEL_TYPE("bluetooth",        cc_bluetooth_panel_get_type,            NULL),
 #endif
+  PANEL_TYPE("camera",           cc_camera_panel_get_type,               NULL),
   PANEL_TYPE("color",            cc_color_panel_get_type,                NULL),
   PANEL_TYPE("datetime",         cc_date_time_panel_get_type,            NULL),
+  PANEL_TYPE("diagnostics",      cc_diagnostics_panel_get_type,          NULL),
   PANEL_TYPE("display",          cc_display_panel_get_type,              NULL),
   PANEL_TYPE("info-overview",    cc_info_overview_panel_get_type,        NULL),
   PANEL_TYPE("default-apps",     cc_info_default_apps_panel_get_type,    NULL),
   PANEL_TYPE("removable-media",  cc_info_removable_media_panel_get_type, NULL),
   PANEL_TYPE("keyboard",         cc_keyboard_panel_get_type,             NULL),
+  PANEL_TYPE("location",         cc_location_panel_get_type,             NULL),
+  PANEL_TYPE("lock",             cc_lock_panel_get_type,                 NULL),
+  PANEL_TYPE("microphone",       cc_microphone_panel_get_type,           NULL),
   PANEL_TYPE("mouse",            cc_mouse_panel_get_type,                NULL),
 #ifdef BUILD_NETWORK
   PANEL_TYPE("network",          cc_network_panel_get_type,              NULL),
@@ -113,7 +125,9 @@ static CcPanelLoaderVtable default_panels[] =
 #ifdef BUILD_THUNDERBOLT
   PANEL_TYPE("thunderbolt",      cc_bolt_panel_get_type,                 NULL),
 #endif
+  PANEL_TYPE("trash",            cc_trash_panel_get_type,                NULL),
   PANEL_TYPE("universal-access", cc_ua_panel_get_type,                   NULL),
+  PANEL_TYPE("usage",            cc_usage_panel_get_type,                NULL),
   PANEL_TYPE("user-accounts",    cc_user_panel_get_type,                 NULL),
 #ifdef BUILD_WACOM
   PANEL_TYPE("wacom",            cc_wacom_panel_get_type,                cc_wacom_panel_static_init_func),
@@ -151,6 +165,8 @@ parse_categories (GDesktopAppInfo *app)
     retval = CC_CATEGORY_DEVICES;
   else if (g_strv_contains (const_strv (split), "X-GNOME-DetailsSettings"))
     retval = CC_CATEGORY_DETAILS;
+  else if (g_strv_contains (const_strv (split), "X-GNOME-PrivacySettings"))
+    retval = CC_CATEGORY_PRIVACY;
   else if (g_strv_contains (const_strv (split), "HardwareSettings"))
     retval = CC_CATEGORY_HARDWARE;
 
diff --git a/shell/cc-shell-model.h b/shell/cc-shell-model.h
index 397fc7d22..9b3eaf6ad 100644
--- a/shell/cc-shell-model.h
+++ b/shell/cc-shell-model.h
@@ -36,6 +36,7 @@ typedef enum
   CC_CATEGORY_PERSONALIZATION,
   CC_CATEGORY_ACCOUNT,
   CC_CATEGORY_HARDWARE,
+  CC_CATEGORY_PRIVACY,
   CC_CATEGORY_DEVICES,
   CC_CATEGORY_DETAILS,
   CC_CATEGORY_LAST
diff --git a/shell/cc-window.c b/shell/cc-window.c
index 8d84eaf83..81fe58672 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -275,6 +275,10 @@ update_list_title (CcWindow *self)
 
   switch (view)
     {
+    case CC_PANEL_LIST_PRIVACY:
+      title = g_strdup (_("Privacy"));
+      break;
+
     case CC_PANEL_LIST_DETAILS:
       title = g_strdup (_("Details"));
       break;


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