[libhandy] status-page: Hide title/description when they're empty or NULL
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] status-page: Hide title/description when they're empty or NULL
- Date: Fri, 18 Dec 2020 13:31:44 +0000 (UTC)
commit 3a954283cc81093d0a32ff1537839f424beefd0f
Author: Yetizone <andreii lisita gmail com>
Date: Fri Dec 18 13:07:41 2020 +0200
status-page: Hide title/description when they're empty or NULL
Fixes https://gitlab.gnome.org/GNOME/libhandy/-/issues/387
src/hdy-status-page.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
---
diff --git a/src/hdy-status-page.c b/src/hdy-status-page.c
index a5b0e644..e8734550 100644
--- a/src/hdy-status-page.c
+++ b/src/hdy-status-page.c
@@ -50,6 +50,22 @@ struct _HdyStatusPage
G_DEFINE_TYPE (HdyStatusPage, hdy_status_page, GTK_TYPE_BIN)
+static void
+update_title_visibility (HdyStatusPage *self)
+{
+ gtk_widget_set_visible (GTK_WIDGET (self->title_label),
+ gtk_label_get_text (self->title_label) != NULL &&
+ g_strcmp0 (gtk_label_get_text (self->title_label), "") != 0);
+}
+
+static void
+update_description_visibility (HdyStatusPage *self)
+{
+ gtk_widget_set_visible (GTK_WIDGET (self->description_label),
+ gtk_label_get_text (self->description_label) != NULL &&
+ g_strcmp0 (gtk_label_get_text (self->description_label), "") != 0);
+}
+
static void
hdy_status_page_get_property (GObject *object,
guint prop_id,
@@ -252,6 +268,9 @@ static void
hdy_status_page_init (HdyStatusPage *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
+
+ update_title_visibility (self);
+ update_description_visibility (self);
}
/**
@@ -351,6 +370,7 @@ hdy_status_page_set_title (HdyStatusPage *self,
return;
gtk_label_set_label (self->title_label, title);
+ update_title_visibility (self);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_TITLE]);
}
@@ -392,6 +412,7 @@ hdy_status_page_set_description (HdyStatusPage *self,
return;
gtk_label_set_label (self->description_label, description);
+ update_description_visibility (self);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_DESCRIPTION]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]