[gnome-panel] Revert "Bug fixes, remove notification buttons"
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-panel] Revert "Bug fixes, remove notification buttons"
- Date: Thu, 6 Aug 2009 14:28:23 +0000 (UTC)
commit e4512ee8211db4d3a4ad2614a71806bbfc4ed228
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Aug 6 10:26:42 2009 -0400
Revert "Bug fixes, remove notification buttons"
This reverts commit cca3d2ebd00d9701cb7b1f17efdd837acc485b26.
applets/clock/clock.c | 50 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 39 insertions(+), 11 deletions(-)
---
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index 71f2808..2978dee 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -372,18 +372,28 @@ set_geoclue_location_as_current (ClockData *cd, ClockLocation *loc)
/* TODO: free current_geo_location if needed and remove from list */
- if (cd->current_geo_location) {
- g_object_unref (cd->current_geo_location);
- cd->locations = g_list_remove (cd->locations, cd->current_geo_location);
- }
cd->current_geo_location = loc;
- cd->locations = g_list_append (cd->locations, g_object_ref (loc));
+ cd->locations = g_list_append (cd->locations, loc);
/* do something to trigger update ? */
}
static void
+edit_notify_callback (NotifyNotification *n, const char *action, ClockNotifyData *data)
+{
+ g_debug ("'edit geoclue location' clicked");
+}
+
+static void
+set_notify_callback (NotifyNotification *n, const char *action, ClockNotifyData *data)
+{
+ set_geoclue_location_as_current (data->cd, data->loc);
+ /*TODO save? */
+}
+
+static void
show_new_timezone_notification (ClockData *cd, ClockLocation *loc)
{
+ ClockNotifyData *data;
NotifyNotification *notification;
gboolean notify_init_ok = FALSE;
char *body;
@@ -394,6 +404,10 @@ show_new_timezone_notification (ClockData *cd, ClockLocation *loc)
return;
}
+ data = g_new0 (ClockNotifyData, 1);
+ data->cd = cd;
+ data->loc = loc;
+
body = g_strdup_printf ("New location '%s', in timezone '%s'",
clock_location_get_name (loc),
clock_location_get_timezone (loc));
@@ -403,8 +417,17 @@ show_new_timezone_notification (ClockData *cd, ClockLocation *loc)
body,
NULL,
cd->panel_button);
+ notify_notification_add_action(notification,
+ "set", "Set as current location",
+ (NotifyActionCallback)set_notify_callback,
+ data, NULL); /* TODO free function */
+ notify_notification_add_action(notification,
+ "edit", "Edit location",
+ (NotifyActionCallback)edit_notify_callback,
+ data, NULL);
if (!notify_notification_show (notification, NULL)) {
g_warning ("Failed to send notification\n");
+ g_free (data);
}
g_free (body);
@@ -423,11 +446,17 @@ on_location_changed (ClockGeoclue *clock_geo,
g_debug ("New geoclue location was not usable");
return;
}
-
- set_geoclue_location_as_current (cd, geo_loc);
-
+ /* we now know the timezone we're in */
+
+ /* TODO: if timezone is different from current, popup
+ * if timezone is same as current, change current location to geoclue location */
+
if (strcmp (system_timezone_get (cd->systz),
- clock_location_get_timezone (geo_loc)) != 0) {
+ clock_location_get_timezone (geo_loc)) == 0) {
+ g_debug ("new geoclue location (%s), same as system tz",
+ clock_location_get_name (geo_loc));
+ set_geoclue_location_as_current (cd, geo_loc);
+ } else {
g_debug ("new geoclue location (%s) on new timezone, showing notification",
clock_location_get_name (geo_loc));
show_new_timezone_notification (cd, geo_loc);
@@ -2282,8 +2311,7 @@ set_locations (ClockData *cd, GList *locations)
cd->locations = locations;
if (cd->current_geo_location) {
- cd->locations = g_list_append (cd->locations,
- g_object_ref (cd->current_geo_location));
+ cd->locations = g_list_append (cd->locations, cd->current_geo_location);
}
locations_changed (cd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]