From 49965d030fd65d3607ea0b611545163d45019852 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Mon, 9 Jan 2012 12:09:20 +0000 Subject: use libtimezonemap --- src/Makefile.am | 2 -- src/datetime-prefs-locations.h | 2 +- src/datetime-prefs.c | 21 +++++++++++++++------ src/timezone-completion.c | 18 +++++++++++------- 4 files changed, 27 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index a044528..e324117 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,12 +54,10 @@ libindicator_datetime_la_SOURCES =\ libindicator_datetime_la_CFLAGS = \ -Wall \ -Werror \ - -I$(top_srcdir)/libmap \ $(PREF_CFLAGS) \ -DTIMEZONE_FILE="\"/etc/timezone\"" \ -DPKGDATADIR="\"$(pkgdatadir)\"" libindicator_datetime_la_LIBADD = \ - $(top_builddir)/libmap/libmap.la \ $(PREF_LIBS) libindicator_datetime_la_LDFLAGS = -module -avoid-version diff --git a/src/datetime-prefs-locations.h b/src/datetime-prefs-locations.h index e312894..45d3b23 100644 --- a/src/datetime-prefs-locations.h +++ b/src/datetime-prefs-locations.h @@ -24,7 +24,7 @@ with this program. If not, see . #define __DATETIME_PREFS_LOCATIONS_H__ #include -#include "cc-timezone-map.h" +#include G_BEGIN_DECLS diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c index 1b7ddd2..2af0a3c 100644 --- a/src/datetime-prefs.c +++ b/src/datetime-prefs.c @@ -34,13 +34,13 @@ with this program. If not, see . #include #include #include +#include #include "dbus-shared.h" #include "settings-shared.h" #include "utils.h" #include "datetime-prefs-locations.h" #include "timezone-completion.h" -#include "cc-timezone-map.h" #define DATETIME_DIALOG_UI_FILE PKGDATADIR "/datetime-dialog.ui" @@ -243,15 +243,20 @@ sync_entry (IndicatorDatetimePanel * self, const gchar * location) } static void -tz_changed (CcTimezoneMap * map, TzLocation * location, IndicatorDatetimePanel * self) +tz_changed (CcTimezoneMap * map, CcTimezoneLocation * location, IndicatorDatetimePanel * self) { if (location == NULL) return; - g_dbus_proxy_call (self->priv->proxy, "SetTimezone", g_variant_new ("(s)", location->zone), + gchar * zone; + g_object_get (location, "zone", &zone, NULL); + + g_dbus_proxy_call (self->priv->proxy, "SetTimezone", g_variant_new ("(s)", zone), G_DBUS_CALL_FLAGS_NONE, -1, NULL, dbus_set_answered, "timezone"); - sync_entry (self, location->zone); + sync_entry (self, zone); + + g_free (zone); } static void @@ -626,13 +631,17 @@ entry_focus_out (GtkEntry * entry, GdkEventFocus * event, IndicatorDatetimePanel // If the name left in the entry doesn't match the current timezone name, // show an error icon. It's always an error for the user to manually type in // a timezone. - TzLocation * location = cc_timezone_map_get_location (self->priv->tzmap); + CcTimezoneLocation * location = cc_timezone_map_get_location (self->priv->tzmap); if (location == NULL) return FALSE; - gchar * name = get_current_zone_name (location->zone); + gchar * zone; + g_object_get (location, "zone", &zone, NULL); + + gchar * name = get_current_zone_name (zone); gboolean correct = (g_strcmp0 (gtk_entry_get_text (entry), name) == 0); g_free (name); + g_free (zone); gtk_entry_set_icon_from_stock (entry, GTK_ENTRY_ICON_SECONDARY, correct ? NULL : GTK_STOCK_DIALOG_ERROR); diff --git a/src/timezone-completion.c b/src/timezone-completion.c index f223bf4..19c30ad 100644 --- a/src/timezone-completion.c +++ b/src/timezone-completion.c @@ -26,8 +26,8 @@ with this program. If not, see . #include #include #include +#include #include "timezone-completion.h" -#include "tz.h" enum { LAST_SIGNAL @@ -355,7 +355,6 @@ request_zones (TimezoneCompletion * completion) gchar * locale = get_locale (); gchar * url = g_strdup_printf (GEONAME_URL, escaped, version, locale); g_free (locale); - g_free (version); g_free (escaped); GFile * file = g_file_new_for_uri (url); @@ -527,14 +526,18 @@ get_initial_model (void) gint i; for (i = 0; i < locations->len; ++i) { - TzLocation * loc = g_ptr_array_index (locations, i); + CcTimezoneLocation * loc = g_ptr_array_index (locations, i); GtkTreeIter iter; gtk_list_store_append (store, &iter); + gchar * zone; + gchar * country; + g_object_get (loc, "zone", &zone, "country", &country, NULL); + /* FIXME: need something better than below for non-English locales */ - const gchar * last_bit = ((const gchar *)strrchr (loc->zone, '/')) + 1; + const gchar * last_bit = ((const gchar *)strrchr (zone, '/')) + 1; if (last_bit == NULL) - last_bit = loc->zone; + last_bit = zone; gchar * name = g_strdup (last_bit); gchar * underscore; while ((underscore = strchr (name, '_'))) { @@ -542,12 +545,13 @@ get_initial_model (void) } gtk_list_store_set (store, &iter, - TIMEZONE_COMPLETION_ZONE, loc->zone, + TIMEZONE_COMPLETION_ZONE, zone, TIMEZONE_COMPLETION_NAME, name, - TIMEZONE_COMPLETION_COUNTRY, loc->country, + TIMEZONE_COMPLETION_COUNTRY, country, -1); g_free (name); + g_free (zone); } GtkTreeIter iter; -- cgit v1.2.3