[gnome-control-center] list-row: Add 'bold' property



commit 08defd6ec53b5d6bff880423e28ab1c65abceae5
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Thu Dec 17 17:17:12 2020 +0530

    list-row: Add 'bold' property
    
    So that we can set if title is bold or not

 panels/common/cc-list-row.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/panels/common/cc-list-row.c b/panels/common/cc-list-row.c
index 20ee00260..a17aadd02 100644
--- a/panels/common/cc-list-row.c
+++ b/panels/common/cc-list-row.c
@@ -58,6 +58,7 @@ enum {
   PROP_ICON_NAME,
   PROP_SHOW_SWITCH,
   PROP_ACTIVE,
+  PROP_BOLD,
   PROP_USE_UNDERLINE,
   N_PROPS
 };
@@ -141,6 +142,8 @@ cc_list_row_set_property (GObject      *object,
                           GParamSpec   *pspec)
 {
   CcListRow *self = (CcListRow *)object;
+  PangoAttrList *attributes;
+  PangoAttribute *attribute;
   gint margin;
 
   switch (prop_id)
@@ -192,6 +195,24 @@ cc_list_row_set_property (GObject      *object,
                                          cc_list_row_switch_active_cb, self);
       break;
 
+    case PROP_BOLD:
+      if (g_value_get_boolean (value))
+        attribute = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+      else
+        attribute = pango_attr_weight_new (PANGO_WEIGHT_NORMAL);
+
+      attributes = gtk_label_get_attributes (self->title);
+
+      if (!attributes)
+        attributes = pango_attr_list_new ();
+      else
+        pango_attr_list_ref (attributes);
+
+      pango_attr_list_change (attributes, attribute);
+      gtk_label_set_attributes (self->title, attributes);
+      pango_attr_list_unref (attributes);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -248,6 +269,13 @@ cc_list_row_class_init (CcListRowClass *klass)
                           FALSE,
                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+  properties[PROP_BOLD] =
+    g_param_spec_boolean ("bold",
+                          "Bold",
+                          "Whether title is bold or not",
+                          FALSE,
+                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
   properties[PROP_USE_UNDERLINE] =
     g_param_spec_boolean ("use-underline",
                           "Use underline",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]