diff options
author | Sebastien Bacher <seb128@ubuntu.com> | 2012-03-09 13:49:52 +0100 |
---|---|---|
committer | Sebastien Bacher <seb128@ubuntu.com> | 2012-03-09 13:49:52 +0100 |
commit | ad979590948f582a8b521432a49528103698f596 (patch) | |
tree | 0f0f3d2e05101e021f52324147457f65554c2932 | |
parent | 39bc08ed8c8c3d1be351c2642c8e2eb572a3061c (diff) | |
parent | fa7f146fafa83e8e612365a5f74ba06ff438d36a (diff) | |
download | ayatana-indicator-datetime-ad979590948f582a8b521432a49528103698f596.tar.gz ayatana-indicator-datetime-ad979590948f582a8b521432a49528103698f596.tar.bz2 ayatana-indicator-datetime-ad979590948f582a8b521432a49528103698f596.zip |
releasing version 0.3.91-0ubuntu1
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | ChangeLog | 105 | ||||
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | data/indicator-datetime-preferences.desktop | 16 | ||||
-rw-r--r-- | debian/changelog | 11 | ||||
-rw-r--r-- | src/datetime-interface.c | 13 | ||||
-rw-r--r-- | src/datetime-prefs-locations.c | 2 | ||||
-rw-r--r-- | src/datetime-prefs.c | 52 | ||||
-rw-r--r-- | src/datetime-service.c | 381 | ||||
-rw-r--r-- | src/indicator-datetime.c | 93 |
11 files changed, 355 insertions, 341 deletions
@@ -21,5 +21,6 @@ Michael Terry Robert Ancell Rodrigo Moya + Ryan Lortie Sebastien Bacher Ted Gould @@ -1,5 +1,110 @@ # Generated by Makefile. Do not edit. +2012-03-08 Ted Gould <ted@gould.cx> + + 0.3.91 + +2012-03-08 Ted Gould <ted@gould.cx> + + Change GSetting bindings to be read only + +2012-03-07 Ryan Lortie <desrt@desrt.ca> + + Establish read-only bindings to GSettings from the indicator + + The bindings to GSettings are established in the GTypeInstance _init + function of the indicator. During this time, the property notify queue + is frozen. After the construction completes, the queue thaws and the + rush of property change notifications causes GSettings writes to occur. + + We can fix this by switching to using readonly bindings. + +2012-03-08 Ted Gould <ted@gould.cx> + + Specify types explicitly to GVariantBuilder + +2012-03-07 Ryan Lortie <desrt@desrt.ca> + + more GVariantBuilder vs. G_VARIANT_TYPE_ARRAY fixes + +2012-03-05 Charles Kerr <charles.kerr@canonical.com> + + merge lp:~charlesk/indicator-datetime/fix-943747 to silence the Coverity warning reported in bug #943747 + +2012-03-03 Charles Kerr <charles.kerr@canonical.com> + + In Bug #943747, Coverity reported that use of sscanf() needed to be inspected by a human to verify there aren't buffer overruns. This commit adds /* coverity[secure_coding] */ to the lines before the calls to tell Coverity that they've been checked. + +2012-03-05 Charles Kerr <charles.kerr@canonical.com> + + merge lp:~charlesk/indicator-datetime/lp-943746 to fix the warning that Coverity reported in bug #943746 + +2012-03-03 Charles Kerr <charles.kerr@canonical.com> + + remove unused code in populate_appointment_instances(). + + It looks like the local variables 'datetime', 'appointment_zone', and 'current_zone' were used in earlier revisions of the code, but this was removed in <http://bazaar.launchpad.net/~indicator-applet-developers/indicator-datetime/trunk.0.4/revision/57>. They're currently leftover code, and removing them should fix Bug #943746. + +2012-03-03 Charles Kerr <charles.kerr@canonical.com> + + merging lp:~charlesk/indicator-datetime/fix-833337 and lp:~charlesk/indicator-datetime/fix-leaks + +2012-03-02 Charles Kerr <charles.kerr@canonical.com> + + simplify the code by removing special handling for geo_location and current_location, and adding them to the same 'locations' list that we use when pruning duplicates from the user-specified list of locations + +2012-03-02 Charles Kerr <charles.kerr@canonical.com> + + use g_return_if_fail() instead of g_assert() in the new code + +2012-03-02 Charles Kerr <charles.kerr@canonical.com> + + remove duplicate timezone entries + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + rename dconflocations as location_menu_items + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + make update_timezone_menu_items() a void function; its args and return value were unused + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + make the private fields 'conf' and 'gconf' static and init them to NULL + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + more use of g_clear_object() where appropriate + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + in dispose(), add g_clear_object() for priv.ido_calendar and priv.service_proxy_cancel + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + tweak: use g_clear_object() in dispose() + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + fix potential minor memory leak in update_timezone_menu_items() + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + remove unnecessary strdup+free in update_appointment_menu_items() + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + fix memory leak in update_appointment_menu_items() + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + fix memory leaks in day_selected_double_click_cb() + +2012-03-01 Charles Kerr <charles.kerr@canonical.com> + + extract method on common code + 2012-02-17 Ted Gould <ted@gould.cx> 0.3.90 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for indicator-datetime 0.3.90. +# Generated by GNU Autoconf 2.68 for indicator-datetime 0.3.91. # # Report bugs to <http://bugs.launchpad.net/indicator-datetime>. # @@ -572,8 +572,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='indicator-datetime' PACKAGE_TARNAME='indicator-datetime' -PACKAGE_VERSION='0.3.90' -PACKAGE_STRING='indicator-datetime 0.3.90' +PACKAGE_VERSION='0.3.91' +PACKAGE_STRING='indicator-datetime 0.3.91' PACKAGE_BUGREPORT='http://bugs.launchpad.net/indicator-datetime' PACKAGE_URL='http://launchpad.net/indicator-datetime' @@ -1395,7 +1395,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures indicator-datetime 0.3.90 to adapt to many kinds of systems. +\`configure' configures indicator-datetime 0.3.91 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1466,7 +1466,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of indicator-datetime 0.3.90:";; + short | recursive ) echo "Configuration of indicator-datetime 0.3.91:";; esac cat <<\_ACEOF @@ -1600,7 +1600,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -indicator-datetime configure 0.3.90 +indicator-datetime configure 0.3.91 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1971,7 +1971,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by indicator-datetime $as_me 0.3.90, which was +It was created by indicator-datetime $as_me 0.3.91, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2795,7 +2795,7 @@ fi # Define the identity of the package. PACKAGE='indicator-datetime' - VERSION='0.3.90' + VERSION='0.3.91' cat >>confdefs.h <<_ACEOF @@ -15041,7 +15041,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by indicator-datetime $as_me 0.3.90, which was +This file was extended by indicator-datetime $as_me 0.3.91, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15108,7 +15108,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -indicator-datetime config.status 0.3.90 +indicator-datetime config.status 0.3.91 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 9ab4c38..f033f41 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([indicator-datetime], - [0.3.90], + [0.3.91], [http://bugs.launchpad.net/indicator-datetime], [indicator-datetime], [http://launchpad.net/indicator-datetime]) diff --git a/data/indicator-datetime-preferences.desktop b/data/indicator-datetime-preferences.desktop new file mode 100644 index 0000000..8231e22 --- /dev/null +++ b/data/indicator-datetime-preferences.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Version=1.0 + +Name=Time & Date +Comment=Change your clock and date settings + +Icon=preferences-system-time +TryExec=gnome-control-center +Exec=gnome-control-center indicator-datetime + +StartupNotify=true + +Type=Application +Categories=GNOME;GTK;Utility;DesktopSettings;Settings;X-GNOME-SystemSettings;X-GNOME-Settings-Panel; +X-GNOME-Settings-Panel=indicator-datetime +OnlyShowIn=Unity; diff --git a/debian/changelog b/debian/changelog index d71eb4f..7a1de4c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +indicator-datetime (0.3.91-0ubuntu1) precise; urgency=low + + * New upstream release. + * Make GSettings readonly to fix DConf service starting on boot + * Explicitly give types to GVariant Builder + * Confirm scanf usage for Coverity (LP: #943747) + * Remove unused code (LP: #943746) + * Fix timezone ordering in the menu (LP: #833325, LP: #833337) + + -- Ted Gould <ted@ubuntu.com> Thu, 08 Mar 2012 16:58:28 -0600 + indicator-datetime (0.3.90-0ubuntu1) precise; urgency=low * New upstream release. diff --git a/src/datetime-interface.c b/src/datetime-interface.c index 5939061..e67be85 100644 --- a/src/datetime-interface.c +++ b/src/datetime-interface.c @@ -124,10 +124,7 @@ bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data) g_warn_if_fail(priv->bus == NULL); priv->bus = connection; - if (priv->bus_cancel != NULL) { - g_object_unref(priv->bus_cancel); - priv->bus_cancel = NULL; - } + g_clear_object (&priv->bus_cancel); /* Now register our object on our new connection */ priv->dbus_registration = g_dbus_connection_register_object(priv->bus, @@ -158,15 +155,11 @@ datetime_interface_dispose (GObject *object) priv->dbus_registration = 0; } - if (priv->bus != NULL) { - g_object_unref(priv->bus); - priv->bus = NULL; - } + g_clear_object (&priv->bus); if (priv->bus_cancel != NULL) { g_cancellable_cancel(priv->bus_cancel); - g_object_unref(priv->bus_cancel); - priv->bus_cancel = NULL; + g_clear_object (&priv->bus_cancel); } G_OBJECT_CLASS (datetime_interface_parent_class)->dispose (object); diff --git a/src/datetime-prefs-locations.c b/src/datetime-prefs-locations.c index b734a69..9c71f8e 100644 --- a/src/datetime-prefs-locations.c +++ b/src/datetime-prefs-locations.c @@ -339,7 +339,7 @@ save_to_settings (GObject * store, GSettings * conf) { gboolean empty = TRUE; GVariantBuilder builder; - g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); + g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY); GtkTreeIter iter; if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) { diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c index 9fdfbed..bfe75c0 100644 --- a/src/datetime-prefs.c +++ b/src/datetime-prefs.c @@ -405,6 +405,7 @@ input_time_text (GtkWidget * spinner, gdouble * value, IndicatorDatetimePanel * if (is_locale_12h ()) { // TODO: make this look-at/watch gsettings? char ampm[51]; + /* coverity[secure_coding] */ scanned = sscanf (text, "%u:%u:%u %50s", &hour_in, &minute_in, &second_in, ampm); passed = (scanned == 4); @@ -415,6 +416,7 @@ input_time_text (GtkWidget * spinner, gdouble * value, IndicatorDatetimePanel * } } } else { + /* coverity[secure_coding] */ scanned = sscanf (text, "%u:%u:%u", &hour_in, &minute_in, &second_in); passed = (scanned == 3); } @@ -433,6 +435,7 @@ input_time_text (GtkWidget * spinner, gdouble * value, IndicatorDatetimePanel * else { gint year_in, month_in, day_in; + /* coverity[secure_coding] */ scanned = sscanf (text, "%u-%u-%u", &year_in, &month_in, &day_in); if (scanned != 3 || year_in < 1 || year_in > 9999 || @@ -776,46 +779,39 @@ static void indicator_datetime_panel_dispose (GObject * object) { IndicatorDatetimePanel * self = (IndicatorDatetimePanel *) object; + IndicatorDatetimePanelPrivate * priv = self->priv; - if (self->priv->builder) { - g_object_unref (self->priv->builder); - self->priv->builder = NULL; - } - - if (self->priv->proxy) { - g_object_unref (self->priv->proxy); - self->priv->proxy = NULL; - } + g_clear_object (&priv->builder); + g_clear_object (&priv->proxy); - if (self->priv->loc_dlg) { - gtk_widget_destroy (self->priv->loc_dlg); - self->priv->loc_dlg = NULL; + if (priv->loc_dlg) { + gtk_widget_destroy (priv->loc_dlg); + priv->loc_dlg = NULL; } - if (self->priv->save_time_id) { - g_source_remove (self->priv->save_time_id); - self->priv->save_time_id = 0; + if (priv->save_time_id) { + g_source_remove (priv->save_time_id); + priv->save_time_id = 0; } - if (self->priv->completion) { - cc_timezone_completion_watch_entry (self->priv->completion, NULL); - g_object_unref (self->priv->completion); - self->priv->completion = NULL; + if (priv->completion) { + cc_timezone_completion_watch_entry (priv->completion, NULL); + g_clear_object (&priv->completion); } - if (self->priv->tz_entry) { - gtk_widget_destroy (self->priv->tz_entry); - self->priv->tz_entry = NULL; + if (priv->tz_entry) { + gtk_widget_destroy (priv->tz_entry); + priv->tz_entry = NULL; } - if (self->priv->time_spin) { - gtk_widget_destroy (self->priv->time_spin); - self->priv->time_spin = NULL; + if (priv->time_spin) { + gtk_widget_destroy (priv->time_spin); + priv->time_spin = NULL; } - if (self->priv->date_spin) { - gtk_widget_destroy (self->priv->date_spin); - self->priv->date_spin = NULL; + if (priv->date_spin) { + gtk_widget_destroy (priv->date_spin); + priv->date_spin = NULL; } } diff --git a/src/datetime-service.c b/src/datetime-service.c index ef43594..a782d80 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -62,12 +62,14 @@ with this program. If not, see <http://www.gnu.org/licenses/>. static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data); static gboolean update_appointment_menu_items (gpointer user_data); -static gboolean update_timezone_menu_items(gpointer user_data); +static void update_location_menu_items (void); static void setup_timer (void); static void geo_client_invalid (GeoclueMasterClient * client, gpointer user_data); static void geo_address_change (GeoclueMasterClient * client, gchar * a, gchar * b, gchar * c, gchar * d, gpointer user_data); static gboolean get_greeter_mode (void); +static void quick_set_tz (DbusmenuMenuitem * menuitem, guint timestamp, gpointer user_data); + static IndicatorService * service = NULL; static GMainLoop * mainloop = NULL; static DbusmenuServer * server = NULL; @@ -80,17 +82,14 @@ static DbusmenuMenuitem * calendar = NULL; static DbusmenuMenuitem * settings = NULL; static DbusmenuMenuitem * events_separator = NULL; static DbusmenuMenuitem * locations_separator = NULL; -static DbusmenuMenuitem * geo_location = NULL; -static DbusmenuMenuitem * current_location = NULL; -//static DbusmenuMenuitem * ecal_location = NULL; static DbusmenuMenuitem * add_appointment = NULL; -static GList * appointments = NULL; -static GList * dconflocations = NULL; -static GList * comp_instances = NULL; +static GList * appointments = NULL; +static GSList * location_menu_items = NULL; +static GList * comp_instances = NULL; static gboolean updating_appointments = FALSE; -static time_t start_time_appointments = (time_t) 0; -GSettings *conf; -GConfClient* gconf; +static time_t start_time_appointments = (time_t) 0; +static GSettings * conf = NULL; +static GConfClient * gconf = NULL; /* Geoclue trackers */ @@ -108,115 +107,141 @@ struct comp_instance { ESource *source; }; +/** + * A temp struct used by update_location_menu_items() for pruning duplicates. + */ +struct TimeLocation +{ + gint32 offset; + gchar * zone; + gchar * name; +}; static void -set_timezone_label (DbusmenuMenuitem * mi, const gchar * location) +time_location_free (struct TimeLocation * loc) { - gchar * zone, * name; - split_settings_location (location, &zone, &name); - - dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_NAME, name); - dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_ZONE, zone); + g_free (loc->name); + g_free (loc->zone); + g_free (loc); +} +static struct TimeLocation* +time_location_new (const char * zone, const char * name) +{ + struct TimeLocation * loc = g_new (struct TimeLocation, 1); + GTimeZone * tz = g_time_zone_new (zone); + loc->offset = g_time_zone_get_offset (tz, 0); + loc->zone = g_strdup (zone); + loc->name = g_strdup (name); + g_time_zone_unref (tz); + return loc; +} +static int +time_location_compare (const struct TimeLocation * a, const struct TimeLocation * b) +{ + int ret; + if (a->offset != b->offset) /* primary key s.t. we can sort by timezone order */ + ret = a->offset - b->offset; + else + ret = g_strcmp0 (a->name, b->name); /* secondary key */ + g_debug ("%s comparing '%s' (%d) to '%s' (%d), returning %d", G_STRLOC, a->name, (int)a->offset, b->name, (int)b->offset, ret); + return ret; +} +static GSList* +locations_add (GSList * locations, const char * zone, const char * name) +{ + struct TimeLocation * loc = time_location_new (zone, name); - g_free (zone); - g_free (name); + if (g_slist_find_custom (locations, loc, (GCompareFunc)time_location_compare) == NULL) { + g_debug ("%s Adding zone '%s', name '%s'", G_STRLOC, zone, name); + locations = g_slist_prepend (locations, loc); + } else { + g_debug("%s Skipping duplicate zone '%s' name '%s'", G_STRLOC, zone, name); + time_location_free (loc); + } + return locations; } +/* Update the timezone entries */ static void -set_current_timezone_label (DbusmenuMenuitem * mi, const gchar * location) +update_location_menu_items (void) { - gchar * name = get_current_zone_name (location); + /* if we're in greeter mode, don't bother */ + if (locations_separator == NULL) + return; - dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_NAME, name); - dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_ZONE, location); + /* remove the previous locations */ + while (location_menu_items != NULL) { + DbusmenuMenuitem * item = DBUSMENU_MENUITEM(location_menu_items->data); + location_menu_items = g_slist_remove(location_menu_items, item); + dbusmenu_menuitem_child_delete(root, DBUSMENU_MENUITEM(item)); + g_object_unref(G_OBJECT(item)); + } - g_free (name); -} + /*** + **** Build a list of locations to add: use geo_timezone, + **** current_timezone, and SETTINGS_LOCATIONS_S, but omit duplicates. + ***/ -/* Check to see if our timezones are the same */ -static void -check_timezone_sync (void) { - gchar * label; - gboolean in_sync = FALSE; - - if (geo_timezone == NULL) { - in_sync = TRUE; - } + GSList * locations = NULL; - if (current_timezone == NULL) { - in_sync = TRUE; + /* maybe add geo_timezone */ + if (geo_timezone != NULL) { + gchar * name = get_current_zone_name (geo_timezone); + locations = locations_add (locations, geo_timezone, name); + g_free (name); } - if (!in_sync && g_strcmp0(geo_timezone, current_timezone) == 0) { - in_sync = TRUE; + /* maybe add current_timezone */ + if (current_timezone != NULL) { + gchar * name = get_current_zone_name (current_timezone); + locations = locations_add (locations, current_timezone, name); + g_free (name); } - if (in_sync) { - g_debug("Timezones in sync"); - } else { - g_debug("Timezones are different"); + /* maybe add the user-specified custom locations */ + gchar ** user_locations = g_settings_get_strv (conf, SETTINGS_LOCATIONS_S); + if (user_locations != NULL) { + gint i; + const guint location_count = g_strv_length (user_locations); + g_debug ("%s Found %u user-specified locations", G_STRLOC, location_count); + for (i=0; i<location_count; i++) { + gchar * zone; + gchar * name; + split_settings_location (user_locations[i], &zone, &name); + locations = locations_add (locations, zone, name); + g_free (name); + g_free (zone); + } + g_strfreev (user_locations); + user_locations = NULL; } - gboolean show = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S); - - if (geo_location != NULL && current_location != NULL) { - g_debug("Got timezone %s", current_timezone); - g_debug("Got timezone %s", geo_timezone); - // Show neither current location nor geo location if both are the same - // however, we want to set their time and label accordingly - if (in_sync) { - if (current_timezone == NULL && geo_timezone == NULL) { - dbusmenu_menuitem_property_set_bool(locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - update_timezone_menu_items(NULL); // Update the timezone menu items - return; - } - - dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); - - if (current_timezone != NULL) { - label = current_timezone; - } else { - label = geo_timezone; - } - - if (label != NULL) { - // TODO work out the current location name in a nice way - set_current_timezone_label (current_location, label); - // TODO work out the current time at that location - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - dbusmenu_menuitem_property_set_bool(current_location, TIMEZONE_MENUITEM_PROP_RADIO, TRUE); - } else { - g_debug("Label for current location is null, this shouldn't happen"); - } - if (geo_timezone != NULL) { - // TODO work out the geo location name in a nice way - set_current_timezone_label (geo_location, geo_timezone); - // TODO work out the current time at that location - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - } - } else { - // TODO work out the geo location name in a nice way - set_current_timezone_label (geo_location, geo_timezone); - // TODO work out the current time at that location - dbusmenu_menuitem_property_set_bool(geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - - // TODO work out the current location name in a nice way - set_current_timezone_label (current_location, current_timezone); - // TODO work out the current time at that location - dbusmenu_menuitem_property_set_bool(current_location, TIMEZONE_MENUITEM_PROP_RADIO, TRUE); - dbusmenu_menuitem_property_set_bool(current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - dbusmenu_menuitem_property_set_bool(locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - } + /* sort the list by timezone offset */ + locations = g_slist_sort (locations, (GCompareFunc)time_location_compare); + + /* finally create menuitems for each location */ + gint offset = dbusmenu_menuitem_get_position (locations_separator, root)+1; + const gboolean show_locations = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S); + GSList * l; + for (l=locations; l!=NULL; l=l->next) { + struct TimeLocation * loc = l->data; + g_debug("%s Adding location: zone '%s', name '%s'", G_STRLOC, loc->zone, loc->name); + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE); + dbusmenu_menuitem_property_set (item, TIMEZONE_MENUITEM_PROP_NAME, loc->name); + dbusmenu_menuitem_property_set (item, TIMEZONE_MENUITEM_PROP_ZONE, loc->zone); + dbusmenu_menuitem_property_set_bool (item, TIMEZONE_MENUITEM_PROP_RADIO, FALSE); + dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_VISIBLE, show_locations); + dbusmenu_menuitem_child_add_position (root, item, offset++); + g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); + location_menu_items = g_slist_append (location_menu_items, item); + time_location_free (loc); } - g_debug("Finished checking timezone sync"); - update_timezone_menu_items(NULL); // Update the timezone menu items + g_slist_free (locations); + locations = NULL; - return; + /* if there's at least one item being shown, show the separator too */ + dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show_locations && (location_menu_items!=NULL)); } /* Update the current timezone */ @@ -235,7 +260,7 @@ update_current_timezone (void) { g_debug("System timezone is: %s", current_timezone); - check_timezone_sync(); + update_location_menu_items(); return; } @@ -331,7 +356,7 @@ update_datetime (gpointer user_data) /* Run a particular program based on an activation */ static void -activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) +execute_command (const gchar * command) { GError * error = NULL; @@ -342,6 +367,15 @@ activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) } } +/* Run a particular program based on an activation */ +static void +activate_cb (DbusmenuMenuitem * menuitem G_GNUC_UNUSED, + guint timestamp G_GNUC_UNUSED, + const gchar * command) +{ + execute_command (command); +} + static gboolean update_appointment_menu_items_idle (gpointer user_data) { @@ -411,22 +445,22 @@ day_selected_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, gu } static gboolean -day_selected_double_click_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) +day_selected_double_click_cb (DbusmenuMenuitem * menuitem G_GNUC_UNUSED, + gchar * name G_GNUC_UNUSED, + GVariant * variant, + guint timestamp G_GNUC_UNUSED) { - time_t evotime = (time_t)g_variant_get_uint32(variant); + const time_t evotime = (time_t)g_variant_get_uint32(variant); g_debug("Received day-selected-double-click with timestamp: %d -> %s",(int)evotime, ctime(&evotime)); gchar *ad = isodate_from_time_t(evotime); gchar *cmd = g_strconcat("evolution calendar:///?startdate=", ad, NULL); - GError * error = NULL; + execute_command (cmd); - g_debug("Issuing command '%s'", cmd); - if (!g_spawn_command_line_async(cmd, &error)) { - g_warning("Unable to start %s: %s", (char *)cmd, error->message); - g_error_free(error); - } + g_free (cmd); + g_free (ad); return TRUE; } @@ -557,68 +591,6 @@ check_for_calendar (gpointer user_data) return FALSE; } - -static gboolean -update_timezone_menu_items(gpointer user_data) { - g_debug("Updating timezone menu items"); - - if (locations_separator == NULL || current_location == NULL) { - return FALSE; - } - - gchar ** locations = g_settings_get_strv(conf, SETTINGS_LOCATIONS_S); - - if (locations == NULL) { - g_debug("No locations configured (NULL)"); - return FALSE; - } - guint len = g_strv_length(locations); - DbusmenuMenuitem *item; - gint i, offset; - - /* Remove all of the previous locations */ - if (dconflocations != NULL) { - while (dconflocations != NULL) { - DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(dconflocations->data); - // Remove all the existing menu items which are in dconflocations. - dconflocations = g_list_remove(dconflocations, litem); - dbusmenu_menuitem_child_delete(root, DBUSMENU_MENUITEM(litem)); - g_object_unref(G_OBJECT(litem)); - } - } - - gboolean show = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S); - - dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); - - if (len == 0) { - g_debug("No locations configured (Empty List)"); - return FALSE; - } - - offset = dbusmenu_menuitem_get_position (current_location, root)+1; - for (i = 0; i < len; i++) { - // Iterate over configured places and add any which aren't already listed - if ((current_timezone == NULL || !g_str_has_prefix(locations[i], current_timezone)) && - (geo_timezone == NULL || !g_str_has_prefix(locations[i], geo_timezone))) { - g_debug("Adding timezone in update_timezones %s", locations[i]); - item = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE); - set_timezone_label (item, locations[i]); - dbusmenu_menuitem_property_set_bool (item, TIMEZONE_MENUITEM_PROP_RADIO, FALSE); - dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); - dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - dbusmenu_menuitem_child_add_position (root, item, offset++); - g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); - dconflocations = g_list_append(dconflocations, item); - } - } - g_strfreev (locations); - return FALSE; -} - // Authentication function static gchar * auth_func (ECal *ecal, @@ -668,25 +640,7 @@ populate_appointment_instances (ECalComponent *comp, if (status == ICAL_STATUS_COMPLETED || status == ICAL_STATUS_CANCELLED) return FALSE; g_object_ref(comp); - - ECalComponentDateTime datetime; - icaltimezone *appointment_zone = NULL; - icaltimezone *current_zone = NULL; - - if (vtype == E_CAL_COMPONENT_EVENT) - e_cal_component_get_dtstart (comp, &datetime); - else - e_cal_component_get_due (comp, &datetime); - appointment_zone = icaltimezone_get_builtin_timezone_from_tzid(datetime.tzid); - current_zone = icaltimezone_get_builtin_timezone_from_tzid(current_timezone); - if (!appointment_zone || datetime.value->is_date) { // If it's today put in the current timezone? - appointment_zone = current_zone; - } - - // TODO: Convert the timezone into a 3 letter abbreviation if it's different to current_timezone - // TODO: Add the appointment timezone to the list if it's not already there. - struct comp_instance *ci; ci = g_new (struct comp_instance, 1); @@ -718,7 +672,6 @@ update_appointment_menu_items (gpointer user_data) updating_appointments = TRUE; time_t curtime = 0, t1 = 0, t2 = 0; - gchar *ad; GList *l; GSList *g; GError *gerror = NULL; @@ -877,15 +830,13 @@ update_appointment_menu_items (gpointer user_data) } GVariantBuilder markeddays; - g_variant_builder_init (&markeddays, G_VARIANT_TYPE_ARRAY); + g_variant_builder_init (&markeddays, G_VARIANT_TYPE ("ai")); i = 0; GList * cached_appointment = appointments; for (l = sorted_comp_instances; l; l = l->next) { struct comp_instance *ci = l->data; ECalComponent *ecalcomp = ci->comp; - ECalComponentText valuetext; - gchar *summary, *cmd; char right[20]; //const gchar *uri; DbusmenuMenuitem * item; @@ -942,12 +893,11 @@ update_appointment_menu_items (gpointer user_data) // Label text + ECalComponentText valuetext; e_cal_component_get_summary (ecalcomp, &valuetext); - summary = g_strdup (valuetext.value); - - dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_LABEL, summary); + const gchar * summary = valuetext.value; g_debug("Summary: %s", summary); - g_free (summary); + dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_LABEL, summary); gboolean full_day = FALSE; if (vtype == E_CAL_COMPONENT_EVENT) { @@ -986,12 +936,12 @@ update_appointment_menu_items (gpointer user_data) // Now we pull out the URI for the calendar event and try to create a URI that'll work when we execute evolution // FIXME Because the URI stuff is really broken, we're going to open the calendar at todays date instead //e_cal_component_get_uid(ecalcomp, &uri); - ad = isodate_from_time_t(mktime(due)); - cmd = g_strconcat("evolution calendar:///?startdate=", ad, NULL); - g_signal_connect (G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_cb), cmd); - + gchar * ad = isodate_from_time_t(mktime(due)); + gchar * cmd = g_strconcat("evolution calendar:///?startdate=", ad, NULL); g_debug("Command to Execute: %s", cmd); + g_signal_connect_data (G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(activate_cb), cmd, (GClosureNotify)g_free, 0); + g_free (ad); const gchar *color_spec = e_source_peek_color_spec(ci->source); g_debug("Colour to use: %s", color_spec); @@ -1099,7 +1049,7 @@ static void show_locations_changed (void) { /* Re-calculate */ - check_timezone_sync(); + update_location_menu_items(); } static void @@ -1142,22 +1092,7 @@ build_menus (DbusmenuMenuitem * root) dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_append(root, locations_separator); - geo_location = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (geo_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE); - set_current_timezone_label (geo_location, ""); - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); - dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - g_signal_connect(G_OBJECT(geo_location), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); - dbusmenu_menuitem_child_append(root, geo_location); - - current_location = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (current_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE); - set_current_timezone_label (current_location, ""); - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_child_append(root, current_location); - - check_timezone_sync(); + update_location_menu_items(); g_signal_connect (conf, "changed::" SETTINGS_SHOW_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL); g_signal_connect (conf, "changed::" SETTINGS_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL); @@ -1298,7 +1233,7 @@ geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, geo_timezone = g_strdup((gchar *)tz_hash); } - check_timezone_sync(); + update_location_menu_items(); return; } @@ -1395,7 +1330,7 @@ geo_client_invalid (GeoclueMasterClient * client, gpointer user_data) geo_timezone = NULL; } - check_timezone_sync(); + update_location_menu_items(); return; } @@ -1417,7 +1352,7 @@ geo_address_change (GeoclueMasterClient * client, gchar * a, gchar * b, gchar * geo_timezone = NULL; } - check_timezone_sync(); + update_location_menu_items(); return; } diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index c847d47..77fdb40 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -162,7 +162,6 @@ static GtkLabel * get_label (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); static const gchar * get_accessible_desc (IndicatorObject * io); static const gchar * get_name_hint (IndicatorObject * io); -static GVariant * bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data); static gboolean bind_enum_get (GValue * value, GVariant * variant, gpointer user_data); static gchar * generate_format_string_now (IndicatorDatetime * self); static void update_label (IndicatorDatetime * io, GDateTime ** datetime); @@ -321,45 +320,44 @@ indicator_datetime_init (IndicatorDatetime *self) SETTINGS_SHOW_CLOCK_S, self, PROP_SHOW_CLOCK_S, - G_SETTINGS_BIND_DEFAULT); + G_SETTINGS_BIND_GET); g_settings_bind_with_mapping(self->priv->settings, SETTINGS_TIME_FORMAT_S, self, PROP_TIME_FORMAT_S, - G_SETTINGS_BIND_DEFAULT, + G_SETTINGS_BIND_GET, bind_enum_get, - bind_enum_set, - NULL, NULL); /* Userdata and destroy func */ + NULL, NULL, NULL); /* set mapping, userdata and destroy func */ g_settings_bind(self->priv->settings, SETTINGS_SHOW_SECONDS_S, self, PROP_SHOW_SECONDS_S, - G_SETTINGS_BIND_DEFAULT); + G_SETTINGS_BIND_GET); g_settings_bind(self->priv->settings, SETTINGS_SHOW_DAY_S, self, PROP_SHOW_DAY_S, - G_SETTINGS_BIND_DEFAULT); + G_SETTINGS_BIND_GET); g_settings_bind(self->priv->settings, SETTINGS_SHOW_DATE_S, self, PROP_SHOW_DATE_S, - G_SETTINGS_BIND_DEFAULT); + G_SETTINGS_BIND_GET); g_settings_bind(self->priv->settings, SETTINGS_CUSTOM_TIME_FORMAT_S, self, PROP_CUSTOM_TIME_FORMAT_S, - G_SETTINGS_BIND_DEFAULT); + G_SETTINGS_BIND_GET); g_settings_bind(self->priv->settings, SETTINGS_SHOW_WEEK_NUMBERS_S, self, PROP_SHOW_WEEK_NUMBERS_S, - G_SETTINGS_BIND_DEFAULT); + G_SETTINGS_BIND_GET); g_settings_bind(self->priv->settings, SETTINGS_SHOW_CALENDAR_S, self, PROP_SHOW_CALENDAR_S, - G_SETTINGS_BIND_DEFAULT); + G_SETTINGS_BIND_GET); } else { g_warning("Unable to get settings for '" SETTINGS_INTERFACE "'"); } @@ -405,10 +403,7 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); - if (priv->service_proxy_cancel != NULL) { - g_object_unref(priv->service_proxy_cancel); - priv->service_proxy_cancel = NULL; - } + g_clear_object (&priv->service_proxy_cancel); if (error != NULL) { g_warning("Could not grab DBus proxy for %s: %s", SERVICE_NAME, error->message); @@ -429,46 +424,26 @@ static void indicator_datetime_dispose (GObject *object) { IndicatorDatetime * self = INDICATOR_DATETIME(object); + IndicatorDatetimePrivate * priv = self->priv; - if (self->priv->label != NULL) { - g_object_unref(self->priv->label); - self->priv->label = NULL; - } - - if (self->priv->timer != 0) { - g_source_remove(self->priv->timer); - self->priv->timer = 0; - } - - if (self->priv->idle_measure != 0) { - g_source_remove(self->priv->idle_measure); - self->priv->idle_measure = 0; - } - - if (self->priv->menu != NULL) { - g_object_unref(G_OBJECT(self->priv->menu)); - self->priv->menu = NULL; - } - - if (self->priv->sm != NULL) { - g_object_unref(G_OBJECT(self->priv->sm)); - self->priv->sm = NULL; - } - - if (self->priv->settings != NULL) { - g_object_unref(G_OBJECT(self->priv->settings)); - self->priv->settings = NULL; + if (priv->timer != 0) { + g_source_remove(priv->timer); + priv->timer = 0; } - if (self->priv->service_proxy != NULL) { - g_object_unref(self->priv->service_proxy); - self->priv->service_proxy = NULL; + if (priv->idle_measure != 0) { + g_source_remove(priv->idle_measure); + priv->idle_measure = 0; } - if (self->priv->indicator_right_group != NULL) { - g_object_unref(G_OBJECT(self->priv->indicator_right_group)); - self->priv->indicator_right_group = NULL; - } + g_clear_object (&priv->label); + g_clear_object (&priv->menu); + g_clear_object (&priv->sm); + g_clear_object (&priv->settings); + g_clear_object (&priv->service_proxy); + g_clear_object (&priv->indicator_right_group); + g_clear_object (&priv->ido_calendar); + g_clear_object (&priv->service_proxy_cancel); G_OBJECT_CLASS (indicator_datetime_parent_class)->dispose (object); return; @@ -493,24 +468,6 @@ indicator_datetime_finalize (GObject *object) return; } -/* Turns the int value into a string GVariant */ -static GVariant * -bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data) -{ - switch (g_value_get_int(value)) { - case SETTINGS_TIME_LOCALE: - return g_variant_new_string("locale-default"); - case SETTINGS_TIME_12_HOUR: - return g_variant_new_string("12-hour"); - case SETTINGS_TIME_24_HOUR: - return g_variant_new_string("24-hour"); - case SETTINGS_TIME_CUSTOM: - return g_variant_new_string("custom"); - default: - return NULL; - } -} - /* Turns a string GVariant into an int value */ static gboolean bind_enum_get (GValue * value, GVariant * variant, gpointer user_data) |