[shotwell] map: add menu entry to show/hide the map



commit 0a3e0b0d596961e62fd577924fc5cee4679a3388
Author: Andreas Brauchli <a brauchli elementarea net>
Date:   Fri Jul 22 23:30:11 2016 +0200

    map: add menu entry to show/hide the map
    
    Bind the show/hide map menu action to the keyboard shortcut F10
    Add help documentation for the map widget

 data/gsettings/org.yorba.shotwell.gschema.xml |  6 ++++++
 data/ui/event.ui                              |  5 +++++
 data/ui/events_directory.ui                   |  5 +++++
 data/ui/import.ui                             |  5 +++++
 data/ui/media.ui                              |  5 +++++
 data/ui/offline.ui                            |  5 +++++
 data/ui/photo.ui                              |  5 +++++
 data/ui/tags.ui                               |  5 +++++
 data/ui/trash.ui                              |  5 +++++
 help/C/view-information.page                  |  2 ++
 src/MapWidget.vala                            | 12 ++++++++++++
 src/config/ConfigurationInterfaces.vala       | 27 +++++++++++++++++++++++++--
 src/config/GSettingsEngine.vala               |  2 ++
 src/library/LibraryWindow.vala                | 17 +++++++++++++++++
 14 files changed, 104 insertions(+), 2 deletions(-)
---
diff --git a/data/gsettings/org.yorba.shotwell.gschema.xml b/data/gsettings/org.yorba.shotwell.gschema.xml
index 68593654..6ac75cf5 100644
--- a/data/gsettings/org.yorba.shotwell.gschema.xml
+++ b/data/gsettings/org.yorba.shotwell.gschema.xml
@@ -42,6 +42,12 @@
         <description>True if the bottom toolbar is to be displayed, false otherwise.</description>
     </key>
 
+    <key name="display-map-widget" type="b">
+        <default>true</default>
+        <summary>display map widget</summary>
+        <description>True if the map widget is to be displayed, false otherwise.</description>
+    </key>
+
     <key name="display-search-bar" type="b">
         <default>false</default>
         <summary>display search bar</summary>
diff --git a/data/ui/event.ui b/data/ui/event.ui
index 771b2a9d..8c0dcfee 100644
--- a/data/ui/event.ui
+++ b/data/ui/event.ui
@@ -123,6 +123,11 @@
           <attribute name="accel">&lt;Primary&gt;F9</attribute>
           <attribute name="action">win.CommonDisplayToolbar</attribute>
         </item>
+        <item>
+          <attribute name="label" translatable="yes">_Map Overview</attribute>
+          <attribute name="accel">F10</attribute>
+          <attribute name="action">win.CommonDisplayMap</attribute>
+        </item>
       </section>
       <section>
         <item>
diff --git a/data/ui/events_directory.ui b/data/ui/events_directory.ui
index 6d0e939e..00dba593 100644
--- a/data/ui/events_directory.ui
+++ b/data/ui/events_directory.ui
@@ -95,6 +95,11 @@
           <attribute name="accel">&lt;Primary&gt;F9</attribute>
           <attribute name="action">win.CommonDisplayToolbar</attribute>
         </item>
+        <item>
+          <attribute name="label" translatable="yes">_Map Overview</attribute>
+          <attribute name="accel">F10</attribute>
+          <attribute name="action">win.CommonDisplayMap</attribute>
+        </item>
       </section>
       <section>
         <item>
diff --git a/data/ui/import.ui b/data/ui/import.ui
index 6f13e314..c23b2f96 100644
--- a/data/ui/import.ui
+++ b/data/ui/import.ui
@@ -98,6 +98,11 @@
           <attribute name="accel">&lt;Primary&gt;F9</attribute>
           <attribute name="action">win.CommonDisplayToolbar</attribute>
         </item>
+        <item>
+          <attribute name="label" translatable="yes">_Map Overview</attribute>
+          <attribute name="accel">F10</attribute>
+          <attribute name="action">win.CommonDisplayMap</attribute>
+        </item>
       </section>
       <section>
         <item>
diff --git a/data/ui/media.ui b/data/ui/media.ui
index 22a6b835..3cd7ab41 100644
--- a/data/ui/media.ui
+++ b/data/ui/media.ui
@@ -123,6 +123,11 @@
           <attribute name="accel">&lt;Primary&gt;F9</attribute>
           <attribute name="action">win.CommonDisplayToolbar</attribute>
         </item>
+        <item>
+          <attribute name="label" translatable="yes">_Map Overview</attribute>
+          <attribute name="accel">F10</attribute>
+          <attribute name="action">win.CommonDisplayMap</attribute>
+        </item>
       </section>
       <section>
         <item>
diff --git a/data/ui/offline.ui b/data/ui/offline.ui
index 3daefca3..3372f0af 100644
--- a/data/ui/offline.ui
+++ b/data/ui/offline.ui
@@ -102,6 +102,11 @@
           <attribute name="accel">&lt;Primary&gt;F9</attribute>
           <attribute name="action">win.CommonDisplayToolbar</attribute>
         </item>
+        <item>
+          <attribute name="label" translatable="yes">_Map Overview</attribute>
+          <attribute name="accel">F10</attribute>
+          <attribute name="action">win.CommonDisplayMap</attribute>
+        </item>
       </section>
       <section>
         <submenu>
diff --git a/data/ui/photo.ui b/data/ui/photo.ui
index 3219557c..dc69a7c2 100644
--- a/data/ui/photo.ui
+++ b/data/ui/photo.ui
@@ -114,6 +114,11 @@
           <attribute name="accel">&lt;Primary&gt;F9</attribute>
           <attribute name="action">win.CommonDisplayToolbar</attribute>
         </item>
+        <item>
+          <attribute name="label" translatable="yes">_Map Overview</attribute>
+          <attribute name="accel">F10</attribute>
+          <attribute name="action">win.CommonDisplayMap</attribute>
+        </item>
       </section>
       <section>
         <item>
diff --git a/data/ui/tags.ui b/data/ui/tags.ui
index 03378aee..66b62f94 100644
--- a/data/ui/tags.ui
+++ b/data/ui/tags.ui
@@ -123,6 +123,11 @@
           <attribute name="accel">&lt;Primary&gt;F9</attribute>
           <attribute name="action">win.CommonDisplayToolbar</attribute>
         </item>
+        <item>
+          <attribute name="label" translatable="yes">_Map Overview</attribute>
+          <attribute name="accel">F10</attribute>
+          <attribute name="action">win.CommonDisplayMap</attribute>
+        </item>
       </section>
       <section>
         <item>
diff --git a/data/ui/trash.ui b/data/ui/trash.ui
index 1dc188d3..cf18c2aa 100644
--- a/data/ui/trash.ui
+++ b/data/ui/trash.ui
@@ -111,6 +111,11 @@
           <attribute name="accel">&lt;Primary&gt;F9</attribute>
           <attribute name="action">win.CommonDisplayToolbar</attribute>
         </item>
+        <item>
+          <attribute name="label" translatable="yes">_Map Overview</attribute>
+          <attribute name="accel">F10</attribute>
+          <attribute name="action">win.CommonDisplayMap</attribute>
+        </item>
       </section>
       <section>
         <submenu>
diff --git a/help/C/view-information.page b/help/C/view-information.page
index c62f27ec..380ba80a 100644
--- a/help/C/view-information.page
+++ b/help/C/view-information.page
@@ -13,6 +13,8 @@
 
 <p>The Basic Information pane appears at the bottom of the sidebar, and displays a brief summary of the 
photos you've selected. If no photos are selected, it displays a summary of the entire collection. You can 
toggle the display of this pane using the <guiseq><gui>View</gui><gui>Basic Information</gui></guiseq> 
command.</p>
 
+<p>The map pane appears at the bottom of the sidebar as part of the Basic Information pane, and displays an 
overview map the photos you've selected. If no photos are selected, it displays an overview of the entire 
collection. You can toggle the display of this pane using the <guiseq><gui>View</gui><gui>Show 
Map</gui></guiseq> command. Note that the map will only show when the Basic Information pane is displayed.</p>
+
 <p>The floating Extended Information window displays more information about the selected photo.  The 
<guiseq><gui>View</gui><gui>Extended Information</gui></guiseq> command or 
<keyseq><key>Ctrl</key><key>Shift</key><key>X</key></keyseq> toggles the display of this window.</p>
 
 </page>
diff --git a/src/MapWidget.vala b/src/MapWidget.vala
index df0dee3d..56295404 100644
--- a/src/MapWidget.vala
+++ b/src/MapWidget.vala
@@ -310,6 +310,7 @@ private class MapWidget : Gtk.Bin {
     private const uint DEFAULT_ZOOM_LEVEL = 8;
 
     private static MapWidget instance = null;
+    private bool hide_map = false;
 
     private GtkChamplain.Embed gtk_champlain_widget = new GtkChamplain.Embed();
     private Champlain.View map_view = null;
@@ -368,6 +369,17 @@ private class MapWidget : Gtk.Bin {
         Gtk.drag_finish(context, success, false, time);
     }
 
+    public new void set_visible(bool visible) {
+        /* hides Gtk.Widget.set_visible */
+        hide_map = !visible;
+        base.set_visible(visible);
+    }
+
+    public override void show_all() {
+        if (!hide_map)
+            base.show_all();
+    }
+
     public void set_page(Page page) {
         bool page_changed = false;
         if (this.page != page) {
diff --git a/src/config/ConfigurationInterfaces.vala b/src/config/ConfigurationInterfaces.vala
index 8af5a735..195a28f7 100644
--- a/src/config/ConfigurationInterfaces.vala
+++ b/src/config/ConfigurationInterfaces.vala
@@ -39,6 +39,7 @@ public enum ConfigurableProperty {
     DISPLAY_EXTENDED_PROPERTIES,
     DISPLAY_SIDEBAR,
     DISPLAY_TOOLBAR,
+    DISPLAY_MAP_WIDGET,
     DISPLAY_SEARCH_BAR,
     DISPLAY_PHOTO_RATINGS,
     DISPLAY_PHOTO_TAGS,
@@ -150,7 +151,10 @@ public enum ConfigurableProperty {
 
             case DISPLAY_TOOLBAR:
                 return "DISPLAY_TOOLBAR";
-                
+
+            case DISPLAY_MAP_WIDGET:
+                return "DISPLAY_MAP_WIDGET";
+
             case DISPLAY_SEARCH_BAR:
                 return "DISPLAY_SEARCH_BAR";
                 
@@ -722,7 +726,6 @@ public abstract class ConfigurationFacade : Object {
             on_configuration_error(err);
         }
     }
-    
 
     //
     // display toolbar
@@ -745,6 +748,26 @@ public abstract class ConfigurationFacade : Object {
         }
     }
 
+    //
+    // display map widget
+    //
+    public virtual bool get_display_map_widget() {
+        try {
+            return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_MAP_WIDGET);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+
+            return false;
+        }
+    }
+    public virtual void set_display_map_widget(bool display) {
+        try {
+            get_engine().set_bool_property(ConfigurableProperty.DISPLAY_MAP_WIDGET, display);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+        }
+    }
+
     //
     // display search & filter toolbar
     //
diff --git a/src/config/GSettingsEngine.vala b/src/config/GSettingsEngine.vala
index a3d4e04e..dcc05c6d 100644
--- a/src/config/GSettingsEngine.vala
+++ b/src/config/GSettingsEngine.vala
@@ -48,6 +48,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
         schema_names[ConfigurableProperty.DISPLAY_EXTENDED_PROPERTIES] = UI_PREFS_SCHEMA_NAME;
         schema_names[ConfigurableProperty.DISPLAY_SIDEBAR] = UI_PREFS_SCHEMA_NAME;
         schema_names[ConfigurableProperty.DISPLAY_TOOLBAR] = UI_PREFS_SCHEMA_NAME;
+        schema_names[ConfigurableProperty.DISPLAY_MAP_WIDGET] = UI_PREFS_SCHEMA_NAME;
         schema_names[ConfigurableProperty.DISPLAY_SEARCH_BAR] = UI_PREFS_SCHEMA_NAME;
         schema_names[ConfigurableProperty.DISPLAY_PHOTO_RATINGS] = UI_PREFS_SCHEMA_NAME;
         schema_names[ConfigurableProperty.DISPLAY_PHOTO_TAGS] = UI_PREFS_SCHEMA_NAME;
@@ -122,6 +123,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
         key_names[ConfigurableProperty.DISPLAY_EXTENDED_PROPERTIES] = "display-extended-properties";
         key_names[ConfigurableProperty.DISPLAY_SIDEBAR] = "display-sidebar";
         key_names[ConfigurableProperty.DISPLAY_TOOLBAR] = "display-toolbar";
+        key_names[ConfigurableProperty.DISPLAY_MAP_WIDGET] = "display-map-widget";
         key_names[ConfigurableProperty.DISPLAY_SEARCH_BAR] = "display-search-bar";
         key_names[ConfigurableProperty.DISPLAY_PHOTO_RATINGS] = "display-photo-ratings";
         key_names[ConfigurableProperty.DISPLAY_PHOTO_TAGS] = "display-photo-tags";
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index 079e801d..34052fc6 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -299,6 +299,7 @@ public class LibraryWindow : AppWindow {
         { "CommonDisplaySearchbar", null, null, "false", on_display_searchbar },
         { "CommonDisplaySidebar", on_action_toggle, null, "true", on_display_sidebar },
         { "CommonDisplayToolbar", null, null, "true", on_display_toolbar },
+        { "CommonDisplayMap", on_action_toggle, null, "true", on_display_map_widget },
 
         { "CommonSortEvents", on_action_radio, "s", "'ascending'", on_events_sort_changed }
     };
@@ -311,6 +312,7 @@ public class LibraryWindow : AppWindow {
         lookup_action ("CommonDisplaySearchbar").change_state 
(Config.Facade.get_instance().get_display_search_bar());
         lookup_action ("CommonDisplaySidebar").change_state (is_sidebar_visible ());
         lookup_action ("CommonDisplayToolbar").change_state (is_toolbar_visible ());
+        lookup_action ("CommonDisplayMap").change_state (is_map_widget_visible ());
     }
 
     protected override void switched_pages(Page? old_page, Page? new_page) {
@@ -770,6 +772,21 @@ public class LibraryWindow : AppWindow {
         return Config.Facade.get_instance ().get_display_toolbar ();
     }
 
+    private void on_display_map_widget (GLib.SimpleAction action, Variant variant) {
+        set_map_widget_visible (variant.get_boolean ());
+
+        action.set_state (variant);
+    }
+
+    private void set_map_widget_visible(bool visible) {
+        MapWidget.get_instance().set_visible(visible);
+        Config.Facade.get_instance().set_display_map_widget(visible);
+    }
+
+    private bool is_map_widget_visible() {
+        return Config.Facade.get_instance().get_display_map_widget();
+    }
+
     public void enqueue_batch_import(BatchImport batch_import, bool allow_user_cancel) {
         library_branch.import_queue_entry.enqueue_and_schedule(batch_import, allow_user_cancel);
     }


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