[gnome-control-center/wip/privacy-swarm: 21/31] shell: Add a new privacy section
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/privacy-swarm: 21/31] shell: Add a new privacy section
- Date: Thu, 7 Nov 2019 01:20:13 +0000 (UTC)
commit 3860a2e2afd6c7babb5d1065205a9f43ef5fcc45
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 | 70 +++++++++++++++++++++++++++++++++++++++----------
shell/cc-panel-list.h | 1 +
shell/cc-panel-list.ui | 69 ++++++++++++++++++++++++++++++++++++++++++++++++
shell/cc-panel-loader.c | 14 ++++++++++
shell/cc-shell-model.h | 1 +
shell/cc-window.c | 4 +++
6 files changed, 145 insertions(+), 14 deletions(-)
---
diff --git a/shell/cc-panel-list.c b/shell/cc-panel-list.c
index e2850ae0d..71863a155 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;
gchar *current_panel_id;
gchar *search_query;
@@ -102,6 +104,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;
@@ -128,6 +133,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;
@@ -169,6 +178,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;
}
@@ -388,6 +400,14 @@ static const gchar * const panel_order[] = {
"power",
"network",
+ /* Privacy page */
+ "location",
+ "camera",
+ "microphone",
+ "usage",
+ "lock",
+ "diagnostics",
+
/* Devices page */
"display",
"keyboard",
@@ -425,20 +445,21 @@ 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);
+ for (i = 0; i < 3; i++)
+ {
+ if (a == special[i]) ai = i;
+ if (b == special[i]) bi = i;
+ }
- /* 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;
+ if (ai >= 0 || bi >= 0)
+ return ai - bi;
/*
* We can only retrieve the data after assuring that none
@@ -511,7 +532,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;
@@ -525,9 +546,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;
}
@@ -566,6 +588,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)
{
@@ -594,6 +622,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));
}
/*
@@ -643,6 +674,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;
@@ -815,6 +848,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, main_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPanelList, search_listbox);
@@ -836,6 +871,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,
@@ -1003,6 +1043,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 76995c2b8..7b77e72ba 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 32066fb93..244b5fa17 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 b894370ed..819747aa7 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -65,6 +65,12 @@ 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);
/* Static init functions */
#ifdef BUILD_NETWORK
@@ -89,12 +95,17 @@ 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("default-apps", cc_default_apps_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("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),
@@ -114,6 +125,7 @@ static CcPanelLoaderVtable default_panels[] =
PANEL_TYPE("thunderbolt", cc_bolt_panel_get_type, NULL),
#endif
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 +163,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 19e302c06..74ec0eabe 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -273,6 +273,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]