[gnome-control-center/wip/applications] More tweaks
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/applications] More tweaks
- Date: Thu, 29 Nov 2018 07:08:54 +0000 (UTC)
commit 20d11d5430e02bea9f08b4debc07e014286c0ac4
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Nov 28 20:40:51 2018 -0500
More tweaks
panels/applications/cc-applications-panel.c | 171 ++++++++++++++++++++++++---
panels/applications/cc-applications-panel.ui | 60 ++++++----
panels/applications/cc-info-row.c | 90 +++++++++++---
panels/applications/cc-info-row.h | 3 +
panels/applications/cc-info-row.ui | 29 ++---
panels/applications/cc-toggle-row.c | 95 ++++-----------
panels/applications/cc-toggle-row.h | 4 -
panels/applications/cc-toggle-row.ui | 44 +++----
8 files changed, 326 insertions(+), 170 deletions(-)
---
diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c
index 5da724097..8054263f8 100644
--- a/panels/applications/cc-applications-panel.c
+++ b/panels/applications/cc-applications-panel.c
@@ -44,6 +44,11 @@
* - usb devices
*/
+enum {
+ PROP_0,
+ PROP_PARAMETERS
+};
+
struct _CcApplicationsPanel
{
CcPanel parent;
@@ -59,21 +64,24 @@ struct _CcApplicationsPanel
GDBusProxy *perm_store;
GSettings *notification_settings;
+ GSettings *location_settings;
GtkListBox *stack;
GtkWidget *permission_section;
GtkWidget *permission_list;
GtkWidget *camera;
+ GtkWidget *no_camera;
GtkWidget *location;
+ GtkWidget *no_location;
GtkWidget *microphone;
-
- GtkWidget *permission_footer;
+ GtkWidget *no_microphone;
GtkWidget *information_section;
GtkWidget *information_list;
GtkWidget *notification;
GtkWidget *sound;
+ GtkWidget *builtin;
GtkWidget *device_section;
GtkWidget *device_list;
@@ -107,6 +115,8 @@ cc_applications_panel_finalize (GObject *object)
{
CcApplicationsPanel *self = CC_APPLICATIONS_PANEL (object);
+ g_clear_object (&self->notification_settings);
+ g_clear_object (&self->location_settings);
g_clear_object (&self->cancellable);
g_free (self->current_app_id);
@@ -367,6 +377,17 @@ calculate_dir_size (const char *app_id,
return file_size_recursively (cachedir);
}
+static void
+privacy_link_cb (CcToggleRow *row,
+ CcApplicationsPanel *self)
+{
+ CcShell *shell = cc_panel_get_shell (CC_PANEL (self));
+ g_autoptr(GError) error = NULL;
+
+ if (!cc_shell_set_active_panel_from_id (shell, "privacy", NULL, &error))
+ g_warning ("Failed to switch to privacy panel: %s", error->message);
+}
+
static void
update_app_row (CcActionRow *row,
const char *app_id)
@@ -455,7 +476,7 @@ find_flatpak_ref (const char *app_id)
return NULL;
}
-static void
+static int
add_static_permission_row (CcApplicationsPanel *self,
const char *title,
const char *subtitle)
@@ -464,11 +485,35 @@ add_static_permission_row (CcApplicationsPanel *self,
row = g_object_new (CC_TYPE_INFO_ROW,
"title", title,
- "subtitle", subtitle,
- "info", _("Built-in"),
- "visible", TRUE,
+ "info", subtitle,
NULL);
+ g_object_bind_property (self->builtin, "expanded",
+ row, "visible",
+ G_BINDING_SYNC_CREATE);
gtk_container_add (GTK_CONTAINER (self->permission_list), row);
+
+ return 1;
+}
+
+static void
+permission_row_activated_cb (GtkListBox *list,
+ GtkListBoxRow *list_row,
+ CcApplicationsPanel *self)
+{
+ CcShell *shell = cc_panel_get_shell (CC_PANEL (self));
+ GtkWidget *row = GTK_WIDGET (list_row);
+ g_autoptr(GError) error = NULL;
+
+ if (row == self->builtin)
+ cc_info_row_set_expanded (CC_INFO_ROW (self->builtin),
+ !cc_info_row_get_expanded (CC_INFO_ROW (self->builtin)));
+ else if (row == self->no_camera ||
+ row == self->no_microphone ||
+ row == self->no_location)
+ {
+ if (!cc_shell_set_active_panel_from_id (shell, "privacy", NULL, &error))
+ g_warning ("Failed to switch to privacy panel: %s", error->message);
+ }
}
static void
@@ -481,6 +526,7 @@ add_static_permissions (CcApplicationsPanel *self,
g_autoptr(GKeyFile) keyfile = NULL;
char **strv;
char *str;
+ int added = 0;
ref = find_flatpak_ref (app_id);
bytes = flatpak_installed_ref_load_metadata (ref, NULL, NULL);
@@ -496,38 +542,40 @@ add_static_permissions (CcApplicationsPanel *self,
strv = g_key_file_get_string_list (keyfile, "Context", "sockets", NULL, NULL);
if (strv && g_strv_contains ((const char * const*)strv, "system-bus"))
- add_static_permission_row (self, _("System Bus"), _("Has access to the system bus"));
- if (strv && g_strv_contains ((const char * const*)strv, "x11"))
- add_static_permission_row (self, _("X11"), _("Has access to the display server"));
+ added += add_static_permission_row (self, _("System Bus"), _("Full access"));
+ if (strv && g_strv_contains ((const char * const*)strv, "session-bus"))
+ added += add_static_permission_row (self, _("Session Bus"), _("Full access"));
g_strfreev (strv);
strv = g_key_file_get_string_list (keyfile, "Context", "devices", NULL, NULL);
if (strv && g_strv_contains ((const char * const*)strv, "all"))
- add_static_permission_row (self, _("Devices"), _("Has full access to /dev"));
+ added += add_static_permission_row (self, _("Devices"), _("Full access to /dev"));
g_strfreev (strv);
strv = g_key_file_get_string_list (keyfile, "Context", "shared", NULL, NULL);
if (strv && g_strv_contains ((const char * const*)strv, "network"))
- add_static_permission_row (self, _("Network"), _("Has network access"));
+ added += add_static_permission_row (self, _("Network"), _("Has network access"));
g_strfreev (strv);
strv = g_key_file_get_string_list (keyfile, "Context", "filesystems", NULL, NULL);
if (strv && (g_strv_contains ((const char * const *)strv, "home") ||
g_strv_contains ((const char * const *)strv, "home:rw")))
- add_static_permission_row (self, _("Home"), _("Read-write access"));
+ added += add_static_permission_row (self, _("Home"), _("Full access"));
else if (strv && g_strv_contains ((const char * const *)strv, "home:ro"))
- add_static_permission_row (self, _("Home"), _("Readonly access"));
+ added += add_static_permission_row (self, _("Home"), _("Read-only"));
if (strv && (g_strv_contains ((const char * const *)strv, "host") ||
g_strv_contains ((const char * const *)strv, "host:rw")))
- add_static_permission_row (self, _("Filesystem"), _("Full filesystem access"));
+ added += add_static_permission_row (self, _("File System"), _("Full access"));
else if (strv && g_strv_contains ((const char * const *)strv, "host:ro"))
- add_static_permission_row (self, _("Filesystem"), _("Readonly access"));
+ added += add_static_permission_row (self, _("File System"), _("Read-only"));
g_strfreev (strv);
str = g_key_file_get_string (keyfile, "Session Bus Policy", "ca.desrt.dconf", NULL);
if (str && g_str_equal (str, "talk"))
- add_static_permission_row (self, _("Settings"), _("Can change settings"));
+ added += add_static_permission_row (self, _("Settings"), _("Can change settings"));
g_free (str);
+
+ gtk_widget_set_visible (self->builtin, added > 0);
}
static void
@@ -539,7 +587,12 @@ remove_static_permissions (CcApplicationsPanel *self)
for (l = children; l; l = l->next)
{
if (CC_IS_INFO_ROW (l->data))
- gtk_widget_destroy (GTK_WIDGET (l->data));
+ {
+ gboolean has_expander;
+ g_object_get (l->data, "has-expander", &has_expander, NULL);
+ if (!has_expander)
+ gtk_widget_destroy (GTK_WIDGET (l->data));
+ }
}
g_list_free (children);
}
@@ -549,7 +602,7 @@ update_permission_section (CcApplicationsPanel *self,
GAppInfo *info)
{
g_autofree char *app_id = get_app_id (info);
- g_autofree char *permissions = NULL;
+ gboolean enabled;
if (!app_info_is_flatpak (info))
{
@@ -559,6 +612,19 @@ update_permission_section (CcApplicationsPanel *self,
gtk_widget_show (self->permission_section);
+ enabled = TRUE; /* FIXME add a camera-enabled setting */
+ gtk_widget_set_visible (self->camera, enabled);
+ gtk_widget_set_visible (self->no_camera, !enabled);
+
+ enabled = TRUE; /* FIXME add a microphone-enabled setting */
+ gtk_widget_set_visible (self->microphone, enabled);
+ gtk_widget_set_visible (self->no_microphone, !enabled);
+
+ enabled = g_settings_get_boolean (self->location_settings, "enabled");
+ gtk_widget_set_visible (self->location, enabled);
+ gtk_widget_set_visible (self->no_location, !enabled);
+
+
remove_static_permissions (self);
add_static_permissions (self, app_id);
@@ -808,6 +874,63 @@ on_perm_store_ready (GObject *source_object,
update_panel (self);
}
+static void
+select_app (CcApplicationsPanel *self,
+ const char *app_id)
+{
+ GList *children, *l;
+
+ children = gtk_container_get_children (GTK_CONTAINER (self->sidebar_listbox));
+ for (l = children; l; l = l->next)
+ {
+ CcApplicationsRow *row = CC_APPLICATIONS_ROW (l->data);
+ GAppInfo *info = cc_applications_row_get_info (row);
+ if (g_str_has_prefix (g_app_info_get_id (info), app_id))
+ {
+ gtk_list_box_select_row (self->sidebar_listbox, GTK_LIST_BOX_ROW (row));
+ break;
+ }
+ }
+ g_list_free (children);
+}
+
+static void
+cc_applications_panel_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ case PROP_PARAMETERS:
+ {
+ GVariant *parameters, *v;
+ const gchar *first_arg = NULL;
+
+ parameters = g_value_get_variant (value);
+ if (parameters == NULL)
+ return;
+
+ if (g_variant_n_children (parameters) > 0)
+ {
+ g_variant_get_child (parameters, 0, "v", &v);
+ if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
+ first_arg = g_variant_get_string (v, NULL);
+ else
+ g_warning ("Wrong type for the second argument GVariant, expected 's' but got '%s'",
+ (gchar *)g_variant_get_type (v));
+ g_variant_unref (v);
+
+ select_app (CC_APPLICATIONS_PANEL (object), first_arg);
+ }
+
+ return;
+ }
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
static void
cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
{
@@ -818,10 +941,13 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
object_class->dispose = cc_applications_panel_dispose;
object_class->finalize = cc_applications_panel_finalize;
object_class->constructed = cc_applications_panel_constructed;
+ object_class->set_property = cc_applications_panel_set_property;
panel_class->get_sidebar_widget = cc_applications_panel_get_sidebar_widget;
panel_class->get_title_widget = cc_applications_panel_get_title_widget;
+ g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters");
+
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/applications/cc-applications-panel.ui");
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, sidebar_listbox);
@@ -831,13 +957,16 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, permission_section);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, permission_list);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, camera);
+ gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, no_camera);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, location);
+ gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, no_location);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, microphone);
- gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, permission_footer);
+ gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, no_microphone);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, information_section);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, information_list);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, notification);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, sound);
+ gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, builtin);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, device_section);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, device_list);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_section);
@@ -852,7 +981,9 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, location_cb);
gtk_widget_class_bind_template_callback (widget_class, microphone_cb);
gtk_widget_class_bind_template_callback (widget_class, notification_cb);
+ gtk_widget_class_bind_template_callback (widget_class, privacy_link_cb);
gtk_widget_class_bind_template_callback (widget_class, sound_cb);
+ gtk_widget_class_bind_template_callback (widget_class, permission_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, clear_cb);
gtk_widget_class_bind_template_callback (widget_class, uninstall_cb);
}
@@ -880,6 +1011,8 @@ cc_applications_panel_init (CcApplicationsPanel *self)
g_signal_connect (self->header_button, "clicked", G_CALLBACK (open_software_cb), self);
+ self->location_settings = g_settings_new ("org.gnome.system.location");
+
populate_applications (self);
self->monitor = g_app_info_monitor_get ();
diff --git a/panels/applications/cc-applications-panel.ui b/panels/applications/cc-applications-panel.ui
index b6dc32df9..71f9f8f52 100644
--- a/panels/applications/cc-applications-panel.ui
+++ b/panels/applications/cc-applications-panel.ui
@@ -64,7 +64,7 @@
<object class="GtkLabel">
<property name="visible">1</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Applications will ask for access
and permission that they require</property>
+ <property name="label" translatable="yes">Data and services that this app
has asked for access to and permissions that it requires</property>
<style>
<class name="section-subtitle"/>
</style>
@@ -76,28 +76,57 @@
<object class="GtkListBox" id="permission_list">
<property name="visible">1</property>
<property name="selection-mode">none</property>
+ <signal name="row-activated" handler="permission_row_activated_cb"/>
<child>
<object class="CcToggleRow" id="camera">
<property name="title" translatable="yes">Camera</property>
- <property name="on-subtitle" translatable="yes">Only when using the
app</property>
- <property name="off-subtitle" translatable="yes">Off</property>
<signal name="notify::allowed" handler="camera_cb" swapped="yes"/>
+ <signal name="link-activated" handler="privacy_link_cb"/>
+ </object>
+ </child>
+ <child>
+ <object class="CcInfoRow" id="no_camera">
+ <property name="title" translatable="yes">Camera</property>
+ <property name="info" translatable="yes">Disabled</property>
+ <property name="has-expander">True</property>
+ <property name="is-link">True</property>
</object>
</child>
<child>
<object class="CcToggleRow" id="microphone">
<property name="title" translatable="yes">Microphone</property>
- <property name="on-subtitle" translatable="yes">Only when using the
app</property>
- <property name="off-subtitle" translatable="yes">Off</property>
<signal name="notify::allowed" handler="microphone_cb" swapped="yes"/>
+ <signal name="link-activated" handler="privacy_link_cb"/>
+ </object>
+ </child>
+ <child>
+ <object class="CcInfoRow" id="no_microphone">
+ <property name="title" translatable="yes">Microphone</property>
+ <property name="info" translatable="yes">Disabled</property>
+ <property name="has-expander">True</property>
+ <property name="is-link">True</property>
</object>
</child>
<child>
<object class="CcToggleRow" id="location">
<property name="title" translatable="yes">Location Services</property>
- <property name="on-subtitle" translatable="yes">Only when using the
app</property>
- <property name="off-subtitle" translatable="yes">Off</property>
<signal name="notify::allowed" handler="location_cb" swapped="yes"/>
+ <signal name="link-activated" handler="privacy_link_cb"/>
+ </object>
+ </child>
+ <child>
+ <object class="CcInfoRow" id="no_location">
+ <property name="title" translatable="yes">Location Services</property>
+ <property name="info" translatable="yes">Disabled</property>
+ <property name="has-expander">True</property>
+ <property name="is-link">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="CcInfoRow" id="builtin">
+ <property name="title" translatable="yes">Built-in Permissions</property>
+ <property name="info" translatable="yes">Cannot be changed</property>
+ <property name="has-expander">True</property>
</object>
</child>
<style>
@@ -106,17 +135,6 @@
</style>
</object>
</child>
- <child>
- <object class="GtkLabel" id="permission_footer">
- <property name="visible">1</property>
- <property name="xalign">0</property>
- <property name="wrap">1</property>
- <property name="label" translatable="yes">To manage access and
permission-related settings for all applications, go to the Privacy panel.</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
</object>
</child>
<child>
@@ -161,17 +179,15 @@
<child>
<object class="CcToggleRow" id="notification">
<property name="title" translatable="yes">Notifications</property>
- <property name="on-subtitle" translatable="yes">Only on lock
screen</property>
- <property name="off-subtitle" translatable="yes">Off</property>
<signal name="notify::allowed" handler="notification_cb" swapped="yes"/>
+ <signal name="link-activated" handler="privacy_link_cb"/>
</object>
</child>
<child>
<object class="CcToggleRow" id="sound">
<property name="title" translatable="yes">Sounds</property>
- <property name="on-subtitle" translatable="yes">Alerts only</property>
- <property name="off-subtitle" translatable="yes">Off</property>
<signal name="notify::allowed" handler="sound_cb" swapped="yes"/>
+ <signal name="link-activated" handler="privacy_link_cb"/>
</object>
</child>
<style>
diff --git a/panels/applications/cc-info-row.c b/panels/applications/cc-info-row.c
index 2f11e180c..1370cf653 100644
--- a/panels/applications/cc-info-row.c
+++ b/panels/applications/cc-info-row.c
@@ -27,8 +27,10 @@
enum {
PROP_ZERO,
PROP_TITLE,
- PROP_SUBTITLE,
- PROP_INFO
+ PROP_INFO,
+ PROP_HAS_EXPANDER,
+ PROP_IS_LINK,
+ PROP_EXPANDED
};
struct _CcInfoRow
@@ -36,8 +38,11 @@ struct _CcInfoRow
GtkListBoxRow parent;
GtkWidget *title;
- GtkWidget *subtitle;
GtkWidget *info;
+ GtkWidget *expander;
+
+ gboolean expanded;
+ gboolean link;
};
G_DEFINE_TYPE (CcInfoRow, cc_info_row, GTK_TYPE_LIST_BOX_ROW)
@@ -63,18 +68,35 @@ cc_info_row_get_property (GObject *object,
case PROP_TITLE:
g_value_set_string (value, gtk_label_get_label (GTK_LABEL (row->title)));
break;
- case PROP_SUBTITLE:
- g_value_set_string (value, gtk_label_get_label (GTK_LABEL (row->subtitle)));
- break;
case PROP_INFO:
g_value_set_string (value, gtk_label_get_label (GTK_LABEL (row->info)));
break;
+ case PROP_HAS_EXPANDER:
+ g_value_set_boolean (value, gtk_widget_get_visible (row->expander));
+ break;
+ case PROP_IS_LINK:
+ g_value_set_boolean (value, row->link);
+ break;
+ case PROP_EXPANDED:
+ g_value_set_boolean (value, cc_info_row_get_expanded (row));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
+static void
+update_expander (CcInfoRow *row)
+{
+ if (row->link)
+ gtk_image_set_from_icon_name (GTK_IMAGE (row->expander), "go-next-symbolic", GTK_ICON_SIZE_BUTTON);
+ else if (row->expanded)
+ gtk_image_set_from_icon_name (GTK_IMAGE (row->expander), "pan-down-symbolic", GTK_ICON_SIZE_BUTTON);
+ else
+ gtk_image_set_from_icon_name (GTK_IMAGE (row->expander), "pan-end-symbolic", GTK_ICON_SIZE_BUTTON);
+}
+
static void
cc_info_row_set_property (GObject *object,
guint prop_id,
@@ -88,12 +110,20 @@ cc_info_row_set_property (GObject *object,
case PROP_TITLE:
gtk_label_set_label (GTK_LABEL (row->title), g_value_get_string (value));
break;
- case PROP_SUBTITLE:
- gtk_label_set_label (GTK_LABEL (row->subtitle), g_value_get_string (value));
- break;
case PROP_INFO:
gtk_label_set_label (GTK_LABEL (row->info), g_value_get_string (value));
break;
+ case PROP_HAS_EXPANDER:
+ gtk_widget_set_visible (row->expander, g_value_get_boolean (value));
+ gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), g_value_get_boolean (value));
+ break;
+ case PROP_IS_LINK:
+ row->link = g_value_get_boolean (value);
+ update_expander (row);
+ break;
+ case PROP_EXPANDED:
+ cc_info_row_set_expanded (row, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -117,19 +147,29 @@ cc_info_row_class_init (CcInfoRowClass *klass)
g_param_spec_string ("title", "title", "title",
NULL, G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_SUBTITLE,
- g_param_spec_string ("subtitle", "subtitle", "subtitle",
- NULL, G_PARAM_READWRITE));
-
g_object_class_install_property (object_class,
PROP_INFO,
g_param_spec_string ("info", "info", "info",
NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_HAS_EXPANDER,
+ g_param_spec_boolean ("has-expander", "has-expander", "has-expander",
+ FALSE, G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_EXPANDED,
+ g_param_spec_boolean ("expanded", "expanded", "expanded",
+ FALSE, G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_IS_LINK,
+ g_param_spec_boolean ("is-link", "is-link", "is-link",
+ FALSE, G_PARAM_READWRITE));
+
gtk_widget_class_bind_template_child (widget_class, CcInfoRow, title);
- gtk_widget_class_bind_template_child (widget_class, CcInfoRow, subtitle);
gtk_widget_class_bind_template_child (widget_class, CcInfoRow, info);
+ gtk_widget_class_bind_template_child (widget_class, CcInfoRow, expander);
}
static void
@@ -143,3 +183,23 @@ cc_info_row_new (void)
{
return CC_INFO_ROW (g_object_new (CC_TYPE_INFO_ROW, NULL));
}
+
+gboolean
+cc_info_row_get_expanded (CcInfoRow *row)
+{
+ return row->expanded;
+}
+
+void
+cc_info_row_set_expanded (CcInfoRow *row,
+ gboolean expanded)
+{
+ if (row->expanded == expanded)
+ return;
+
+ row->expanded = expanded;
+ update_expander (row);
+
+ g_object_notify (G_OBJECT (row), "expanded");
+}
+
diff --git a/panels/applications/cc-info-row.h b/panels/applications/cc-info-row.h
index 583de2e7f..c0961ed7f 100644
--- a/panels/applications/cc-info-row.h
+++ b/panels/applications/cc-info-row.h
@@ -28,5 +28,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (CcInfoRow, cc_info_row, CC, INFO_ROW, GtkListBoxRow)
CcInfoRow *cc_info_row_new (void);
+void cc_info_row_set_expanded (CcInfoRow *row,
+ gboolean expanded);
+gboolean cc_info_row_get_expanded (CcInfoRow *row);
G_END_DECLS
diff --git a/panels/applications/cc-info-row.ui b/panels/applications/cc-info-row.ui
index cb4b1c53e..fa3d5ea34 100644
--- a/panels/applications/cc-info-row.ui
+++ b/panels/applications/cc-info-row.ui
@@ -10,27 +10,10 @@
<property name="border-width">12</property>
<property name="spacing">12</property>
<child>
- <object class="GtkBox">
+ <object class="GtkLabel" id="title">
<property name="visible">True</property>
- <property name="spacing">4</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkLabel" id="title">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="hexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="subtitle">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="hexpand">True</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
+ <property name="xalign">0</property>
+ <property name="hexpand">True</property>
</object>
</child>
<child>
@@ -42,6 +25,12 @@
</style>
</object>
</child>
+ <child>
+ <object class="GtkImage" id="expander">
+ <property name="valign">center</property>
+ <property name="icon-name">pan-end-symbolic</property>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/panels/applications/cc-toggle-row.c b/panels/applications/cc-toggle-row.c
index 9060ad89a..faef63c6f 100644
--- a/panels/applications/cc-toggle-row.c
+++ b/panels/applications/cc-toggle-row.c
@@ -27,8 +27,6 @@
enum {
PROP_ZERO,
PROP_TITLE,
- PROP_ON_SUBTITLE,
- PROP_OFF_SUBTITLE,
PROP_ALLOWED
};
@@ -36,12 +34,9 @@ struct _CcToggleRow
{
GtkListBoxRow parent;
- char *on_subtitle;
- char *off_subtitle;
-
GtkWidget *title;
- GtkWidget *subtitle;
GtkWidget *toggle;
+ GtkWidget *link;
};
G_DEFINE_TYPE (CcToggleRow, cc_toggle_row, GTK_TYPE_LIST_BOX_ROW)
@@ -49,10 +44,7 @@ G_DEFINE_TYPE (CcToggleRow, cc_toggle_row, GTK_TYPE_LIST_BOX_ROW)
static void
cc_toggle_row_finalize (GObject *object)
{
- CcToggleRow *row = CC_TOGGLE_ROW (object);
-
- g_free (row->on_subtitle);
- g_free (row->off_subtitle);
+ //CcToggleRow *row = CC_TOGGLE_ROW (object);
G_OBJECT_CLASS (cc_toggle_row_parent_class)->finalize (object);
}
@@ -70,12 +62,6 @@ cc_toggle_row_get_property (GObject *object,
case PROP_TITLE:
g_value_set_string (value, gtk_label_get_label (GTK_LABEL (row->title)));
break;
- case PROP_ON_SUBTITLE:
- g_value_set_string (value, row->on_subtitle);
- break;
- case PROP_OFF_SUBTITLE:
- g_value_set_string (value, row->off_subtitle);
- break;
case PROP_ALLOWED:
g_value_set_boolean (value, cc_toggle_row_get_allowed (row));
break;
@@ -98,12 +84,6 @@ cc_toggle_row_set_property (GObject *object,
case PROP_TITLE:
gtk_label_set_label (GTK_LABEL (row->title), g_value_get_string (value));
break;
- case PROP_ON_SUBTITLE:
- cc_toggle_row_set_on_subtitle (row, g_value_get_string (value));
- break;
- case PROP_OFF_SUBTITLE:
- cc_toggle_row_set_off_subtitle (row, g_value_get_string (value));
- break;
case PROP_ALLOWED:
cc_toggle_row_set_allowed (row, g_value_get_boolean (value));
break;
@@ -113,6 +93,20 @@ cc_toggle_row_set_property (GObject *object,
}
}
+static guint link_activated;
+
+static void
+changed_cb (CcToggleRow *row)
+{
+ g_object_notify (G_OBJECT (row), "allowed");
+}
+
+static void
+link_clicked (CcToggleRow *row)
+{
+ g_signal_emit (row, link_activated, 0);
+}
+
static void
cc_toggle_row_class_init (CcToggleRowClass *klass)
{
@@ -130,48 +124,29 @@ cc_toggle_row_class_init (CcToggleRowClass *klass)
g_param_spec_string ("title", "title", "title",
NULL, G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_ON_SUBTITLE,
- g_param_spec_string ("on-subtitle", "on-subtitle", "on-subtitle",
- NULL, G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_OFF_SUBTITLE,
- g_param_spec_string ("off-subtitle", "off-subtitle", "off-subtitle",
- NULL, G_PARAM_READWRITE));
-
g_object_class_install_property (object_class,
PROP_ALLOWED,
g_param_spec_boolean ("allowed", "allowed", "allowed",
FALSE, G_PARAM_READWRITE));
+ link_activated = g_signal_new ("link-activated",
+ CC_TYPE_TOGGLE_ROW,
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
gtk_widget_class_bind_template_child (widget_class, CcToggleRow, title);
- gtk_widget_class_bind_template_child (widget_class, CcToggleRow, subtitle);
gtk_widget_class_bind_template_child (widget_class, CcToggleRow, toggle);
-}
-
-static void
-update_subtitle (CcToggleRow *row)
-{
- if (gtk_switch_get_active (GTK_SWITCH (row->toggle)))
- gtk_label_set_label (GTK_LABEL (row->subtitle), row->on_subtitle);
- else
- gtk_label_set_label (GTK_LABEL (row->subtitle), row->off_subtitle);
-}
+ gtk_widget_class_bind_template_child (widget_class, CcToggleRow, link);
-static void
-changed_cb (GtkSwitch *toggle, GParamSpec *pspec, CcToggleRow *row)
-{
- update_subtitle (row);
- g_object_notify (G_OBJECT (row), "allowed");
+ gtk_widget_class_bind_template_callback (widget_class, changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, link_clicked);
}
static void
cc_toggle_row_init (CcToggleRow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
-
- g_signal_connect (self->toggle, "notify::active", G_CALLBACK (changed_cb), self);
}
CcToggleRow *
@@ -192,23 +167,3 @@ cc_toggle_row_get_allowed (CcToggleRow *self)
{
return gtk_switch_get_active (GTK_SWITCH (self->toggle));
}
-
-void
-cc_toggle_row_set_on_subtitle (CcToggleRow *self,
- const char *subtitle)
-{
- g_free (self->on_subtitle);
- self->on_subtitle = g_strdup (subtitle);
- update_subtitle (self);
- g_object_notify (G_OBJECT (self), "on-subtitle");
-}
-
-void
-cc_toggle_row_set_off_subtitle (CcToggleRow *self,
- const char *subtitle)
-{
- g_free (self->off_subtitle);
- self->off_subtitle = g_strdup (subtitle);
- update_subtitle (self);
- g_object_notify (G_OBJECT (self), "off-subtitle");
-}
diff --git a/panels/applications/cc-toggle-row.h b/panels/applications/cc-toggle-row.h
index 316e3131a..57cd76fcb 100644
--- a/panels/applications/cc-toggle-row.h
+++ b/panels/applications/cc-toggle-row.h
@@ -31,9 +31,5 @@ CcToggleRow *cc_toggle_row_new (void);
void cc_toggle_row_set_allowed (CcToggleRow *row,
gboolean allowed);
gboolean cc_toggle_row_get_allowed (CcToggleRow *row);
-void cc_toggle_row_set_on_subtitle (CcToggleRow *row,
- const char *subtitle);
-void cc_toggle_row_set_off_subtitle (CcToggleRow *row,
- const char *subtitle);
G_END_DECLS
diff --git a/panels/applications/cc-toggle-row.ui b/panels/applications/cc-toggle-row.ui
index 9de4a8ade..f18cdffd6 100644
--- a/panels/applications/cc-toggle-row.ui
+++ b/panels/applications/cc-toggle-row.ui
@@ -10,33 +10,37 @@
<property name="border-width">12</property>
<property name="spacing">12</property>
<child>
- <object class="GtkBox">
+ <object class="GtkLabel" id="title">
<property name="visible">True</property>
- <property name="spacing">4</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkLabel" id="title">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="hexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="subtitle">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="hexpand">True</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
+ <property name="xalign">0</property>
+ <property name="hexpand">True</property>
</object>
</child>
<child>
<object class="GtkSwitch" id="toggle">
<property name="visible">True</property>
<property name="valign">center</property>
+ <signal name="notify::active" handler="changed_cb" swapped="yes"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="link">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="link_clicked" swapped="yes"/>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">view-more-symbolic</property>
+ <property name="icon-size">4</property>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]