[gnome-maps] sendToDialog: Add rows for other map apps
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] sendToDialog: Add rows for other map apps
- Date: Thu, 13 Jun 2019 19:07:01 +0000 (UTC)
commit 99dc48bb5d6c4a0d336947566d1111ddd9d3092f
Author: James Westman <flyingpimonster flyingpimonster net>
Date: Sat Jun 8 18:19:14 2019 -0500
sendToDialog: Add rows for other map apps
Other apps that can open geo: URIs are listed below the clock and
weather options.
Part of the share dialog overhaul, #167.
data/org.gnome.Maps.data.gresource.xml | 1 +
data/ui/open-with-row.ui | 27 +++++++++++++++++
src/sendToDialog.js | 55 +++++++++++++++++++++++++++++-----
3 files changed, 75 insertions(+), 8 deletions(-)
---
diff --git a/data/org.gnome.Maps.data.gresource.xml b/data/org.gnome.Maps.data.gresource.xml
index 9ed746a..473b351 100644
--- a/data/org.gnome.Maps.data.gresource.xml
+++ b/data/org.gnome.Maps.data.gresource.xml
@@ -13,6 +13,7 @@
<file preprocess="xml-stripblanks">ui/location-service-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/main-window.ui</file>
<file preprocess="xml-stripblanks">ui/map-bubble.ui</file>
+ <file preprocess="xml-stripblanks">ui/open-with-row.ui</file>
<file preprocess="xml-stripblanks">ui/osm-account-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/osm-edit-address.ui</file>
<file preprocess="xml-stripblanks">ui/osm-edit-dialog.ui</file>
diff --git a/data/ui/open-with-row.ui b/data/ui/open-with-row.ui
new file mode 100644
index 0000000..00cce1a
--- /dev/null
+++ b/data/ui/open-with-row.ui
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <template class="Gjs_OpenWithRow" parent="GtkListBoxRow">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImage" id="icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixel-size">32</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/sendToDialog.js b/src/sendToDialog.js
index 8dd3924..5a3eca9 100644
--- a/src/sendToDialog.js
+++ b/src/sendToDialog.js
@@ -18,6 +18,7 @@
*/
const Gdk = imports.gi.Gdk;
+const Geocode = imports.gi.GeocodeGlib;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
@@ -25,6 +26,7 @@ const Gtk = imports.gi.Gtk;
const GWeather = imports.gi.GWeather;
const Soup = imports.gi.Soup;
+const Application = imports.application;
const PlaceFormatter = imports.placeFormatter;
const Utils = imports.utils;
@@ -125,6 +127,19 @@ var SendToDialog = GObject.registerClass({
this._clocksIcon.icon_name = clocksInfo.get_icon().to_string();
}
}
+
+ /* Other apps that can launch geo: URIs */
+ let contentType = Gio.content_type_from_mime_type("x-scheme-handler/geo");
+ let thisId = Application.application.application_id + ".desktop";
+ let apps = Gio.app_info_get_all_for_type(contentType);
+ for (var app of apps) {
+ if (app.get_id() == thisId)
+ return;
+ if (!app.should_show())
+ return;
+
+ this._list.add(new OpenWithRow({ appinfo: app }));
+ }
}
_getSummary(markup) {
@@ -182,14 +197,7 @@ var SendToDialog = GObject.registerClass({
Soup.URI.encode(summary, null));
try {
- let timestamp = Gtk.get_current_event_time();
- let display = Gdk.Display.get_default();
- let ctx = Gdk.Display.get_default().get_app_launch_context();
- let screen = display.get_default_screen();
-
- ctx.set_timestamp(timestamp);
- ctx.set_screen(screen);
- Gio.app_info_launch_default_for_uri(uri, ctx);
+ Gio.app_info_launch_default_for_uri(uri, this._getAppLaunchContext());
} catch(e) {
Utils.showDialog(_("Failed to open URI"), Gtk.MessageType.ERROR,
this.get_toplevel());
@@ -199,6 +207,18 @@ var SendToDialog = GObject.registerClass({
this.response(Response.SUCCESS);
}
+ _getAppLaunchContext() {
+ let timestamp = Gtk.get_current_event_time();
+ let display = Gdk.Display.get_default();
+ let ctx = Gdk.Display.get_default().get_app_launch_context();
+ let screen = display.get_default_screen();
+
+ ctx.set_timestamp(timestamp);
+ ctx.set_screen(screen);
+
+ return ctx;
+ }
+
_activateRow(row) {
if (row === this._weatherRow || row === this._clocksRow) {
let timestamp = Gtk.get_current_event_time();
@@ -217,7 +237,26 @@ var SendToDialog = GObject.registerClass({
action,
new GLib.Variant('v', this._city.serialize()),
timestamp);
+ } else if (row instanceof OpenWithRow) {
+ let uri = this._place.location.to_uri(Geocode.LocationURIScheme.GEO);
+ row.appinfo.launch_uris([ uri ], this._getAppLaunchContext());
}
this.response(Response.SUCCESS);
}
});
+
+var OpenWithRow = GObject.registerClass({
+ Template: 'resource:///org/gnome/Maps/ui/open-with-row.ui',
+ InternalChildren: [ 'label',
+ 'icon' ],
+}, class OpenWithRow extends Gtk.ListBoxRow {
+ _init(params) {
+ this.appinfo = params.appinfo;
+ delete params.appinfo;
+
+ super._init(params);
+
+ this._label.label = _("Open with %s").format(this.appinfo.get_name());
+ this._icon.gicon = this.appinfo.get_icon();
+ }
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]