aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-03-03 10:23:06 -0600
committerCharles Kerr <charles.kerr@canonical.com>2012-03-03 10:23:06 -0600
commita7ffebd9859ded9e44ec6a5b5dca9fb771eac209 (patch)
tree281a7dd4cc36debe3a72c7e5f7109d939370b6ad /src
parent59ade0a5dad1cb85f3576fc89c323a8baceb3a5e (diff)
parentad8b10b4665dbab7a58f0272de9cb3009d0c74b0 (diff)
downloadayatana-indicator-datetime-a7ffebd9859ded9e44ec6a5b5dca9fb771eac209.tar.gz
ayatana-indicator-datetime-a7ffebd9859ded9e44ec6a5b5dca9fb771eac209.tar.bz2
ayatana-indicator-datetime-a7ffebd9859ded9e44ec6a5b5dca9fb771eac209.zip
merging lp:~charlesk/indicator-datetime/fix-833337 and lp:~charlesk/indicator-datetime/fix-leaks
Diffstat (limited to 'src')
-rw-r--r--src/datetime-interface.c13
-rw-r--r--src/datetime-prefs.c49
-rw-r--r--src/datetime-service.c361
-rw-r--r--src/indicator-datetime.c55
4 files changed, 197 insertions, 281 deletions
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.c b/src/datetime-prefs.c
index 9fdfbed..50445ff 100644
--- a/src/datetime-prefs.c
+++ b/src/datetime-prefs.c
@@ -776,46 +776,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..44fffdc 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,
@@ -718,7 +690,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;
@@ -884,8 +855,6 @@ update_appointment_menu_items (gpointer user_data)
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 +911,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 +954,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 +1067,7 @@ static void
show_locations_changed (void)
{
/* Re-calculate */
- check_timezone_sync();
+ update_location_menu_items();
}
static void
@@ -1142,22 +1110,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 +1251,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 +1348,7 @@ geo_client_invalid (GeoclueMasterClient * client, gpointer user_data)
geo_timezone = NULL;
}
- check_timezone_sync();
+ update_location_menu_items();
return;
}
@@ -1417,7 +1370,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..91a029c 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -405,10 +405,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 +426,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;