[Xfce4-commits] [apps/xfce4-notifyd] 10/24: panel-plugin: Update icon if there are unread notifications

noreply at xfce.org noreply at xfce.org
Fri Sep 8 23:27:41 CEST 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 c2a2c63fc055095cc396e8fb0b87618fb7914acf
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Wed Aug 23 01:02:51 2017 +0200

    panel-plugin: Update icon if there are unread notifications
---
 panel-plugin/notification-plugin-log.c |  4 ++++
 panel-plugin/notification-plugin.c     | 31 +++++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/notification-plugin-log.c b/panel-plugin/notification-plugin-log.c
index 19cfea3..1ab1220 100644
--- a/panel-plugin/notification-plugin-log.c
+++ b/panel-plugin/notification-plugin-log.c
@@ -90,6 +90,10 @@ notification_plugin_menu_populate (NotificationPlugin *notification_plugin)
   /* Clean up the list and re-fill it */
   gtk_container_foreach (GTK_CONTAINER (menu), func, menu);
 
+  /* Reset the notitication status icon since all items are now read */
+  gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
+                                "notification-symbolic", GTK_ICON_SIZE_MENU);
+
   notify_log = xfce_notify_log_get();
 
   if (notify_log) {
diff --git a/panel-plugin/notification-plugin.c b/panel-plugin/notification-plugin.c
index 25d3fd7..5d43f3f 100644
--- a/panel-plugin/notification-plugin.c
+++ b/panel-plugin/notification-plugin.c
@@ -202,11 +202,31 @@ cb_menu_deactivate (GtkMenuShell *menu,
 
 
 
+static void
+notification_plugin_log_file_changed (GFileMonitor     *monitor,
+                                       GFile            *file,
+                                       GFile            *other_file,
+                                       GFileMonitorEvent event_type,
+                                       gpointer          user_data)
+{
+  NotificationPlugin    *notification_plugin = user_data;
+
+  if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
+  {
+    gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
+                                  "notification-new-symbolic", GTK_ICON_SIZE_MENU);
+  }
+}
+
+
+
 static NotificationPlugin *
 notification_plugin_new (XfcePanelPlugin *panel_plugin)
 {
-  NotificationPlugin   *notification_plugin;
-  GError *error = NULL;
+  NotificationPlugin    *notification_plugin;
+  GFile                 *log_file;
+  GFileMonitor          *log_file_monitor;
+  gchar                 *notify_log_path = NULL;
 
   /* allocate memory for the plugin structure */
   notification_plugin = panel_slice_new0 (NotificationPlugin);
@@ -238,6 +258,13 @@ notification_plugin_new (XfcePanelPlugin *panel_plugin)
   g_signal_connect (notification_plugin->menu, "deactivate",
                     G_CALLBACK (cb_menu_deactivate), notification_plugin);
 
+  /* start monitoring the log file for changes */
+  notify_log_path = xfce_resource_lookup (XFCE_RESOURCE_CACHE, XFCE_NOTIFY_LOG_FILE);
+  log_file = g_file_new_for_path (notify_log_path);
+  log_file_monitor = g_file_monitor_file (log_file, G_FILE_MONITOR_NONE, NULL, NULL);
+  g_signal_connect (log_file_monitor, "changed",
+                    G_CALLBACK (notification_plugin_log_file_changed), notification_plugin);
+
   return notification_plugin;
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list