[gnome-logs] info_bar: Set label in the UI file
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs] info_bar: Set label in the UI file
- Date: Mon, 28 Mar 2022 16:43:59 +0000 (UTC)
commit 01bf4423f6dee07f9a7efcd8ba42410e78ccc7f2
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Mon Oct 11 00:28:12 2021 +0200
info_bar: Set label in the UI file
Removes the need to use container api.
data/gl-window.ui | 10 ++++++++--
src/gl-window.c | 37 +++++--------------------------------
2 files changed, 13 insertions(+), 34 deletions(-)
---
diff --git a/data/gl-window.ui b/data/gl-window.ui
index 5e40309..dd3e3fa 100644
--- a/data/gl-window.ui
+++ b/data/gl-window.ui
@@ -16,12 +16,18 @@
<child>
<object class="GtkInfoBar" id="info_bar">
<property name="message-type">GTK_MESSAGE_ERROR</property>
+ <property name="visible">False</property>
<child>
<object class="GtkBox" id="action_area">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
- <!-- TODO -->
- <!-- <property name="layout_style">center</property> -->
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="message_label">
+ <property name="hexpand">True</property>
+ <property name="halign">start</property>
+ </object>
+ </child>
<child>
<object class="GtkButton" id="help_button">
<property name="visible">True</property>
diff --git a/src/gl-window.c b/src/gl-window.c
index 4d47eb7..8bbbbd4 100644
--- a/src/gl-window.c
+++ b/src/gl-window.c
@@ -37,6 +37,7 @@ typedef struct
GtkWidget *event_toolbar;
GtkWidget *event_list;
GtkWidget *info_bar;
+ GtkLabel *message_label;
} GlWindowPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GlWindow, gl_window, ADW_TYPE_APPLICATION_WINDOW)
@@ -485,28 +486,14 @@ gl_window_init (GlWindow *window)
{
if (!gl_util_can_read_system_journal (GL_JOURNAL_STORAGE_PERSISTENT))
{
- GtkWidget *message_label;
- GtkWidget *content_area;
-
- message_label = gtk_label_new (_("Unable to read system logs"));
- gtk_widget_set_hexpand (GTK_WIDGET (message_label), TRUE);
- gtk_widget_show (message_label);
- content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (priv->info_bar));
- gtk_container_add (GTK_CONTAINER (content_area), message_label);
+ gtk_label_set_label (priv->message_label, _("Unable to read system logs"));
gtk_widget_show (priv->info_bar);
}
if (!gl_util_can_read_user_journal ())
{
- GtkWidget *message_label;
- GtkWidget *content_area;
-
- message_label = gtk_label_new (_("Unable to read user logs"));
- gtk_widget_set_hexpand (GTK_WIDGET (message_label), TRUE);
- gtk_widget_show (message_label);
- content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (priv->info_bar));
- gtk_container_add (GTK_CONTAINER (content_area), message_label);
+ gtk_label_set_label (priv->message_label, _("Unable to read user logs"));
gtk_widget_show (priv->info_bar);
}
@@ -516,14 +503,7 @@ gl_window_init (GlWindow *window)
{
if (!gl_util_can_read_system_journal (GL_JOURNAL_STORAGE_VOLATILE))
{
- GtkWidget *message_label;
- GtkWidget *content_area;
-
- message_label = gtk_label_new (_("Unable to read system logs"));
- gtk_widget_set_hexpand (GTK_WIDGET (message_label), TRUE);
- gtk_widget_show (message_label);
- content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (priv->info_bar));
- gtk_container_add (GTK_CONTAINER (content_area), message_label);
+ gtk_label_set_label (priv->message_label, _("Unable to read system logs"));
gtk_widget_show (priv->info_bar);
}
@@ -531,14 +511,7 @@ gl_window_init (GlWindow *window)
}
case GL_JOURNAL_STORAGE_NONE:
{
- GtkWidget *message_label;
- GtkWidget *content_area;
-
- message_label = gtk_label_new (_("No logs available"));
- gtk_widget_set_hexpand (GTK_WIDGET (message_label), TRUE);
- gtk_widget_show (message_label);
- content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (priv->info_bar));
- gtk_container_add (GTK_CONTAINER (content_area), message_label);
+ gtk_label_set_label (priv->message_label, _("No logs available"));
gtk_widget_show (priv->info_bar);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]