[gnome-maps/wip/favorites: 7/9] MainWindow: Add favorites toggle



commit e4d3be2a2c7663bf005eb3f4b9645622528152ee
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Sat Nov 22 00:55:55 2014 +0100

    MainWindow: Add favorites toggle
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722102

 src/mainWindow.js |   19 +++++++++++++++++--
 src/map-bubble.ui |   17 +++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index bbdb4bd..b1a91e7 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();
@@ -193,6 +197,14 @@ const MainWindow = new Lang.Class({
         this._headerBar.custom_title = this._placeEntry;
         this._placeEntry.has_focus = true;
 
+        this._favoritesButton.popover.connect('rows-changed', (function() {
+            if (this._favoritesButton.popover.rows > 0)
+                this._favoritesButton.sensitive = true;
+            else
+                this._favoritesButton.sensitive = false;
+        }).bind(this));
+
+
         let app = this.window.application;
         app.bind_property('connected',
                           this._gotoUserLocationButton, 'sensitive',
@@ -204,6 +216,9 @@ const MainWindow = new Lang.Class({
                           this._toggleSidebarButton, 'sensitive',
                           GObject.BindingFlags.DEFAULT);
         app.bind_property('connected',
+                          this._favoritesButton, 'sensitive',
+                          GObject.BindingFlags.DEFAULT);
+        app.bind_property('connected',
                           this._placeEntry, 'sensitive',
                           GObject.BindingFlags.DEFAULT);
     },
diff --git a/src/map-bubble.ui b/src/map-bubble.ui
index 1cbb149..b7143ab 100644
--- a/src/map-bubble.ui
+++ b/src/map-bubble.ui
@@ -78,6 +78,23 @@
                 </child>
               </object>
             </child>
+            <child>
+              <object class="GtkToggleButton" id="bubble-favorite-button">
+                <property name="name">bubble-favorite-button</property>
+                <property name="visible">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <child>
+                  <object class="GtkImage" id="bubble-favorite-button-image">
+                <property name="name">bubble-favorite-button-image</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon-name">emblem-favorite-symbolic</property>
+                    <property name="pixel_size">16</property>
+                  </object>
+                </child>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="left_attach">0</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]