[gnome-shell] location: Add dialog to ask for location data access



commit e98a434edea49d30d41b364a3fe71feff0e976d1
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Feb 15 19:42:09 2016 +0000

    location: Add dialog to ask for location data access
    
    Add a dialog that is used in a following patch, to ask user if they want
    a requesting application to gain access to their location.
    
    Co-author: Florian Müllner <fmuellner gnome org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762119

 data/theme/gnome-shell-high-contrast.css |   16 ++++++++
 data/theme/gnome-shell.css               |   16 ++++++++
 js/ui/status/location.js                 |   61 ++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 0 deletions(-)
---
diff --git a/data/theme/gnome-shell-high-contrast.css b/data/theme/gnome-shell-high-contrast.css
index 140785d..a42016b 100644
--- a/data/theme/gnome-shell-high-contrast.css
+++ b/data/theme/gnome-shell-high-contrast.css
@@ -427,6 +427,22 @@ StScrollBar {
 .audio-selection-device-icon {
   icon-size: 64px; }
 
+/* Geolocation Dialog */
+.geolocation-dialog {
+  spacing: 30px; }
+
+.geolocation-dialog-main-layout {
+  spacing: 12px; }
+
+.geolocation-dialog-content {
+  spacing: 20px; }
+
+.geolocation-dialog-icon {
+  icon-size: 48px; }
+
+.geolocation-dialog-title {
+  font-weight: bold; }
+
 /* Network Agent Dialog */
 .network-dialog-secret-table {
   spacing-rows: 15px;
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 92529a6..3160a74 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -427,6 +427,22 @@ StScrollBar {
 .audio-selection-device-icon {
   icon-size: 64px; }
 
+/* Geolocation Dialog */
+.geolocation-dialog {
+  spacing: 30px; }
+
+.geolocation-dialog-main-layout {
+  spacing: 12px; }
+
+.geolocation-dialog-content {
+  spacing: 20px; }
+
+.geolocation-dialog-icon {
+  icon-size: 48px; }
+
+.geolocation-dialog-title {
+  font-weight: bold; }
+
 /* Network Agent Dialog */
 .network-dialog-secret-table {
   spacing-rows: 15px;
diff --git a/js/ui/status/location.js b/js/ui/status/location.js
index b106fed..2dad0b8 100644
--- a/js/ui/status/location.js
+++ b/js/ui/status/location.js
@@ -1,5 +1,6 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
+const Clutter = imports.gi.Clutter;
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const Lang = imports.lang;
@@ -7,7 +8,10 @@ const Lang = imports.lang;
 const Main = imports.ui.main;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
+const ModalDialog = imports.ui.modalDialog;
 const Shell = imports.gi.Shell;
+const Signals = imports.signals;
+const St = imports.gi.St;
 
 const LOCATION_SCHEMA = 'org.gnome.system.location';
 const MAX_ACCURACY_LEVEL = 'max-accuracy-level';
@@ -217,3 +221,60 @@ const Indicator = new Lang.Class({
 function clamp(value, min, max) {
     return Math.max(min, Math.min(max, value));
 }
+
+const GeolocationDialog = new Lang.Class({
+    Name: 'GeolocationDialog',
+    Extends: ModalDialog.ModalDialog,
+
+    _init: function(name, reason, reqAccuracyLevel) {
+        this.parent({ styleClass: 'geolocation-dialog' });
+        this.reqAccuracyLevel = reqAccuracyLevel;
+
+        let mainContentBox = new St.BoxLayout({ style_class: 'geolocation-dialog-main-layout' });
+        this.contentLayout.add_actor(mainContentBox);
+
+        let icon = new St.Icon({ style_class: 'geolocation-dialog-icon',
+                                 icon_name: 'find-location-symbolic',
+                                 y_align: Clutter.ActorAlign.START });
+        mainContentBox.add_actor(icon);
+
+        let messageBox = new St.BoxLayout({ style_class: 'geolocation-dialog-content',
+                                            vertical: true });
+        mainContentBox.add_actor(messageBox);
+
+        this._title = new St.Label({ style_class: 'geolocation-dialog-title headline' });
+        messageBox.add_actor(this._title);
+
+        this._desc = new St.Label();
+        messageBox.add_actor(this._desc);
+
+        this._reason = new St.Label();
+        messageBox.add_actor(this._reason);
+
+        let button = this.addButton({ label: _("Deny Access"),
+                                      action: Lang.bind(this, this._onDenyClicked),
+                                      key: Clutter.KEY_Escape });
+        this.addButton({ label: _("Grant Access"),
+                         action: Lang.bind(this, this._onGrantClicked) });
+
+        this.setInitialKeyFocus(button);
+
+        this._title.text = _("Give %s access to your location?").format(name);
+        this._desc.text = _("%s is requesting access to your location.").format(name);
+
+        if (reason)
+            this._reason.text = reason;
+        this._reason.visible = (reason != null);
+    },
+
+    _onGrantClicked: function() {
+        this.emit('response', this.reqAccuracyLevel);
+        this.close();
+    },
+
+    _onDenyClicked: function() {
+        this.emit('response', GeoclueAccuracyLevel.NONE);
+        this.close();
+    }
+});
+Signals.addSignalMethods(GeolocationDialog.prototype);


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