[Xfce4-commits] [apps/xfce4-notifyd] 05/29: Improve logging and add a yesterday and before header to the UI

noreply at xfce.org noreply at xfce.org
Sun Jan 29 20:51:55 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 818df54d892bf29527b88831481abc7a066b82d1
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Sat Oct 22 02:58:19 2016 +0200

    Improve logging and add a yesterday and before header to the UI
---
 xfce4-notifyd-config/main.c                     | 66 ++++++++++++++++++++-----
 xfce4-notifyd-config/xfce4-notifyd-config.glade | 14 ++++++
 xfce4-notifyd/xfce-notify-daemon.c              |  1 +
 xfce4-notifyd/xfce-notify-log.c                 |  3 +-
 4 files changed, 70 insertions(+), 14 deletions(-)

diff --git a/xfce4-notifyd-config/main.c b/xfce4-notifyd-config/main.c
index 4ab7562..e092d22 100644
--- a/xfce4-notifyd-config/main.c
+++ b/xfce4-notifyd-config/main.c
@@ -310,8 +310,6 @@ xfce4_notifyd_mute_application (GtkListBox *known_applications_listbox,
         g_warning ("Could not add %s to the list of muted applications.", new_app_name);
 
     xfconf_array_free (muted_applications);
-    /* FIXME: why does this cause a segfault? */
-    //g_free (new_app_name);
 }
 
 static void
@@ -449,12 +447,19 @@ xfce4_notifyd_log_populate (GtkWidget *log_listbox)
     GKeyFile *notify_log;
     GtkCallback func = listbox_remove_all;
     gint i;
+    GDateTime *today;
+    gchar *timestamp;
+
+    today = g_date_time_new_now_local ();
+    timestamp = g_date_time_format (today, "%F");
 
     gtk_container_foreach (GTK_CONTAINER (log_listbox), func, log_listbox);
     notify_log = xfce_notify_log_get();
 
     if (notify_log) {
         gchar **groups;
+        gboolean yesterday = FALSE;
+
         groups = g_key_file_get_groups (notify_log, NULL);
 
         /* Do this asynchronously in a separate thread */
@@ -466,6 +471,16 @@ xfce4_notifyd_log_populate (GtkWidget *log_listbox)
             const char *tooltip_format = "<b>\%s</b>: \%s";
             char *markup;
 
+            if (g_str_match_string(timestamp, group, FALSE) == TRUE && yesterday == FALSE) {
+                GtkWidget *header;
+                header = gtk_label_new ("Yesterday and before");
+                gtk_widget_set_sensitive (header, FALSE);
+                gtk_widget_set_margin_top (header, 3);
+                gtk_widget_set_margin_bottom (header, 3);
+                gtk_list_box_insert (GTK_LIST_BOX (log_listbox), header, 0);
+                yesterday = TRUE;
+            }
+
             markup = g_markup_printf_escaped (format, g_key_file_get_string (notify_log, group, "summary", NULL));
             summary = gtk_label_new (NULL);
             gtk_label_set_markup (GTK_LABEL (summary), markup);
@@ -494,7 +509,11 @@ xfce4_notifyd_log_populate (GtkWidget *log_listbox)
                 gtk_widget_set_tooltip_markup (grid, markup);
                 g_free (markup);
             }
-            gtk_list_box_insert (GTK_LIST_BOX (log_listbox), grid, -1);
+            /* Only show the first 100 notifications from the log */
+            if (i <= 100)
+                gtk_list_box_insert (GTK_LIST_BOX (log_listbox), grid, 0);
+            else
+                return;
         }
         g_key_file_free (notify_log);
     }
@@ -502,6 +521,12 @@ xfce4_notifyd_log_populate (GtkWidget *log_listbox)
     gtk_widget_show_all (log_listbox);
 }
 
+static void
+xfce4_notifyd_log_refresh (GtkButton *button, gpointer user_data) {
+    GtkWidget *log_listbox = user_data;
+    xfce4_notifyd_log_populate (log_listbox);
+}
+
 static void xfce_notify_clear_log_button_clicked (GtkButton *button, gpointer user_data) {
     GtkWidget *log_listbox = user_data;
     GtkCallback func = listbox_remove_all;
@@ -517,6 +542,21 @@ static void xfce4_notifyd_show_help(GtkButton *button,
     xfce_dialog_show_help_with_version(GTK_WINDOW(dialog), "notifyd", "start", NULL, NULL);
 }
 
+GtkWidget *
+placeholder_label_new (gchar *place_holder_text)
+{
+    GtkWidget *label;
+    label = gtk_label_new ("");
+    gtk_label_set_markup (GTK_LABEL (label), place_holder_text);
+    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
+    gtk_widget_set_sensitive (label, FALSE);
+    gtk_widget_set_margin_start (label, 24);
+    gtk_widget_set_margin_end (label, 24);
+    gtk_widget_set_margin_top (label, 24);
+    gtk_widget_set_margin_bottom (label, 24);
+    return label;
+}
+
 static GtkWidget *
 xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
 {
@@ -539,6 +579,7 @@ xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
     GtkWidget *log_scrolled_window;
     GtkWidget *log_listbox;
     GtkWidget *clear_log_button;
+    GtkWidget *refresh_log_button;
     GtkAdjustment *adj;
     GError *error = NULL;
     gchar *current_theme;
@@ -614,15 +655,9 @@ xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
     gtk_container_add (GTK_CONTAINER (known_applications_scrolled_window), known_applications_listbox);
     gtk_list_box_set_header_func (GTK_LIST_BOX (known_applications_listbox), display_header_func, NULL, NULL);
 
-    placeholder_label = gtk_label_new ("");
-    gtk_label_set_markup (GTK_LABEL (placeholder_label),"<b>Currently there are no known applications.</b>\nAs soon as an application sends a notification\nit will appear in this list.");
-    gtk_label_set_justify (GTK_LABEL (placeholder_label), GTK_JUSTIFY_CENTER);
-    gtk_widget_set_sensitive (placeholder_label, FALSE);
-    gtk_widget_set_margin_start (placeholder_label, 24);
-    gtk_widget_set_margin_end (placeholder_label, 24);
-    gtk_widget_set_margin_top (placeholder_label, 24);
-    gtk_widget_set_margin_bottom (placeholder_label, 24);
-
+    placeholder_label = placeholder_label_new ("<big><b>Currently there are no known applications.</b></big>"
+                                                "\nAs soon as an application sends a notification"
+                                                "\nit will appear in this list.");
     /* Initialize the list of known applications */
     xfce4_notifyd_known_applications_changed (channel, KNOWN_APPLICATIONS_PROP, NULL, known_applications_listbox);
     gtk_list_box_set_placeholder (GTK_LIST_BOX (known_applications_listbox), placeholder_label);
@@ -645,11 +680,18 @@ xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
     log_listbox = gtk_list_box_new ();
     gtk_container_add (GTK_CONTAINER (log_scrolled_window), log_listbox);
     gtk_list_box_set_header_func (GTK_LIST_BOX (log_listbox), display_header_func, NULL, NULL);
+    placeholder_label = placeholder_label_new ("<big><b>Empty log</b></big>"
+                                               "\nSo far no notifications have been logged.");
+    gtk_list_box_set_placeholder (GTK_LIST_BOX (log_listbox), placeholder_label);
+    gtk_widget_show_all (placeholder_label);
     xfce4_notifyd_log_populate (log_listbox);
 
     clear_log_button = GTK_WIDGET (gtk_builder_get_object (builder, "clear_log_button"));
     g_signal_connect (G_OBJECT (clear_log_button), "clicked",
                       G_CALLBACK (xfce_notify_clear_log_button_clicked), log_listbox);
+    refresh_log_button = GTK_WIDGET (gtk_builder_get_object (builder, "refresh_log_button"));
+    g_signal_connect (G_OBJECT (refresh_log_button), "clicked",
+                      G_CALLBACK (xfce4_notifyd_log_refresh), log_listbox);
 
     help_button = GTK_WIDGET(gtk_builder_get_object(builder, "help_btn"));
     g_signal_connect(G_OBJECT(help_button), "clicked",
diff --git a/xfce4-notifyd-config/xfce4-notifyd-config.glade b/xfce4-notifyd-config/xfce4-notifyd-config.glade
index 982173c..629040a 100644
--- a/xfce4-notifyd-config/xfce4-notifyd-config.glade
+++ b/xfce4-notifyd-config/xfce4-notifyd-config.glade
@@ -560,6 +560,7 @@ except for messages marked as urgent.</property>
                     <property name="margin_top">12</property>
                     <property name="margin_bottom">12</property>
                     <property name="row_spacing">6</property>
+                    <property name="column_spacing">12</property>
                     <child>
                       <object class="GtkScrolledWindow" id="log_scrolled_window">
                         <property name="visible">True</property>
@@ -574,6 +575,7 @@ except for messages marked as urgent.</property>
                       <packing>
                         <property name="left_attach">0</property>
                         <property name="top_attach">0</property>
+                        <property name="width">2</property>
                       </packing>
                     </child>
                     <child>
@@ -585,6 +587,18 @@ except for messages marked as urgent.</property>
                         <property name="image">image2</property>
                       </object>
                       <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="refresh_log_button">
+                        <property name="label" translatable="yes">Refresh</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                      </object>
+                      <packing>
                         <property name="left_attach">0</property>
                         <property name="top_attach">1</property>
                       </packing>
diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c
index a77d31a..b0e4de9 100644
--- a/xfce4-notifyd/xfce-notify-daemon.c
+++ b/xfce4-notifyd/xfce-notify-daemon.c
@@ -1220,6 +1220,7 @@ notify_notify (XfceNotifyGBus *skeleton,
 
             xndaemon->close_timeout = 0;
 
+
             if (xndaemon->notification_log == TRUE)
                 xfce_notify_log_insert (summary, body, app_icon, expire_timeout, actions);
 
diff --git a/xfce4-notifyd/xfce-notify-log.c b/xfce4-notifyd/xfce-notify-log.c
index f51a616..2ef3eac 100644
--- a/xfce4-notifyd/xfce-notify-log.c
+++ b/xfce4-notifyd/xfce-notify-log.c
@@ -71,7 +71,6 @@ void xfce_notify_log_insert (const gchar *summary,
     gint j = 0;
     GDateTime *now;
     gchar *timestamp;
-    int current_time;
 
     notify_log_path = xfce_resource_save_location (XFCE_RESOURCE_CACHE,
                                                    XFCE_NOTIFY_LOG_FILE, TRUE);
@@ -85,7 +84,7 @@ void xfce_notify_log_insert (const gchar *summary,
         }
 
         now = g_date_time_new_now_local ();
-        timestamp = g_date_time_format (now, "%F-%T");
+        timestamp = g_date_time_format (now, "%FT%T");
         group = g_strdup_printf ("%s", timestamp);
 
         g_key_file_set_value (notify_log, group, "summary", summary);

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


More information about the Xfce4-commits mailing list