[gnome-control-center] privacy: Indicate location service being used
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] privacy: Indicate location service being used
- Date: Thu, 3 Mar 2016 16:59:42 +0000 (UTC)
commit d77ec8e8212434dac188ae43c16627363c215435
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Feb 17 15:56:21 2016 +0000
privacy: Indicate location service being used
As per the new mockup, we should indicate when location service is in
use:
https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/system-settings/privacy/privacy-3.20.png
https://bugzilla.gnome.org/show_bug.cgi?id=761245
panels/privacy/cc-privacy-panel.c | 116 +++++++++++++++++++++++++++++++++++--
1 files changed, 111 insertions(+), 5 deletions(-)
---
diff --git a/panels/privacy/cc-privacy-panel.c b/panels/privacy/cc-privacy-panel.c
index 6668936..da8516d 100644
--- a/panels/privacy/cc-privacy-panel.c
+++ b/panels/privacy/cc-privacy-panel.c
@@ -44,6 +44,7 @@ struct _CcPrivacyPanelPrivate
GtkWidget *recent_dialog;
GtkWidget *screen_lock_dialog;
GtkWidget *location_dialog;
+ GtkWidget *location_label;
GtkWidget *trash_dialog;
GtkWidget *software_dialog;
GtkWidget *list_box;
@@ -57,6 +58,10 @@ struct _CcPrivacyPanelPrivate
GtkWidget *abrt_dialog;
GtkWidget *abrt_row;
guint abrt_watch_id;
+
+ GCancellable *cancellable;
+
+ GDBusProxy *gclue_manager;
};
static char *
@@ -381,22 +386,119 @@ add_screen_lock (CcPrivacyPanel *self)
}
static void
+update_location_label (CcPrivacyPanel *self)
+{
+ CcPrivacyPanelPrivate *priv = self->priv;
+ gboolean in_use = FALSE, on;
+ const gchar *label;
+
+ if (priv->gclue_manager != NULL)
+ {
+ GVariant *variant;
+
+ variant = g_dbus_proxy_get_cached_property (priv->gclue_manager, "InUse");
+ if (variant != NULL)
+ {
+ in_use = g_variant_get_boolean (variant);
+ g_variant_unref (variant);
+ }
+ }
+
+ if (in_use)
+ {
+ gtk_label_set_label (GTK_LABEL (priv->location_label), _("In use"));
+ return;
+ }
+
+ on = g_settings_get_boolean (priv->location_settings, LOCATION_ENABLED);
+ label = on ? C_("Location services status", "On") :
+ C_("Location services status", "Off");
+ gtk_label_set_label (GTK_LABEL (priv->location_label), label);
+}
+
+static void
+on_location_setting_changed (GSettings *settings,
+ gchar *key,
+ gpointer user_data)
+{
+ update_location_label (user_data);
+}
+
+static void
+on_gclue_manager_props_changed (GDBusProxy *manager,
+ GVariant *changed_properties,
+ GStrv invalidated_properties,
+ gpointer user_data)
+{
+ update_location_label (user_data);
+}
+
+static void
+on_gclue_manager_ready (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ CcPrivacyPanel *self;
+ GDBusProxy *proxy;
+ GError *error = NULL;
+
+ proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+ if (proxy == NULL)
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to connect to Geoclue: %s", error->message);
+ g_error_free (error);
+
+ return;
+ }
+ self = user_data;
+ self->priv->gclue_manager = proxy;
+
+ g_signal_connect (self->priv->gclue_manager,
+ "g-properties-changed",
+ G_CALLBACK (on_gclue_manager_props_changed),
+ self);
+
+ update_location_label (self);
+}
+
+static void
add_location (CcPrivacyPanel *self)
{
+ CcPrivacyPanelPrivate *priv = self->priv;
GtkWidget *w;
GtkWidget *dialog;
- w = get_on_off_label (self->priv->location_settings, LOCATION_ENABLED);
- add_row (self, _("Location Services"), "location_dialog", w);
+ priv->location_label = gtk_label_new ("");
+ g_signal_connect (priv->location_settings,
+ "changed::" LOCATION_ENABLED,
+ G_CALLBACK (on_location_setting_changed),
+ self);
+ update_location_label (self);
- dialog = self->priv->location_dialog;
+ add_row (self,
+ _("Location Services"),
+ "location_dialog",
+ priv->location_label);
+
+ dialog = priv->location_dialog;
g_signal_connect (dialog, "delete-event",
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
- w = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "location_services_switch"));
- g_settings_bind (self->priv->location_settings, LOCATION_ENABLED,
+ w = GTK_WIDGET (gtk_builder_get_object (priv->builder, "location_services_switch"));
+ g_settings_bind (priv->location_settings, LOCATION_ENABLED,
w, "active",
G_SETTINGS_BIND_DEFAULT);
+
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.freedesktop.GeoClue2",
+ "/org/freedesktop/GeoClue2/Manager",
+ "org.freedesktop.GeoClue2.Manager",
+ priv->cancellable,
+ on_gclue_manager_ready,
+ self);
}
static void
@@ -785,6 +887,7 @@ cc_privacy_panel_finalize (GObject *object)
priv->abrt_watch_id = 0;
}
+ g_cancellable_cancel (priv->cancellable);
g_clear_pointer (&priv->recent_dialog, gtk_widget_destroy);
g_clear_pointer (&priv->screen_lock_dialog, gtk_widget_destroy);
g_clear_pointer (&priv->location_dialog, gtk_widget_destroy);
@@ -797,6 +900,8 @@ cc_privacy_panel_finalize (GObject *object)
g_clear_object (&priv->privacy_settings);
g_clear_object (&priv->notification_settings);
g_clear_object (&priv->location_settings);
+ g_clear_object (&priv->gclue_manager);
+ g_clear_object (&priv->cancellable);
G_OBJECT_CLASS (cc_privacy_panel_parent_class)->finalize (object);
}
@@ -840,6 +945,7 @@ cc_privacy_panel_init (CcPrivacyPanel *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, CC_TYPE_PRIVACY_PANEL, CcPrivacyPanelPrivate);
g_resources_register (cc_privacy_get_resource ());
+ self->priv->cancellable = g_cancellable_new ();
self->priv->builder = gtk_builder_new ();
error = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]