[gnome-builder] search: add GbSearchDisplayRow
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] search: add GbSearchDisplayRow
- Date: Mon, 19 Jan 2015 10:48:30 +0000 (UTC)
commit 11d6f8ee8629ee885ac33134588c8191b4aabfe9
Author: Christian Hergert <christian hergert me>
Date: Mon Jan 19 02:48:23 2015 -0800
search: add GbSearchDisplayRow
This helps us get the font color right for the subtitle, which we can't
seem to do with span's in cell renderers.
This also changes markup->title and adds subtitle to GbSearchResult.
src/git/gb-git-search-provider.c | 6 +-
src/gnome-builder.mk | 2 +
src/resources/gnome-builder.gresource.xml | 1 +
src/resources/ui/gb-search-display-row.ui | 44 +++++++
src/search/gb-search-display-group.c | 89 +++++++--------
src/search/gb-search-display-row.c | 179 +++++++++++++++++++++++++++++
src/search/gb-search-display-row.h | 54 +++++++++
src/search/gb-search-result.c | 103 ++++++++++++-----
src/search/gb-search-result.h | 16 ++-
src/search/gb-search-types.h | 8 +-
10 files changed, 412 insertions(+), 90 deletions(-)
---
diff --git a/src/git/gb-git-search-provider.c b/src/git/gb-git-search-provider.c
index dd659e6..7c7cb86 100644
--- a/src/git/gb-git-search-provider.c
+++ b/src/git/gb-git-search-provider.c
@@ -348,15 +348,12 @@ gb_git_search_provider_populate (GbSearchProvider *provider,
if (gb_search_reducer_accepts (&reducer, match->score))
{
GbSearchResult *result;
- gchar *markup;
parts = split_path (match->value, &shortname);
for (j = 0; parts [j]; j++)
g_string_append_printf (str, " / %s", parts [j]);
- markup = g_strdup_printf ("%s\n<span color='#a8a8a8'>%s</span>",
- shortname, str->str);
- result = gb_search_result_new (markup, match->score);
+ result = gb_search_result_new (shortname, str->str, match->score);
g_object_set_qdata_full (G_OBJECT (result), gQuarkPath,
g_strdup (match->value), g_free);
g_signal_connect (result,
@@ -366,7 +363,6 @@ gb_git_search_provider_populate (GbSearchProvider *provider,
gb_search_reducer_push (&reducer, result);
g_object_unref (result);
- g_free (markup);
g_free (shortname);
g_strfreev (parts);
g_string_truncate (str, truncate_len);
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 8dd5f32..426b925 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -151,6 +151,8 @@ libgnome_builder_la_SOURCES = \
src/search/gb-search-display.h \
src/search/gb-search-display-group.c \
src/search/gb-search-display-group.h \
+ src/search/gb-search-display-row.c \
+ src/search/gb-search-display-row.h \
src/search/gb-search-manager.c \
src/search/gb-search-manager.h \
src/search/gb-search-provider.c \
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 2c564b3..9b24dee 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -50,6 +50,7 @@
<file>ui/gb-preferences-page-vim.ui</file>
<file>ui/gb-search-box.ui</file>
<file>ui/gb-search-display-group.ui</file>
+ <file>ui/gb-search-display-row.ui</file>
<file>ui/gb-workbench.ui</file>
</gresource>
</gresources>
diff --git a/src/resources/ui/gb-search-display-row.ui b/src/resources/ui/gb-search-display-row.ui
new file mode 100644
index 0000000..fdd0735
--- /dev/null
+++ b/src/resources/ui/gb-search-display-row.ui
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="GbSearchDisplayRow" parent="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox">
+ <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="margin_start">6</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="title">
+ <property name="visible">True</property>
+ <property name="xalign">0.0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="subtitle">
+ <property name="visible">False</property>
+ <property name="xalign">0.0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkProgressBar" id="progress">
+ <property name="inverted">True</property>
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="margin_end">6</property>
+ <style>
+ <class name="osd"/>
+ </style>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/search/gb-search-display-group.c b/src/search/gb-search-display-group.c
index 35c6ac8..765f1a5 100644
--- a/src/search/gb-search-display-group.c
+++ b/src/search/gb-search-display-group.c
@@ -19,6 +19,7 @@
#include <glib/gi18n.h>
#include "gb-search-display-group.h"
+#include "gb-search-display-row.h"
#include "gb-search-provider.h"
#include "gb-search-result.h"
#include "gb-widget.h"
@@ -55,7 +56,6 @@ enum {
LAST_SIGNAL
};
-static GQuark gQuarkResult;
static GQuark gQuarkRow;
static GParamSpec *gParamSpecs [LAST_PROP];
static guint gSignals [LAST_SIGNAL];
@@ -68,8 +68,15 @@ gb_search_display_group_get_first (GbSearchDisplayGroup *group)
g_return_val_if_fail (GB_IS_SEARCH_DISPLAY_GROUP (group), NULL);
row = gtk_list_box_get_row_at_y (group->priv->rows, 1);
+
if (row)
- return g_object_get_qdata (G_OBJECT (row), gQuarkResult);
+ {
+ GtkWidget *child;
+
+ child = gtk_bin_get_child (GTK_BIN (row));
+ if (GB_IS_SEARCH_DISPLAY_ROW (child))
+ return gb_search_display_row_get_result (GB_SEARCH_DISPLAY_ROW (child));
+ }
return NULL;
}
@@ -113,52 +120,21 @@ gb_search_display_group_set_size_group (GbSearchDisplayGroup *group,
GtkWidget *
gb_search_display_group_create_row (GbSearchResult *result)
{
- GtkProgressBar *progress;
GtkListBoxRow *row;
- const gchar *markup;
- GtkLabel *label;
- GtkBox *box;
- gfloat score;
+ GbSearchDisplayRow *disp_row;
g_return_val_if_fail (GB_IS_SEARCH_RESULT (result), NULL);
row = g_object_new (GTK_TYPE_LIST_BOX_ROW,
"visible", TRUE,
NULL);
- g_object_set_qdata_full (G_OBJECT (row), gQuarkResult,
- g_object_ref (result), g_object_unref);
- g_object_set_qdata (G_OBJECT (result), gQuarkRow, row);
- box = g_object_new (GTK_TYPE_BOX,
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "spacing", 6,
- "visible", TRUE,
- NULL);
- gtk_container_add (GTK_CONTAINER (row), GTK_WIDGET (box));
- markup = gb_search_result_get_markup (result);
- label = g_object_new (GTK_TYPE_LABEL,
- "hexpand", TRUE,
- "label", markup,
- "use-markup", TRUE,
- "visible", TRUE,
- "xalign", 0.0f,
- "xpad", 6,
- "ypad", 3,
- NULL);
- gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (label));
- score = gb_search_result_get_score (result);
- progress = g_object_new (GTK_TYPE_PROGRESS_BAR,
- "fraction", score,
- "hexpand", FALSE,
- "inverted", TRUE,
+ disp_row = g_object_new (GB_TYPE_SEARCH_DISPLAY_ROW,
"visible", TRUE,
- "width-request", 30,
- "valign", GTK_ALIGN_CENTER,
- "margin-start", 6,
- "margin-end", 6,
+ "result", result,
NULL);
- gtk_style_context_add_class (
- gtk_widget_get_style_context (GTK_WIDGET (progress)), "osd");
- gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (progress));
+ gtk_container_add (GTK_CONTAINER (row), GTK_WIDGET (disp_row));
+
+ g_object_set_qdata (G_OBJECT (result), gQuarkRow, row);
return GTK_WIDGET (row);
}
@@ -222,6 +198,8 @@ compare_cb (GtkListBoxRow *row1,
gpointer user_data)
{
GtkListBoxRow *more_row = user_data;
+ GtkWidget *child1;
+ GtkWidget *child2;
GbSearchResult *result1;
GbSearchResult *result2;
gfloat score1;
@@ -232,8 +210,11 @@ compare_cb (GtkListBoxRow *row1,
else if (row2 == more_row)
return -1;
- result1 = g_object_get_qdata (G_OBJECT (row1), gQuarkResult);
- result2 = g_object_get_qdata (G_OBJECT (row2), gQuarkResult);
+ child1 = gtk_bin_get_child (GTK_BIN (row1));
+ child2 = gtk_bin_get_child (GTK_BIN (row2));
+
+ result1 = gb_search_display_row_get_result (GB_SEARCH_DISPLAY_ROW (child1));
+ result2 = gb_search_display_row_get_result (GB_SEARCH_DISPLAY_ROW (child2));
score1 = gb_search_result_get_score (result1);
score2 = gb_search_result_get_score (result2);
@@ -259,14 +240,22 @@ gb_search_display_group_row_activated (GbSearchDisplayGroup *group,
GtkListBoxRow *row,
GtkListBox *list_box)
{
- GbSearchResult *result;
+ GtkWidget *child;
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);
+ child = gtk_bin_get_child (GTK_BIN (row));
+
+ if (GB_IS_SEARCH_DISPLAY_ROW (child))
+ {
+ GbSearchResult *result;
+
+ result = gb_search_display_row_get_result (GB_SEARCH_DISPLAY_ROW (child));
+ if (result)
+ g_signal_emit (group, gSignals [RESULT_ACTIVATED], 0, result);
+ }
}
static void
@@ -274,16 +263,21 @@ gb_search_display_group_row_selected (GbSearchDisplayGroup *group,
GtkListBoxRow *row,
GtkListBox *list_box)
{
+ GtkWidget *child;
+
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));
- if (row)
+ child = gtk_bin_get_child (GTK_BIN (row));
+
+ if (GB_IS_SEARCH_DISPLAY_ROW (child))
{
GbSearchResult *result;
- result = g_object_get_qdata (G_OBJECT (row), gQuarkResult);
- g_signal_emit (group, gSignals [RESULT_SELECTED], 0, result);
+ result = gb_search_display_row_get_result (GB_SEARCH_DISPLAY_ROW (child));
+ if (result)
+ g_signal_emit (group, gSignals [RESULT_SELECTED], 0, result);
}
}
@@ -469,7 +463,6 @@ gb_search_display_group_class_init (GbSearchDisplayGroupClass *klass)
GB_WIDGET_CLASS_BIND (widget_class, GbSearchDisplayGroup, label);
GB_WIDGET_CLASS_BIND (widget_class, GbSearchDisplayGroup, rows);
- gQuarkResult = g_quark_from_static_string ("GB_SEARCH_RESULT");
gQuarkRow = g_quark_from_static_string ("GB_SEARCH_DISPLAY_ROW");
}
diff --git a/src/search/gb-search-display-row.c b/src/search/gb-search-display-row.c
new file mode 100644
index 0000000..f7fc31a
--- /dev/null
+++ b/src/search/gb-search-display-row.c
@@ -0,0 +1,179 @@
+/* gb-search-display-row.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gb-search-display-row.h"
+#include "gb-search-result.h"
+#include "gb-widget.h"
+
+struct _GbSearchDisplayRowPrivate
+{
+ GbSearchResult *result;
+
+ /* References owned by template */
+ GtkLabel *title;
+ GtkLabel *subtitle;
+ GtkProgressBar *progress;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbSearchDisplayRow, gb_search_display_row,
+ GTK_TYPE_BOX)
+
+enum {
+ PROP_0,
+ PROP_RESULT,
+ LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+static void
+gb_search_display_row_connect (GbSearchDisplayRow *row,
+ GbSearchResult *result)
+{
+ const gchar *title;
+ const gchar *subtitle;
+ gfloat fraction;
+
+ g_return_if_fail (GB_IS_SEARCH_DISPLAY_ROW (row));
+ g_return_if_fail (GB_IS_SEARCH_RESULT (result));
+
+ title = gb_search_result_get_title (result);
+ gtk_label_set_markup (row->priv->title, title);
+
+ subtitle = gb_search_result_get_subtitle (result);
+ if (subtitle)
+ gtk_label_set_markup (row->priv->subtitle, subtitle);
+ gtk_widget_set_visible (GTK_WIDGET (row->priv->subtitle), !!subtitle);
+
+ fraction = gb_search_result_get_score (result);
+ gtk_progress_bar_set_fraction (row->priv->progress, fraction);
+ gtk_widget_set_visible (GTK_WIDGET (row->priv->progress), (fraction > 0.0));
+}
+
+GbSearchResult *
+gb_search_display_row_get_result (GbSearchDisplayRow *row)
+{
+ g_return_val_if_fail (GB_IS_SEARCH_DISPLAY_ROW (row), NULL);
+
+ return row->priv->result;
+}
+
+void
+gb_search_display_row_set_result (GbSearchDisplayRow *row,
+ GbSearchResult *result)
+{
+ g_return_if_fail (GB_IS_SEARCH_DISPLAY_ROW (row));
+ g_return_if_fail (GB_IS_SEARCH_RESULT (result));
+
+ if (result != row->priv->result)
+ {
+ g_clear_object (&row->priv->result);
+
+ if (result)
+ {
+ row->priv->result = g_object_ref (result);
+ gb_search_display_row_connect (row, result);
+ }
+
+ g_object_notify_by_pspec (G_OBJECT (row), gParamSpecs [PROP_RESULT]);
+ }
+}
+
+static void
+gb_search_display_row_finalize (GObject *object)
+{
+ GbSearchDisplayRowPrivate *priv = GB_SEARCH_DISPLAY_ROW (object)->priv;
+
+ g_clear_object (&priv->result);
+
+ G_OBJECT_CLASS (gb_search_display_row_parent_class)->finalize (object);
+}
+
+static void
+gb_search_display_row_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbSearchDisplayRow *self = GB_SEARCH_DISPLAY_ROW (object);
+
+ switch (prop_id)
+ {
+ case PROP_RESULT:
+ g_value_set_object (value, gb_search_display_row_get_result (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_search_display_row_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbSearchDisplayRow *self = GB_SEARCH_DISPLAY_ROW (object);
+
+ switch (prop_id)
+ {
+ case PROP_RESULT:
+ gb_search_display_row_set_result (self, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_search_display_row_class_init (GbSearchDisplayRowClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gb_search_display_row_finalize;
+ object_class->get_property = gb_search_display_row_get_property;
+ object_class->set_property = gb_search_display_row_set_property;
+
+ gParamSpecs [PROP_RESULT] =
+ g_param_spec_object ("result",
+ _("Result"),
+ _("Result"),
+ GB_TYPE_SEARCH_RESULT,
+ (G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_RESULT,
+ gParamSpecs [PROP_RESULT]);
+
+ GB_WIDGET_CLASS_TEMPLATE (widget_class, "gb-search-display-row.ui");
+ GB_WIDGET_CLASS_BIND (widget_class, GbSearchDisplayRow, progress);
+ GB_WIDGET_CLASS_BIND (widget_class, GbSearchDisplayRow, subtitle);
+ GB_WIDGET_CLASS_BIND (widget_class, GbSearchDisplayRow, title);
+}
+
+static void
+gb_search_display_row_init (GbSearchDisplayRow *self)
+{
+ self->priv = gb_search_display_row_get_instance_private (self);
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/search/gb-search-display-row.h b/src/search/gb-search-display-row.h
new file mode 100644
index 0000000..807a6c1
--- /dev/null
+++ b/src/search/gb-search-display-row.h
@@ -0,0 +1,54 @@
+/* gb-search-display-row.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GB_SEARCH_DISPLAY_ROW_H
+#define GB_SEARCH_DISPLAY_ROW_H
+
+#include <gtk/gtk.h>
+
+#include "gb-search-types.h"
+
+G_BEGIN_DECLS
+
+#define GB_SEARCH_DISPLAY_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_SEARCH_DISPLAY_ROW, GbSearchDisplayRow))
+#define GB_SEARCH_DISPLAY_ROW_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_SEARCH_DISPLAY_ROW, GbSearchDisplayRow const))
+#define GB_SEARCH_DISPLAY_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GB_TYPE_SEARCH_DISPLAY_ROW, GbSearchDisplayRowClass))
+#define GB_IS_SEARCH_DISPLAY_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GB_TYPE_SEARCH_DISPLAY_ROW))
+#define GB_IS_SEARCH_DISPLAY_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GB_TYPE_SEARCH_DISPLAY_ROW))
+#define GB_SEARCH_DISPLAY_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GB_TYPE_SEARCH_DISPLAY_ROW, GbSearchDisplayRowClass))
+
+struct _GbSearchDisplayRow
+{
+ GtkBox parent;
+
+ /*< private >*/
+ GbSearchDisplayRowPrivate *priv;
+};
+
+struct _GbSearchDisplayRowClass
+{
+ GtkBoxClass parent;
+};
+
+GbSearchResult *gb_search_display_row_get_result (GbSearchDisplayRow *row);
+void gb_search_display_row_set_result (GbSearchDisplayRow *row,
+ GbSearchResult *result);
+
+G_END_DECLS
+
+#endif /* GB_SEARCH_DISPLAY_ROW_H */
diff --git a/src/search/gb-search-result.c b/src/search/gb-search-result.c
index a140f66..fec15fe 100644
--- a/src/search/gb-search-result.c
+++ b/src/search/gb-search-result.c
@@ -22,7 +22,8 @@
struct _GbSearchResultPrivate
{
- gchar *markup;
+ gchar *subtitle;
+ gchar *title;
gfloat score;
};
@@ -30,8 +31,9 @@ G_DEFINE_TYPE_WITH_PRIVATE (GbSearchResult, gb_search_result, G_TYPE_OBJECT)
enum {
PROP_0,
- PROP_MARKUP,
PROP_SCORE,
+ PROP_SUBTITLE,
+ PROP_TITLE,
LAST_PROP
};
@@ -56,33 +58,56 @@ gb_search_result_compare (const GbSearchResult *a,
}
GbSearchResult *
-gb_search_result_new (const gchar *markup,
+gb_search_result_new (const gchar *title,
+ const gchar *subtitle,
gfloat score)
{
return g_object_new (GB_TYPE_SEARCH_RESULT,
- "markup", markup,
"score", score,
+ "subtitle", subtitle,
+ "title", title,
NULL);
}
const gchar *
-gb_search_result_get_markup (GbSearchResult *result)
+gb_search_result_get_subtitle (GbSearchResult *result)
{
g_return_val_if_fail (GB_IS_SEARCH_RESULT (result), NULL);
- return result->priv->markup;
+ return result->priv->subtitle;
+}
+
+const gchar *
+gb_search_result_get_title (GbSearchResult *result)
+{
+ g_return_val_if_fail (GB_IS_SEARCH_RESULT (result), NULL);
+
+ return result->priv->title;
+}
+
+static void
+gb_search_result_set_subtitle (GbSearchResult *result,
+ const gchar *subtitle)
+{
+ g_return_if_fail (GB_IS_SEARCH_RESULT (result));
+
+ if (result->priv->subtitle != subtitle)
+ {
+ g_free (result->priv->subtitle);
+ result->priv->subtitle = g_strdup (subtitle);
+ }
}
static void
-gb_search_result_set_markup (GbSearchResult *result,
- const gchar *markup)
+gb_search_result_set_title (GbSearchResult *result,
+ const gchar *title)
{
g_return_if_fail (GB_IS_SEARCH_RESULT (result));
- if (result->priv->markup != markup)
+ if (result->priv->title != title)
{
- g_free (result->priv->markup);
- result->priv->markup = g_strdup (markup);
+ g_free (result->priv->title);
+ result->priv->title = g_strdup (title);
}
}
@@ -118,7 +143,8 @@ gb_search_result_finalize (GObject *object)
{
GbSearchResultPrivate *priv = GB_SEARCH_RESULT (object)->priv;
- g_clear_pointer (&priv->markup, g_free);
+ g_clear_pointer (&priv->subtitle, g_free);
+ g_clear_pointer (&priv->title, g_free);
G_OBJECT_CLASS (gb_search_result_parent_class)->finalize (object);
}
@@ -133,14 +159,18 @@ gb_search_result_get_property (GObject *object,
switch (prop_id)
{
- case PROP_MARKUP:
- g_value_set_string (value, gb_search_result_get_markup (self));
- break;
-
case PROP_SCORE:
g_value_set_float (value, gb_search_result_get_score (self));
break;
+ case PROP_SUBTITLE:
+ g_value_set_string (value, gb_search_result_get_subtitle (self));
+ break;
+
+ case PROP_TITLE:
+ g_value_set_string (value, gb_search_result_get_title (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -156,14 +186,18 @@ gb_search_result_set_property (GObject *object,
switch (prop_id)
{
- case PROP_MARKUP:
- gb_search_result_set_markup (self, g_value_get_string (value));
+ case PROP_SUBTITLE:
+ gb_search_result_set_subtitle (self, g_value_get_string (value));
break;
case PROP_SCORE:
gb_search_result_set_score (self, g_value_get_float (value));
break;
+ case PROP_TITLE:
+ gb_search_result_set_title (self, g_value_get_string (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -178,17 +212,6 @@ gb_search_result_class_init (GbSearchResultClass *klass)
object_class->get_property = gb_search_result_get_property;
object_class->set_property = gb_search_result_set_property;
- gParamSpecs [PROP_MARKUP] =
- g_param_spec_string ("markup",
- _("Markup"),
- _("The pango markup to be rendered."),
- NULL,
- (G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class, PROP_MARKUP,
- gParamSpecs [PROP_MARKUP]);
-
gParamSpecs [PROP_SCORE] =
g_param_spec_float ("score",
_("Score"),
@@ -202,6 +225,28 @@ gb_search_result_class_init (GbSearchResultClass *klass)
g_object_class_install_property (object_class, PROP_SCORE,
gParamSpecs [PROP_SCORE]);
+ gParamSpecs [PROP_SUBTITLE] =
+ g_param_spec_string ("subtitle",
+ _("Subtitle"),
+ _("The pango markup to be rendered."),
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_SUBTITLE,
+ gParamSpecs [PROP_SUBTITLE]);
+
+ gParamSpecs [PROP_TITLE] =
+ g_param_spec_string ("title",
+ _("Title"),
+ _("The pango markup to be rendered."),
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_TITLE,
+ gParamSpecs [PROP_TITLE]);
+
gSignals [ACTIVATE] =
g_signal_new ("activate",
G_TYPE_FROM_CLASS (klass),
diff --git a/src/search/gb-search-result.h b/src/search/gb-search-result.h
index 03fe8b4..8a08898 100644
--- a/src/search/gb-search-result.h
+++ b/src/search/gb-search-result.h
@@ -47,13 +47,15 @@ struct _GbSearchResultClass
void (*activate) (GbSearchResult *result);
};
-GbSearchResult *gb_search_result_new (const gchar *markup,
- gfloat score);
-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);
+GbSearchResult *gb_search_result_new (const gchar *title,
+ const gchar *subtitle,
+ gfloat score);
+gfloat gb_search_result_get_score (GbSearchResult *result);
+const gchar *gb_search_result_get_title (GbSearchResult *result);
+const gchar *gb_search_result_get_subtitle (GbSearchResult *result);
+gint gb_search_result_compare (const GbSearchResult *a,
+ const GbSearchResult *b);
+void gb_search_result_activate (GbSearchResult *result);
G_END_DECLS
diff --git a/src/search/gb-search-types.h b/src/search/gb-search-types.h
index 160c1c8..95e7f55 100644
--- a/src/search/gb-search-types.h
+++ b/src/search/gb-search-types.h
@@ -19,13 +19,14 @@
#ifndef GB_SEARCH_TYPES_H
#define GB_SEARCH_TYPES_H
-#include <glib.h>
+#include <glib-object.h>
G_BEGIN_DECLS
#define GB_TYPE_SEARCH_CONTEXT (gb_search_context_get_type())
#define GB_TYPE_SEARCH_DISPLAY (gb_search_display_get_type())
#define GB_TYPE_SEARCH_DISPLAY_GROUP (gb_search_display_group_get_type())
+#define GB_TYPE_SEARCH_DISPLAY_ROW (gb_search_display_row_get_type())
#define GB_TYPE_SEARCH_MANAGER (gb_search_manager_get_type())
#define GB_TYPE_SEARCH_PROVIDER (gb_search_provider_get_type())
#define GB_TYPE_SEARCH_RESULT (gb_search_result_get_type())
@@ -42,6 +43,10 @@ typedef struct _GbSearchDisplayGroup GbSearchDisplayGroup;
typedef struct _GbSearchDisplayGroupClass GbSearchDisplayGroupClass;
typedef struct _GbSearchDisplayGroupPrivate GbSearchDisplayGroupPrivate;
+typedef struct _GbSearchDisplayRow GbSearchDisplayRow;
+typedef struct _GbSearchDisplayRowClass GbSearchDisplayRowClass;
+typedef struct _GbSearchDisplayRowPrivate GbSearchDisplayRowPrivate;
+
typedef struct _GbSearchProvider GbSearchProvider;
typedef struct _GbSearchProviderClass GbSearchProviderClass;
typedef struct _GbSearchProviderPrivate GbSearchProviderPrivate;
@@ -57,6 +62,7 @@ typedef struct _GbSearchResultPrivate GbSearchResultPrivate;
GType gb_search_context_get_type (void);
GType gb_search_display_get_type (void);
GType gb_search_display_group_get_type (void);
+GType gb_search_display_row_get_type (void);
GType gb_search_manager_get_type (void);
GType gb_search_provider_get_type (void);
GType gb_search_result_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]