[gnome-maps/wip/mlundblad/replace-notifications] Add dialog to open privacy settings panel



commit e0a7507367190283f5f788af0fbc005d88cb260a
Author: Marcus Lundblad <ml update uu se>
Date:   Wed May 23 22:47:35 2018 +0200

    Add dialog to open privacy settings panel
    
    Used when trying access current location
    when location services are turned off.

 data/org.gnome.Maps.data.gresource.xml |  1 +
 data/ui/location-service-dialog.ui     | 53 +++++++++++++++++++++++++++
 po/POTFILES.in                         |  1 +
 src/locationServiceDialog.js           | 65 ++++++++++++++++++++++++++++++++++
 src/org.gnome.Maps.src.gresource.xml   |  1 +
 5 files changed, 121 insertions(+)
---
diff --git a/data/org.gnome.Maps.data.gresource.xml b/data/org.gnome.Maps.data.gresource.xml
index a0c1853..ac29278 100644
--- a/data/org.gnome.Maps.data.gresource.xml
+++ b/data/org.gnome.Maps.data.gresource.xml
@@ -12,6 +12,7 @@
     <file preprocess="xml-stripblanks">ui/layers-popover.ui</file>
     <file preprocess="xml-stripblanks">ui/shape-layer-row.ui</file>
     <file preprocess="xml-stripblanks">ui/shape-layer-file-chooser.ui</file>
+    <file preprocess="xml-stripblanks">ui/location-service-dialog.ui</file>
     <file preprocess="xml-stripblanks">ui/location-service-notification.ui</file>
     <file preprocess="xml-stripblanks">ui/main-window.ui</file>
     <file preprocess="xml-stripblanks">ui/map-bubble.ui</file>
diff --git a/data/ui/location-service-dialog.ui b/data/ui/location-service-dialog.ui
new file mode 100644
index 0000000..0c3ae66
--- /dev/null
+++ b/data/ui/location-service-dialog.ui
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <template class="Gjs_LocationServiceDialog" parent="GtkDialog">
+    <property name="can_focus">False</property>
+    <property name="type">popup</property>
+    <property name="type_hint">dialog</property>
+    <property name="width_request">400</property>
+    <property name="height_request">150</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="contentArea">
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">Turn on location services to find your 
location</property>
+          </object>
+        </child>
+      </object>
+    </child>
+    <child type="titlebar">
+      <object class="GtkHeaderBar" id="headerBar">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="show-close-button">False</property>
+        <child>
+          <object class="GtkButton" id="cancelButton">
+            <property name="label" translatable="yes">Cancel</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+          </object>
+          <packing>
+            <property name="pack-type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="settingsButton">
+            <property name="label" translatable="yes">Location Settings</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <style>
+              <class name="default"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
\ No newline at end of file
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5ca23de..5d4b634 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -9,6 +9,7 @@ data/ui/context-menu.ui
 data/ui/export-view-dialog.ui
 data/ui/help-overlay.ui
 data/ui/layers-popover.ui
+data/ui/location-service-dialog.ui
 data/ui/location-service-notification.ui
 data/ui/main-window.ui
 data/ui/map-bubble.ui
diff --git a/src/locationServiceDialog.js b/src/locationServiceDialog.js
new file mode 100644
index 0000000..4e45955
--- /dev/null
+++ b/src/locationServiceDialog.js
@@ -0,0 +1,65 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2018 Marcus Lundblad
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+const Gdk = imports.gi.Gdk;
+const Gio = imports.gi.Gio;
+const GObject = imports.gi.GObject;
+const Gtk = imports.gi.Gtk;
+
+const Utils = imports.utils;
+
+const _PRIVACY_PANEL = 'gnome-privacy-panel.desktop';
+
+var LocationServiceDialog = GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/location-service-dialog.ui',
+    InternalChildren: [ 'cancelButton',
+                        'settingsButton'],
+}, class LocationServiceDialog extends Gtk.Dialog {
+
+    _init(params) {
+        /* This is a construct-only property and cannot be set by GtkBuilder */
+        params.use_header_bar = true;
+
+        super._init(params);
+
+        this._settingsButton.connect('clicked', () => this._onSettings());
+        this._cancelButton.connect('clicked', () => this._onCancel());
+    }
+
+    _onSettings() {
+        let privacyInfo = Gio.DesktopAppInfo.new(_PRIVACY_PANEL);
+
+        try {
+            let display = Gdk.Display.get_default();
+
+            privacyInfo.launch([], display.get_app_launch_context());
+        } catch(e) {
+            Utils.debug('launching privacy panel failed: ' + e);
+        }
+
+        this.response(Gtk.ResponseType.OK);
+    }
+
+    _onCancel() {
+        this.response(Gtk.ResponseType.CANCEL);
+    }
+});
\ No newline at end of file
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index 4629824..1fd998f 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -28,6 +28,7 @@
     <file>kmlShapeLayer.js</file>
     <file>layersPopover.js</file>
     <file>location.js</file>
+    <file>locationServiceDialog.js</file>
     <file>locationServiceNotification.js</file>
     <file>longPrintLayout.js</file>
     <file>main.js</file>


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