[Xfce4-commits] [apps/xfce4-notifyd] 24/29: Show information about the log only showing the first 100 entries
noreply at xfce.org
noreply at xfce.org
Sun Jan 29 20:52:14 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 d043c63f724cc09279ea60707dcafa24f646d1ff
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Sat Jan 7 23:40:25 2017 +0100
Show information about the log only showing the first 100 entries
---
xfce4-notifyd-config/main.c | 133 +++++++++++++++++++++++---------------------
1 file changed, 70 insertions(+), 63 deletions(-)
diff --git a/xfce4-notifyd-config/main.c b/xfce4-notifyd-config/main.c
index bd3f26b..e705a58 100644
--- a/xfce4-notifyd-config/main.c
+++ b/xfce4-notifyd-config/main.c
@@ -475,6 +475,7 @@ xfce4_notifyd_log_populate (GtkWidget *log_listbox)
gint i;
GDateTime *today;
gchar *timestamp;
+ GtkWidget *limit;
today = g_date_time_new_now_local ();
timestamp = g_date_time_format (today, "%F");
@@ -488,76 +489,82 @@ xfce4_notifyd_log_populate (GtkWidget *log_listbox)
groups = g_key_file_get_groups (notify_log, NULL);
- /* Do this asynchronously in a separate thread */
+ /* TODO: Do this asynchronously in a separate thread */
for (i = 0; groups && groups[i]; i += 1) {
- GtkWidget *grid, *box;
- GtkWidget *summary, *body, *app_icon, *expire_timeout;
- const gchar *group = groups[i];
- const char *format = "<b>\%s</b>";
- const char *tooltip_format = "<b>\%s</b> - \%s\n\%s";
- const char *tooltip_format_simple = "<b>\%s</b> - \%s";
- char *markup;
- gchar *app_name;
- gchar *tooltip_timestamp;
- GTimeVal tv;
- GDateTime *log_timestamp;
-
- if (g_time_val_from_iso8601 (group, &tv) == TRUE) {
- if (log_timestamp = g_date_time_new_from_timeval_local (&tv)) {
- tooltip_timestamp = g_date_time_format (log_timestamp, "%c");
- g_date_time_unref(log_timestamp);
+ /* Only show the first 100 notifications from the log */
+ if (i <= 100) {
+ GtkWidget *grid, *box;
+ GtkWidget *summary, *body, *app_icon, *expire_timeout;
+ const gchar *group = groups[i];
+ const char *format = "<b>\%s</b>";
+ const char *tooltip_format = "<b>\%s</b> - \%s\n\%s";
+ const char *tooltip_format_simple = "<b>\%s</b> - \%s";
+ char *markup;
+ gchar *app_name;
+ gchar *tooltip_timestamp;
+ GTimeVal tv;
+ GDateTime *log_timestamp;
+
+ if (g_time_val_from_iso8601 (group, &tv) == TRUE) {
+ if (log_timestamp = g_date_time_new_from_timeval_local (&tv)) {
+ tooltip_timestamp = g_date_time_format (log_timestamp, "%c");
+ g_date_time_unref(log_timestamp);
+ }
}
- }
- 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;
- }
+ 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;
+ }
- app_name = g_key_file_get_string (notify_log, group, "app_name", NULL);
- 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);
- gtk_label_set_xalign (GTK_LABEL (summary), 0);
- g_free (markup);
- body = gtk_label_new (g_key_file_get_string (notify_log, group, "body", NULL));
- gtk_label_set_xalign (GTK_LABEL (body), 0);
- gtk_label_set_ellipsize (GTK_LABEL (body), PANGO_ELLIPSIZE_END);
- app_icon = gtk_image_new_from_icon_name (g_key_file_get_string (notify_log, group, "app_icon", NULL), GTK_ICON_SIZE_LARGE_TOOLBAR);
- gtk_image_set_pixel_size (GTK_IMAGE (app_icon), 24);
- gtk_widget_set_margin_start (app_icon, 3);
- expire_timeout = gtk_label_new (g_key_file_get_string (notify_log, group, "expire-timeout", NULL));
- // TODO: actions and timeout are missing (timeout is only interesting for urgent messages) - do we need that?
- grid = gtk_grid_new ();
- gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
- gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (app_icon), 0, 0 , 1, 2);
-
- /* Handle icon-only notifications */
- if (g_strcmp0 (g_key_file_get_string (notify_log, group, "body", NULL), "") == 0) {
- gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (summary), 1, 0, 1, 2);
- markup = g_strdup_printf (tooltip_format_simple, app_name, tooltip_timestamp);
- }
- else {
- gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (summary), 1, 0, 1, 1);
- gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (body), 1, 1, 1, 1);
- markup = g_strdup_printf (tooltip_format, app_name, tooltip_timestamp, g_key_file_get_string (notify_log, group, "body", NULL));
- }
+ app_name = g_key_file_get_string (notify_log, group, "app_name", NULL);
+ 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);
+ gtk_label_set_xalign (GTK_LABEL (summary), 0);
+ g_free (markup);
+ body = gtk_label_new (g_key_file_get_string (notify_log, group, "body", NULL));
+ gtk_label_set_xalign (GTK_LABEL (body), 0);
+ gtk_label_set_ellipsize (GTK_LABEL (body), PANGO_ELLIPSIZE_END);
+ app_icon = gtk_image_new_from_icon_name (g_key_file_get_string (notify_log, group, "app_icon", NULL), GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_image_set_pixel_size (GTK_IMAGE (app_icon), 24);
+ gtk_widget_set_margin_start (app_icon, 3);
+ expire_timeout = gtk_label_new (g_key_file_get_string (notify_log, group, "expire-timeout", NULL));
+ // TODO: actions and timeout are missing (timeout is only interesting for urgent messages) - do we need that?
+ grid = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
+ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (app_icon), 0, 0 , 1, 2);
+
+ /* Handle icon-only notifications */
+ if (g_strcmp0 (g_key_file_get_string (notify_log, group, "body", NULL), "") == 0) {
+ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (summary), 1, 0, 1, 2);
+ markup = g_strdup_printf (tooltip_format_simple, app_name, tooltip_timestamp);
+ }
+ else {
+ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (summary), 1, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (body), 1, 1, 1, 1);
+ markup = g_strdup_printf (tooltip_format, app_name, tooltip_timestamp, g_key_file_get_string (notify_log, group, "body", NULL));
+ }
+
+ gtk_widget_set_tooltip_markup (grid, markup);
+ g_free (markup);
- gtk_widget_set_tooltip_markup (grid, markup);
- g_free (markup);
- /* Only show the first 100 notifications from the log */
- if (i <= 100)
gtk_list_box_insert (GTK_LIST_BOX (log_listbox), grid, 0);
- else
- /* TODO: Show a warning in the UI that only the first 100 are shown */
- return;
+ }
+ }
+ if (i > 101) {
+ limit = gtk_label_new (g_strdup_printf("Showing 100 of %d notifications.", i - 1));
+ gtk_widget_set_sensitive (limit, FALSE);
+ gtk_widget_set_margin_top (limit, 3);
+ gtk_widget_set_margin_bottom (limit, 3);
+ gtk_list_box_insert (GTK_LIST_BOX (log_listbox), limit, 101);
+ g_key_file_free (notify_log);
}
- g_key_file_free (notify_log);
}
gtk_widget_show_all (log_listbox);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list