[gnome-maps] placeBar: Add PlaceDialog
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] placeBar: Add PlaceDialog
- Date: Tue, 9 Feb 2021 20:56:56 +0000 (UTC)
commit d5771cc4fe4e37a83a9613f259ae0b1de705d149
Author: James Westman <james flyingpimonster net>
Date: Mon Dec 28 17:28:01 2020 -0600
placeBar: Add PlaceDialog
This dialog contains a PlaceView to show information about a place, and is
shown when you click/top the PlaceBar. It usually matches the size of the main
window, unless that would make it very wide.
data/org.gnome.Maps.data.gresource.xml | 1 +
data/ui/place-bar.ui | 49 +++++++++++++------------
data/ui/place-dialog.ui | 36 +++++++++++++++++++
src/org.gnome.Maps.src.gresource.xml | 1 +
src/placeBar.js | 18 ++++++++--
src/placeDialog.js | 65 ++++++++++++++++++++++++++++++++++
src/placeView.js | 10 +++---
src/userLocationMarker.js | 2 --
8 files changed, 152 insertions(+), 30 deletions(-)
---
diff --git a/data/org.gnome.Maps.data.gresource.xml b/data/org.gnome.Maps.data.gresource.xml
index 87062c86..5ad801fa 100644
--- a/data/org.gnome.Maps.data.gresource.xml
+++ b/data/org.gnome.Maps.data.gresource.xml
@@ -23,6 +23,7 @@
<file preprocess="xml-stripblanks">ui/osm-type-popover.ui</file>
<file preprocess="xml-stripblanks">ui/place-bar.ui</file>
<file preprocess="xml-stripblanks">ui/place-buttons.ui</file>
+ <file preprocess="xml-stripblanks">ui/place-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/place-entry.ui</file>
<file preprocess="xml-stripblanks">ui/place-list-row.ui</file>
<file preprocess="xml-stripblanks">ui/place-popover.ui</file>
diff --git a/data/ui/place-bar.ui b/data/ui/place-bar.ui
index 47ad3a0b..2845f468 100644
--- a/data/ui/place-bar.ui
+++ b/data/ui/place-bar.ui
@@ -8,38 +8,43 @@
<object class="GtkActionBar" id="actionbar">
<property name="visible">True</property>
<child>
- <object class="GtkBox" id="box">
+ <object class="GtkEventBox" id="eventbox">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="box">
<property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkLabel" id="title">
- <style>
- <class name="title-2"/>
- </style>
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="label"></property>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="altSendToButton">
- <property name="visible">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="hexpand">True</property>
<child>
- <object class="GtkImage">
+ <object class="GtkLabel" id="title">
+ <style>
+ <class name="title-2"/>
+ </style>
<property name="visible">True</property>
- <property name="icon_name">send-to-symbolic</property>
- <property name="tooltip_text" translatable="yes" comments="Translators: This is a
tooltip">Share location</property>
+ <property name="ellipsize">end</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="altSendToButton">
+ <property name="visible">False</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon_name">send-to-symbolic</property>
+ <property name="tooltip_text" translatable="yes" comments="Translators: This is
a tooltip">Share location</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
</child>
</object>
</child>
diff --git a/data/ui/place-dialog.ui b/data/ui/place-dialog.ui
new file mode 100644
index 00000000..9c49c767
--- /dev/null
+++ b/data/ui/place-dialog.ui
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="Gjs_PlaceDialog" parent="GtkDialog">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="use_header_bar">1</property>
+ <child type="action">
+ <object class="GtkButton" id="closeButton">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon_name">go-previous-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="cancel">closeButton</action-widget>
+ </action-widgets>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scroll">
+ <property name="visible">True</property>
+ <property name="propagate_natural_height">True</property>
+ <property name="hscrollbar_policy">never</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
+
+
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index dd9da686..af1f606b 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -57,6 +57,7 @@
<file>place.js</file>
<file>placeBar.js</file>
<file>placeButtons.js</file>
+ <file>placeDialog.js</file>
<file>placeEntry.js</file>
<file>placeFormatter.js</file>
<file>placeListRow.js</file>
diff --git a/src/placeBar.js b/src/placeBar.js
index 2ddc12d5..b293e441 100644
--- a/src/placeBar.js
+++ b/src/placeBar.js
@@ -26,6 +26,7 @@ const Gtk = imports.gi.Gtk;
const Application = imports.application;
const PlaceButtons = imports.placeButtons;
+const PlaceDialog = imports.placeDialog;
const PlaceFormatter = imports.placeFormatter;
var PlaceBar = GObject.registerClass({
@@ -33,6 +34,7 @@ var PlaceBar = GObject.registerClass({
InternalChildren: [ 'actionbar',
'altSendToButton',
'box',
+ 'eventbox',
'title' ],
Properties: {
'place': GObject.ParamSpec.object('place',
@@ -44,15 +46,18 @@ var PlaceBar = GObject.registerClass({
},
}, class PlaceBar extends Gtk.Revealer {
_init(params) {
- let mapView = params.mapView;
+ this._mapView = params.mapView;
delete params.mapView;
super._init(params);
- this._buttons = new PlaceButtons.PlaceButtons({ mapView });
+ this._buttons = new PlaceButtons.PlaceButtons({ mapView: this._mapView });
this._buttons.initSendToButton(this._altSendToButton);
this._box.add(this._buttons);
+ this._multipress = new Gtk.GestureMultiPress({ widget: this._eventbox });
+ this._multipress.connect('released', this._onEventBoxClicked.bind(this));
+
Application.application.connect('notify::adaptive-mode', this._updateVisibility.bind(this));
this.connect('notify::place', this._updatePlace.bind(this));
}
@@ -80,4 +85,13 @@ var PlaceBar = GObject.registerClass({
this.reveal_child = false;
}
}
+
+ _onEventBoxClicked() {
+ let dialog = new PlaceDialog.PlaceDialog ({ transient_for: this.get_toplevel(),
+ modal: true,
+ mapView: this._mapView,
+ place: this.place });
+ dialog.connect('response', () => dialog.destroy());
+ dialog.show();
+ }
});
diff --git a/src/placeDialog.js b/src/placeDialog.js
new file mode 100644
index 00000000..81cf6677
--- /dev/null
+++ b/src/placeDialog.js
@@ -0,0 +1,65 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2020 James Westman
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: James Westman <james flyingpimonster net>
+ */
+
+const GObject = imports.gi.GObject;
+const Gtk = imports.gi.Gtk;
+
+const PlaceFormatter = imports.placeFormatter;
+const PlaceView = imports.placeView;
+
+var PlaceDialog = GObject.registerClass({
+ Template: 'resource:///org/gnome/Maps/ui/place-dialog.ui',
+ InternalChildren: [ 'scroll' ]
+}, class PlaceDialog extends Gtk.Dialog {
+ _init(params) {
+ let place = params.place;
+ delete params.place;
+
+ let mapView = params.mapView;
+ delete params.mapView;
+
+ params.use_header_bar = true;
+ super._init(params);
+
+ if (this.transient_for.is_maximized) {
+ this.maximize();
+ } else {
+ let [width, height] = this.transient_for.get_size();
+
+ // Don't let the dialog get too wide
+ if (width > 400) {
+ width = 400 - 36;
+ height -= 36;
+ }
+
+ this.set_default_size(width, height);
+ }
+
+ this._placeView = new PlaceView.PlaceView({ place,
+ mapView,
+ valign: Gtk.Align.START,
+ visible: true });
+ this._scroll.add(this._placeView);
+
+ let formatter = new PlaceFormatter.PlaceFormatter(place);
+ this.title = formatter.title;
+ }
+});
diff --git a/src/placeView.js b/src/placeView.js
index 628dee03..a756c2dd 100644
--- a/src/placeView.js
+++ b/src/placeView.js
@@ -150,11 +150,8 @@ var PlaceView = GObject.registerClass({
}
this.updatePlaceDetails();
- }
- updateLocation() {
- /* Called by the UserLocationMarker when its location changes */
- this._populate(this.place);
+ this._place.connect('notify::location', () => this._updateLocation());
}
get place() {
@@ -547,4 +544,9 @@ var PlaceView = GObject.registerClass({
_clearView() {
this._placeDetails.get_children().forEach((child) => child.destroy());
}
+
+ // called when the place's location changes (e.g. for the current location)
+ _updateLocation() {
+ this._populate(this.place);
+ }
});
diff --git a/src/userLocationMarker.js b/src/userLocationMarker.js
index d0a56725..6181d238 100644
--- a/src/userLocationMarker.js
+++ b/src/userLocationMarker.js
@@ -114,8 +114,6 @@ class UserLocationMarker extends MapMarker.MapMarker {
this.add_actor(this._actor);
this._updateAccuracyCircle();
- if (this._bubble)
- this._bubble.updateLocation();
}
_updateAccuracyCircle() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]