[libdazzle: 1/2] bolding: Add constructor for bolding-label



commit 99afbf90b25e3e9e9343415800f66da8093d588f
Author: Christopher Davis <brainblasted disroot org>
Date:   Wed Apr 24 18:35:16 2019 -0400

    bolding: Add constructor for bolding-label

 src/widgets/dzl-bolding-label.c | 32 ++++++++++++++++++++++++++++++++
 src/widgets/dzl-bolding-label.h | 14 ++++++++++----
 2 files changed, 42 insertions(+), 4 deletions(-)
---
diff --git a/src/widgets/dzl-bolding-label.c b/src/widgets/dzl-bolding-label.c
index ba6259b..280a4aa 100644
--- a/src/widgets/dzl-bolding-label.c
+++ b/src/widgets/dzl-bolding-label.c
@@ -53,6 +53,38 @@ enum {
 
 static GParamSpec *properties [N_PROPS];
 
+DzlBoldingLabel *
+dzl_bolding_label_new (const gchar *str,
+                       gboolean     bold)
+{
+  DzlBoldingLabel *label;
+
+  label = g_object_new (DZL_TYPE_BOLDING_LABEL,
+                        "bold", bold,
+                        NULL);
+
+  if (str && *str)
+    gtk_label_set_text (GTK_LABEL (label), str);
+
+  return label;
+}
+
+DzlBoldingLabel *
+dzl_bolding_label_new_with_mnemonic (const gchar *str,
+                                     gboolean     bold)
+{
+  DzlBoldingLabel *label;
+
+  label = g_object_new (DZL_TYPE_BOLDING_LABEL,
+                        "bold", bold,
+                        NULL);
+
+  if (str && *str)
+    gtk_label_set_text_with_mnemonic (GTK_LABEL (label), str);
+
+  return label;
+}
+
 static void
 dzl_bolding_label_get_preferred_width (GtkWidget *widget,
                                        gint      *min_width,
diff --git a/src/widgets/dzl-bolding-label.h b/src/widgets/dzl-bolding-label.h
index d0e7604..5fb9193 100644
--- a/src/widgets/dzl-bolding-label.h
+++ b/src/widgets/dzl-bolding-label.h
@@ -30,12 +30,18 @@ G_BEGIN_DECLS
 DZL_AVAILABLE_IN_ALL
 G_DECLARE_FINAL_TYPE (DzlBoldingLabel, dzl_bolding_label, DZL, BOLDING_LABEL, GtkLabel)
 
+DZL_AVAILABLE_IN_3_34
+DzlBoldingLabel *dzl_bolding_label_new               (const gchar     *str,
+                                                      gboolean         bold);
+DZL_AVAILABLE_IN_3_34
+DzlBoldingLabel *dzl_bolding_label_new_with_mnemonic (const gchar     *str,
+                                                      gboolean         bold);
 DZL_AVAILABLE_IN_ALL
-void dzl_bolding_label_set_weight (DzlBoldingLabel *self,
-                                   PangoWeight      weight);
+void             dzl_bolding_label_set_weight        (DzlBoldingLabel *self,
+                                                      PangoWeight      weight);
 DZL_AVAILABLE_IN_ALL
-void dzl_bolding_label_set_bold   (DzlBoldingLabel *self,
-                                   gboolean         bold);
+void             dzl_bolding_label_set_bold          (DzlBoldingLabel *self,
+                                                      gboolean         bold);
 
 G_END_DECLS
 


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