[gnome-maps] MainWindow: Add favorites toggle
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] MainWindow: Add favorites toggle
- Date: Mon, 24 Nov 2014 06:50:27 +0000 (UTC)
commit aa3315e10af11a6e4c6f8ea584f76b772a3d64b2
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Sat Nov 22 21:13:57 2014 +0100
MainWindow: Add favorites toggle
https://bugzilla.gnome.org/show_bug.cgi?id=722102
src/main-window.ui | 21 +++++++++++++++++++++
src/mainWindow.js | 37 ++++++++++++++++++++++---------------
2 files changed, 43 insertions(+), 15 deletions(-)
---
diff --git a/src/main-window.ui b/src/main-window.ui
index 3e725a8..6094495 100644
--- a/src/main-window.ui
+++ b/src/main-window.ui
@@ -76,6 +76,27 @@
<property name="pack-type">end</property>
</packing>
</child>
+ <child>
+ <object class="GtkMenuButton" id="favorites-button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="valign">center</property>
+ <property name="tooltip-text" translatable="yes">Toggle favorites</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="favorites-button-image">
+ <property name="visible">True</property>
+ <property name="icon-size">1</property>
+ <property name="icon-name">emblem-favorite-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
</object>
</child>
<child>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d833166..30455ae 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -31,9 +31,11 @@ const Mainloop = imports.mainloop;
const Application = imports.application;
const Config = imports.config;
const ContextMenu = imports.contextMenu;
+const FavoritesPopover = imports.favoritesPopover;
const LayersPopover = imports.layersPopover;
const MapView = imports.mapView;
const PlaceEntry = imports.placeEntry;
+const PlaceStore = imports.placeStore;
const Sidebar = imports.sidebar;
const Utils = imports.utils;
const ZoomControl = imports.zoomControl;
@@ -56,7 +58,8 @@ const MainWindow = new Lang.Class({
'no-network-view',
'goto-user-location-button',
'toggle-sidebar-button',
- 'layers-button']);
+ 'layers-button',
+ 'favorites-button' ]);
this.window = ui.appWindow;
this.window.application = app;
this._overlay = overlay;
@@ -71,7 +74,7 @@ const MainWindow = new Lang.Class({
this._contextMenu = new ContextMenu.ContextMenu(this.mapView);
ui.layersButton.popover = new LayersPopover.LayersPopover();
-
+ ui.favoritesButton.popover = new FavoritesPopover.FavoritesPopover({ mapView: this.mapView });
this._overlay.add_overlay(new ZoomControl.ZoomControl(this.mapView));
this._mainStack = ui.mainStack;
@@ -81,6 +84,7 @@ const MainWindow = new Lang.Class({
this._gotoUserLocationButton = ui.gotoUserLocationButton;
this._toggleSidebarButton = ui.toggleSidebarButton;
this._layersButton = ui.layersButton;
+ this._favoritesButton = ui.favoritesButton;
this._initHeaderbar();
this._initActions();
@@ -194,19 +198,22 @@ const MainWindow = new Lang.Class({
this._headerBar.custom_title = this._placeEntry;
this._placeEntry.has_focus = true;
- let app = this.window.application;
- app.bind_property('connected',
- this._gotoUserLocationButton, 'sensitive',
- GObject.BindingFlags.DEFAULT);
- app.bind_property('connected',
- this._layersButton, 'sensitive',
- GObject.BindingFlags.DEFAULT);
- app.bind_property('connected',
- this._toggleSidebarButton, 'sensitive',
- GObject.BindingFlags.DEFAULT);
- app.bind_property('connected',
- this._placeEntry, 'sensitive',
- GObject.BindingFlags.DEFAULT);
+ let favoritesPopover = this._favoritesButton.popover;
+ this._favoritesButton.sensitive = favoritesPopover.rows > 0;
+ favoritesPopover.connect('notify::rows', (function() {
+ this._favoritesButton.sensitive = favoritesPopover.rows > 0;
+ }).bind(this));
+
+ this.window.application.connect('notify::connected', (function() {
+ let app = this.window.application;
+
+ this._gotoUserLocationButton.sensitive = app.connected;
+ this._layersButton.sensitive = app.connected;
+ this._toggleSidebarButton.sensitive = app.connected;
+ this._favoritesButton.sensitive = (app.connected &&
+ favoritesPopover.rows > 0);
+ this._placeEntry.sensitive = app.connected;
+ }).bind(this));
},
_saveWindowGeometry: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]