[gnome-builder] libide/search: add use-markup and use-underline properties
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/search: add use-markup and use-underline properties
- Date: Tue, 19 Jul 2022 22:29:33 +0000 (UTC)
commit b66e67696153e4fe18bb25ad341f4d6d238e64ed
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 19 14:26:16 2022 -0700
libide/search: add use-markup and use-underline properties
src/libide/gui/ide-search-popover.ui | 12 ++++-
src/libide/search/ide-search-engine.c | 2 +-
src/libide/search/ide-search-result.c | 84 +++++++++++++++++++++++++++++++++++
src/libide/search/ide-search-result.h | 56 +++++++++++++----------
4 files changed, 128 insertions(+), 26 deletions(-)
---
diff --git a/src/libide/gui/ide-search-popover.ui b/src/libide/gui/ide-search-popover.ui
index 8675f1809..bb080b2cf 100644
--- a/src/libide/gui/ide-search-popover.ui
+++ b/src/libide/gui/ide-search-popover.ui
@@ -69,8 +69,16 @@
<object class="GtkLabel">
<property name="halign">start</property>
<property name="ellipsize">end</property>
- <property name="use-markup">true</property>
- <property name="use-underline">true</property>
+ <binding name="use-markup">
+ <lookup name="use-markup" type="IdeSearchResult">
+ <lookup name="item">GtkListItem</lookup>
+ </lookup>
+ </binding>
+ <binding name="use-underline">
+ <lookup name="use-underline" type="IdeSearchResult">
+ <lookup name="item">GtkListItem</lookup>
+ </lookup>
+ </binding>
<binding name="label">
<lookup name="title" type="IdeSearchResult">
<lookup name="item">GtkListItem</lookup>
diff --git a/src/libide/search/ide-search-engine.c b/src/libide/search/ide-search-engine.c
index 8e90fc4d6..cb473bb96 100644
--- a/src/libide/search/ide-search-engine.c
+++ b/src/libide/search/ide-search-engine.c
@@ -145,7 +145,7 @@ ide_search_engine_parent_set (IdeObject *object,
self->extensions = ide_extension_set_adapter_new (object,
peas_engine_get_default (),
IDE_TYPE_SEARCH_PROVIDER,
- NULL, NULL);
+ "Search-Provider", NULL);
g_signal_connect (self->extensions,
"extension-added",
diff --git a/src/libide/search/ide-search-result.c b/src/libide/search/ide-search-result.c
index 80867f359..22b7782f8 100644
--- a/src/libide/search/ide-search-result.c
+++ b/src/libide/search/ide-search-result.c
@@ -34,6 +34,8 @@ typedef struct
GIcon *gicon;
float score;
guint priority;
+ guint use_underline : 1;
+ guint use_markup : 1;
} IdeSearchResultPrivate;
enum {
@@ -44,6 +46,8 @@ enum {
PROP_SCORE,
PROP_SUBTITLE,
PROP_TITLE,
+ PROP_USE_MARKUP,
+ PROP_USE_UNDERLINE,
N_PROPS
};
@@ -115,6 +119,14 @@ ide_search_result_get_property (GObject *object,
g_value_set_string (value, ide_search_result_get_title (self));
break;
+ case PROP_USE_MARKUP:
+ g_value_set_boolean (value, ide_search_result_get_use_markup (self));
+ break;
+
+ case PROP_USE_UNDERLINE:
+ g_value_set_boolean (value, ide_search_result_get_use_underline (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -154,6 +166,14 @@ ide_search_result_set_property (GObject *object,
ide_search_result_set_title (self, g_value_get_string (value));
break;
+ case PROP_USE_MARKUP:
+ ide_search_result_set_use_markup (self, g_value_get_boolean (value));
+ break;
+
+ case PROP_USE_UNDERLINE:
+ ide_search_result_set_use_underline (self, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -216,6 +236,16 @@ ide_search_result_class_init (IdeSearchResultClass *klass)
NULL,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ properties [PROP_USE_MARKUP] =
+ g_param_spec_boolean ("use-markup", NULL, NULL,
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ properties [PROP_USE_UNDERLINE] =
+ g_param_spec_boolean ("use-underline", NULL, NULL,
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
g_object_class_install_properties (object_class, N_PROPS, properties);
}
@@ -434,3 +464,57 @@ ide_search_result_get_gicon (IdeSearchResult *self)
return priv->gicon;
}
+
+gboolean
+ide_search_result_get_use_underline (IdeSearchResult *self)
+{
+ IdeSearchResultPrivate *priv = ide_search_result_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_SEARCH_RESULT (self), FALSE);
+
+ return priv->use_underline;
+}
+
+void
+ide_search_result_set_use_underline (IdeSearchResult *self,
+ gboolean use_underline)
+{
+ IdeSearchResultPrivate *priv = ide_search_result_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_SEARCH_RESULT (self));
+
+ use_underline = !!use_underline;
+
+ if (priv->use_underline != use_underline)
+ {
+ priv->use_underline = use_underline;
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_USE_UNDERLINE]);
+ }
+}
+
+gboolean
+ide_search_result_get_use_markup (IdeSearchResult *self)
+{
+ IdeSearchResultPrivate *priv = ide_search_result_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_SEARCH_RESULT (self), FALSE);
+
+ return priv->use_markup;
+}
+
+void
+ide_search_result_set_use_markup (IdeSearchResult *self,
+ gboolean use_markup)
+{
+ IdeSearchResultPrivate *priv = ide_search_result_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_SEARCH_RESULT (self));
+
+ use_markup = !!use_markup;
+
+ if (priv->use_markup != use_markup)
+ {
+ priv->use_markup = use_markup;
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_USE_MARKUP]);
+ }
+}
diff --git a/src/libide/search/ide-search-result.h b/src/libide/search/ide-search-result.h
index 681a052a9..cf78faed6 100644
--- a/src/libide/search/ide-search-result.h
+++ b/src/libide/search/ide-search-result.h
@@ -46,42 +46,52 @@ struct _IdeSearchResultClass
};
IDE_AVAILABLE_IN_ALL
-IdeSearchResult *ide_search_result_new (void);
+IdeSearchResult *ide_search_result_new (void);
IDE_AVAILABLE_IN_ALL
-void ide_search_result_activate (IdeSearchResult *self,
- GtkWidget *last_focus);
+void ide_search_result_activate (IdeSearchResult *self,
+ GtkWidget *last_focus);
IDE_AVAILABLE_IN_ALL
-int ide_search_result_compare (gconstpointer a,
- gconstpointer b);
+int ide_search_result_compare (gconstpointer a,
+ gconstpointer b);
IDE_AVAILABLE_IN_ALL
-int ide_search_result_get_priority (IdeSearchResult *self);
+int ide_search_result_get_priority (IdeSearchResult *self);
IDE_AVAILABLE_IN_ALL
-void ide_search_result_set_priority (IdeSearchResult *self,
- int priority);
+void ide_search_result_set_priority (IdeSearchResult *self,
+ int priority);
IDE_AVAILABLE_IN_ALL
-float ide_search_result_get_score (IdeSearchResult *self);
+float ide_search_result_get_score (IdeSearchResult *self);
IDE_AVAILABLE_IN_ALL
-void ide_search_result_set_score (IdeSearchResult *self,
- gfloat score);
+void ide_search_result_set_score (IdeSearchResult *self,
+ gfloat score);
IDE_AVAILABLE_IN_ALL
-GdkPaintable *ide_search_result_get_paintable (IdeSearchResult *self);
+GdkPaintable *ide_search_result_get_paintable (IdeSearchResult *self);
IDE_AVAILABLE_IN_ALL
-void ide_search_result_set_paintable (IdeSearchResult *self,
- GdkPaintable *paintable);
+void ide_search_result_set_paintable (IdeSearchResult *self,
+ GdkPaintable *paintable);
IDE_AVAILABLE_IN_ALL
-GIcon *ide_search_result_get_gicon (IdeSearchResult *self);
+GIcon *ide_search_result_get_gicon (IdeSearchResult *self);
IDE_AVAILABLE_IN_ALL
-void ide_search_result_set_gicon (IdeSearchResult *self,
- GIcon *gicon);
+void ide_search_result_set_gicon (IdeSearchResult *self,
+ GIcon *gicon);
IDE_AVAILABLE_IN_ALL
-const char *ide_search_result_get_title (IdeSearchResult *self);
+const char *ide_search_result_get_title (IdeSearchResult *self);
IDE_AVAILABLE_IN_ALL
-void ide_search_result_set_title (IdeSearchResult *self,
- const char *title);
+void ide_search_result_set_title (IdeSearchResult *self,
+ const char *title);
IDE_AVAILABLE_IN_ALL
-const char *ide_search_result_get_subtitle (IdeSearchResult *self);
+const char *ide_search_result_get_subtitle (IdeSearchResult *self);
IDE_AVAILABLE_IN_ALL
-void ide_search_result_set_subtitle (IdeSearchResult *self,
- const char *subtitle);
+void ide_search_result_set_subtitle (IdeSearchResult *self,
+ const char *subtitle);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_search_result_get_use_markup (IdeSearchResult *self);
+IDE_AVAILABLE_IN_ALL
+void ide_search_result_set_use_markup (IdeSearchResult *self,
+ gboolean use_markup);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_search_result_get_use_underline (IdeSearchResult *self);
+IDE_AVAILABLE_IN_ALL
+void ide_search_result_set_use_underline (IdeSearchResult *self,
+ gboolean use_underline);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]