[gnome-builder/wip/search] search: add plumbing to activate GbSearchResult.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/search] search: add plumbing to activate GbSearchResult.
- Date: Sun, 18 Jan 2015 06:59:49 +0000 (UTC)
commit a9b4a83b70994df53ea32eadd74d1b18ea04d9e9
Author: Christian Hergert <christian hergert me>
Date: Sat Jan 17 22:59:38 2015 -0800
search: add plumbing to activate GbSearchResult.
src/search/gb-search-display-group.c | 33 +++++++++++++++++++++++++++++++++
src/search/gb-search-display.c | 29 +++++++++++++++++++++++++++++
src/search/gb-search-result.c | 25 +++++++++++++++++++++++++
src/search/gb-search-result.h | 3 +++
4 files changed, 90 insertions(+), 0 deletions(-)
---
diff --git a/src/search/gb-search-display-group.c b/src/search/gb-search-display-group.c
index 611e787..bd38da7 100644
--- a/src/search/gb-search-display-group.c
+++ b/src/search/gb-search-display-group.c
@@ -50,6 +50,7 @@ enum {
};
enum {
+ RESULT_ACTIVATED,
RESULT_SELECTED,
LAST_SIGNAL
};
@@ -240,6 +241,21 @@ gb_search_display_group_unselect (GbSearchDisplayGroup *group)
}
static void
+gb_search_display_group_row_activated (GbSearchDisplayGroup *group,
+ GtkListBoxRow *row,
+ GtkListBox *list_box)
+{
+ GbSearchResult *result;
+
+ g_return_if_fail (GB_IS_SEARCH_DISPLAY_GROUP (group));
+ g_return_if_fail (!row || GTK_IS_LIST_BOX_ROW (row));
+ g_return_if_fail (GTK_IS_LIST_BOX (list_box));
+
+ result = g_object_get_qdata (G_OBJECT (row), gQuarkResult);
+ g_signal_emit (group, gSignals [RESULT_ACTIVATED], 0, result);
+}
+
+static void
gb_search_display_group_row_selected (GbSearchDisplayGroup *group,
GtkListBoxRow *row,
GtkListBox *list_box)
@@ -409,6 +425,18 @@ gb_search_display_group_class_init (GbSearchDisplayGroupClass *klass)
g_object_class_install_property (object_class, PROP_SIZE_GROUP,
gParamSpecs [PROP_SIZE_GROUP]);
+ gSignals [RESULT_ACTIVATED] =
+ g_signal_new ("result-activated",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE,
+ 1,
+ GB_TYPE_SEARCH_RESULT);
+
gSignals [RESULT_SELECTED] =
g_signal_new ("result-selected",
G_TYPE_FROM_CLASS (klass),
@@ -447,6 +475,11 @@ gb_search_display_group_init (GbSearchDisplayGroup *self)
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->priv->rows,
+ "row-activated",
+ G_CALLBACK (gb_search_display_group_row_activated),
+ self,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->priv->rows,
"row-selected",
G_CALLBACK (gb_search_display_group_row_selected),
self,
diff --git a/src/search/gb-search-display.c b/src/search/gb-search-display.c
index 0ce09cc..92b22a9 100644
--- a/src/search/gb-search-display.c
+++ b/src/search/gb-search-display.c
@@ -83,6 +83,28 @@ gb_search_display_new (void)
}
static void
+gb_search_display_real_result_activated (GbSearchDisplay *display,
+ GbSearchResult *result)
+{
+ g_return_if_fail (GB_IS_SEARCH_DISPLAY (display));
+ g_return_if_fail (GB_IS_SEARCH_RESULT (result));
+
+ gb_search_result_activate (result);
+}
+
+static void
+gb_search_display_result_activated (GbSearchDisplay *display,
+ GbSearchResult *result,
+ GbSearchDisplayGroup *group)
+{
+ g_return_if_fail (GB_IS_SEARCH_DISPLAY (display));
+ g_return_if_fail (!result || GB_IS_SEARCH_RESULT (result));
+ g_return_if_fail (GB_IS_SEARCH_DISPLAY_GROUP (group));
+
+ g_signal_emit (display, gSignals [RESULT_ACTIVATED], 0, result);
+}
+
+static void
gb_search_display_result_selected (GbSearchDisplay *display,
GbSearchResult *result,
GbSearchDisplayGroup *group)
@@ -189,6 +211,11 @@ gb_search_display_add_provider (GbSearchDisplay *display,
"visible", FALSE,
NULL);
g_signal_connect_object (entry.group,
+ "result-activated",
+ G_CALLBACK (gb_search_display_result_activated),
+ display,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (entry.group,
"result-selected",
G_CALLBACK (gb_search_display_result_selected),
display,
@@ -479,6 +506,8 @@ gb_search_display_class_init (GbSearchDisplayClass *klass)
object_class->get_property = gb_search_display_get_property;
object_class->set_property = gb_search_display_set_property;
+ klass->result_activated = gb_search_display_real_result_activated;
+
gParamSpecs [PROP_CONTEXT] =
g_param_spec_object ("context",
_("Context"),
diff --git a/src/search/gb-search-result.c b/src/search/gb-search-result.c
index da9fe60..a140f66 100644
--- a/src/search/gb-search-result.c
+++ b/src/search/gb-search-result.c
@@ -35,7 +35,13 @@ enum {
LAST_PROP
};
+enum {
+ ACTIVATE,
+ LAST_SIGNAL
+};
+
static GParamSpec *gParamSpecs [LAST_PROP];
+static guint gSignals [LAST_SIGNAL];
gint
gb_search_result_compare (const GbSearchResult *a,
@@ -99,6 +105,14 @@ gb_search_result_set_score (GbSearchResult *result,
result->priv->score = score;
}
+void
+gb_search_result_activate (GbSearchResult *result)
+{
+ g_return_if_fail (GB_IS_SEARCH_RESULT (result));
+
+ g_signal_emit (result, gSignals [ACTIVATE], 0);
+}
+
static void
gb_search_result_finalize (GObject *object)
{
@@ -187,6 +201,17 @@ gb_search_result_class_init (GbSearchResultClass *klass)
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_SCORE,
gParamSpecs [PROP_SCORE]);
+
+ gSignals [ACTIVATE] =
+ g_signal_new ("activate",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbSearchResultClass, activate),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
diff --git a/src/search/gb-search-result.h b/src/search/gb-search-result.h
index 63515a2..03fe8b4 100644
--- a/src/search/gb-search-result.h
+++ b/src/search/gb-search-result.h
@@ -43,6 +43,8 @@ struct _GbSearchResult
struct _GbSearchResultClass
{
GObjectClass parent;
+
+ void (*activate) (GbSearchResult *result);
};
GbSearchResult *gb_search_result_new (const gchar *markup,
@@ -51,6 +53,7 @@ gfloat gb_search_result_get_score (GbSearchResult *result);
const gchar *gb_search_result_get_markup (GbSearchResult *result);
gint gb_search_result_compare (const GbSearchResult *a,
const GbSearchResult *b);
+void gb_search_result_activate (GbSearchResult *result);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]