[nautilus] toolbar: Fix search button and search entry state desync
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] toolbar: Fix search button and search entry state desync
- Date: Mon, 11 Feb 2019 09:52:05 +0000 (UTC)
commit 6a9c7f3fd4fdab268ef18add75ec43f312d56ddb
Author: George Mocanu <mocanu geo98 gmail com>
Date: Mon Jan 14 11:55:34 2019 +0200
toolbar: Fix search button and search entry state desync
Sometimes the search button and search entry state can get out of
sync. This will lead to the need of pressing the search button
twice to display the search entry again.
This patch solves this behavior by binding the "searching"
property between toolbar and window-slot.
Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/570
src/nautilus-toolbar.c | 35 ++++++++++++++++++++++++++++++++++-
src/nautilus-window-slot.c | 6 ++++++
2 files changed, 40 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index fb0d2d4c0..d14f17867 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -104,6 +104,8 @@ struct _NautilusToolbar
GtkGesture *back_button_longpress_gesture;
GtkGesture *back_button_multi_press_gesture;
+ GtkWidget *search_button;
+
GtkWidget *location_entry_close_button;
NautilusProgressInfoManager *progress_manager;
@@ -111,6 +113,7 @@ struct _NautilusToolbar
/* active slot & bindings */
NautilusWindowSlot *window_slot;
GBinding *icon_binding;
+ GBinding *search_binding;
};
enum
@@ -118,6 +121,7 @@ enum
PROP_WINDOW = 1,
PROP_SHOW_LOCATION_ENTRY,
PROP_WINDOW_SLOT,
+ PROP_SEARCHING,
NUM_PROPERTIES
};
@@ -138,7 +142,6 @@ toolbar_update_appearance (NautilusToolbar *self)
g_settings_get_boolean (nautilus_preferences,
NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY);
-
if (self->window_slot != NULL &&
nautilus_window_slot_get_searching (self->window_slot))
{
@@ -1032,6 +1035,12 @@ nautilus_toolbar_get_property (GObject *object,
}
break;
+ case PROP_SEARCHING:
+ {
+ g_value_set_boolean (value, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(self->search_button)));
+ }
+ break;
+
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1052,6 +1061,7 @@ on_window_slot_destroyed (gpointer data,
* Null it here, so that dispose() does not trip over itself when removing it.
*/
self->icon_binding = NULL;
+ self->search_binding = NULL;
nautilus_toolbar_set_window_slot_real (self, NULL);
}
@@ -1130,6 +1140,13 @@ nautilus_toolbar_set_property (GObject *object,
}
break;
+ case PROP_SEARCHING:
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->search_button),
+ g_value_get_boolean (value));
+ }
+ break;
+
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1148,6 +1165,7 @@ nautilus_toolbar_dispose (GObject *object)
g_clear_object (&self->forward_button_multi_press_gesture);
g_clear_object (&self->back_button_multi_press_gesture);
g_clear_pointer (&self->icon_binding, g_binding_unbind);
+ g_clear_pointer (&self->search_binding, g_binding_unbind);
G_OBJECT_CLASS (nautilus_toolbar_parent_class)->dispose (object);
}
@@ -1220,6 +1238,13 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
(G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
+ properties [PROP_SEARCHING] =
+ g_param_spec_boolean ("searching",
+ "Current view is searching",
+ "Whether the current view is searching or not",
+ FALSE,
+ G_PARAM_READWRITE);
+
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (widget_class,
@@ -1243,6 +1268,8 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, undo_button);
gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, redo_button);
+ gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, search_button);
+
gtk_widget_class_bind_template_callback (widget_class, on_operations_icon_draw);
gtk_widget_class_bind_template_callback (widget_class, on_operations_button_toggled);
}
@@ -1406,6 +1433,10 @@ nautilus_toolbar_set_window_slot_real (NautilusToolbar *self,
self,
NULL);
+ self->search_binding = g_object_bind_property (self->window_slot, "searching",
+ self, "searching",
+ G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+
on_slot_toolbar_menu_sections_changed (self, NULL, self->window_slot);
g_signal_connect_swapped (self->window_slot, "notify::toolbar-menu-sections",
G_CALLBACK (on_slot_toolbar_menu_sections_changed), self);
@@ -1434,6 +1465,7 @@ nautilus_toolbar_set_window_slot_real (NautilusToolbar *self,
toolbar_update_appearance (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_WINDOW_SLOT]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SEARCHING]);
}
void
@@ -1449,6 +1481,7 @@ nautilus_toolbar_set_window_slot (NautilusToolbar *self,
}
g_clear_pointer (&self->icon_binding, g_binding_unbind);
+ g_clear_pointer (&self->search_binding, g_binding_unbind);
disconnect_toolbar_menu_sections_change_handler (self);
if (self->window_slot != NULL)
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 787bb5b7d..7bec9a0d8 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -941,6 +941,12 @@ nautilus_window_slot_get_property (GObject *object,
}
break;
+ case PROP_SEARCHING:
+ {
+ g_value_set_boolean (value, nautilus_window_slot_get_searching (self));
+ }
+ break;
+
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]