[Xfce4-commits] [apps/xfce4-notifyd] 01/01: panel-plugin: Fix always showing the placeholder for empty logs
noreply at xfce.org
noreply at xfce.org
Sat Dec 2 00:22:55 CET 2017
This is an automated email from the git hooks/post-receive script.
o c h o s i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-notifyd.
commit e2f6f5f158fd267739baeb8861373c95e08f82ff
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Sat Dec 2 00:21:34 2017 +0100
panel-plugin: Fix always showing the placeholder for empty logs
Also make sure that the text is actually centered based on the theme's
padding (instead of hardcoding Adwaita's value).
---
panel-plugin/notification-plugin-log.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/panel-plugin/notification-plugin-log.c b/panel-plugin/notification-plugin-log.c
index 098c745..a675cfb 100644
--- a/panel-plugin/notification-plugin-log.c
+++ b/panel-plugin/notification-plugin-log.c
@@ -99,6 +99,7 @@ notification_plugin_menu_populate (NotificationPlugin *notification_plugin)
gchar *notify_log_icon_path;
int log_icon_size;
gboolean state;
+ gboolean no_notifications = FALSE;
today = g_date_time_new_now_local ();
timestamp = g_date_time_format (today, "%F");
@@ -160,6 +161,12 @@ notification_plugin_menu_populate (NotificationPlugin *notification_plugin)
if (log_length < 0)
log_length = 0;
+ /* Check if the menu is going to be empty despite there being a log file, e.g.
+ when showing only the notifications of today but the log only contains entries
+ from yesterday and before. In this case show the placeholder. */
+ if (numberof_groups == 0)
+ no_notifications = TRUE;
+
/* Notifications are only shown until LOG_DISPLAY_LIMIT is hit */
for (i = numberof_groups; i >= log_length; i--) {
GtkWidget *grid;
@@ -277,17 +284,22 @@ G_GNUC_END_IGNORE_DEPRECATIONS
g_key_file_free (notify_log);
}
/* Show a placeholder label when there are no notifications */
- else {
+ if (!notify_log ||
+ no_notifications) {
+ GtkStyleContext *context;
+ GtkBorder padding;
mi = gtk_menu_item_new ();
label = gtk_label_new (_("No notifications"));
gtk_widget_set_sensitive (mi, FALSE);
gtk_container_add (GTK_CONTAINER (mi), label);
- /* Try to center the text and add top and bottom padding */
- gtk_widget_set_margin_end (label, log_icon_size + 6);
- gtk_widget_set_margin_top (label, 6);
- gtk_widget_set_margin_bottom (label, 6);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
gtk_widget_show_all (mi);
+ /* Center the text and add top and bottom padding */
+ context = gtk_widget_get_style_context (GTK_WIDGET (mi));
+ gtk_style_context_get_padding (context, gtk_widget_get_state_flags (GTK_WIDGET (mi)), &padding);
+ gtk_widget_set_margin_end (label, log_icon_size + padding.left);
+ gtk_widget_set_margin_top (label, padding.top * 2);
+ gtk_widget_set_margin_bottom (label, padding.top * 2);
}
/* footer items */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list