summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Westman <james@flyingpimonster.net>2020-08-05 17:32:05 -0500
committerJames Westman <james@flyingpimonster.net>2020-11-11 22:40:04 -0600
commit18ca9fb175c94bc41ea6f667814152cb84e6f28a (patch)
treefe18f9452db27487f5782ec1c9fc8706efc90d51
parent7a131b05866149f47acb764fefc39edf5448b4e5 (diff)
downloadgnome-maps-18ca9fb175c94bc41ea6f667814152cb84e6f28a.tar.gz
mapBubble: Move Edit button from placeBubble
This way, it can be shown alongside the rest of the buttons, rather than in the grid created by placeBubble.
-rw-r--r--data/ui/map-bubble.ui15
-rw-r--r--data/ui/place-bubble.ui28
-rw-r--r--src/mapBubble.js56
-rw-r--r--src/placeBubble.js61
4 files changed, 73 insertions, 87 deletions
diff --git a/data/ui/map-bubble.ui b/data/ui/map-bubble.ui
index 06bf37fb..c5971dae 100644
--- a/data/ui/map-bubble.ui
+++ b/data/ui/map-bubble.ui
@@ -98,6 +98,21 @@
<property name="tooltip-text" translatable="yes" comments="Translators: This is a tooltip">Check in here</property>
</object>
</child>
+ <child>
+ <object class="GtkButton" id="bubble-edit-button">
+ <property name="visible">False</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip-text" translatable="yes" comments="Translators: This is a tooltip">Edit on OpenStreetMap</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon-name">document-edit-symbolic</property>
+ <property name="pixel_size">16</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="left_attach">0</property>
diff --git a/data/ui/place-bubble.ui b/data/ui/place-bubble.ui
index 5689792f..57eb682c 100644
--- a/data/ui/place-bubble.ui
+++ b/data/ui/place-bubble.ui
@@ -37,34 +37,6 @@
</object>
</child>
<child>
- <object class="GtkGrid">
- <property name="margin-left">10</property>
- <property name="visible">True</property>
- <child>
- <object class="GtkButton" id="edit-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="valign">GTK_ALIGN_START</property>
- <property name="halign">GTK_ALIGN_CENTER</property>
- <property name="tooltip-text" translatable="yes" comments="Translators: This is a tooltip">Edit on OpenStreetMap</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon-name">document-edit-symbolic</property>
- <property name="pixel_size">16</property>
- </object>
- </child>
- <style>
- <class name="image-button"/>
- <class name="circular"/>
- <class name="flat"/>
- </style>
- </object>
- </child>
- </object>
- </child>
- <child>
<object class="GtkToggleButton" id="expand-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 998f0213..25fb4a4d 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -26,6 +26,9 @@ const Gtk = imports.gi.Gtk;
const Mainloop = imports.mainloop;
const Application = imports.application;
+const OSMAccountDialog = imports.osmAccountDialog;
+const OSMEditDialog = imports.osmEditDialog;
+const OSMUtils = imports.osmUtils;
const Place = imports.place;
const PlaceStore = imports.placeStore;
const SendToDialog = imports.sendToDialog;
@@ -36,7 +39,8 @@ var Button = {
ROUTE: 2,
SEND_TO: 4,
FAVORITE: 8,
- CHECK_IN: 16
+ CHECK_IN: 16,
+ EDIT_ON_OSM: 32,
};
var MapBubble = GObject.registerClass({ Abstract: true },
@@ -75,6 +79,7 @@ class MapBubble extends Gtk.Popover {
'bubble-send-to-button',
'bubble-favorite-button',
'bubble-check-in-button',
+ 'bubble-edit-button',
'bubble-favorite-button-image']);
this._image = ui.bubbleImage;
this._thumbnail = ui.bubbleThumbnail;
@@ -92,6 +97,8 @@ class MapBubble extends Gtk.Popover {
this._initFavoriteButton(ui.bubbleFavoriteButton, ui.bubbleFavoriteButtonImage);
if (buttonFlags & Button.CHECK_IN)
this._initCheckInButton(ui.bubbleCheckInButton, checkInMatchPlace);
+ if (buttonFlags & Button.EDIT_ON_OSM)
+ this._initEditButton(ui.bubbleEditButton);
}
this.add(ui.bubbleMainGrid);
@@ -189,4 +196,51 @@ class MapBubble extends Gtk.Popover {
matchPlace);
});
}
+
+ _initEditButton(button) {
+ button.visible = true;
+ button.connect('clicked', this._onEditClicked.bind(this));
+ }
+
+ _onEditClicked() {
+ let osmEdit = Application.osmEdit;
+ /* if the user is not alread signed in, show the account dialog */
+ if (!osmEdit.isSignedIn) {
+ let dialog = osmEdit.createAccountDialog(this.get_toplevel(), true);
+
+ dialog.show();
+ dialog.connect('response', (dialog, response) => {
+ dialog.destroy();
+ if (response === OSMAccountDialog.Response.SIGNED_IN)
+ this._edit();
+ });
+
+ return;
+ }
+
+ this._edit();
+ }
+
+ _edit() {
+ let osmEdit = Application.osmEdit;
+ let dialog = osmEdit.createEditDialog(this.get_toplevel(), this._place);
+
+ dialog.show();
+ dialog.connect('response', (dialog, response) => {
+ dialog.destroy();
+
+ switch (response) {
+ case OSMEditDialog.Response.UPLOADED:
+ // update place
+ let object = osmEdit.object;
+ OSMUtils.updatePlaceFromOSMObject(this._place, object);
+ // refresh place view
+ this._clearView();
+ this._populate(this._place);
+ break;
+ default:
+ break;
+ }
+ });
+ }
});
diff --git a/src/placeBubble.js b/src/placeBubble.js
index a9adefd1..107ac79a 100644
--- a/src/placeBubble.js
+++ b/src/placeBubble.js
@@ -29,9 +29,6 @@ const Format = imports.format;
const Application = imports.application;
const ContactPlace = imports.contactPlace;
const MapBubble = imports.mapBubble;
-const OSMAccountDialog = imports.osmAccountDialog;
-const OSMEditDialog = imports.osmEditDialog;
-const OSMUtils = imports.osmUtils;
const Overpass = imports.overpass;
const Place = imports.place;
const PlaceFormatter = imports.placeFormatter;
@@ -60,7 +57,6 @@ var PlaceBubble = GObject.registerClass({
'box-content',
'grid-content',
'label-title',
- 'edit-button',
'expand-button',
'expanded-content',
'content-revealer']);
@@ -70,6 +66,9 @@ var PlaceBubble = GObject.registerClass({
if (params.place.store)
params.buttons |= MapBubble.Button.FAVORITE;
+ if (!(params.place instanceof ContactPlace.ContactPlace) && params.place.osm_id)
+ params.buttons |= MapBubble.Button.EDIT_ON_OSM;
+
super._init(params);
Utils.load_icon(this.place.icon, 48, (pixbuf) => this.image.pixbuf = pixbuf);
@@ -78,7 +77,6 @@ var PlaceBubble = GObject.registerClass({
this._title = ui.labelTitle;
this._boxContent = ui.boxContent;
this._gridContent = ui.gridContent;
- this._editButton = ui.editButton;
this._expandButton = ui.expandButton;
this._expandedContent = ui.expandedContent;
this._revealer = ui.contentRevealer;
@@ -108,12 +106,6 @@ var PlaceBubble = GObject.registerClass({
}
this.content.add(this._stack);
- let osm_id = this.place.osm_id;
- if (this.place instanceof ContactPlace.ContactPlace || !osm_id)
- this._editButton.visible = false;
- else
- this._initEditButton();
-
this._initExpandButton();
}
@@ -313,11 +305,6 @@ var PlaceBubble = GObject.registerClass({
this._expandedContent.get_children().forEach((child) => child.destroy());
}
- _initEditButton() {
- this._editButton.visible = true;
- this._editButton.connect('clicked', this._onEditClicked.bind(this));
- }
-
_initExpandButton() {
let image = this._expandButton.get_child();
@@ -325,46 +312,4 @@ var PlaceBubble = GObject.registerClass({
this._revealer.reveal_child = !this._revealer.child_revealed;
}).bind(this));
}
-
- _onEditClicked() {
- let osmEdit = Application.osmEdit;
- /* if the user is not alread signed in, show the account dialog */
- if (!osmEdit.isSignedIn) {
- let dialog = osmEdit.createAccountDialog(this.get_toplevel(), true);
-
- dialog.show();
- dialog.connect('response', (dialog, response) => {
- dialog.destroy();
- if (response === OSMAccountDialog.Response.SIGNED_IN)
- this._edit();
- });
-
- return;
- }
-
- this._edit();
- }
-
- _edit() {
- let osmEdit = Application.osmEdit;
- let dialog = osmEdit.createEditDialog(this.get_toplevel(), this._place);
-
- dialog.show();
- dialog.connect('response', (dialog, response) => {
- dialog.destroy();
-
- switch (response) {
- case OSMEditDialog.Response.UPLOADED:
- // update place
- let object = osmEdit.object;
- OSMUtils.updatePlaceFromOSMObject(this._place, object);
- // refresh place view
- this._clearView();
- this._populate(this._place);
- break;
- default:
- break;
- }
- });
- }
});