[libhandy] preferences-group: Add the use-markup property
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] preferences-group: Add the use-markup property
- Date: Wed, 11 Aug 2021 13:51:56 +0000 (UTC)
commit 58edddc7e2a49490183c0a367949f66b2202d18e
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Aug 11 13:21:36 2021 +0200
preferences-group: Add the use-markup property
This allows to use markup in the title and the description.
debian/libhandy-1-0.symbols | 2 ++
src/hdy-preferences-group.c | 73 +++++++++++++++++++++++++++++++++++++++++++++
src/hdy-preferences-group.h | 6 ++++
3 files changed, 81 insertions(+)
---
diff --git a/debian/libhandy-1-0.symbols b/debian/libhandy-1-0.symbols
index 8bbe291b..e934c495 100644
--- a/debian/libhandy-1-0.symbols
+++ b/debian/libhandy-1-0.symbols
@@ -264,9 +264,11 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
hdy_preferences_group_get_description@LIBHANDY_1_0 0.0.10
hdy_preferences_group_get_title@LIBHANDY_1_0 0.0.10
hdy_preferences_group_get_type@LIBHANDY_1_0 0.0.10
+ hdy_preferences_group_get_use_markup@LIBHANDY_1_0 1.4.0
hdy_preferences_group_new@LIBHANDY_1_0 0.0.10
hdy_preferences_group_set_description@LIBHANDY_1_0 0.0.10
hdy_preferences_group_set_title@LIBHANDY_1_0 0.0.10
+ hdy_preferences_group_set_use_markup@LIBHANDY_1_0 1.4.0
hdy_preferences_page_get_icon_name@LIBHANDY_1_0 0.0.10
hdy_preferences_page_get_title@LIBHANDY_1_0 0.0.10
hdy_preferences_page_get_type@LIBHANDY_1_0 0.0.10
diff --git a/src/hdy-preferences-group.c b/src/hdy-preferences-group.c
index f8e1c2d8..b90ef3d8 100644
--- a/src/hdy-preferences-group.c
+++ b/src/hdy-preferences-group.c
@@ -46,6 +46,7 @@ enum {
PROP_0,
PROP_DESCRIPTION,
PROP_TITLE,
+ PROP_USE_MARKUP,
LAST_PROP,
};
@@ -160,6 +161,9 @@ hdy_preferences_group_get_property (GObject *object,
case PROP_TITLE:
g_value_set_string (value, hdy_preferences_group_get_title (self));
break;
+ case PROP_USE_MARKUP:
+ g_value_set_boolean (value, hdy_preferences_group_get_use_markup (self));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -180,6 +184,9 @@ hdy_preferences_group_set_property (GObject *object,
case PROP_TITLE:
hdy_preferences_group_set_title (self, g_value_get_string (value));
break;
+ case PROP_USE_MARKUP:
+ hdy_preferences_group_set_use_markup (self, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -289,6 +296,20 @@ hdy_preferences_group_class_init (HdyPreferencesGroupClass *klass)
"",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ /**
+ * HdyPreferencesGroup:use-markup:
+ *
+ * Whether to use markup for the title and description.
+ *
+ * Since: 1.4
+ */
+ props[PROP_USE_MARKUP] =
+ g_param_spec_boolean ("use-markup",
+ _("Use markup"),
+ _("Whether to uses markup"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (object_class, LAST_PROP, props);
gtk_widget_class_set_css_name (widget_class, "preferencesgroup");
@@ -427,6 +448,58 @@ hdy_preferences_group_set_description (HdyPreferencesGroup *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_DESCRIPTION]);
}
+/**
+ * hdy_preferences_group_get_use_markup:
+ * @self: a #HdyPreferencesGroup
+ *
+ * Gets whether @self uses markup for the title and description.
+ *
+ * Returns: Whether @self uses markup for its labels.
+ *
+ * Since: 1.4
+ */
+gboolean
+hdy_preferences_group_get_use_markup (HdyPreferencesGroup *self)
+{
+ HdyPreferencesGroupPrivate *priv;
+
+ g_return_val_if_fail (HDY_IS_PREFERENCES_GROUP (self), FALSE);
+
+ priv = hdy_preferences_group_get_instance_private (self);
+
+ return gtk_label_get_use_markup (priv->title);
+}
+
+/**
+ * hdy_preferences_group_set_use_markup:
+ * @self: a #HdyPreferencesGroup
+ * @use_markup: whether to use markup
+ *
+ * Sets whether @self uses markup for the title and description.
+ *
+ * Since: 1.4
+ */
+void
+hdy_preferences_group_set_use_markup (HdyPreferencesGroup *self,
+ gboolean use_markup)
+{
+ HdyPreferencesGroupPrivate *priv;
+
+ g_return_if_fail (HDY_IS_PREFERENCES_GROUP (self));
+
+ priv = hdy_preferences_group_get_instance_private (self);
+
+ use_markup = !!use_markup;
+
+ if (gtk_label_get_use_markup (priv->title) == use_markup)
+ return;
+
+ gtk_label_set_use_markup (priv->title, use_markup);
+ gtk_label_set_use_markup (priv->description, use_markup);
+
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_USE_MARKUP]);
+}
+
static void
add_preferences_to_model (HdyPreferencesRow *row,
GListStore *model)
diff --git a/src/hdy-preferences-group.h b/src/hdy-preferences-group.h
index 2a7952cc..6f626bb3 100644
--- a/src/hdy-preferences-group.h
+++ b/src/hdy-preferences-group.h
@@ -48,4 +48,10 @@ HDY_AVAILABLE_IN_ALL
void hdy_preferences_group_set_description (HdyPreferencesGroup *self,
const gchar *description);
+HDY_AVAILABLE_IN_1_4
+gboolean hdy_preferences_group_get_use_markup (HdyPreferencesGroup *self);
+HDY_AVAILABLE_IN_1_4
+void hdy_preferences_group_set_use_markup (HdyPreferencesGroup *self,
+ gboolean use_markup);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]