diff options
author | Carlos Soriano <csoriano@gnome.org> | 2016-03-22 13:43:41 +0100 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2016-04-05 15:13:50 +0200 |
commit | 9a0040a4da338acc09a6ac1afc572c28d09bf4c9 (patch) | |
tree | a44ba88fe8d1cc22220db9b0cc15b15e3c8970d3 | |
parent | dc870890f035d51661278b5ab3508fa7194f82fb (diff) | |
download | nautilus-9a0040a4da338acc09a6ac1afc572c28d09bf4c9.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.c | 8 | ||||
-rw-r--r-- | src/nautilus-window-slot.c | 14 |
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 e6b6efc2d..b96694205 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); } |