diff options
author | Carlos Soriano <csoriano@gnome.org> | 2016-01-31 10:19:12 +0100 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2016-02-02 22:22:38 +0100 |
commit | ab4c655aea9b6c23892d170ee31a9cd21f327289 (patch) | |
tree | e0955957e2e61a2974dac860e8cac3a567932a7e /src | |
parent | 4f23b0e903a84f4692f6a500feca5c618b59fbd4 (diff) | |
download | nautilus-ab4c655aea9b6c23892d170ee31a9cd21f327289.tar.gz |
search-popover: remove unneeded location property
We were using it only for binding with the query editor and update
the switch for recursive search, but looks like something it doesn't
belong to the search popover, and instead to its owner, the query.
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-query-editor.c | 4 | ||||
-rw-r--r-- | src/nautilus-search-popover.c | 125 | ||||
-rw-r--r-- | src/nautilus-search-popover.h | 5 |
3 files changed, 46 insertions, 88 deletions
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c index 4ff13cabf..1b9ab080f 100644 --- a/src/nautilus-query-editor.c +++ b/src/nautilus-query-editor.c @@ -430,10 +430,6 @@ setup_widgets (NautilusQueryEditor *editor) /* setup the search popover */ priv->popover = nautilus_search_popover_new (); - g_object_bind_property (editor, "location", - priv->popover, "location", - G_BINDING_DEFAULT); - g_object_bind_property (editor, "query", priv->popover, "query", G_BINDING_DEFAULT); diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c index 485efaa88..7eb155ef3 100644 --- a/src/nautilus-search-popover.c +++ b/src/nautilus-search-popover.c @@ -43,7 +43,6 @@ struct _NautilusSearchPopover GtkWidget *last_used_button; GtkWidget *last_modified_button; - GFile *location; NautilusQuery *query; GBinding *recursive_binding; }; @@ -65,7 +64,6 @@ G_DEFINE_TYPE (NautilusSearchPopover, nautilus_search_popover, GTK_TYPE_POPOVER) enum { PROP_0, - PROP_LOCATION, PROP_QUERY, LAST_PROP }; @@ -301,6 +299,44 @@ query_date_changed (GObject *object, } static void +update_recursive_switch (NautilusSearchPopover *popover, + GFile *location) +{ + if (!popover->query && location) + { + NautilusFile *file; + gboolean active; + + file = nautilus_file_get (location); + + if (!nautilus_file_is_local (file)) + { + active = g_settings_get_boolean (nautilus_preferences, + "enable-remote-recursive-search"); + } + else + { + active = g_settings_get_boolean (nautilus_preferences, + "enable-recursive-search"); + } + + gtk_switch_set_active (GTK_SWITCH (popover->recursive_switch), active); + } + +} + +static void +query_location_changed (GObject *object, + GParamSpec *pspec, + NautilusSearchPopover *popover) +{ + GFile *location; + + location = nautilus_query_get_location (popover->query); + update_recursive_switch (popover, location); +} + +static void clear_date_button_clicked (GtkButton *button, NautilusSearchPopover *popover) { @@ -892,10 +928,6 @@ nautilus_search_popover_get_property (GObject *object, switch (prop_id) { - case PROP_LOCATION: - g_value_set_object (value, self->location); - break; - case PROP_QUERY: g_value_set_object (value, self->query); break; @@ -917,10 +949,6 @@ nautilus_search_popover_set_property (GObject *object, switch (prop_id) { - case PROP_LOCATION: - nautilus_search_popover_set_location (self, g_value_get_object (value)); - break; - case PROP_QUERY: nautilus_search_popover_set_query (self, g_value_get_object (value)); break; @@ -956,19 +984,6 @@ nautilus_search_popover_class_init (NautilusSearchPopoverClass *klass) G_TYPE_POINTER); /** - * NautilusSearchPopover::location: - * - * The current location of the search. - */ - g_object_class_install_property (object_class, - PROP_LOCATION, - g_param_spec_object ("location", - "Location of the popover", - "The current location of the search", - G_TYPE_FILE, - G_PARAM_READWRITE)); - - /** * NautilusSearchPopover::query: * * The current #NautilusQuery being edited. @@ -1039,62 +1054,6 @@ nautilus_search_popover_new (void) } /** - * nautilus_search_popover_get_location: - * - * Retrieves the current directory as a #GFile. - * - * Returns: (transfer none): a #GFile. - */ -GFile* -nautilus_search_popover_get_location (NautilusSearchPopover *popover) -{ - g_return_val_if_fail (NAUTILUS_IS_SEARCH_POPOVER (popover), NULL); - - return popover->location; -} - -/** - * nautilus_search_popover_set_location: - * - * Sets the current location that the search is being - * performed on. - * - * Returns: - */ -void -nautilus_search_popover_set_location (NautilusSearchPopover *popover, - GFile *location) -{ - g_return_if_fail (NAUTILUS_IS_SEARCH_POPOVER (popover)); - - if (g_set_object (&popover->location, location)) - { - if (!popover->query && location) - { - NautilusFile *file; - gboolean active; - - file = nautilus_file_get (location); - - if (!nautilus_file_is_local (file)) - { - active = g_settings_get_boolean (nautilus_preferences, - "enable-remote-recursive-search"); - } - else - { - active = g_settings_get_boolean (nautilus_preferences, - "enable-recursive-search"); - } - - gtk_switch_set_active (GTK_SWITCH (popover->recursive_switch), active); - } - - g_object_notify (G_OBJECT (popover), "location"); - } -} - -/** * nautilus_search_popover_get_query: * @popover: a #NautilusSearchPopover * @@ -1135,6 +1094,7 @@ nautilus_search_popover_set_query (NautilusSearchPopover *popover, if (previous_query) { g_signal_handlers_disconnect_by_func (query, query_date_changed, popover); + g_signal_handlers_disconnect_by_func (query, query_location_changed, popover); g_clear_pointer (&popover->recursive_binding, g_binding_unbind); } @@ -1149,6 +1109,13 @@ nautilus_search_popover_set_query (NautilusSearchPopover *popover, "notify::date", G_CALLBACK (query_date_changed), popover); + + g_signal_connect (query, + "notify::location", + G_CALLBACK (query_location_changed), + popover); + + update_recursive_switch (popover, nautilus_query_get_location (query)); /* Recursive */ gtk_switch_set_active (GTK_SWITCH (popover->recursive_switch), nautilus_query_get_recursive (query)); diff --git a/src/nautilus-search-popover.h b/src/nautilus-search-popover.h index a733b2cdb..a54847d39 100644 --- a/src/nautilus-search-popover.h +++ b/src/nautilus-search-popover.h @@ -39,11 +39,6 @@ G_DECLARE_FINAL_TYPE (NautilusSearchPopover, nautilus_search_popover, NAUTILUS, GtkWidget* nautilus_search_popover_new (void); -GFile* nautilus_search_popover_get_location (NautilusSearchPopover *popover); - -void nautilus_search_popover_set_location (NautilusSearchPopover *popover, - GFile *location); - NautilusQuery* nautilus_search_popover_get_query (NautilusSearchPopover *popover); void nautilus_search_popover_set_query (NautilusSearchPopover *popover, |