[shotwell] Fix actions for fullscreen



commit 719fc9935a3f8c36009e028e8e893347e0b730ab
Author: Jens Georg <mail jensge org>
Date:   Sat Dec 31 00:41:06 2016 +0100

    Fix actions for fullscreen
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776614
    
    Signed-off-by: Jens Georg <mail jensge org>

 src/CollectionPage.vala             |   12 ++++++------
 src/MediaPage.vala                  |   14 +++++++-------
 src/Page.vala                       |   22 +++++++++++++++-------
 src/PhotoPage.vala                  |   15 +++++++--------
 src/camera/ImportPage.vala          |   12 ++++++------
 src/direct/DirectPhotoPage.vala     |   12 ++++++------
 src/events/EventPage.vala           |   12 ++++++------
 src/events/EventsDirectoryPage.vala |   12 ++++++------
 src/library/ImportQueuePage.vala    |   12 ++++++------
 src/library/LibraryWindow.vala      |    4 +++-
 src/library/OfflinePage.vala        |   12 ++++++------
 src/library/TrashPage.vala          |   12 ++++++------
 src/searches/SavedSearchPage.vala   |   12 ++++++------
 src/tags/TagPage.vala               |   12 ++++++------
 14 files changed, 92 insertions(+), 83 deletions(-)
---
diff --git a/src/CollectionPage.vala b/src/CollectionPage.vala
index 0c97bf9..3be532c 100644
--- a/src/CollectionPage.vala
+++ b/src/CollectionPage.vala
@@ -170,16 +170,16 @@ public abstract class CollectionPage : MediaPage {
         { "Slideshow", on_slideshow }
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions (GLib.ActionMap map) {
+        base.add_actions (map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries (entries, this);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/MediaPage.vala b/src/MediaPage.vala
index b21517e..a2d5185 100644
--- a/src/MediaPage.vala
+++ b/src/MediaPage.vala
@@ -320,14 +320,14 @@ public abstract class MediaPage : CheckerboardPage {
         { "Sort", on_action_radio, "s", "'ascending'", on_sort_changed },
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions (GLib.ActionMap map) {
+        base.add_actions (map);
 
         bool sort_order;
         int sort_by;
         get_config_photos_sort(out sort_order, out sort_by);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries (entries, this);
         get_action ("ViewTitle").change_state (Config.Facade.get_instance ().get_display_photo_titles ());
         get_action ("ViewComment").change_state (Config.Facade.get_instance ().get_display_photo_comments 
());
         get_action ("ViewRatings").change_state (Config.Facade.get_instance ().get_display_photo_ratings ());
@@ -340,13 +340,13 @@ public abstract class MediaPage : CheckerboardPage {
                 GLib.VariantType.STRING, d == RawDeveloper.SHOTWELL ? "Shotwell" : "Camera");
         action.change_state.connect(on_raw_developer_changed);
         action.set_enabled(true);
-        AppWindow.get_instance().add_action(action);
+        map.add_action(action);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/Page.vala b/src/Page.vala
index 9a6549a..06454d8 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -268,7 +268,7 @@ public abstract class Page : Gtk.ScrolledWindow {
     
     public virtual void switching_from() {
         in_view = false;
-        remove_actions();
+        remove_actions(AppWindow.get_instance());
         if (toolbar_path != null)
             toolbar = null;
     }
@@ -276,7 +276,7 @@ public abstract class Page : Gtk.ScrolledWindow {
     public virtual void switched_to() {
         in_view = true;
         add_ui();
-        add_actions();
+        add_actions(AppWindow.get_instance());
         int selected_count = get_view().get_selected_count();
         int count = get_view().get_count();
         init_actions(selected_count, count);
@@ -292,16 +292,24 @@ public abstract class Page : Gtk.ScrolledWindow {
     }
     
     public virtual void switching_to_fullscreen(FullscreenWindow fsw) {
+        add_actions(fsw);
     }
     
     public virtual void returning_from_fullscreen(FullscreenWindow fsw) {
+        remove_actions(fsw);
+        switched_to();
     }
 
     public GLib.Action? get_action (string name) {
-        var aw = AppWindow.get_instance ();
+        GLib.ActionMap? map = null;
+        if (container is FullscreenWindow) {
+            map = container as GLib.ActionMap;
+        } else {
+            map = AppWindow.get_instance () as GLib.ActionMap;
+        }
 
-        if (aw != null) {
-            return aw.lookup_action (name);
+        if (map != null) {
+            return map.lookup_action(name);
         }
 
         return null;
@@ -472,8 +480,8 @@ public abstract class Page : Gtk.ScrolledWindow {
         return AppWindow.get_command_manager();
     }
 
-    protected virtual void add_actions () { }
-    protected virtual void remove_actions () { }
+    protected virtual void add_actions (GLib.ActionMap map) { }
+    protected virtual void remove_actions (GLib.ActionMap map) { }
 
     protected void on_action_toggle (GLib.Action action, Variant? value) {
         Variant new_state = ! (bool) action.get_state ();
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index 2c86acb..5c8537f 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -2433,23 +2433,23 @@ public class LibraryPhotoPage : EditingHostPage {
         // Radio actions
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions (GLib.ActionMap map) {
+        base.add_actions (map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries (entries, this);
         (get_action ("ViewRatings") as GLib.SimpleAction).change_state (Config.Facade.get_instance 
().get_display_photo_ratings ());
         var d = Config.Facade.get_instance().get_default_raw_developer();
         var action = new GLib.SimpleAction.stateful("RawDeveloper",
                 GLib.VariantType.STRING, d == RawDeveloper.SHOTWELL ? "Shotwell" : "Camera");
         action.change_state.connect(on_raw_developer_changed);
         action.set_enabled(true);
-        AppWindow.get_instance().add_action(action);
+        map.add_action(action);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
@@ -3140,6 +3140,5 @@ public class LibraryPhotoPage : EditingHostPage {
         
         get_command_manager().execute(new ModifyTagsCommand(photo, new_tags));
     }
-
 }
 
diff --git a/src/camera/ImportPage.vala b/src/camera/ImportPage.vala
index ca54836..734c06d 100644
--- a/src/camera/ImportPage.vala
+++ b/src/camera/ImportPage.vala
@@ -879,18 +879,18 @@ public class ImportPage : CheckerboardPage {
         { "ViewTitle", on_action_toggle, null, "false", on_display_titles },
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions (GLib.ActionMap map) {
+        base.add_actions (map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries (entries, this);
 
         get_action ("ViewTitle").change_state (Config.Facade.get_instance ().get_display_photo_titles ());
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/direct/DirectPhotoPage.vala b/src/direct/DirectPhotoPage.vala
index a07305d..a48f9e0 100644
--- a/src/direct/DirectPhotoPage.vala
+++ b/src/direct/DirectPhotoPage.vala
@@ -65,16 +65,16 @@ public class DirectPhotoPage : EditingHostPage {
         { "Zoom200", snap_zoom_to_max }
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions (GLib.ActionMap map) {
+        base.add_actions (map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries (entries, this);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/events/EventPage.vala b/src/events/EventPage.vala
index f4179c5..960eee8 100644
--- a/src/events/EventPage.vala
+++ b/src/events/EventPage.vala
@@ -53,16 +53,16 @@ public class EventPage : CollectionPage {
         { "EditEventComment", on_edit_comment }
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions(GLib.ActionMap map) {
+        base.add_actions(map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries(entries, this);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/events/EventsDirectoryPage.vala b/src/events/EventsDirectoryPage.vala
index cc5ca22..4650fd2 100644
--- a/src/events/EventsDirectoryPage.vala
+++ b/src/events/EventsDirectoryPage.vala
@@ -114,18 +114,18 @@ public abstract class EventsDirectoryPage : CheckerboardPage {
         { "ViewComment", on_action_toggle, null, "false", on_display_comments  }
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
-        AppWindow.get_instance ().add_action_entries (entries, this);
+    protected override void add_actions (GLib.ActionMap map) {
+        base.add_actions (map);
+        map.add_action_entries (entries, this);
 
         var display_comments = Config.Facade.get_instance().get_display_event_comments();
         get_action ("ViewComment").change_state (display_comments);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/library/ImportQueuePage.vala b/src/library/ImportQueuePage.vala
index fc6e999..feb525d 100644
--- a/src/library/ImportQueuePage.vala
+++ b/src/library/ImportQueuePage.vala
@@ -63,16 +63,16 @@ public class ImportQueuePage : SinglePhotoPage {
         {"Stop", on_stop }
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions (GLib.ActionMap map) {
+        base.add_actions(map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries(entries, this);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index ccb9fb5..0a39318 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -84,12 +84,14 @@ public class LibraryWindow : AppWindow {
             base.switched_to();
         }
 
+        public override void switching_from() {
+        }
+
         protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
             // We intentionally don't call the base class here since we don't want the
             // top-level menu in photo.ui.
             ui_filenames.add("photo_context.ui");
         }
-        
     }
 
     private string import_dir = Environment.get_home_dir();
diff --git a/src/library/OfflinePage.vala b/src/library/OfflinePage.vala
index 115c592..1982618 100644
--- a/src/library/OfflinePage.vala
+++ b/src/library/OfflinePage.vala
@@ -56,16 +56,16 @@ public class OfflinePage : CheckerboardPage {
         { "RemoveFromLibrary", on_remove_from_library }
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions (GLib.ActionMap map) {
+        base.add_actions(map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries(entries, this);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/library/TrashPage.vala b/src/library/TrashPage.vala
index f01970b..c06fbbf 100644
--- a/src/library/TrashPage.vala
+++ b/src/library/TrashPage.vala
@@ -52,16 +52,16 @@ public class TrashPage : CheckerboardPage {
         { "Restore", on_restore }
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions(GLib.ActionMap map) {
+        base.add_actions(map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries (entries, this);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/searches/SavedSearchPage.vala b/src/searches/SavedSearchPage.vala
index 2db26d3..9267137 100644
--- a/src/searches/SavedSearchPage.vala
+++ b/src/searches/SavedSearchPage.vala
@@ -53,16 +53,16 @@ public class SavedSearchPage : CollectionPage {
         { "DeleteSearch", on_delete_search }
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions(GLib.ActionMap map) {
+        base.add_actions(map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries(entries, this);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 
diff --git a/src/tags/TagPage.vala b/src/tags/TagPage.vala
index fe31165..431eaf4 100644
--- a/src/tags/TagPage.vala
+++ b/src/tags/TagPage.vala
@@ -47,16 +47,16 @@ public class TagPage : CollectionPage {
         { "NewChildTagSidebar", on_new_child_tag_sidebar }
     };
 
-    protected override void add_actions () {
-        base.add_actions ();
+    protected override void add_actions(GLib.ActionMap map) {
+        base.add_actions(map);
 
-        AppWindow.get_instance ().add_action_entries (entries, this);
+        map.add_action_entries(entries, this);
     }
 
-    protected override void remove_actions() {
-        base.remove_actions();
+    protected override void remove_actions(GLib.ActionMap map) {
+        base.remove_actions(map);
         foreach (var entry in entries) {
-            AppWindow.get_instance().remove_action(entry.name);
+            map.remove_action(entry.name);
         }
     }
 


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