[gnome-builder] libide-search: add subtitle property to IdeSearchResult
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide-search: add subtitle property to IdeSearchResult
- Date: Wed, 13 Jul 2022 06:31:08 +0000 (UTC)
commit ba8108c7420213874964e2be7bfc81fe3c07cdc1
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 12 21:41:51 2022 -0700
libide-search: add subtitle property to IdeSearchResult
We aren't using this yet, but it allows the code-index provider to use it.
src/libide/search/ide-search-result.c | 45 +++++++++++++++++++++++++++++++++++
src/libide/search/ide-search-result.h | 5 ++++
2 files changed, 50 insertions(+)
---
diff --git a/src/libide/search/ide-search-result.c b/src/libide/search/ide-search-result.c
index b9e900fae..206809c6a 100644
--- a/src/libide/search/ide-search-result.c
+++ b/src/libide/search/ide-search-result.c
@@ -27,6 +27,7 @@
typedef struct
{
char *title;
+ char *subtitle;
GdkPaintable *paintable;
GIcon *gicon;
float score;
@@ -39,6 +40,7 @@ enum {
PROP_GICON,
PROP_PRIORITY,
PROP_SCORE,
+ PROP_SUBTITLE,
PROP_TITLE,
N_PROPS
};
@@ -53,8 +55,10 @@ ide_search_result_finalize (GObject *object)
IdeSearchResult *self = (IdeSearchResult *)object;
IdeSearchResultPrivate *priv = ide_search_result_get_instance_private (self);
+ g_clear_object (&priv->gicon);
g_clear_object (&priv->paintable);
g_clear_pointer (&priv->title, g_free);
+ g_clear_pointer (&priv->subtitle, g_free);
G_OBJECT_CLASS (ide_search_result_parent_class)->finalize (object);
}
@@ -85,6 +89,10 @@ ide_search_result_get_property (GObject *object,
g_value_set_float (value, ide_search_result_get_score (self));
break;
+ case PROP_SUBTITLE:
+ g_value_set_string (value, ide_search_result_get_subtitle (self));
+ break;
+
case PROP_TITLE:
g_value_set_string (value, ide_search_result_get_title (self));
break;
@@ -120,6 +128,10 @@ ide_search_result_set_property (GObject *object,
ide_search_result_set_score (self, g_value_get_float (value));
break;
+ case PROP_SUBTITLE:
+ ide_search_result_set_subtitle (self, g_value_get_string (value));
+ break;
+
case PROP_TITLE:
ide_search_result_set_title (self, g_value_get_string (value));
break;
@@ -177,6 +189,13 @@ ide_search_result_class_init (IdeSearchResultClass *klass)
NULL,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ properties [PROP_SUBTITLE] =
+ g_param_spec_string ("subtitle",
+ "Subtitle",
+ "The subtitle of the search result",
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
g_object_class_install_properties (object_class, N_PROPS, properties);
}
@@ -313,6 +332,32 @@ ide_search_result_set_paintable (IdeSearchResult *self,
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PAINTABLE]);
}
+const char *
+ide_search_result_get_subtitle (IdeSearchResult *self)
+{
+ IdeSearchResultPrivate *priv = ide_search_result_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_SEARCH_RESULT (self), NULL);
+
+ return priv->subtitle;
+}
+
+void
+ide_search_result_set_subtitle (IdeSearchResult *self,
+ const char *subtitle)
+{
+ IdeSearchResultPrivate *priv = ide_search_result_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_SEARCH_RESULT (self));
+
+ if (g_strcmp0 (priv->subtitle, subtitle) != 0)
+ {
+ g_free (priv->subtitle);
+ priv->subtitle = g_strdup (subtitle);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SUBTITLE]);
+ }
+}
+
const char *
ide_search_result_get_title (IdeSearchResult *self)
{
diff --git a/src/libide/search/ide-search-result.h b/src/libide/search/ide-search-result.h
index 3d39e587f..71e61bc80 100644
--- a/src/libide/search/ide-search-result.h
+++ b/src/libide/search/ide-search-result.h
@@ -79,5 +79,10 @@ const char *ide_search_result_get_title (IdeSearchResult *self);
IDE_AVAILABLE_IN_ALL
void ide_search_result_set_title (IdeSearchResult *self,
const char *title);
+IDE_AVAILABLE_IN_ALL
+const char *ide_search_result_get_subtitle (IdeSearchResult *self);
+IDE_AVAILABLE_IN_ALL
+void ide_search_result_set_subtitle (IdeSearchResult *self,
+ const char *subtitle);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]