summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-03-22 13:43:41 +0100
committerCarlos Soriano <csoriano@gnome.org>2016-04-06 10:47:30 +0200
commita23751aa594a3d9194ac42ace009f765371618fb (patch)
tree926694f953af1b50a95af2bea96fcf7bb6d61814
parentb60957a74471a7fd5042958565576430a5a0e05f (diff)
downloadnautilus-a23751aa594a3d9194ac42ace009f765371618fb.tar.gz
window-slot: use action state instead of special casing the search
We were special casing to not enable search in some cases where some special view, like the desktop, doesn't allow it. But that shouldn't be special cased here, but instead use a subclass of the window slot and disable it there. Now that we have that, move the special casing to inheritance for disabling the search in the desktop.
-rw-r--r--src/nautilus-desktop-window-slot.c8
-rw-r--r--src/nautilus-window-slot.c14
2 files changed, 14 insertions, 8 deletions
diff --git a/src/nautilus-desktop-window-slot.c b/src/nautilus-desktop-window-slot.c
index 728e85085..36e9c48d2 100644
--- a/src/nautilus-desktop-window-slot.c
+++ b/src/nautilus-desktop-window-slot.c
@@ -52,4 +52,12 @@ nautilus_desktop_window_slot_class_init (NautilusDesktopWindowSlotClass *klass)
static void
nautilus_desktop_window_slot_init (NautilusDesktopWindowSlot *self)
{
+ GAction *action;
+ GActionGroup *action_group;
+
+ /* Disable search on desktop */
+ action_group = gtk_widget_get_action_group (GTK_WIDGET (self), "slot");
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "search-visible");
+
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
}
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index ee58c72a7..afb6b4232 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -248,16 +248,9 @@ update_search_visible (NautilusWindowSlot *self)
NautilusWindowSlotPrivate *priv;
NautilusQuery *query;
NautilusView *view;
- GAction *action;
priv = nautilus_window_slot_get_instance_private (self);
- action = g_action_map_lookup_action (G_ACTION_MAP (priv->slot_action_group),
- "search-visible");
- /* Don't allow search on desktop */
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- !NAUTILUS_IS_DESKTOP_CANVAS_VIEW (nautilus_window_slot_get_current_view (self)));
-
view = nautilus_window_slot_get_current_view (self);
/* If we changed location just to another search location, for example,
* when changing the query, just keep the search visible.
@@ -519,11 +512,16 @@ nautilus_window_slot_handle_event (NautilusWindowSlot *self,
NautilusWindowSlotPrivate *priv;
NautilusWindow *window;
gboolean retval;
+ GAction *action;
priv = nautilus_window_slot_get_instance_private (self);
retval = FALSE;
window = nautilus_window_slot_get_window (self);
- if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
+ action = g_action_map_lookup_action (G_ACTION_MAP (priv->slot_action_group),
+ "search-visible");
+
+ /* If the action is not enabled, don't try to handle search */
+ if (g_action_get_enabled (action)) {
retval = gtk_search_bar_handle_event (GTK_SEARCH_BAR (priv->query_editor),
(GdkEvent*) event);
}