f61cae
From 7049b72ea6f159108c5f1b6ad25b0d32611f33e8 Mon Sep 17 00:00:00 2001
f61cae
From: Ondrej Holy <oholy@redhat.com>
f61cae
Date: Wed, 24 Jun 2015 13:58:57 +0200
f61cae
Subject: [PATCH] Fix context menu items sensitivity
f61cae
f61cae
Context menu items "Go to parent folder", "Zoom in", "Zoom out" stay
f61cae
always active, even if they can not bring effect (e.g. already in
f61cae
the top directory, maximal zoom). This patch set sensitivity of the
f61cae
mentioned menu items accordingly.
f61cae
f61cae
https://bugzilla.gnome.org/show_bug.cgi?id=751436
f61cae
---
f61cae
 src/baobab-chart.vala | 15 +++++++++++++++
f61cae
 1 file changed, 15 insertions(+)
f61cae
f61cae
diff --git a/src/baobab-chart.vala b/src/baobab-chart.vala
f61cae
index 21d20c6..1bf5803 100644
f61cae
--- a/src/baobab-chart.vala
f61cae
+++ b/src/baobab-chart.vala
f61cae
@@ -559,6 +559,13 @@ namespace Baobab {
f61cae
             (get_toplevel () as Window).trash_file (highlighted_item.iter);
f61cae
         }
f61cae
 
f61cae
+        protected bool can_move_up_root () {
f61cae
+            Gtk.TreeIter iter, parent_iter;
f61cae
+
f61cae
+            model.get_iter (out iter, root);
f61cae
+            return model.iter_parent (out parent_iter, iter);
f61cae
+        }
f61cae
+
f61cae
         public void move_up_root () {
f61cae
             Gtk.TreeIter iter, parent_iter;
f61cae
 
f61cae
@@ -596,6 +603,14 @@ namespace Baobab {
f61cae
             action = action_group.lookup_action ("trash-file") as SimpleAction;
f61cae
             action.set_enabled (enable);
f61cae
 
f61cae
+            action = action_group.lookup_action ("move-up") as SimpleAction;
f61cae
+            action.set_enabled (can_move_up_root ());
f61cae
+
f61cae
+            action = action_group.lookup_action ("zoom-in") as SimpleAction;
f61cae
+            action.set_enabled (can_zoom_in ());
f61cae
+            action = action_group.lookup_action ("zoom-out") as SimpleAction;
f61cae
+            action.set_enabled (can_zoom_out ());
f61cae
+
f61cae
             if (event != null) {
f61cae
                 context_menu.popup (null, null, null, event.button, event.time);
f61cae
             } else {
f61cae
-- 
f61cae
2.4.4
f61cae