[shotwell/wip/dedeprecate: 44/64] WIP



commit 7cfd432312f8b5c442bc27a09edf434661715898
Author: Jens Georg <mail jensge org>
Date:   Wed Nov 2 22:34:38 2016 +0100

    WIP

 src/CollectionPage.vala             |    5 +-
 src/MediaPage.vala                  |  365 ++++++++---------------------------
 src/Page.vala                       |   89 ++++-----
 src/PhotoPage.vala                  |    9 +-
 src/camera/ImportPage.vala          |    4 +-
 src/events/EventsDirectoryPage.vala |   20 +-
 src/library/ImportQueuePage.vala    |    2 +-
 src/library/LibraryWindow.vala      |   58 ++----
 ui/events_directory.ui              |    6 +-
 ui/import.ui                        |    6 +-
 ui/import_queue.ui                  |    6 +-
 ui/media.ui                         |   40 +++--
 ui/offline.ui                       |    6 +-
 ui/photo.ui                         |    6 +-
 ui/trash.ui                         |    6 +-
 15 files changed, 209 insertions(+), 419 deletions(-)
---
diff --git a/src/CollectionPage.vala b/src/CollectionPage.vala
index d4004f2..169b1c9 100644
--- a/src/CollectionPage.vala
+++ b/src/CollectionPage.vala
@@ -333,12 +333,13 @@ public abstract class CollectionPage : MediaPage {
         
         set_action_sensitive("SetBackground", (!selection_has_videos) && has_selected );
         if (has_selected) {
-            Gtk.Action? set_background = get_action("SetBackground");
+            critical ("Setting action label for SetBackground...");
+/*            Gtk.Action? set_background = get_action("SetBackground");
             if (set_background != null) {
                 set_background.label = one_selected
                     ? Resources.SET_BACKGROUND_MENU
                     : Resources.SET_BACKGROUND_SLIDESHOW_MENU;
-            }
+            } */
         }
     }
 
diff --git a/src/MediaPage.vala b/src/MediaPage.vala
index 89aa2fc..fe76f2b 100644
--- a/src/MediaPage.vala
+++ b/src/MediaPage.vala
@@ -282,250 +282,69 @@ public abstract class MediaPage : CheckerboardPage {
         
         ui_filenames.add("media.ui");
     }
-    
-    protected override Gtk.ActionEntry[] init_collect_action_entries() {
-        Gtk.ActionEntry[] actions = base.init_collect_action_entries();
-        
-        Gtk.ActionEntry export = { "Export", Resources.SAVE_AS_LABEL, TRANSLATABLE, "<Ctrl><Shift>E",
-            TRANSLATABLE, on_export };
-        export.label = Resources.EXPORT_MENU;
-        actions += export;
-
-        Gtk.ActionEntry send_to = { "SendTo", "document-send", TRANSLATABLE, null, 
-            TRANSLATABLE, on_send_to };
-        send_to.label = Resources.SEND_TO_MENU;
-        actions += send_to;
-
-        // This is identical to the above action, except that it has different 
-        // mnemonics and is _only_ for use in the context menu.
-        Gtk.ActionEntry send_to_context_menu = { "SendToContextMenu", "document-send", TRANSLATABLE, null,
-            TRANSLATABLE, on_send_to };
-        send_to_context_menu.label = Resources.SEND_TO_CONTEXT_MENU;
-        actions += send_to_context_menu;
-        
-        Gtk.ActionEntry remove_from_library = { "RemoveFromLibrary", Resources.REMOVE_LABEL, TRANSLATABLE,
-            "<Shift>Delete", TRANSLATABLE, on_remove_from_library };
-        remove_from_library.label = Resources.REMOVE_FROM_LIBRARY_MENU;
-        actions += remove_from_library;
-        
-        Gtk.ActionEntry move_to_trash = { "MoveToTrash", "user-trash-full", TRANSLATABLE, "Delete",
-            TRANSLATABLE, on_move_to_trash };
-        move_to_trash.label = Resources.MOVE_TO_TRASH_MENU;
-        actions += move_to_trash;
-        
-        Gtk.ActionEntry new_event = { "NewEvent", Resources.NEW_LABEL, TRANSLATABLE, "<Ctrl>N",
-            TRANSLATABLE, on_new_event };
-        new_event.label = Resources.NEW_EVENT_MENU;
-        actions += new_event;
-
-        Gtk.ActionEntry add_tags = { "AddTags", null, TRANSLATABLE, "<Ctrl>T", TRANSLATABLE, 
-            on_add_tags };
-        add_tags.label = Resources.ADD_TAGS_MENU;
-        actions += add_tags;
-
-        // This is identical to the above action, except that it has different 
-        // mnemonics and is _only_ for use in the context menu.
-        Gtk.ActionEntry add_tags_context_menu = { "AddTagsContextMenu", null, TRANSLATABLE, "<Ctrl>A", 
TRANSLATABLE,
-            on_add_tags };
-        add_tags_context_menu.label = Resources.ADD_TAGS_CONTEXT_MENU;
-        actions += add_tags_context_menu;
-
-        Gtk.ActionEntry modify_tags = { "ModifyTags", null, TRANSLATABLE, "<Ctrl>M", TRANSLATABLE, 
-            on_modify_tags };
-        modify_tags.label = Resources.MODIFY_TAGS_MENU;
-        actions += modify_tags;
-
-        Gtk.ActionEntry increase_size = { "IncreaseSize", Resources.ZOOM_IN_LABEL, TRANSLATABLE,
-            "<Ctrl>plus", TRANSLATABLE, on_increase_size };
-        increase_size.label = _("Zoom _In");
-        increase_size.tooltip = _("Increase the magnification of the thumbnails");
-        actions += increase_size;
-
-        Gtk.ActionEntry decrease_size = { "DecreaseSize", Resources.ZOOM_OUT_LABEL, TRANSLATABLE,
-            "<Ctrl>minus", TRANSLATABLE, on_decrease_size };
-        decrease_size.label = _("Zoom _Out");
-        decrease_size.tooltip = _("Decrease the magnification of the thumbnails");
-        actions += decrease_size;
-        
-        Gtk.ActionEntry flag = { "Flag", null, TRANSLATABLE, "<Ctrl>G", TRANSLATABLE, on_flag_unflag };
-        flag.label = Resources.FLAG_MENU;
-        actions += flag;
-        
-        Gtk.ActionEntry set_rating = { "Rate", null, TRANSLATABLE, null, null, null };
-        set_rating.label = Resources.RATING_MENU;
-        actions += set_rating;
-
-        Gtk.ActionEntry increase_rating = { "IncreaseRating", null, TRANSLATABLE, 
-            "greater", TRANSLATABLE, on_increase_rating };
-        increase_rating.label = Resources.INCREASE_RATING_MENU;
-        actions += increase_rating;
-
-        Gtk.ActionEntry decrease_rating = { "DecreaseRating", null, TRANSLATABLE, 
-            "less", TRANSLATABLE, on_decrease_rating };
-        decrease_rating.label = Resources.DECREASE_RATING_MENU;
-        actions += decrease_rating;
-
-        Gtk.ActionEntry rate_rejected = { "RateRejected", null, TRANSLATABLE, 
-            "9", TRANSLATABLE, on_rate_rejected };
-        rate_rejected.label = Resources.rating_menu(Rating.REJECTED);
-        actions += rate_rejected;
-
-        Gtk.ActionEntry rate_unrated = { "RateUnrated", null, TRANSLATABLE, 
-            "0", TRANSLATABLE, on_rate_unrated };
-        rate_unrated.label = Resources.rating_menu(Rating.UNRATED);
-        actions += rate_unrated;
-
-        Gtk.ActionEntry rate_one = { "RateOne", null, TRANSLATABLE, 
-            "1", TRANSLATABLE, on_rate_one };
-        rate_one.label = Resources.rating_menu(Rating.ONE);
-        actions += rate_one;
-
-        Gtk.ActionEntry rate_two = { "RateTwo", null, TRANSLATABLE, 
-            "2", TRANSLATABLE, on_rate_two };
-        rate_two.label = Resources.rating_menu(Rating.TWO);
-        actions += rate_two;
-
-        Gtk.ActionEntry rate_three = { "RateThree", null, TRANSLATABLE, 
-            "3", TRANSLATABLE, on_rate_three };
-        rate_three.label = Resources.rating_menu(Rating.THREE);
-        actions += rate_three;
-
-        Gtk.ActionEntry rate_four = { "RateFour", null, TRANSLATABLE, 
-            "4", TRANSLATABLE, on_rate_four };
-        rate_four.label = Resources.rating_menu(Rating.FOUR);
-        actions += rate_four;
-
-        Gtk.ActionEntry rate_five = { "RateFive", null, TRANSLATABLE, 
-            "5", TRANSLATABLE, on_rate_five };
-        rate_five.label = Resources.rating_menu(Rating.FIVE);
-        actions += rate_five;
-
-        Gtk.ActionEntry edit_title = { "EditTitle", null, TRANSLATABLE, "F2", TRANSLATABLE,
-            on_edit_title };
-        edit_title.label = Resources.EDIT_TITLE_MENU;
-        actions += edit_title;
-
-        Gtk.ActionEntry edit_comment = { "EditComment", null, TRANSLATABLE, "F3", TRANSLATABLE,
-            on_edit_comment };
-        edit_comment.label = Resources.EDIT_COMMENT_MENU;
-        actions += edit_comment;
-
-        Gtk.ActionEntry sort_photos = { "SortPhotos", null, TRANSLATABLE, null, null, null };
-        sort_photos.label = _("Sort _Photos");
-        actions += sort_photos;
-
-        Gtk.ActionEntry filter_photos = { "FilterPhotos", null, TRANSLATABLE, null, null, null };
-        filter_photos.label = Resources.FILTER_PHOTOS_MENU;
-        actions += filter_photos;
-        
-        Gtk.ActionEntry play = { "PlayVideo", Resources.PLAY_LABEL, TRANSLATABLE, "<Ctrl>Y",
-            TRANSLATABLE, on_play_video };
-        play.label = _("_Play Video");
-        play.tooltip = _("Open the selected videos in the system video player");
-        actions += play;
-        
-        Gtk.ActionEntry raw_developer = { "RawDeveloper", null, TRANSLATABLE, null, null, null };
-        raw_developer.label = _("_Developer");
-        actions += raw_developer;
-        
-        // RAW developers.
-        
-        Gtk.ActionEntry dev_shotwell = { "RawDeveloperShotwell", null, TRANSLATABLE, null, TRANSLATABLE,
-            on_raw_developer_shotwell };
-        dev_shotwell.label = _("Shotwell");
-        actions += dev_shotwell;
-        
-        Gtk.ActionEntry dev_camera = { "RawDeveloperCamera", null, TRANSLATABLE, null, TRANSLATABLE,
-            on_raw_developer_camera };
-        dev_camera.label = _("Camera");
-        actions += dev_camera;
-
-        return actions;
-    }
-    
-    protected override Gtk.ToggleActionEntry[] init_collect_toggle_action_entries() {
-        Gtk.ToggleActionEntry[] toggle_actions = base.init_collect_toggle_action_entries();
-        
-        Gtk.ToggleActionEntry titles = { "ViewTitle", null, TRANSLATABLE, "<Ctrl><Shift>T",
-            TRANSLATABLE, on_display_titles, Config.Facade.get_instance().get_display_photo_titles() };
-        titles.label = _("_Titles");
-        titles.tooltip = _("Display the title of each photo");
-        toggle_actions += titles;
-        
-        Gtk.ToggleActionEntry comments = { "ViewComment", null, TRANSLATABLE, "<Ctrl><Shift>C",
-            TRANSLATABLE, on_display_comments, Config.Facade.get_instance().get_display_photo_comments() };
-        comments.label = _("_Comments");
-        comments.tooltip = _("Display the comment of each photo");
-        toggle_actions += comments;
-        
-        Gtk.ToggleActionEntry ratings = { "ViewRatings", null, TRANSLATABLE, "<Ctrl><Shift>N",
-            TRANSLATABLE, on_display_ratings, Config.Facade.get_instance().get_display_photo_ratings() };
-        ratings.label = Resources.VIEW_RATINGS_MENU;
-        ratings.tooltip = Resources.VIEW_RATINGS_TOOLTIP;
-        toggle_actions += ratings;
-
-        Gtk.ToggleActionEntry tags = { "ViewTags", null, TRANSLATABLE, "<Ctrl><Shift>G",
-            TRANSLATABLE, on_display_tags, Config.Facade.get_instance().get_display_photo_tags() };
-        tags.label = _("Ta_gs");
-        tags.tooltip = _("Display each photo’s tags");
-        toggle_actions += tags;
-        
-        return toggle_actions;
-    }
-    
-    protected override void register_radio_actions(Gtk.ActionGroup action_group) {
+
+    private const GLib.ActionEntry[] entries = {
+        { "Export", on_export },
+        { "SendTo", on_send_to },
+        { "SendToContextMenu", on_send_to },
+        { "RemoveFromLibrary", on_remove_from_library },
+        { "MoveToTrash", on_move_to_trash },
+        { "NewEvent", on_new_event },
+        { "AddTags", on_add_tags },
+        { "AddTagsContextMenu", on_add_tags },
+        { "ModifyTags", on_modify_tags },
+        { "IncreaseSize", on_increase_size },
+        { "DecreaseSize", on_decrease_size },
+        { "Flag", on_flag_unflag },
+        { "IncreaseRating", on_increase_rating },
+        { "DecreaseRating", on_decrease_rating },
+        { "RateRejected", on_rate_rejected },
+        { "RateUnrated", on_rate_unrated },
+        { "RateOne", on_rate_one },
+        { "RateTwo", on_rate_two },
+        { "RateThree", on_rate_three },
+        { "RateFour", on_rate_four },
+        { "RateFive", on_rate_five },
+        { "EditTitle", on_edit_title },
+        { "EditComment", on_edit_comment },
+        { "PlayVideo", on_play_video },
+        { "RawDeveloperShotwell", on_raw_developer_shotwell },
+        { "RawDeveloperCamera", on_raw_developer_camera },
+
+        // Toggle actions
+        { "ViewTitle", on_action_toggle, null, "false", on_display_titles },
+        { "ViewComment", on_action_toggle, null, "false", on_display_comments },
+        { "ViewRatings", on_action_toggle, null, "false", on_display_ratings },
+        { "ViewTags", on_action_toggle, null, "false", on_display_tags },
+
+        // Radio actions
+        { "SortBy", on_action_radio, "s", "'1'", on_sort_changed },
+        { "Sort", on_action_radio, "s", "'ascending'", on_sort_changed }
+    };
+
+    private void on_action_toggle (GLib.Action action, Variant? value) {
+        Variant new_state = ! (bool) action.get_state ();
+        action.change_state (new_state);
+    }
+
+    private void on_action_radio (GLib.Action action, Variant? value) {
+        action.change_state (value);
+    }
+
+    protected override void add_actions () {
+        base.add_actions ();
+
         bool sort_order;
         int sort_by;
         get_config_photos_sort(out sort_order, out sort_by);
-        
-        // Sort criteria.
-        Gtk.RadioActionEntry[] sort_crit_actions = new Gtk.RadioActionEntry[0];
-        
-        Gtk.RadioActionEntry by_title = { "SortByTitle", null, TRANSLATABLE, null, TRANSLATABLE,
-            SortBy.TITLE };
-        by_title.label = _("By _Title");
-        by_title.tooltip = _("Sort photos by title");
-        sort_crit_actions += by_title;
-        
-        Gtk.RadioActionEntry by_date = { "SortByExposureDate", null, TRANSLATABLE, null,
-            TRANSLATABLE, SortBy.EXPOSURE_DATE };
-        by_date.label = _("By Exposure _Date");
-        by_date.tooltip = _("Sort photos by exposure date");
-        sort_crit_actions += by_date;
-        
-        Gtk.RadioActionEntry by_rating = { "SortByRating", null, TRANSLATABLE, null,
-            TRANSLATABLE, SortBy.RATING };
-        by_rating.label = _("By _Rating");
-        by_rating.tooltip = _("Sort photos by rating");
-        sort_crit_actions += by_rating;
-        
-        Gtk.RadioActionEntry by_filename = { "SortByFilename", null, TRANSLATABLE, null,
-            TRANSLATABLE, SortBy.FILENAME };
-        by_filename.label = _("By _Filename");
-        by_filename.tooltip = _("Sort photos by filename");
-        sort_crit_actions += by_filename;
 
-        action_group.add_radio_actions(sort_crit_actions, sort_by, on_sort_changed);
-        
-        // Sort order.
-        Gtk.RadioActionEntry[] sort_order_actions = new Gtk.RadioActionEntry[0];
-        
-        Gtk.RadioActionEntry ascending = { "SortAscending", Resources.SORT_ASCENDING_LABEL,
-            TRANSLATABLE, null, TRANSLATABLE, SORT_ORDER_ASCENDING };
-        ascending.label = _("_Ascending");
-        ascending.tooltip = _("Sort photos in an ascending order");
-        sort_order_actions += ascending;
-        
-        Gtk.RadioActionEntry descending = { "SortDescending", Resources.SORT_DESCENDING_LABEL,
-            TRANSLATABLE, null, TRANSLATABLE, SORT_ORDER_DESCENDING };
-        descending.label = _("D_escending");
-        descending.tooltip = _("Sort photos in a descending order");
-        sort_order_actions += descending;
-        
-        action_group.add_radio_actions(sort_order_actions,
-            sort_order ? SORT_ORDER_ASCENDING : SORT_ORDER_DESCENDING, on_sort_changed);
-        
-        base.register_radio_actions(action_group);
+        AppWindow.get_instance ().add_action_entries (entries, this);
+        (get_action ("ViewTitle") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_titles ());
+        (get_action ("ViewComment") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_comments ());
+        (get_action ("ViewRatings") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_ratings ());
+        (get_action ("ViewTags") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_tags ());
+        (get_action ("SortBy") as GLib.SimpleAction).set_state ("%d".printf (sort_by));
+        (get_action ("Sort") as GLib.SimpleAction).set_state (sort_order ? "'ascending'" : "'descending'");
     }
     
     protected override void update_actions(int selected_count, int count) {
@@ -636,10 +455,7 @@ public abstract class MediaPage : CheckerboardPage {
             }
         }
         
-        Gtk.Action? flag_action = get_action("Flag");
-        if (flag_action != null) {
-            flag_action.label = flag_label;
-        }
+        critical ("=> Switiching \"Flag\" action label to %s",flag_label);
     }
     
     public override Core.ViewTracker? get_view_tracker() {
@@ -1072,36 +888,40 @@ public abstract class MediaPage : CheckerboardPage {
             get_command_manager().execute(new EditMultipleCommentsCommand(media_sources, new_comment));
     }
 
-    protected virtual void on_display_titles(Gtk.Action action) {
-        bool display = ((Gtk.ToggleAction) action).get_active();
+    protected virtual void on_display_titles(GLib.SimpleAction action, Variant? value) {
+        bool display = value.get_boolean ();
         
         set_display_titles(display);
         
         Config.Facade.get_instance().set_display_photo_titles(display);
+        action.set_state (value);
     }
 
-    protected virtual void on_display_comments(Gtk.Action action) {
-        bool display = ((Gtk.ToggleAction) action).get_active();
+    protected virtual void on_display_comments(GLib.SimpleAction action, Variant? value) {
+        bool display = value.get_boolean ();
         
         set_display_comments(display);
         
         Config.Facade.get_instance().set_display_photo_comments(display);
+        action.set_state (value);
     }
 
-    protected virtual void on_display_ratings(Gtk.Action action) {
-        bool display = ((Gtk.ToggleAction) action).get_active();
+    protected virtual void on_display_ratings(GLib.SimpleAction action, Variant? value) {
+        bool display = value.get_boolean ();
         
         set_display_ratings(display);
         
         Config.Facade.get_instance().set_display_photo_ratings(display);
+        action.set_state (value);
     }
 
-    protected virtual void on_display_tags(Gtk.Action action) {
-        bool display = ((Gtk.ToggleAction) action).get_active();
+    protected virtual void on_display_tags(GLib.SimpleAction action, Variant? value) {
+        bool display = value.get_boolean ();
         
         set_display_tags(display);
         
         Config.Facade.get_instance().set_display_photo_tags(display);
+        action.set_state (value);
     }
 
     protected abstract void get_config_photos_sort(out bool sort_order, out int sort_by);
@@ -1116,11 +936,11 @@ public abstract class MediaPage : CheckerboardPage {
         set_config_photos_sort(sort_order, sort_by);
     }
     
-    public void on_raw_developer_shotwell(Gtk.Action action) {
+    public void on_raw_developer_shotwell() {
         developer_changed(RawDeveloper.SHOTWELL);
     }
     
-    public void on_raw_developer_camera(Gtk.Action action) {
+    public void on_raw_developer_camera() {
         developer_changed(RawDeveloper.CAMERA);
     }
     
@@ -1170,35 +990,36 @@ public abstract class MediaPage : CheckerboardPage {
             action.set_active(display);
     }
 
-    private Gtk.RadioAction sort_by_title_action() {
-        Gtk.RadioAction action = (Gtk.RadioAction) get_action("SortByTitle");
+    private GLib.Action sort_by_title_action() {
+        var action = get_action ("SortBy");
         assert(action != null);
         return action;
     }
 
-    private Gtk.RadioAction sort_ascending_action() {
-        Gtk.RadioAction action = (Gtk.RadioAction) get_action("SortAscending");
+    private GLib.Action sort_ascending_action() {
+        var action = get_action ("Sort");
         assert(action != null);
         return action;
     }
 
     protected int get_menu_sort_by() {
         // any member of the group knows the current value
-        return sort_by_title_action().get_current_value();
+        return int.parse (sort_by_title_action().get_state().get_string ());
     }
     
     protected void set_menu_sort_by(int val) {
-        sort_by_title_action().set_current_value(val);
+        var sort = "%d".printf (val);
+        (sort_by_title_action() as GLib.SimpleAction).set_state (sort);
     }
     
     protected bool get_menu_sort_order() {
         // any member of the group knows the current value
-        return sort_ascending_action().get_current_value() == SORT_ORDER_ASCENDING;
+        return sort_ascending_action().get_state ().get_string () == "ascending";
     }
     
     protected void set_menu_sort_order(bool ascending) {
-        sort_ascending_action().set_current_value(
-            ascending ? SORT_ORDER_ASCENDING : SORT_ORDER_DESCENDING);
+        (sort_ascending_action() as GLib.SimpleAction).set_state (
+            ascending ? "'ascending'" : "'descending'");
     }
     
     void set_view_comparator(int sort_by, bool ascending) {
@@ -1244,26 +1065,6 @@ public abstract class MediaPage : CheckerboardPage {
         get_view().set_comparator(comparator, predicate);
     }
 
-    protected string get_sortby_path(int sort_by) {
-        switch(sort_by) {
-            case SortBy.TITLE:
-                return "/MenuBar/ViewMenu/SortPhotos/SortByTitle";
-            
-            case SortBy.EXPOSURE_DATE:
-                return "/MenuBar/ViewMenu/SortPhotos/SortByExposureDate";
-            
-            case SortBy.RATING:
-                return "/MenuBar/ViewMenu/SortPhotos/SortByRating";
-
-            case SortBy.FILENAME:
-                return "/MenuBar/ViewMenu/SortPhotos/SortByFilename";
-            
-            default:
-                debug("Unknown sort criteria: %d", sort_by);
-                return "/MenuBar/ViewMenu/SortPhotos/SortByTitle";
-        }
-    }
-
     protected void sync_sort() {
         // It used to be that the config and UI could both agree on what 
         // sort order and criteria were selected, but the sorting wouldn't
diff --git a/src/Page.vala b/src/Page.vala
index 2d62998..e7b188a 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -294,77 +294,63 @@ public abstract class Page : Gtk.ScrolledWindow {
     
     public virtual void returning_from_fullscreen(FullscreenWindow fsw) {
     }
-    
-    public Gtk.Action? get_action(string name) {
-        if (action_group == null)
-            return null;
-        
-        Gtk.Action? action = action_group.get_action(name);
-        if (action == null)
-            action = get_common_action(name, false);
-        
-        if (action == null)
-            warning("Page %s: Unable to locate action %s", get_page_name(), name);
-        
-        return action;
+
+    public GLib.Action? get_action (string name) {
+        var aw = AppWindow.get_instance ();
+
+        if (aw != null) {
+            return aw.lookup_action (name);
+        }
+
+        return null;
     }
     
     public void set_action_sensitive(string name, bool sensitive) {
-        Gtk.Action? action = get_action(name);
+        GLib.SimpleAction? action = get_action(name) as GLib.SimpleAction;
         if (action != null)
-            action.sensitive = sensitive;
+            action.set_enabled (sensitive);
     }
     
     public void set_action_important(string name, bool important) {
-        Gtk.Action? action = get_action(name);
-        if (action != null)
-            action.is_important = important;
+        critical ("=> Set action important called for %s", name);
     }
     
     public void set_action_visible(string name, bool visible) {
-        Gtk.Action? action = get_action(name);
-        if (action == null)
-            return;
-        
-        action.visible = visible;
-        action.sensitive = visible;
+        critical ("=> Set action visible called for %s", name);
+        set_action_sensitive (name, visible);
     }
     
     public void set_action_short_label(string name, string short_label) {
-        Gtk.Action? action = get_action(name);
-        if (action != null)
-            action.short_label = short_label;
+        critical ("=> Set action short_label called for %s", name);
     }
     
     public void set_action_details(string name, string? label, string? tooltip, bool sensitive) {
-        Gtk.Action? action = get_action(name);
+        GLib.SimpleAction? action = get_action(name) as GLib.SimpleAction;
+
         if (action == null)
             return;
-        
+#if 0
         if (label != null)
             action.label = label;
         
         if (tooltip != null)
             action.tooltip = tooltip;
-        
-        action.sensitive = sensitive;
+#endif
+        action.set_enabled (sensitive);
     }
     
     public void activate_action(string name) {
-        Gtk.Action? action = get_action(name);
+        var action = get_action(name);
+
         if (action != null)
-            action.activate();
+            action.activate (null);
     }
     
-    public Gtk.Action? get_common_action(string name, bool log_warning = true) {
-        if (common_action_groups == null)
-            return null;
-        
-        foreach (Gtk.ActionGroup group in common_action_groups) {
-            Gtk.Action? action = group.get_action(name);
-            if (action != null)
-                return action;
-        }
+    public GLib.Action? get_common_action(string name, bool log_warning = true) {
+        var action = get_action (name);
+
+        if (action != null)
+            return action;
         
         if (log_warning)
             warning("Page %s: Unable to locate common action %s", get_page_name(), name);
@@ -373,27 +359,23 @@ public abstract class Page : Gtk.ScrolledWindow {
     }
     
     public void set_common_action_sensitive(string name, bool sensitive) {
-        Gtk.Action? action = get_common_action(name);
+        var action = get_common_action(name) as GLib.SimpleAction;
         if (action != null)
-            action.sensitive = sensitive;
+            action.set_enabled (sensitive);
     }
 
     public void set_common_action_label(string name, string label) {
-        Gtk.Action? action = get_common_action(name);
-        if (action != null)
-            action.set_label(label);
+        critical ("Trying to set common action label for %s", name);
     }
     
     public void set_common_action_important(string name, bool important) {
-        Gtk.Action? action = get_common_action(name);
-        if (action != null)
-            action.is_important = important;
+        critical ("Setting action to important: %s", name);
     }
     
     public void activate_common_action(string name) {
-        Gtk.Action? action = get_common_action(name);
+        var action = get_common_action(name) as GLib.SimpleAction;
         if (action != null)
-            action.activate();
+            action.activate(null);
     }
     
     public bool get_ctrl_pressed() {
@@ -484,8 +466,11 @@ public abstract class Page : Gtk.ScrolledWindow {
     public CommandManager get_command_manager() {
         return AppWindow.get_command_manager();
     }
+
+    protected virtual void add_actions () { }
     
     private void init_ui() {
+        add_actions ();
         action_group = new Gtk.ActionGroup("PageActionGroup");
         
         // Collect all Gtk.Actions and add them to the Page's Gtk.ActionGroup
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index 881a8e6..8c700f0 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -2799,13 +2799,14 @@ public class LibraryPhotoPage : EditingHostPage {
     
     private void update_flag_action() {
         if (has_photo()) {
-            Gtk.Action? action = get_action("Flag");
+            var action = get_action("Flag") as GLib.SimpleAction;
             assert(action != null);
             
-            bool is_flagged = ((LibraryPhoto) get_photo()).is_flagged();
+//            bool is_flagged = ((LibraryPhoto) get_photo()).is_flagged();
             
-            action.label = is_flagged ? Resources.UNFLAG_MENU : Resources.FLAG_MENU;
-            action.sensitive = true;
+            critical ("Setting label of action flagged");
+//            action.label = is_flagged ? Resources.UNFLAG_MENU : Resources.FLAG_MENU;
+            action.set_enabled (true);
         } else {
             set_action_sensitive("Flag", false);
         }
diff --git a/src/camera/ImportPage.vala b/src/camera/ImportPage.vala
index dade13a..ab2908d 100644
--- a/src/camera/ImportPage.vala
+++ b/src/camera/ImportPage.vala
@@ -811,14 +811,14 @@ public class ImportPage : CheckerboardPage {
             // Import selected
             Gtk.ToolButton import_selected_button = new Gtk.ToolButton(null, null);
             import_selected_button.set_icon_name(Resources.IMPORT);
-            import_selected_button.set_related_action(get_action("ImportSelected"));
+            import_selected_button.set_action_name ("win.ImportSelected");
             
             toolbar.insert(import_selected_button, -1);
             
             // Import all
             Gtk.ToolButton import_all_button = new Gtk.ToolButton(null, null);
             import_all_button.set_icon_name(Resources.IMPORT_ALL);
-            import_all_button.set_related_action(get_action("ImportAll"));
+            import_all_button.set_action_name ("win.ImportAll");
             
             toolbar.insert(import_all_button, -1);
 
diff --git a/src/events/EventsDirectoryPage.vala b/src/events/EventsDirectoryPage.vala
index 75ac468..b0d9c2c 100644
--- a/src/events/EventsDirectoryPage.vala
+++ b/src/events/EventsDirectoryPage.vala
@@ -54,7 +54,7 @@ public abstract class EventsDirectoryPage : CheckerboardPage {
         get_view().set_property(Event.PROP_SHOW_COMMENTS,
             Config.Facade.get_instance().get_display_event_comments());
         
-        init_item_context_menu("/EventsDirectoryContextMenu");
+        init_item_context_menu("EventsDirectoryContextMenu");
 
         this.view_manager = view_manager;
 
@@ -63,15 +63,15 @@ public abstract class EventsDirectoryPage : CheckerboardPage {
         
         // merge tool
         Gtk.ToolButton merge_button = new Gtk.ToolButton.from_stock(Resources.MERGE);
-        merge_button.set_related_action(get_action("Merge"));
+        merge_button.set_action_name("win.Merge");
         
         toolbar.insert(merge_button, -1);
     }
     
     ~EventsDirectoryPage() {
-        Gtk.RadioAction? action = get_action("CommonSortEventsAscending") as Gtk.RadioAction;
+        var action = get_action("CommonSortEvents") as GLib.SimpleAction;
         assert(action != null);
-        action.changed.disconnect(on_sort_changed);
+        action.change_state.disconnect(on_sort_changed);
     }
     
     protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
@@ -137,9 +137,9 @@ public abstract class EventsDirectoryPage : CheckerboardPage {
     protected override void init_actions(int selected_count, int count) {
         base.init_actions(selected_count, count);
         
-        Gtk.RadioAction? action = get_action("CommonSortEventsAscending") as Gtk.RadioAction;
+        var action = get_action("CommonSortEvents") as GLib.SimpleAction;
         assert(action != null);
-        action.changed.connect(on_sort_changed);
+        action.change_state.connect(on_sort_changed);
     }
     
     protected override void update_actions(int selected_count, int count) {
@@ -165,12 +165,12 @@ public abstract class EventsDirectoryPage : CheckerboardPage {
         LibraryWindow.get_app().switch_to_event(event.event);
     }
     
-    private void on_sort_changed(Gtk.Action action, Gtk.Action c) {
-        Gtk.RadioAction current = (Gtk.RadioAction) c;
-        
+    private void on_sort_changed(GLib.SimpleAction action, Variant? value) {
         get_view().set_comparator(
-            get_event_comparator(current.current_value == LibraryWindow.SORT_EVENTS_ORDER_ASCENDING),
+            get_event_comparator(value.get_string() == LibraryWindow.SORT_EVENTS_ORDER_ASCENDING),
             event_comparator_predicate);
+
+        action.set_state (value);
     }
     
     private void on_rename() {
diff --git a/src/library/ImportQueuePage.vala b/src/library/ImportQueuePage.vala
index b5a5eb6..070203d 100644
--- a/src/library/ImportQueuePage.vala
+++ b/src/library/ImportQueuePage.vala
@@ -30,7 +30,7 @@ public class ImportQueuePage : SinglePhotoPage {
         // Stop button
         Gtk.ToolButton stop_button = new Gtk.ToolButton(null, null);
         stop_button.set_icon_name("stop");
-        stop_button.set_related_action(get_action("Stop"));
+        stop_button.set_action_name ("win.Stop");
         
         toolbar.insert(stop_button, -1);
 
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index 2d5ccf8..db51ac5 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -13,8 +13,8 @@ public class LibraryWindow : AppWindow {
         }
     }
     
-    public const int SORT_EVENTS_ORDER_ASCENDING = 0;
-    public const int SORT_EVENTS_ORDER_DESCENDING = 1;
+    public const string SORT_EVENTS_ORDER_ASCENDING = "ascending";
+    public const string SORT_EVENTS_ORDER_DESCENDING = "descending";
     
     private const string[] SUPPORTED_MOUNT_SCHEMES = {
         "gphoto2:",
@@ -98,8 +98,6 @@ public class LibraryWindow : AppWindow {
     private Gtk.Paned client_paned = new Gtk.Paned(Gtk.Orientation.HORIZONTAL);
     private Gtk.Frame bottom_frame = new Gtk.Frame(null);
     
-    //private Gtk.ActionGroup common_action_group = new Gtk.ActionGroup("LibraryWindowGlobalActionGroup");
-    
     private OneShotScheduler properties_scheduler = null;
     private bool notify_library_is_home_dir = true;
     
@@ -299,7 +297,9 @@ public class LibraryWindow : AppWindow {
 #endif
         { "CommonDisplaySearchbar", on_action_toggle, null, "false", on_display_searchbar },
         { "CommonDisplaySidebar", on_action_toggle, null, "true", on_display_sidebar },
-        { "CommonDisplayToolbar", on_action_toggle, null, "true", on_display_toolbar }
+        { "CommonDisplayToolbar", on_action_toggle, null, "true", on_display_toolbar },
+
+        { "CommonSortEvents", on_action_radio, "s", "'ascending'", on_events_sort_changed }
     };
 
     protected override void add_actions () {
@@ -308,28 +308,6 @@ public class LibraryWindow : AppWindow {
         this.add_action_entries (search_actions.get_actions (), search_actions);
     }
 
-#if 0
-    private void add_common_radio_actions(Gtk.ActionGroup group) {
-        Gtk.RadioActionEntry[] actions = new Gtk.RadioActionEntry[0];
-
-        Gtk.RadioActionEntry ascending = { "CommonSortEventsAscending",
-            Resources.SORT_ASCENDING_LABEL, TRANSLATABLE, null, TRANSLATABLE,
-            SORT_EVENTS_ORDER_ASCENDING };
-        ascending.label = _("_Ascending");
-        ascending.tooltip = _("Sort photos in an ascending order");
-        actions += ascending;
-
-        Gtk.RadioActionEntry descending = { "CommonSortEventsDescending",
-            Resources.SORT_DESCENDING_LABEL, TRANSLATABLE, null, TRANSLATABLE,
-            SORT_EVENTS_ORDER_DESCENDING };
-        descending.label = _("D_escending");
-        descending.tooltip = _("Sort photos in a descending order");
-        actions += descending;
-
-        group.add_radio_actions(actions, SORT_EVENTS_ORDER_ASCENDING, on_events_sort_changed);
-    }
-#endif
-
     protected override void switched_pages(Page? old_page, Page? new_page) {
         base.switched_pages(old_page, new_page);
 
@@ -668,19 +646,20 @@ public class LibraryWindow : AppWindow {
     }
     
     public int get_events_sort() {
-        Gtk.RadioAction? action = get_common_action("CommonSortEventsAscending") as Gtk.RadioAction;
+        var action = this.lookup_action ("CommonSortEvents") as GLib.SimpleAction;
         
-        return (action != null) ? action.current_value : SORT_EVENTS_ORDER_DESCENDING;
+        return (action != null) ? (action.state.get_string () == SORT_EVENTS_ORDER_ASCENDING)
+            ? 0 : 1
+            : 1;
     }
 
-    /*
-    private void on_events_sort_changed(Gtk.Action action, Gtk.Action c) {
-        Gtk.RadioAction current = (Gtk.RadioAction) c;
+    private void on_events_sort_changed(GLib.SimpleAction action, Variant? value) {
         
         Config.Facade.get_instance().set_events_sort_ascending(
-            current.current_value == SORT_EVENTS_ORDER_ASCENDING);
+            value.get_string () == SORT_EVENTS_ORDER_ASCENDING);
+
+        action.set_state (value);
     }
-    */
     
     private void on_preferences() {
         PreferencesDialog.show();
@@ -708,6 +687,10 @@ public class LibraryWindow : AppWindow {
         action.change_state (new_state);
     }
 
+    private void on_action_radio (GLib.Action action, Variant? value) {
+        action.change_state (value);
+    }
+
     private void on_display_extended_properties(GLib.SimpleAction action, Variant? value) {
         bool display = value.get_boolean ();
 
@@ -1041,17 +1024,16 @@ public class LibraryWindow : AppWindow {
         assert(search_bar_display_action != null);
         search_bar_display_action.set_active(Config.Facade.get_instance().get_display_search_bar());
 
-        Gtk.RadioAction? sort_events_action = get_common_action("CommonSortEventsAscending")
-            as Gtk.RadioAction;
+        var sort_events_action = get_common_action("CommonSortEvents") as GLib.SimpleAction;
         assert(sort_events_action != null);
         
         // Ticket #3321 - Event sorting order wasn't saving on exit.
         // Instead of calling set_active against one of the toggles, call
         // set_current_value against the entire radio group...
-        int event_sort_val = Config.Facade.get_instance().get_events_sort_ascending() ? 
SORT_EVENTS_ORDER_ASCENDING :
+        string event_sort_val = Config.Facade.get_instance().get_events_sort_ascending() ? 
SORT_EVENTS_ORDER_ASCENDING :
             SORT_EVENTS_ORDER_DESCENDING;
         
-        sort_events_action.set_current_value(event_sort_val);
+        sort_events_action.set_state (event_sort_val);
     }
     
     private void start_pulse_background_progress_bar(string label, int priority) {
diff --git a/ui/events_directory.ui b/ui/events_directory.ui
index 54754ce..3b32796 100644
--- a/ui/events_directory.ui
+++ b/ui/events_directory.ui
@@ -109,11 +109,13 @@
           <section>
             <item>
               <attribute name="label" translatable="yes">_Ascending</attribute>
-              <attribute name="action">win.CommonSortEventsAscending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">ascending</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">D_escending</attribute>
-              <attribute name="action">win.CommonSortEventsDescending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">descending</attribute>
             </item>
           </section>
         </submenu>
diff --git a/ui/import.ui b/ui/import.ui
index bbf15af..5ded29e 100644
--- a/ui/import.ui
+++ b/ui/import.ui
@@ -167,11 +167,13 @@
           <section>
             <item>
               <attribute name="label" translatable="yes">_Ascending</attribute>
-              <attribute name="action">win.CommonSortEventsAscending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">ascending</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">_Descending</attribute>
-              <attribute name="action">win.CommonSortEventsDescending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">descending</attribute>
             </item>
           </section>
         </submenu>
diff --git a/ui/import_queue.ui b/ui/import_queue.ui
index a72b98b..9b07d9c 100644
--- a/ui/import_queue.ui
+++ b/ui/import_queue.ui
@@ -49,11 +49,13 @@
           <section>
             <item>
               <attribute name="label" translatable="yes">_Ascending</attribute>
-              <attribute name="action">win.CommonSortEventsAscending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">ascending</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">D_escending</attribute>
-              <attribute name="action">win.CommonSortEventsDescending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">descending</attribute>
             </item>
           </section>
         </submenu>
diff --git a/ui/media.ui b/ui/media.ui
index 6c7c602..0c9fb39 100644
--- a/ui/media.ui
+++ b/ui/media.ui
@@ -152,49 +152,49 @@
           <section>
             <item>
               <attribute name="label" translatable="no">★★★★★</attribute>
-              <attribute name="action">filterbar.display.rating</attribute>
+              <attribute name="action">win.display.rating</attribute>
               <attribute name="target">7</attribute>
               <attribute name="accel">&lt;Primary&gt;5</attribute>
             </item>
             <item>
               <attribute name="label" translatable="no">★★★★</attribute>
-              <attribute name="action">filterbar.display.rating</attribute>
+              <attribute name="action">win.display.rating</attribute>
               <attribute name="target">6</attribute>
               <attribute name="accel">&lt;Primary&gt;4</attribute>
             </item>
             <item>
               <attribute name="label" translatable="no">★★★</attribute>
-              <attribute name="action">filterbar.display.rating</attribute>
+              <attribute name="action">win.display.rating</attribute>
               <attribute name="target">5</attribute>
               <attribute name="accel">&lt;Primary&gt;3</attribute>
             </item>
             <item>
               <attribute name="label" translatable="no">★★</attribute>
-              <attribute name="action">filterbar.display.rating</attribute>
+              <attribute name="action">win.display.rating</attribute>
               <attribute name="target">4</attribute>
               <attribute name="accel">&lt;Primary&gt;2</attribute>
             </item>
             <item>
               <attribute name="label" translatable="no">★</attribute>
-              <attribute name="action">filterbar.display.rating</attribute>
+              <attribute name="action">win.display.rating</attribute>
               <attribute name="target">3</attribute>
               <attribute name="accel">&lt;Primary&gt;1</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">_All Photos</attribute>
-              <attribute name="action">filterbar.display.rating</attribute>
+              <attribute name="action">win.display.rating</attribute>
               <attribute name="target">2</attribute>
               <attribute name="accel">&lt;Primary&gt;0</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">All + _Rejected</attribute>
-              <attribute name="action">filterbar.display.rating</attribute>
+              <attribute name="action">win.display.rating</attribute>
               <attribute name="target">1</attribute>
               <attribute name="accel">&lt;Primary&gt;9</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">Rejected _Only</attribute>
-              <attribute name="action">filterbar.display.rating</attribute>
+              <attribute name="action">win.display.rating</attribute>
               <attribute name="target">8</attribute>
               <attribute name="accel">&lt;Primary&gt;8</attribute>
             </item>
@@ -207,29 +207,35 @@
           <section>
             <item>
               <attribute name="label" translatable="yes">By _Title</attribute>
-              <attribute name="action">win.SortByTitle</attribute>
+              <attribute name="action">win.SortBy</attribute>
+              <attribute name="target">1</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">By _Filename</attribute>
-              <attribute name="action">win.SortByFilename</attribute>
+              <attribute name="action">win.SortBy</attribute>
+              <attribute name="target">4</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">By Exposure _Date</attribute>
-              <attribute name="action">win.SortByExposureDate</attribute>
+              <attribute name="action">win.SortBy</attribute>
+              <attribute name="target">2</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">By _Rating</attribute>
-              <attribute name="action">win.SortByRating</attribute>
+              <attribute name="action">win.SortBy</attribute>
+              <attribute name="target">3</attribute>
             </item>
           </section>
           <section>
             <item>
               <attribute name="label" translatable="yes">_Ascending</attribute>
-              <attribute name="action">win.SortAscending</attribute>
+              <attribute name="action">win.Sort</attribute>
+              <attribute name="target">ascending</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">D_escending</attribute>
-              <attribute name="action">win.SortDescending</attribute>
+              <attribute name="action">win.Sort</attribute>
+              <attribute name="target">descending</attribute>
             </item>
           </section>
         </submenu>
@@ -238,11 +244,13 @@
           <section>
             <item>
               <attribute name="label" translatable="yes">_Ascending</attribute>
-              <attribute name="action">win.CommonSortEventsAscending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">ascending</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">_Descending</attribute>
-              <attribute name="action">win.CommonSortEventsDescending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">descending</attribute>
             </item>
           </section>
         </submenu>
diff --git a/ui/offline.ui b/ui/offline.ui
index d1d2ddb..3de3629 100644
--- a/ui/offline.ui
+++ b/ui/offline.ui
@@ -164,11 +164,13 @@
           <section>
             <item>
               <attribute name="label" translatable="yes">_Ascending</attribute>
-              <attribute name="action">win.CommonSortEventsAscending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">ascending</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">D_escending</attribute>
-              <attribute name="action">win.CommonSortEventsDescending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">descending</attribute>
             </item>
           </section>
         </submenu>
diff --git a/ui/photo.ui b/ui/photo.ui
index 3a64227..a0d6e88 100644
--- a/ui/photo.ui
+++ b/ui/photo.ui
@@ -128,11 +128,13 @@
           <section>
             <item>
               <attribute name="label" translatable="yes">_Ascending</attribute>
-              <attribute name="action">win.CommonSortEventsAscending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">ascending</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">_Descending</attribute>
-              <attribute name="action">win.CommonSortEventsDescending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">descending</attribute>
             </item>
           </section>
         </submenu>
diff --git a/ui/trash.ui b/ui/trash.ui
index c2396a7..a2d2ac8 100644
--- a/ui/trash.ui
+++ b/ui/trash.ui
@@ -173,11 +173,13 @@
           <section>
             <item>
               <attribute name="label" translatable="yes">_Ascending</attribute>
-              <attribute name="action">win.CommonSortEventsAscending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">ascending</attribute>
             </item>
             <item>
               <attribute name="label" translatable="yes">D_escending</attribute>
-              <attribute name="action">win.CommonSortEventsDescending</attribute>
+              <attribute name="action">win.CommonSortEvents</attribute>
+              <attribute name="target">descending</attribute>
             </item>
           </section>
         </submenu>


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