summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSimon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>2017-11-15 23:50:10 +0100
committerSimon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>2017-11-15 23:50:10 +0100
commite43248058e67e1cf2725788c894616dc431458cd (patch)
treeac3f8588be16c43d6e72524605cc3946c3de98f2 /plugins
parent5ab8e2ba2ddac3e13a44a94e11318e45070e23e8 (diff)
downloadxfce4-panel-e43248058e67e1cf2725788c894616dc431458cd.tar.gz
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.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/clock/clock-time.c7
-rw-r--r--plugins/clock/clock.c30
2 files changed, 25 insertions, 12 deletions
diff --git a/plugins/clock/clock-time.c b/plugins/clock/clock-time.c
index 8d2d2087..cfb5920b 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 e982fdf7..7fc8537f 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++,