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:21:13 -0500
commit95ec145831d862f8c3279872b4fdb3ba8db97097 (patch)
tree3e43d5e605325fc97d8e8a955398aff7f23b6e54
parentf22a95554a999ae074c4093b22255f8f04418ccf (diff)
downloadnautilus-95ec145831d862f8c3279872b4fdb3ba8db97097.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 9a168d437..ca1013f17 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);
}
@@ -1169,11 +1178,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) {
@@ -1190,16 +1217,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;
}