[Xfce4-commits] [xfce/xfce4-panel] 01/01: clock: Fix invalid datetime formats appearing in list (Bug #11527)

noreply at xfce.org noreply at xfce.org
Wed Nov 15 23:50:21 CET 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 xfce/xfce4-panel.

commit e43248058e67e1cf2725788c894616dc431458cd
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Wed Nov 15 23:50:10 2017 +0100

    clock: Fix invalid datetime formats appearing in list (Bug #11527)
    
    Unfortunately some format specifiers don't seem to work in specific locales,
    as it was reported with Germand and %r. Now we simply don't show these formats
    in the default list of selections anymore, but they can still be set through
    custom formats (thus producing an empty clock widget). We would have to add
    a validator function for the gtkentry to completely fix this problem.
---
 plugins/clock/clock-time.c |  7 ++++++-
 plugins/clock/clock.c      | 30 +++++++++++++++++++-----------
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/plugins/clock/clock-time.c b/plugins/clock/clock-time.c
index 8d2d208..cfb5920 100644
--- a/plugins/clock/clock-time.c
+++ b/plugins/clock/clock-time.c
@@ -223,7 +223,12 @@ clock_time_strdup_strftime (ClockTime       *time,
 
   g_date_time_unref (date_time);
 
-  return str;
+  /* Explicitely return NULL if a format specifier fails */
+  if (!str ||
+      g_strcmp0 (str, "") == 0)
+    return NULL;
+  else
+    return str;
 }
 
 
diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c
index e982fdf..7fc8537 100644
--- a/plugins/clock/clock.c
+++ b/plugins/clock/clock.c
@@ -799,19 +799,27 @@ clock_plugin_configure_plugin_chooser_fill (ClockPlugin *plugin,
   for (i = 0; formats[i] != NULL; i++)
     {
       preview = clock_time_strdup_strftime (plugin->time, _(formats[i]));
-      gtk_list_store_insert_with_values (store, &iter, i,
-                                         COLUMN_FORMAT, _(formats[i]),
-                                         COLUMN_TEXT, preview, -1);
-      g_free (preview);
-
-      if (has_active == FALSE
-          && !panel_str_is_empty (active_format)
-          && strcmp (active_format, formats[i]) == 0)
+      if (preview)
         {
-          gtk_combo_box_set_active_iter (combo, &iter);
-          gtk_widget_hide (GTK_WIDGET (entry));
-          has_active = TRUE;
+          gtk_list_store_insert_with_values (store, &iter, i,
+            COLUMN_FORMAT, _(formats[i]),
+            COLUMN_TEXT, preview, -1);
+
+          g_free (preview);
+
+          if (has_active == FALSE
+            && !panel_str_is_empty (active_format)
+            && strcmp (active_format, formats[i]) == 0)
+            {
+              gtk_combo_box_set_active_iter (combo, &iter);
+              gtk_widget_hide (GTK_WIDGET (entry));
+              has_active = TRUE;
+
+            }
         }
+      else
+        g_warning ("Getting a time preview failed for format specifier %s, so"
+                    "omitting it from the list of default formats", formats[i]);
     }
 
   gtk_list_store_insert_with_values (store, NULL, i++,

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


More information about the Xfce4-commits mailing list