[Xfce4-commits] [apps/xfce4-notifyd] 09/29: Implement options for logging
noreply at xfce.org
noreply at xfce.org
Sun Jan 29 20:51:59 CET 2017
This is an automated email from the git hooks/post-receive script.
ochosi pushed a commit to branch master
in repository apps/xfce4-notifyd.
commit a49d0869d7a9221a96f8c4e70cdf5231d400d394
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Tue Jan 3 17:10:10 2017 +0100
Implement options for logging
---
xfce4-notifyd-config/main.c | 54 +++++++-
xfce4-notifyd-config/xfce4-notifyd-config.glade | 167 +++++++++++++++++++-----
xfce4-notifyd/xfce-notify-daemon.c | 40 +++++-
3 files changed, 216 insertions(+), 45 deletions(-)
diff --git a/xfce4-notifyd-config/main.c b/xfce4-notifyd-config/main.c
index 275e6dc..23d79c0 100644
--- a/xfce4-notifyd-config/main.c
+++ b/xfce4-notifyd-config/main.c
@@ -42,6 +42,16 @@
#define KNOWN_APPLICATIONS_PROP "/applications/known_applications"
#define MUTED_APPLICATIONS_PROP "/applications/muted_applications"
+typedef struct
+{
+ GtkWidget *log_tab;
+ GtkWidget *log_level;
+ GtkWidget *log_level_label;
+ GtkWidget *log_level_apps;
+ GtkWidget *log_level_apps_label;
+ GtkWidget *infobar_label;
+} NotificationLogWidgets;
+
static void
xfce_notifyd_config_show_notification_callback(NotifyNotification *notification,
const char *action,
@@ -432,13 +442,24 @@ xfce4_notifyd_log_activated (GtkSwitch *log_switch,
gboolean state,
gpointer user_data)
{
- GtkWidget *log_tab = user_data;
+ NotificationLogWidgets *log_widgets = user_data;
+ const char *format = "<b>Currently only urgent notifications are shown.</b>\nNotification logging is \%s.";
+ char *markup;
+
+ markup = g_markup_printf_escaped (format, state ? "enabled" : "disabled");
if (state == TRUE)
- gtk_widget_show (log_tab);
+ gtk_widget_show (log_widgets->log_tab);
else
- gtk_widget_hide (log_tab);
- gtk_switch_set_active (GTK_SWITCH (log_switch), state);
+ gtk_widget_hide (log_widgets->log_tab);
+
+ gtk_switch_set_state (GTK_SWITCH (log_switch), state);
+ gtk_widget_set_sensitive (GTK_WIDGET (log_widgets->log_level), state);
+ gtk_widget_set_sensitive (GTK_WIDGET (log_widgets->log_level_label), state);
+ gtk_widget_set_sensitive (GTK_WIDGET (log_widgets->log_level_apps), state);
+ gtk_widget_set_sensitive (GTK_WIDGET (log_widgets->log_level_apps_label), state);
+ gtk_label_set_markup (GTK_LABEL (log_widgets->infobar_label), markup);
+ g_free (markup);
}
static void
@@ -600,6 +621,7 @@ xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
GError *error = NULL;
gchar *current_theme;
GKeyFile *notification_log;
+ NotificationLogWidgets log_widgets;
gtk_builder_connect_signals(builder, NULL);
@@ -684,14 +706,32 @@ xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
g_signal_connect (G_OBJECT (channel),
"property-changed::" KNOWN_APPLICATIONS_PROP,
G_CALLBACK (xfce4_notifyd_known_applications_changed), known_applications_listbox);
-
+// TODO: Properly initialize fadeout switch
+ /* Notification log settings */
notify_notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notify_notebook"));
- log_tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notify_notebook), -1);
+ log_widgets.log_tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notify_notebook), -1);
+ log_widgets.log_level = GTK_WIDGET (gtk_builder_get_object (builder, "log_level"));
+ log_widgets.log_level_label = GTK_WIDGET (gtk_builder_get_object (builder, "log_level_label"));
+ log_widgets.log_level_apps = GTK_WIDGET (gtk_builder_get_object (builder, "log_level_apps"));
+ log_widgets.log_level_apps_label = GTK_WIDGET (gtk_builder_get_object (builder, "log_level_apps_label"));
+ log_widgets.infobar_label = GTK_WIDGET (gtk_builder_get_object (builder, "infobar_label"));
log_switch = GTK_WIDGET (gtk_builder_get_object (builder, "log_switch"));
xfconf_g_property_bind (channel, "/notification-log", G_TYPE_BOOLEAN,
G_OBJECT (log_switch), "active");
g_signal_connect (G_OBJECT (log_switch), "state-set",
- G_CALLBACK (xfce4_notifyd_log_activated), log_tab);
+ G_CALLBACK (xfce4_notifyd_log_activated), &log_widgets);
+ xfconf_g_property_bind(channel, "/log-level", G_TYPE_UINT,
+ G_OBJECT(log_widgets.log_level), "active");
+ xfconf_g_property_bind(channel, "/log-level-apps", G_TYPE_UINT,
+ G_OBJECT(log_widgets.log_level_apps), "active");
+
+ /* Initialize the settings' states correctly */
+ if(gtk_combo_box_get_active(GTK_COMBO_BOX(log_widgets.log_level)) == -1)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(log_widgets.log_level), 0);
+ if(gtk_combo_box_get_active(GTK_COMBO_BOX(log_widgets.log_level_apps)) == -1)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(log_widgets.log_level_apps), 0);
+ xfce4_notifyd_log_activated (GTK_SWITCH (log_switch), gtk_switch_get_active (GTK_SWITCH(log_switch)), &log_widgets);
+
log_scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "log_scrolled_window"));
log_listbox = gtk_list_box_new ();
gtk_container_add (GTK_CONTAINER (log_scrolled_window), log_listbox);
diff --git a/xfce4-notifyd-config/xfce4-notifyd-config.glade b/xfce4-notifyd-config/xfce4-notifyd-config.glade
index 629040a..5b3f7a8 100644
--- a/xfce4-notifyd-config/xfce4-notifyd-config.glade
+++ b/xfce4-notifyd-config/xfce4-notifyd-config.glade
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<requires lib="libxfce4ui-2" version="4.12"/>
@@ -22,6 +22,40 @@
<property name="can_focus">False</property>
<property name="stock">gtk-clear</property>
</object>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name gchararray -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">never</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">during "Do not disturb"</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">always</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkListStore" id="liststore2">
+ <columns>
+ <!-- column-name gchararray -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">all</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">all except muted</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">only muted</col>
+ </row>
+ </data>
+ </object>
<object class="GtkListStore" id="model1">
<columns>
<!-- column-name gchararray -->
@@ -121,30 +155,6 @@
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
- <object class="GtkSwitch" id="primary_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="primary_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">By default the notification bubbles will be shown on the display on which the mouse pointer is located.</property>
- <property name="label" translatable="yes">Always show notifications on primary display</property>
- <property name="ellipsize">end</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="do_not_disturb_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -161,6 +171,7 @@
<object class="GtkSwitch" id="do_not_disturb">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="halign">end</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -171,7 +182,6 @@
<object class="GtkRevealer" id="do_not_disturb_info">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="transition_type">none</property>
<property name="reveal_child">True</property>
<child>
<object class="GtkInfoBar" id="infobar1">
@@ -216,11 +226,10 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label10">
+ <object class="GtkLabel" id="infobar_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes"><b>Currently no notifications are shown</b>
-except for messages marked as urgent.</property>
+ <property name="label" translatable="yes"><b>Currently only urgent notifications are shown.</b></property>
<property name="use_markup">True</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
@@ -261,24 +270,115 @@ except for messages marked as urgent.</property>
<object class="GtkLabel" id="log_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Enable notification log</property>
+ <property name="margin_top">1</property>
+ <property name="label" translatable="yes"><b>Notification log</b></property>
+ <property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="log_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="halign">end</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="primary_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">By default the notification bubbles will be shown on the display on which the mouse pointer is located.</property>
+ <property name="label" translatable="yes">Always show notifications on primary display</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="primary_switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">end</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="log_level_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="label" translatable="yes">Log notifications</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="log_level_apps_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="label" translatable="yes">Log applications</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="log_level">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">liststore1</property>
+ <property name="popup_fixed_width">False</property>
+ <property name="active_id">1</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer2"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="log_level_apps">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">liststore2</property>
+ <property name="active_id">0</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer4"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">5</property>
+ </packing>
+ </child>
</object>
</child>
<child type="tab">
@@ -346,10 +446,11 @@ except for messages marked as urgent.</property>
</child>
<child>
<object class="GtkComboBox" id="theme_combo">
+ <property name="name">theme</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkCellRendererText" id="renderer2"/>
+ <object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
@@ -379,7 +480,7 @@ except for messages marked as urgent.</property>
<property name="can_focus">False</property>
<property name="model">model1</property>
<child>
- <object class="GtkCellRendererText" id="renderer1"/>
+ <object class="GtkCellRendererText" id="renderer3"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c
index d571c79..982b33c 100644
--- a/xfce4-notifyd/xfce-notify-daemon.c
+++ b/xfce4-notifyd/xfce-notify-daemon.c
@@ -64,6 +64,8 @@ struct _XfceNotifyDaemon
gboolean primary_monitor;
gboolean do_not_disturb;
gboolean notification_log;
+ gint log_level;
+ gint log_level_apps;
GtkCssProvider *css_provider;
gboolean is_default_theme;
@@ -1142,6 +1144,7 @@ notify_notify (XfceNotifyGBus *skeleton,
GVariant *item;
GVariantIter iter;
guint OUT_id;
+ gboolean application_is_muted = FALSE;
g_variant_iter_init (&iter, hints);
@@ -1208,13 +1211,14 @@ notify_notify (XfceNotifyGBus *skeleton,
if(expire_timeout == -1)
expire_timeout = xndaemon->expire_timeout;
+ application_is_muted = notify_application_is_muted (xndaemon->settings, new_app_name);
/* Don't show notification bubbles in the "Do not disturb" mode or if the
application has been muted by the user. Exceptions are "urgent"
notifications which do not expire. */
if (expire_timeout != 0)
{
if (xndaemon->do_not_disturb == TRUE ||
- notify_application_is_muted (xndaemon->settings, new_app_name) == TRUE)
+ application_is_muted == TRUE)
{
/* Reset the close timeout since we're processing a new notification,
even if we're not showing a notification bubble */
@@ -1223,9 +1227,18 @@ notify_notify (XfceNotifyGBus *skeleton,
xndaemon->close_timeout = 0;
- /* Notifications marked as transient won't be logged */
- if (xndaemon->notification_log == TRUE && transient == FALSE)
- xfce_notify_log_insert (new_app_name, summary, body, app_icon, expire_timeout, actions);
+ /* Notifications marked as transient will never be logged */
+ if (xndaemon->notification_log == TRUE &&
+ transient == FALSE) {
+ /* Either log in DND mode or always for muted apps */
+ if (xndaemon->log_level == 1 && xndaemon->do_not_disturb == TRUE ||
+ xndaemon->log_level == 2)
+ /* Log either all, all except muted or only muted applications */
+ if (xndaemon->log_level_apps == 0 ||
+ xndaemon->log_level_apps == 1 && application_is_muted == FALSE ||
+ xndaemon->log_level_apps == 2 && application_is_muted == TRUE)
+ xfce_notify_log_insert (new_app_name, summary, body, app_icon, expire_timeout, actions);
+ }
xfce_notify_gbus_complete_notify(skeleton, invocation, OUT_id);
return TRUE;
@@ -1323,7 +1336,10 @@ notify_notify (XfceNotifyGBus *skeleton,
// for a complete notification we need:
// app_name, summary, body, app_icon, expire_timeout, actions
// TODO: icons need to be handled, app_icon is bad - what shall be done with image_data??
- if (xndaemon->notification_log == TRUE && transient == FALSE)
+ if (xndaemon->notification_log == TRUE &&
+ xndaemon->log_level == 2 &&
+ xndaemon->log_level_apps <= 1 &&
+ transient == FALSE)
xfce_notify_log_insert (new_app_name, summary, body, app_icon, expire_timeout, actions);
xfce_notify_window_set_icon_only(window, x_canonical);
@@ -1551,6 +1567,14 @@ xfce_notify_daemon_settings_changed(XfconfChannel *channel,
xndaemon->notification_log = G_VALUE_TYPE(value)
? g_value_get_boolean(value)
: FALSE;
+ } else if(!strcmp(property, "/log-level")) {
+ xndaemon->log_level = G_VALUE_TYPE(value)
+ ? g_value_get_uint(value)
+ : 0;
+ } else if(!strcmp(property, "/log-level-apps")) {
+ xndaemon->log_level_apps = G_VALUE_TYPE(value)
+ ? g_value_get_uint(value)
+ : 0;
}
}
@@ -1595,6 +1619,12 @@ xfce_notify_daemon_load_config (XfceNotifyDaemon *xndaemon,
xndaemon->notification_log = xfconf_channel_get_bool(xndaemon->settings,
"/notification-log",
FALSE);
+ xndaemon->log_level = xfconf_channel_get_uint(xndaemon->settings,
+ "/log-level",
+ FALSE);
+ xndaemon->log_level_apps = xfconf_channel_get_uint(xndaemon->settings,
+ "/log-level-apps",
+ FALSE);
/* Clean up old notifications from the backlog */
xfconf_channel_reset_property (xndaemon->settings, "/backlog", TRUE);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list