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