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



commit d5f42f0edcdd41d896dc2d5ff56f7a3209da68d5
Author: Jens Georg <mail jensge org>
Date:   Wed Nov 2 22:59:18 2016 +0100

    WIP

 src/CollectionPage.vala    |  118 +++++++++-----------------------------------
 src/MediaPage.vala         |   16 ------
 src/Page.vala              |   20 +++++++-
 src/camera/ImportPage.vala |   49 ++++++------------
 4 files changed, 59 insertions(+), 144 deletions(-)
---
diff --git a/src/CollectionPage.vala b/src/CollectionPage.vala
index 169b1c9..438684e 100644
--- a/src/CollectionPage.vala
+++ b/src/CollectionPage.vala
@@ -150,102 +150,32 @@ public abstract class CollectionPage : MediaPage {
         
         ui_filenames.add("collection.ui");
     }
-    
-    protected override Gtk.ActionEntry[] init_collect_action_entries() {
-        Gtk.ActionEntry[] actions = base.init_collect_action_entries();
 
-        Gtk.ActionEntry print = { "Print", Resources.PRINT_LABEL, TRANSLATABLE, "<Ctrl>P",
-            TRANSLATABLE, on_print };
-        print.label = Resources.PRINT_MENU;
-        actions += print;
-        
-        Gtk.ActionEntry publish = { "Publish", Resources.PUBLISH, TRANSLATABLE, "<Ctrl><Shift>P",
-            TRANSLATABLE, on_publish };
-        publish.label = Resources.PUBLISH_MENU;
-        publish.tooltip = Resources.PUBLISH_TOOLTIP;
-        actions += publish;
-  
-        Gtk.ActionEntry rotate_right = { "RotateClockwise", Resources.CLOCKWISE,
-            TRANSLATABLE, "<Ctrl>R", TRANSLATABLE, on_rotate_clockwise };
-        rotate_right.label = Resources.ROTATE_CW_MENU;
-        rotate_right.tooltip = Resources.ROTATE_CW_TOOLTIP;
-        actions += rotate_right;
-
-        Gtk.ActionEntry rotate_left = { "RotateCounterclockwise", Resources.COUNTERCLOCKWISE,
-            TRANSLATABLE, "<Ctrl><Shift>R", TRANSLATABLE, on_rotate_counterclockwise };
-        rotate_left.label = Resources.ROTATE_CCW_MENU;
-        rotate_left.tooltip = Resources.ROTATE_CCW_TOOLTIP;
-        actions += rotate_left;
-
-        Gtk.ActionEntry hflip = { "FlipHorizontally", Resources.HFLIP, TRANSLATABLE, null,
-            TRANSLATABLE, on_flip_horizontally };
-        hflip.label = Resources.HFLIP_MENU;
-        actions += hflip;
-        
-        Gtk.ActionEntry vflip = { "FlipVertically", Resources.VFLIP, TRANSLATABLE, null,
-            TRANSLATABLE, on_flip_vertically };
-        vflip.label = Resources.VFLIP_MENU;
-        actions += vflip;
-
-        Gtk.ActionEntry enhance = { "Enhance", Resources.ENHANCE, TRANSLATABLE, "<Ctrl>E",
-            TRANSLATABLE, on_enhance };
-        enhance.label = Resources.ENHANCE_MENU;
-        enhance.tooltip = Resources.ENHANCE_TOOLTIP;
-        actions += enhance;
-
-        Gtk.ActionEntry copy_adjustments = { "CopyColorAdjustments", null, TRANSLATABLE,
-            "<Ctrl><Shift>C", TRANSLATABLE, on_copy_adjustments};
-        copy_adjustments.label = Resources.COPY_ADJUSTMENTS_MENU;
-        copy_adjustments.tooltip = Resources.COPY_ADJUSTMENTS_TOOLTIP;
-        actions += copy_adjustments;
-
-        Gtk.ActionEntry paste_adjustments = { "PasteColorAdjustments", null, TRANSLATABLE,
-            "<Ctrl><Shift>V", TRANSLATABLE, on_paste_adjustments};
-        paste_adjustments.label = Resources.PASTE_ADJUSTMENTS_MENU;
-        paste_adjustments.tooltip = Resources.PASTE_ADJUSTMENTS_TOOLTIP;
-        actions += paste_adjustments;
-
-        Gtk.ActionEntry revert = { "Revert", null, TRANSLATABLE, null,
-            TRANSLATABLE, on_revert };
-        revert.label = Resources.REVERT_MENU;
-        actions += revert;
-        
-        Gtk.ActionEntry set_background = { "SetBackground", null, TRANSLATABLE, "<Ctrl>B",
-            TRANSLATABLE, on_set_background };
-        set_background.label = Resources.SET_BACKGROUND_MENU;
-        set_background.tooltip = Resources.SET_BACKGROUND_TOOLTIP;
-        actions += set_background;
-
-        Gtk.ActionEntry duplicate = { "Duplicate", null, TRANSLATABLE, "<Ctrl>D", TRANSLATABLE,
-            on_duplicate_photo };
-        duplicate.label = Resources.DUPLICATE_PHOTO_MENU;
-        duplicate.tooltip = Resources.DUPLICATE_PHOTO_TOOLTIP;
-        actions += duplicate;
-
-        Gtk.ActionEntry adjust_date_time = { "AdjustDateTime", null, TRANSLATABLE, null,
-            TRANSLATABLE, on_adjust_date_time };
-        adjust_date_time.label = Resources.ADJUST_DATE_TIME_MENU;
-        actions += adjust_date_time;
-        
-        Gtk.ActionEntry external_edit = { "ExternalEdit", Resources.EDIT_LABEL, TRANSLATABLE, "<Ctrl>Return",
-            TRANSLATABLE, on_external_edit };
-        external_edit.label = Resources.EXTERNAL_EDIT_MENU;
-        actions += external_edit;
-        
-        Gtk.ActionEntry edit_raw = { "ExternalEditRAW", null, TRANSLATABLE, "<Ctrl><Shift>Return", 
-            TRANSLATABLE, on_external_edit_raw };
-        edit_raw.label = Resources.EXTERNAL_EDIT_RAW_MENU;
-        actions += edit_raw;
-        
-        Gtk.ActionEntry slideshow = { "Slideshow", null, TRANSLATABLE, "F5", TRANSLATABLE,
-            on_slideshow };
-        slideshow.label = _("S_lideshow");
-        slideshow.tooltip = _("Play a slideshow");
-        actions += slideshow;
-        
-        return actions;
+    private const GLib.ActionEntry[] entries = {
+        { "Print", on_print },
+        { "Publish", on_publish },
+        { "RotateClockwise", on_rotate_clockwise },
+        { "RotateCounterclockwise", on_rotate_counterclockwise },
+        { "FlipHorizontally", on_flip_horizontally },
+        { "FlipVertically", on_flip_vertically },
+        { "Enhance", on_enhance },
+        { "CopyColorAdjustments", on_copy_adjustments },
+        { "PasteColorAdjustments", on_paste_adjustments },
+        { "Revert", on_revert },
+        { "SetBackground", on_set_background },
+        { "Duplicate", on_duplicate_photo },
+        { "AdjustDateTime", on_adjust_date_time },
+        { "ExternalEdit", on_external_edit },
+        { "ExternalEditRAW", on_external_edit_raw },
+        { "Slideshow", on_slideshow }
+    };
+
+    protected override void add_actions () {
+        base.add_actions ();
+
+        AppWindow.get_instance ().add_action_entries (entries, this);
     }
-    
+
     protected override InjectionGroup[] init_collect_injection_groups() {
         InjectionGroup[] groups = base.init_collect_injection_groups();
         
diff --git a/src/MediaPage.vala b/src/MediaPage.vala
index 7b3bf86..8d8fe76 100644
--- a/src/MediaPage.vala
+++ b/src/MediaPage.vala
@@ -322,15 +322,6 @@ public abstract class MediaPage : CheckerboardPage {
         { "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 ();
 
@@ -462,13 +453,6 @@ public abstract class MediaPage : CheckerboardPage {
         return tracker;
     }
 
-    private void set_action_active (string name, bool active) {
-        var action = get_action (name) as GLib.SimpleAction;
-        if (action != null) {
-            action.set_state (active);
-        }
-    }
-    
     public void set_display_ratings(bool display) {
         get_view().freeze_notifications();
         get_view().set_property(Thumbnail.PROP_SHOW_RATINGS, display);
diff --git a/src/Page.vala b/src/Page.vala
index e7b188a..b4b3891 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -393,7 +393,14 @@ public abstract class Page : Gtk.ScrolledWindow {
     public bool get_super_pressed() {
         return super_pressed;
     }
-    
+
+     protected void set_action_active (string name, bool active) {
+        var action = get_action (name) as GLib.SimpleAction;
+        if (action != null) {
+            action.set_state (active);
+        }
+    }
+
     private bool get_modifiers(out bool ctrl, out bool alt, out bool shift, out bool super) {
         if (AppWindow.get_instance().get_window() == null) {
             ctrl = false;
@@ -468,7 +475,16 @@ public abstract class Page : Gtk.ScrolledWindow {
     }
 
     protected virtual void add_actions () { }
-    
+
+    protected void on_action_toggle (GLib.Action action, Variant? value) {
+        Variant new_state = ! (bool) action.get_state ();
+        action.change_state (new_state);
+    }
+
+    protected void on_action_radio (GLib.Action action, Variant? value) {
+        action.change_state (value);
+    }
+
     private void init_ui() {
         add_actions ();
         action_group = new Gtk.ActionGroup("PageActionGroup");
diff --git a/src/camera/ImportPage.vala b/src/camera/ImportPage.vala
index ab2908d..3ff5123 100644
--- a/src/camera/ImportPage.vala
+++ b/src/camera/ImportPage.vala
@@ -864,35 +864,20 @@ public class ImportPage : CheckerboardPage {
         
         ui_filenames.add("import.ui");
     }
-    
-    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;
+    private const GLib.ActionEntry[] entries = {
+        { "ImportSelected", on_import_selected },
+        { "ImportAll", on_import_all },
+        // Toggle actions
+        { "ViewTitle", on_action_toggle, null, "false", on_display_titles },
+    };
 
-        return toggle_actions;
-    }
+    protected override void add_actions () {
+        base.add_actions ();
 
-    protected override Gtk.ActionEntry[] init_collect_action_entries() {
-        Gtk.ActionEntry[] actions = base.init_collect_action_entries();
-        
-        Gtk.ActionEntry import_selected = { "ImportSelected", Resources.IMPORT,
-            TRANSLATABLE, null, null, on_import_selected };
-        import_selected.label = _("Import _Selected");
-        import_selected.tooltip = _("Import the selected photos into your library");
-        actions += import_selected;
+        AppWindow.get_instance ().add_action_entries (entries, this);
 
-        Gtk.ActionEntry import_all = { "ImportAll", Resources.IMPORT_ALL, TRANSLATABLE,
-            null, null, on_import_all };
-        import_all.label = _("Import _All");
-        import_all.tooltip = _("Import all the photos into your library");
-        actions += import_all;
-
-        return actions;
+        (get_action ("ViewTitle") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_titles ());
     }
     
     public GPhoto.Camera get_camera() {
@@ -958,13 +943,15 @@ public class ImportPage : CheckerboardPage {
         search_filter.refresh();
     }
 
-    private void on_display_titles(Gtk.Action action) {
-        bool display = ((Gtk.ToggleAction) action).get_active();
+    private 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);
     }
-    
+
     public override void switched_to() {
         set_display_titles(Config.Facade.get_instance().get_display_photo_titles());
         
@@ -1791,10 +1778,8 @@ public class ImportPage : CheckerboardPage {
 
     public override void set_display_titles(bool display) {
         base.set_display_titles(display);
-    
-        Gtk.ToggleAction? action = get_action("ViewTitle") as Gtk.ToggleAction;
-        if (action != null)
-            action.set_active(display);
+
+        set_action_active ("ViewTitle", display);
     }
     
     // Gets the search view filter for this page.


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