summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-11-12 15:53:55 -0500
committerCosimo Cecchi <cosimoc@gnome.org>2012-11-12 16:02:04 -0500
commit708ed78e6fc5889f7c38c7149c91c468a7cdbd4d (patch)
treeb0570254008dec14f1191a480961e171d427cfde
parentfb14117ab007778e3772d781591a16a7042f0e96 (diff)
downloadnautilus-708ed78e6fc5889f7c38c7149c91c468a7cdbd4d.tar.gz
query-editor: don't always re-add mimetype rows when setting query
Since we also use nautilus_query_editor_set_query() when the query editor already has a query, don't unconditionally add mimetype rows from there, but only when we're being called with a previous query. Fix a bug where mimetype rows were added when switching between current location and all files. https://bugzilla.gnome.org/show_bug.cgi?id=687537
-rw-r--r--src/nautilus-query-editor.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index b4cc29047..e35637465 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -70,6 +70,8 @@ struct NautilusQueryEditorDetails {
GList *rows;
gboolean got_preedit;
+
+ NautilusQuery *query;
};
enum {
@@ -247,6 +249,8 @@ nautilus_query_editor_dispose (GObject *object)
editor->details->typing_timeout_id = 0;
}
+ g_clear_object (&editor->details->query);
+
G_OBJECT_CLASS (nautilus_query_editor_parent_class)->dispose (object);
}
@@ -852,15 +856,20 @@ get_next_free_type (NautilusQueryEditor *editor)
}
static void
+row_destroy (NautilusQueryEditorRow *row)
+{
+ gtk_widget_destroy (row->toolbar);
+ g_free (row);
+}
+
+static void
remove_row_cb (GtkButton *clicked_button, NautilusQueryEditorRow *row)
{
NautilusQueryEditor *editor;
editor = row->editor;
- gtk_container_remove (GTK_CONTAINER (editor), row->toolbar);
-
editor->details->rows = g_list_remove (editor->details->rows, row);
- g_free (row);
+ row_destroy (row);
nautilus_query_editor_changed (editor);
}
@@ -1172,11 +1181,29 @@ nautilus_query_editor_set_location (NautilusQueryEditor *editor,
update_location (editor);
}
+static void
+update_rows (NautilusQueryEditor *editor,
+ NautilusQuery *query)
+{
+ NautilusQueryEditorRowType type;
+
+ /* if we were just created, set the rows from query,
+ * otherwise, re-use the query setting we have already.
+ */
+ if (query != NULL && editor->details->query == NULL) {
+ for (type = 0; type < NAUTILUS_QUERY_EDITOR_ROW_LAST; type++) {
+ row_type[type].add_rows_from_query (editor, query);
+ }
+ } else if (query == NULL && editor->details->query != NULL) {
+ g_list_free_full (editor->details->rows, (GDestroyNotify) row_destroy);
+ editor->details->rows = NULL;
+ }
+}
+
void
nautilus_query_editor_set_query (NautilusQueryEditor *editor,
NautilusQuery *query)
{
- NautilusQueryEditorRowType type;
char *text = NULL;
if (query != NULL) {
@@ -1193,16 +1220,14 @@ nautilus_query_editor_set_query (NautilusQueryEditor *editor,
g_free (editor->details->current_uri);
editor->details->current_uri = NULL;
+ update_rows (editor, query);
+ g_clear_object (&editor->details->query);
+
if (query != NULL) {
+ editor->details->query = g_object_ref (query);
editor->details->current_uri = nautilus_query_get_location (query);
update_location (editor);
-
-
- for (type = 0; type < NAUTILUS_QUERY_EDITOR_ROW_LAST; type++) {
- row_type[type].add_rows_from_query (editor, query);
- }
}
-
editor->details->change_frozen = FALSE;
}