[libgweather] GWeatherLocationEntry: Add show-named-timezones property
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather] GWeatherLocationEntry: Add show-named-timezones property
- Date: Wed, 6 Dec 2017 00:49:18 +0000 (UTC)
commit cd7f213f53f6125be6674f1268a620c59313892e
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Tue Dec 5 09:05:58 2017 -0800
GWeatherLocationEntry: Add show-named-timezones property
Whether to show named timezone locations, such as the "UTC"
timezone as a location in the completion list.
Based on a patch by Bastien Nocera <hadess hadess net>
https://bugzilla.gnome.org/show_bug.cgi?id=791066
libgweather/gweather-location-entry.c | 42 +++++++++++++++++++++++++++-----
1 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/libgweather/gweather-location-entry.c b/libgweather/gweather-location-entry.c
index e9755c7..82d6a2f 100644
--- a/libgweather/gweather-location-entry.c
+++ b/libgweather/gweather-location-entry.c
@@ -40,6 +40,7 @@
struct _GWeatherLocationEntryPrivate {
GWeatherLocation *location;
GWeatherLocation *top;
+ gboolean show_named_timezones;
gboolean custom_text;
GCancellable *cancellable;
GtkTreeModel *model;
@@ -51,6 +52,7 @@ enum {
PROP_0,
PROP_TOP,
+ PROP_SHOW_NAMED_TIMEZONES,
PROP_LOCATION,
LAST_PROP
@@ -75,7 +77,8 @@ static void
fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
const char *parent_display_name,
const char *parent_compare_local_name,
- const char *parent_compare_english_name);
+ const char *parent_compare_english_name,
+ gboolean show_named_timezones);
enum LOC
{
@@ -181,7 +184,7 @@ constructed (GObject *object)
entry->priv->top = gweather_location_ref (gweather_location_get_world ());
store = gtk_tree_store_new (4, G_TYPE_STRING, GWEATHER_TYPE_LOCATION, G_TYPE_STRING, G_TYPE_STRING);
- fill_location_entry_model (store, entry->priv->top, NULL, NULL, NULL);
+ fill_location_entry_model (store, entry->priv->top, NULL, NULL, NULL, entry->priv->show_named_timezones);
entry->priv->model = GTK_TREE_MODEL (store);
completion = gtk_entry_get_completion (GTK_ENTRY (entry));
@@ -211,6 +214,13 @@ gweather_location_entry_class_init (GWeatherLocationEntryClass *location_entry_c
GWEATHER_TYPE_LOCATION,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (
+ object_class, PROP_SHOW_NAMED_TIMEZONES,
+ g_param_spec_boolean ("show-named-timezones",
+ "Show named timezones",
+ "Whether UTC and other named timezones are shown in the list of locations",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (
object_class, PROP_LOCATION,
g_param_spec_boxed ("location",
"Location",
@@ -231,6 +241,9 @@ set_property (GObject *object, guint prop_id,
case PROP_TOP:
entry->priv->top = g_value_dup_boxed (value);
break;
+ case PROP_SHOW_NAMED_TIMEZONES:
+ entry->priv->show_named_timezones = g_value_get_boolean (value);
+ break;
case PROP_LOCATION:
gweather_location_entry_set_location (GWEATHER_LOCATION_ENTRY (object),
g_value_get_boxed (value));
@@ -248,6 +261,9 @@ get_property (GObject *object, guint prop_id,
GWeatherLocationEntry *entry = GWEATHER_LOCATION_ENTRY (object);
switch (prop_id) {
+ case PROP_SHOW_NAMED_TIMEZONES:
+ g_value_set_boolean (value, entry->priv->show_named_timezones);
+ break;
case PROP_LOCATION:
g_value_set_boxed (value, entry->priv->location);
break;
@@ -476,7 +492,8 @@ static void
fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
const char *parent_display_name,
const char *parent_compare_local_name,
- const char *parent_compare_english_name)
+ const char *parent_compare_english_name,
+ gboolean show_named_timezones)
{
GWeatherLocation **children;
char *display_name, *local_compare_name, *english_compare_name;
@@ -495,7 +512,8 @@ fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
fill_location_entry_model (store, children[i],
parent_display_name,
parent_compare_local_name,
- parent_compare_english_name);
+ parent_compare_english_name,
+ show_named_timezones);
}
break;
@@ -505,7 +523,8 @@ fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
fill_location_entry_model (store, children[i],
loc->local_name,
loc->local_sort_name,
- loc->english_sort_name);
+ loc->english_sort_name,
+ show_named_timezones);
}
break;
@@ -517,7 +536,8 @@ fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
for (i = 0; children[i]; i++) {
fill_location_entry_model (store, children[i],
- display_name, local_compare_name, english_compare_name);
+ display_name, local_compare_name, english_compare_name,
+ show_named_timezones);
}
g_free (display_name);
@@ -554,7 +574,15 @@ fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
break;
case GWEATHER_LOCATION_NAMED_TIMEZONE:
- break;
+ if (show_named_timezones) {
+ gtk_tree_store_insert_with_values (store, NULL, NULL, -1,
+ LOC_GWEATHER_LOCATION_ENTRY_COL_LOCATION, loc,
+ LOC_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME, loc->local_name,
+ LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME,
loc->local_sort_name,
+ LOC_GWEATHER_LOCATION_ENTRY_COL_ENGLISH_COMPARE_NAME,
loc->english_sort_name,
+ -1);
+ }
+ break;
case GWEATHER_LOCATION_DETACHED:
g_assert_not_reached ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]