event-popover: Support the maps URI for opening locations
Open gnome-maps (or other map application) when clicking on a map icon next to the location address. Resolves: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/326 Signed-off-by: Alistair Francis <alistair@alistair23.me> Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/590>
This commit is contained in:
committed by
Marge Bot
parent
b0321c369d
commit
6c09758633
@@ -138,25 +138,43 @@ template $GcalEventPopover: Popover {
|
||||
Separator {}
|
||||
|
||||
Box {
|
||||
orientation: vertical;
|
||||
margin-top: 12;
|
||||
margin-bottom: 12;
|
||||
margin-start: 18;
|
||||
margin-end: 18;
|
||||
spacing: 12;
|
||||
|
||||
Label {
|
||||
halign: start;
|
||||
label: _("Location");
|
||||
Box {
|
||||
orientation: vertical;
|
||||
|
||||
styles [
|
||||
"heading",
|
||||
]
|
||||
Label {
|
||||
halign: start;
|
||||
label: _("Location");
|
||||
|
||||
styles [
|
||||
"heading",
|
||||
]
|
||||
}
|
||||
|
||||
Label location_label {
|
||||
halign: start;
|
||||
selectable: true;
|
||||
ellipsize: end;
|
||||
}
|
||||
}
|
||||
|
||||
Label location_label {
|
||||
halign: start;
|
||||
selectable: true;
|
||||
ellipsize: end;
|
||||
Button {
|
||||
halign: end;
|
||||
hexpand: true;
|
||||
valign: center;
|
||||
tooltip-text: _("Open Location");
|
||||
icon-name: "map-symbolic";
|
||||
|
||||
styles [
|
||||
"circular",
|
||||
]
|
||||
|
||||
clicked => $on_map_button_clicked_cb(template) not-swapped;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,6 +642,31 @@ on_join_meeting_cb (GcalMeetingRow *meeting_row,
|
||||
g_object_ref (self));
|
||||
}
|
||||
|
||||
static void
|
||||
on_map_button_clicked_cb (GtkButton *action_button,
|
||||
GcalEventPopover *self)
|
||||
{
|
||||
g_autoptr (GtkUriLauncher) uri_launcher = NULL;
|
||||
g_autofree gchar *location = NULL;
|
||||
g_autofree gchar *uri = NULL;
|
||||
GtkWindow *window;
|
||||
|
||||
window = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self)));
|
||||
g_assert (window != NULL);
|
||||
|
||||
location = g_strdup (gcal_event_get_location (self->event));
|
||||
g_strstrip (location);
|
||||
|
||||
uri = g_strconcat ("maps:q=", location, NULL);
|
||||
g_assert (g_uri_is_valid (uri, G_URI_FLAGS_NONE, NULL));
|
||||
uri_launcher = gtk_uri_launcher_new (uri);
|
||||
gtk_uri_launcher_launch (uri_launcher,
|
||||
window,
|
||||
NULL,
|
||||
on_uri_launched_cb,
|
||||
g_object_ref (self));
|
||||
}
|
||||
|
||||
static void
|
||||
on_time_format_changed_cb (GcalEventPopover *self)
|
||||
{
|
||||
@@ -771,6 +796,7 @@ gcal_event_popover_class_init (GcalEventPopoverClass *klass)
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_action_button_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_ics_export_button_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_map_button_clicked_cb);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -16,5 +16,6 @@
|
||||
<file compressed="true">info-outline-symbolic.svg</file>
|
||||
<file compressed="true">loupe-large-symbolic.svg</file>
|
||||
<file compressed="true">share-symbolic.svg</file>
|
||||
<file compressed="true">map-symbolic.svg</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 15 2 v 10 l -5 3 l -5 -3 l -5 3 v -10 l 5 -3 l 5 3 z m -10 1 v 8 l 5 3 v -8 z m 0 0" fill="#222222"/></svg>
|
||||
|
After Width: | Height: | Size: 245 B |
Reference in New Issue
Block a user