[nautilus/wip/csoriano/search-popover: 3/13] search-popover: use single signals for changes
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/search-popover: 3/13] search-popover: use single signals for changes
- Date: Wed, 3 Feb 2016 15:34:38 +0000 (UTC)
commit 946cd0d8070db0d1439b3a960da6fa4a508dd188
Author: Carlos Soriano <csoriano gnome org>
Date: Tue Feb 2 18:30:03 2016 +0100
search-popover: use single signals for changes
It's more flexible and better to maintain different signals
for different changes, rather than a single signal with a single
generic parameter.
src/nautilus-query-editor.c | 39 +++++++++++++++++++++----------------
src/nautilus-search-popover.c | 43 +++++++++++++++++++++++++---------------
2 files changed, 49 insertions(+), 33 deletions(-)
---
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 57dbc85..1b34503 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -381,10 +381,9 @@ search_popover_date_range_changed_cb (NautilusSearchPopover *popover,
}
static void
-search_popover_changed_cb (NautilusSearchPopover *popover,
- NautilusSearchFilter filter,
- gpointer data,
- NautilusQueryEditor *editor)
+search_popover_mime_type_changed_cb (NautilusSearchPopover *popover,
+ GList *data,
+ NautilusQueryEditor *editor)
{
NautilusQueryEditorPrivate *priv;
@@ -392,19 +391,23 @@ search_popover_changed_cb (NautilusSearchPopover *popover,
if (!priv->query)
create_query (editor);
- switch (filter) {
- case NAUTILUS_SEARCH_FILTER_TYPE:
- nautilus_query_set_mime_types (priv->query, data);
- break;
+ nautilus_query_set_mime_types (priv->query, data);
- case NAUTILUS_SEARCH_FILTER_LAST:
- nautilus_query_set_search_type (priv->query, GPOINTER_TO_INT (data));
- break;
+ nautilus_query_editor_changed (editor);
+}
- default:
- g_warning ("Search filter type not valid");
- break;
- }
+static void
+search_popover_time_type_changed_cb (NautilusSearchPopover *popover,
+ NautilusQuerySearchType data,
+ NautilusQueryEditor *editor)
+{
+ NautilusQueryEditorPrivate *priv;
+
+ priv = nautilus_query_editor_get_instance_private (NAUTILUS_QUERY_EDITOR (editor));
+ if (!priv->query)
+ create_query (editor);
+
+ nautilus_query_set_search_type (priv->query, data);
nautilus_query_editor_changed (editor);
}
@@ -462,10 +465,12 @@ setup_widgets (NautilusQueryEditor *editor)
G_CALLBACK (entry_changed_cb), editor);
g_signal_connect (priv->entry, "stop-search",
G_CALLBACK (nautilus_query_editor_on_stop_search), editor);
- g_signal_connect (priv->popover, "changed",
- G_CALLBACK (search_popover_changed_cb), editor);
g_signal_connect (priv->popover, "date-range",
G_CALLBACK (search_popover_date_range_changed_cb), editor);
+ g_signal_connect (priv->popover, "mime-type",
+ G_CALLBACK (search_popover_mime_type_changed_cb), editor);
+ g_signal_connect (priv->popover, "time-type",
+ G_CALLBACK (search_popover_time_type_changed_cb), editor);
/* show everything */
gtk_widget_show_all (vbox);
diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c
index ea580b6..e207d04 100644
--- a/src/nautilus-search-popover.c
+++ b/src/nautilus-search-popover.c
@@ -69,7 +69,8 @@ enum {
};
enum {
- CHANGED,
+ MIME_TYPE,
+ TIME_TYPE,
DATE_RANGE,
LAST_SIGNAL
};
@@ -512,7 +513,7 @@ types_listbox_row_activated (GtkListBox *listbox,
gtk_label_set_label (GTK_LABEL (popover->type_label), gettext (mimetype_groups[group].name));
- g_signal_emit (popover, signals[CHANGED], 0, NAUTILUS_SEARCH_FILTER_TYPE, mimetypes);
+ g_signal_emit_by_name (popover, "mime-type", mimetypes, NULL);
g_list_free (mimetypes);
}
@@ -537,7 +538,7 @@ search_time_type_changed (GtkToggleButton *button,
g_settings_set_enum (nautilus_preferences, "search-filter-time-type", type);
- g_signal_emit (popover, signals[CHANGED], 0, NAUTILUS_SEARCH_FILTER_LAST, type);
+ g_signal_emit_by_name (popover, "time-type", type, NULL);
}
/* Auxiliary methods */
@@ -820,7 +821,7 @@ show_other_types_dialog (NautilusSearchPopover *popover)
gtk_label_set_label (GTK_LABEL (popover->type_label), description);
- g_signal_emit (popover, signals[CHANGED], 0, NAUTILUS_SEARCH_FILTER_TYPE, mimetypes);
+ g_signal_emit_by_name (popover, "mime-type", mimetypes, NULL);
gtk_stack_set_visible_child_name (GTK_STACK (popover->type_stack), "type-button");
}
@@ -977,18 +978,6 @@ nautilus_search_popover_class_init (NautilusSearchPopoverClass *klass)
popover_class->closed = nautilus_search_popover_closed;
- signals[CHANGED] = g_signal_new ("changed",
- NAUTILUS_TYPE_SEARCH_POPOVER,
- G_SIGNAL_RUN_LAST,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_generic,
- G_TYPE_NONE,
- 2,
- NAUTILUS_TYPE_SEARCH_FILTER,
- G_TYPE_POINTER);
-
signals[DATE_RANGE] = g_signal_new ("date-range",
NAUTILUS_TYPE_SEARCH_POPOVER,
G_SIGNAL_RUN_LAST,
@@ -1000,6 +989,28 @@ nautilus_search_popover_class_init (NautilusSearchPopoverClass *klass)
1,
G_TYPE_POINTER);
+ signals[MIME_TYPE] = g_signal_new ("mime-type",
+ NAUTILUS_TYPE_SEARCH_POPOVER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+
+ signals[TIME_TYPE] = g_signal_new ("time-type",
+ NAUTILUS_TYPE_SEARCH_POPOVER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+
/**
* NautilusSearchPopover::query:
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]