[Xfce4-commits] [apps/xfce4-notifyd] 01/02: panel-plugin: Add button to clear the log (Bug #13955)
noreply at xfce.org
noreply at xfce.org
Fri Oct 27 23:52:16 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 4244c8fec53f0f4f8c5ac6d12569fdfc34100a85
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Fri Oct 27 23:30:24 2017 +0200
panel-plugin: Add button to clear the log (Bug #13955)
The log file is now removed upon clearing the log as that
makes file-monitoring easier and in turn enables us to
show the correct un/read state in the panel plugin's icon.
---
panel-plugin/Makefile.am | 4 +++-
panel-plugin/notification-plugin-log.c | 35 ++++++++++------------------------
panel-plugin/notification-plugin.c | 13 ++++++++++++-
xfce4-notifyd/xfce-notify-log.c | 19 +++++++++---------
4 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index cab7d99..08b70a8 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -19,7 +19,9 @@ libnotification_plugin_la_SOURCES = \
notification-plugin-dialogs.c \
notification-plugin-dialogs.h \
notification-plugin-log.c \
- notification-plugin-log.h
+ notification-plugin-log.h \
+ ../xfce4-notifyd/xfce-notify-log.c \
+ ../xfce4-notifyd/xfce-notify-log.h
libnotification_plugin_la_CFLAGS = \
$(LIBXFCE4UTIL_CFLAGS) \
diff --git a/panel-plugin/notification-plugin-log.c b/panel-plugin/notification-plugin-log.c
index 14996a9..937b04c 100644
--- a/panel-plugin/notification-plugin-log.c
+++ b/panel-plugin/notification-plugin-log.c
@@ -35,6 +35,7 @@
#include <libxfce4panel/xfce-panel-plugin.h>
#include <glib.h>
+#include "xfce4-notifyd/xfce-notify-log.h"
#include "notification-plugin.h"
#include "notification-plugin-log.h"
@@ -59,34 +60,11 @@ notification_plugin_settings_activate_cb (GtkMenuItem *menuitem,
-GKeyFile *
-xfce_notify_log_get (void)
-{
- GKeyFile *notify_log;
- gchar *notify_log_path = NULL;
-
- notify_log_path = xfce_resource_lookup (XFCE_RESOURCE_CACHE, XFCE_NOTIFY_LOG_FILE);
-
- if (notify_log_path)
- {
- notify_log = g_key_file_new ();
- if (g_key_file_load_from_file (notify_log, notify_log_path, G_KEY_FILE_NONE, NULL) == FALSE)
- return NULL;
- }
- else
- return NULL;
- g_free (notify_log_path);
-
- return notify_log;
-}
-
-
-
static void
notification_plugin_menu_clear (GtkWidget *widget, gpointer user_data)
{
- GtkWidget *container = user_data;
- gtk_container_remove (GTK_CONTAINER (container), widget);
+ GtkWidget *container = user_data;
+ gtk_container_remove (GTK_CONTAINER (container), widget);
}
@@ -278,6 +256,13 @@ G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect (mi, "toggled",
G_CALLBACK (dnd_toggled_cb), notification_plugin);
+ /* checkmenuitem for the do not disturb mode of xfce4-notifyd */
+ mi = gtk_menu_item_new_with_mnemonic (_("_Clear log"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ gtk_widget_show (mi);
+ g_signal_connect (mi, "activate", G_CALLBACK (xfce_notify_log_clear),
+ NULL);
+
mi = gtk_menu_item_new_with_mnemonic (_("_Notification settingsā¦"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
gtk_widget_show (mi);
diff --git a/panel-plugin/notification-plugin.c b/panel-plugin/notification-plugin.c
index bb7b9ba..a91ab1b 100644
--- a/panel-plugin/notification-plugin.c
+++ b/panel-plugin/notification-plugin.c
@@ -158,7 +158,18 @@ notification_plugin_log_file_changed (GFileMonitor *monitor,
{
NotificationPlugin *notification_plugin = user_data;
- if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
+ /* If the log gets cleared, the file gets deleted so make sure not to indicate that
+ there are new notifications */
+ if (event_type == G_FILE_MONITOR_EVENT_DELETED)
+ {
+ if (xfconf_channel_get_bool (notification_plugin->channel, "/do-not-disturb", TRUE))
+ gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
+ "notification-disabled-symbolic", GTK_ICON_SIZE_MENU);
+ else
+ gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
+ "notification-symbolic", GTK_ICON_SIZE_MENU);
+ }
+ else if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
{
if (xfconf_channel_get_bool (notification_plugin->channel, "/do-not-disturb", TRUE))
gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
diff --git a/xfce4-notifyd/xfce-notify-log.c b/xfce4-notifyd/xfce-notify-log.c
index 39bb6fa..1387580 100644
--- a/xfce4-notifyd/xfce-notify-log.c
+++ b/xfce4-notifyd/xfce-notify-log.c
@@ -228,17 +228,18 @@ void xfce_notify_log_insert (const gchar *app_name,
void xfce_notify_log_clear (void)
{
- gchar *notify_log = NULL;
+ gchar *notify_log_path = NULL;
- notify_log = xfce_resource_save_location (XFCE_RESOURCE_CACHE,
- XFCE_NOTIFY_LOG_FILE, FALSE);
+ notify_log_path = xfce_resource_save_location (XFCE_RESOURCE_CACHE,
+ XFCE_NOTIFY_LOG_FILE, FALSE);
- if (notify_log)
+ if (notify_log_path)
{
- FILE *f;
- f = fopen (notify_log, "w");
- if (f)
- fclose (f);
- g_free (notify_log);
+ GFile *log_file;
+ log_file = g_file_new_for_path (notify_log_path);
+ if (!g_file_delete (log_file, NULL, NULL))
+ g_warning ("Could not delete the notification log file: %s", notify_log_path);
+ g_object_unref (log_file);
+ g_free (notify_log_path);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list