[nautilus/wip/csoriano/flow: 21/55] window-slot: use action state instead of special casing the search



commit 54eecbfbb0236b630b9b882c664bd2947ed11a46
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue Mar 22 13:43:41 2016 +0100

    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.

 src/nautilus-desktop-window-slot.c |    8 ++++++++
 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 728e850..36e9c48 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 ee58c72..afb6b42 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);
        }


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