[shotwell] Re-add label switching for background menu item



commit 01da01587dc184a940a9bbf2d84ab0647dcf30d5
Author: Jens Georg <mail jensge org>
Date:   Mon Dec 5 23:27:43 2016 +0100

    Re-add label switching for background menu item
    
    Signed-off-by: Jens Georg <mail jensge org>

 src/CollectionPage.vala |    6 ++----
 src/Page.vala           |   23 ++++++++++-------------
 src/PhotoPage.vala      |   13 +------------
 3 files changed, 13 insertions(+), 29 deletions(-)
---
diff --git a/src/CollectionPage.vala b/src/CollectionPage.vala
index dbb03a3..c43c0c8 100644
--- a/src/CollectionPage.vala
+++ b/src/CollectionPage.vala
@@ -269,12 +269,10 @@ public abstract class CollectionPage : MediaPage {
         set_action_sensitive("SetBackground", (!selection_has_videos) && has_selected );
         if (has_selected) {
             debug ("Setting action label for SetBackground...");
-/*            Gtk.Action? set_background = get_action("SetBackground");
-            if (set_background != null) {
-                set_background.label = one_selected
+            var label = one_selected
                     ? Resources.SET_BACKGROUND_MENU
                     : Resources.SET_BACKGROUND_SLIDESHOW_MENU;
-            } */
+            this.update_menu_item_label ("SetBackground", label);
         }
     }
 
diff --git a/src/Page.vala b/src/Page.vala
index 13caae6..c3e7802 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -40,8 +40,7 @@ public class InjectionGroup {
         return elements;
     }
 
-    public void add_menu_item(string name, string? action = null, string?
-            accellerator = null) {
+    public void add_menu_item(string name, string? action = null, string? accellerator = null) {
         elements.add(new Element(name, action, accellerator, Element.ItemType.MENUITEM));
     }
 
@@ -1174,17 +1173,15 @@ public abstract class Page : Gtk.ScrolledWindow {
                 for (var k = 0; k < sub_items; k++) {
                     var it = subsection.iterate_item_attributes (k);
                     while (it.next ()) {
-                        if (it.get_name () == "id") {
-                            if (it.get_value ().get_string () == id) {
-                                var md = subsection as GLib.Menu;
-                                var m = new GLib.MenuItem.from_model
-                                    (subsection, k);
-                                m.set_label (new_label);
-                                md.remove (k);
-                                md.insert_item (k, m);
-
-                                return;
-                            }
+                        if ((it.get_name() == "id" && it.get_value ().get_string () == id) ||
+                            (it.get_name() == "action" && it.get_value().get_string().has_suffix("." + id))) 
{
+                            var md = subsection as GLib.Menu;
+                            var m = new GLib.MenuItem.from_model (subsection, k);
+                            m.set_label (new_label);
+                            md.remove (k);
+                            md.insert_item (k, m);
+
+                            return;
                         }
                     }
                 }
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index ba0ba43..a6fb529 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -2569,18 +2569,7 @@ public class LibraryPhotoPage : EditingHostPage {
     }
     
     private void update_flag_action() {
-        if (has_photo()) {
-            var action = get_action("Flag") as GLib.SimpleAction;
-            assert(action != null);
-            
-//            bool is_flagged = ((LibraryPhoto) get_photo()).is_flagged();
-            
-            debug ("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);
-        }
+        set_action_sensitive ("Flag", has_photo());
     }
     
     // Displays a photo from a specific CollectionPage.  When the user exits this view,


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