b67bf81
--- gnome-panel-2.21.91/applets/clock/set-timezone.c	2008-02-11 16:15:51.000000000 -0500
b67bf81
+++ hacked/applets/clock/set-timezone.c	2008-02-18 00:49:27.000000000 -0500
b67bf81
@@ -91,108 +91,6 @@
b67bf81
 	return pk_context;
b67bf81
 }
b67bf81
 
b67bf81
-gboolean
b67bf81
-set_system_timezone (const char *filename, GError **err)
b67bf81
-{
b67bf81
-        DBusGConnection *session_bus;
b67bf81
-        DBusGConnection *system_bus;
b67bf81
-        DBusGProxy      *mechanism_proxy;
b67bf81
-        DBusGProxy      *polkit_gnome_proxy;
b67bf81
-	gboolean ret = FALSE;
b67bf81
-
b67bf81
-       	session_bus = get_session_bus ();
b67bf81
-        if (session_bus == NULL) 
b67bf81
-		goto out;
b67bf81
-
b67bf81
-        system_bus = get_system_bus ();
b67bf81
-        if (system_bus == NULL) 
b67bf81
-               	goto out;
b67bf81
-
b67bf81
-	mechanism_proxy = dbus_g_proxy_new_for_name (system_bus,
b67bf81
-                                                     "org.gnome.ClockApplet.Mechanism",
b67bf81
-                                                     "/",
b67bf81
-                                                     "org.gnome.ClockApplet.Mechanism");
b67bf81
-
b67bf81
-	polkit_gnome_proxy = dbus_g_proxy_new_for_name (session_bus,
b67bf81
-                                                        "org.gnome.PolicyKit",
b67bf81
-                                                        "/org/gnome/PolicyKit/Manager",
b67bf81
-                                                        "org.gnome.PolicyKit.Manager");
b67bf81
-
b67bf81
-        if (filename != NULL) {
b67bf81
-                GError *error;
b67bf81
-
b67bf81
-                g_debug ("Trying to set timezone '%s'", filename);
b67bf81
-        try_again:
b67bf81
-                error = NULL;
b67bf81
-                /* first, try to call into the mechanism */
b67bf81
-                if (!dbus_g_proxy_call_with_timeout (mechanism_proxy,
b67bf81
-                                                     "SetTimezone",
b67bf81
-                                                     INT_MAX,
b67bf81
-                                                     &error,
b67bf81
-                                                     /* parameters: */
b67bf81
-                                                     G_TYPE_STRING, filename,
b67bf81
-                                                     G_TYPE_INVALID,
b67bf81
-                                                     /* return values: */
b67bf81
-                                                     G_TYPE_INVALID)) {
b67bf81
-                        if (dbus_g_error_has_name (error, "org.gnome.ClockApplet.Mechanism.NotPrivileged")) {
b67bf81
-                                char **tokens;
b67bf81
-                                char *polkit_result_textual;
b67bf81
-                                char *polkit_action;
b67bf81
-                                gboolean gained_privilege;
b67bf81
-
b67bf81
-                                tokens = g_strsplit (error->message, " ", 2);
b67bf81
-                                g_error_free (error);                                
b67bf81
-                                if (g_strv_length (tokens) != 2) {
b67bf81
-                                        g_warning ("helper return string malformed");
b67bf81
-                                        g_strfreev (tokens);
b67bf81
-                                        goto out;
b67bf81
-                                }
b67bf81
-                                polkit_action = tokens[0];
b67bf81
-                                polkit_result_textual = tokens[1];
b67bf81
-
b67bf81
-                                g_debug ("helper refused; returned polkit_result='%s' and polkit_action='%s'", 
b67bf81
-                                         polkit_result_textual, polkit_action);
b67bf81
-
b67bf81
-                                /* Now ask the user for auth... */
b67bf81
-                                if (!dbus_g_proxy_call_with_timeout (polkit_gnome_proxy,
b67bf81
-                                                                     "ShowDialog",
b67bf81
-                                                                     INT_MAX,
b67bf81
-                                                                     &error,
b67bf81
-                                                                     /* parameters: */
b67bf81
-                                                                     G_TYPE_STRING, polkit_action,
b67bf81
-                                                                     G_TYPE_UINT, 0, /* X11 window ID; none */
b67bf81
-                                                                     G_TYPE_INVALID,
b67bf81
-                                                                     /* return values: */
b67bf81
-                                                                     G_TYPE_BOOLEAN, &gained_privilege,
b67bf81
-                                                                     G_TYPE_INVALID)) {
b67bf81
-                                        g_propagate_error (err, error);
b67bf81
-                                        g_strfreev (tokens);
b67bf81
-                                        goto out;
b67bf81
-                                }
b67bf81
-                                g_strfreev (tokens);
b67bf81
-
b67bf81
-                                if (gained_privilege) {
b67bf81
-                                        g_debug ("Gained privilege; trying to set timezone again");
b67bf81
-                                        goto try_again;
b67bf81
-                                }
b67bf81
-
b67bf81
-                        } else {
b67bf81
-                                g_propagate_error (err, error);
b67bf81
-                        }
b67bf81
-                        goto out;
b67bf81
-                }
b67bf81
-
b67bf81
-                g_debug ("Successfully set time zone to '%s'", filename);
b67bf81
-        }
b67bf81
-
b67bf81
-        ret = TRUE;
b67bf81
-out:
b67bf81
-	g_object_unref (mechanism_proxy);
b67bf81
-	g_object_unref (polkit_gnome_proxy);
b67bf81
-
b67bf81
-        return ret;
b67bf81
-}
b67bf81
-
b67bf81
 static gint
b67bf81
 can_do (const gchar *pk_action_id)
b67bf81
 {
b67bf81
@@ -269,7 +167,9 @@
b67bf81
 
b67bf81
 typedef struct {
b67bf81
 	gint ref_count;
b67bf81
+        gchar *call;
b67bf81
 	gint64 time;
b67bf81
+	gchar *filename;
b67bf81
 	GFunc callback;
b67bf81
 	gpointer data;
b67bf81
 	GDestroyNotify notify;
b67bf81
@@ -284,6 +184,7 @@
b67bf81
 	if (data->ref_count == 0) {
b67bf81
 		if (data->notify)
b67bf81
 			data->notify (data->data);
b67bf81
+		g_free (data->filename);
b67bf81
 		g_free (data);
b67bf81
 	}
b67bf81
 }
b67bf81
@@ -392,16 +293,28 @@
b67bf81
 					   "org.gnome.ClockApplet.Mechanism");
b67bf81
 
b67bf81
 	data->ref_count++;
b67bf81
-	dbus_g_proxy_begin_call_with_timeout (proxy, 
b67bf81
-					      "SetTime",
b67bf81
-					      set_time_notify,
b67bf81
-					      data, free_data,
b67bf81
-					      INT_MAX,
b67bf81
-					      /* parameters: */
b67bf81
-					      G_TYPE_INT64, data->time,
b67bf81
-					      G_TYPE_INVALID,
b67bf81
-					      /* return values: */
b67bf81
-					      G_TYPE_INVALID);
b67bf81
+	if (strcmp (data->call, "SetTime") == 0)
b67bf81
+		dbus_g_proxy_begin_call_with_timeout (proxy, 
b67bf81
+						      "SetTime",
b67bf81
+						      set_time_notify,
b67bf81
+						      data, free_data,
b67bf81
+						      INT_MAX,
b67bf81
+						      /* parameters: */
b67bf81
+						      G_TYPE_INT64, data->time,
b67bf81
+						      G_TYPE_INVALID,
b67bf81
+						      /* return values: */
b67bf81
+						      G_TYPE_INVALID);
b67bf81
+	else 
b67bf81
+		dbus_g_proxy_begin_call_with_timeout (proxy, 
b67bf81
+						      "SetTimezone",
b67bf81
+						      set_time_notify,
b67bf81
+						      data, free_data,
b67bf81
+						      INT_MAX,
b67bf81
+						      /* parameters: */
b67bf81
+						      G_TYPE_STRING, data->filename,
b67bf81
+						      G_TYPE_INVALID,
b67bf81
+						      /* return values: */
b67bf81
+						      G_TYPE_INVALID);
b67bf81
 }
b67bf81
 
b67bf81
 void
b67bf81
@@ -417,7 +330,33 @@
b67bf81
 
b67bf81
 	data = g_new (SetTimeCallbackData, 1);
b67bf81
 	data->ref_count = 1;
b67bf81
+	data->call = "SetTime";
b67bf81
 	data->time = time;
b67bf81
+	data->filename = NULL;
b67bf81
+	data->callback = callback;
b67bf81
+	data->data = d;
b67bf81
+	data->notify = notify;
b67bf81
+
b67bf81
+	set_time_async (data);
b67bf81
+	free_data (data);
b67bf81
+}
b67bf81
+
b67bf81
+void
b67bf81
+set_system_timezone_async (const gchar    *filename,
b67bf81
+	             	   GFunc           callback, 
b67bf81
+		           gpointer        d, 
b67bf81
+		           GDestroyNotify  notify)
b67bf81
+{
b67bf81
+	SetTimeCallbackData *data;
b67bf81
+
b67bf81
+	if (filename == NULL)
b67bf81
+		return;
b67bf81
+
b67bf81
+	data = g_new (SetTimeCallbackData, 1);
b67bf81
+	data->ref_count = 1;
b67bf81
+	data->call = "SetTimezone";
b67bf81
+	data->time = -1;
b67bf81
+	data->filename = g_strdup (filename);
b67bf81
 	data->callback = callback;
b67bf81
 	data->data = d;
b67bf81
 	data->notify = notify;
b67bf81
--- gnome-panel-2.21.91/applets/clock/set-timezone.h	2008-02-11 16:15:51.000000000 -0500
b67bf81
+++ hacked/applets/clock/set-timezone.h	2008-02-18 00:48:40.000000000 -0500
b67bf81
@@ -23,8 +23,6 @@
b67bf81
 #include <glib.h>
b67bf81
 #include <time.h>
b67bf81
 
b67bf81
-gboolean set_system_timezone     (const char  *filename, 
b67bf81
-                                  GError     **err);
b67bf81
 gint     can_set_system_timezone (void);
b67bf81
 
b67bf81
 gint     can_set_system_time     (void);
b67bf81
@@ -34,4 +32,9 @@
b67bf81
                                   gpointer       data,
b67bf81
                                   GDestroyNotify notify);
b67bf81
 
b67bf81
+void     set_system_timezone_async   (const gchar    *filename,
b67bf81
+                                      GFunc           callback,
b67bf81
+                                      gpointer        data,
b67bf81
+                                      GDestroyNotify  notify);
b67bf81
+
b67bf81
 #endif
b67bf81
--- gnome-panel-2.21.91/applets/clock/clock-location.h	2008-02-11 16:15:51.000000000 -0500
b67bf81
+++ hacked/applets/clock/clock-location.h	2008-02-18 00:11:57.000000000 -0500
b67bf81
@@ -52,7 +52,10 @@
b67bf81
 void clock_location_localtime (ClockLocation *loc, struct tm *tm);
b67bf81
 
b67bf81
 gboolean clock_location_is_current (ClockLocation *loc);
b67bf81
-gboolean clock_location_make_current (ClockLocation *loc, GError **error);
b67bf81
+void clock_location_make_current (ClockLocation *loc, 
b67bf81
+				  GFunc          callback,
b67bf81
+				  gpointer       data,
b67bf81
+				  GDestroyNotify destroy);
b67bf81
 
b67bf81
 const gchar *clock_location_get_weather_code (ClockLocation *loc);
b67bf81
 void         clock_location_set_weather_code (ClockLocation *loc, const gchar *code);
b67bf81
--- gnome-panel-2.21.91/applets/clock/clock-location.c	2008-02-11 16:15:51.000000000 -0500
b67bf81
+++ hacked/applets/clock/clock-location.c	2008-02-18 00:50:53.000000000 -0500
b67bf81
@@ -667,18 +667,20 @@
b67bf81
         return offset;
b67bf81
 }
b67bf81
 
b67bf81
-gboolean
b67bf81
-clock_location_make_current (ClockLocation *loc, GError **error)
b67bf81
-{
b67bf81
-        ClockLocationPrivate *priv = PRIVATE (loc);
b67bf81
-        gchar *filename;
b67bf81
-        gboolean ret;
b67bf81
+typedef struct {
b67bf81
+	ClockLocation *location;
b67bf81
+	GFunc callback;
b67bf81
+	gpointer data;
b67bf81
+	GDestroyNotify destroy;
b67bf81
+} MakeCurrentData;
b67bf81
 
b67bf81
-        filename = g_build_filename (SYSTEM_ZONEINFODIR, priv->timezone, NULL);
b67bf81
-        ret = set_system_timezone (filename, error);
b67bf81
-        g_free (filename);
b67bf81
+static void
b67bf81
+make_current_cb (gpointer data, GError *error)
b67bf81
+{
b67bf81
+	MakeCurrentData *mcdata = data;
b67bf81
+        ClockLocationPrivate *priv = PRIVATE (mcdata->location);
b67bf81
 
b67bf81
-	if (ret) {
b67bf81
+	if (error == NULL) {
b67bf81
 		/* FIXME this ugly shortcut is necessary until we move the
b67bf81
  	  	 * current timezone tracking to clock.c and emit the
b67bf81
  	 	 * signal from there
b67bf81
@@ -687,7 +689,47 @@
b67bf81
 		current_zone = g_strdup (priv->timezone);
b67bf81
 	}
b67bf81
 
b67bf81
-        return ret;
b67bf81
+	if (mcdata->callback)
b67bf81
+		mcdata->callback (mcdata->data, error);
b67bf81
+	else
b67bf81
+		g_error_free (error);
b67bf81
+}
b67bf81
+
b67bf81
+static void
b67bf81
+free_make_current_data (gpointer data)
b67bf81
+{
b67bf81
+	MakeCurrentData *mcdata = data;
b67bf81
+	
b67bf81
+	if (mcdata->destroy)
b67bf81
+		mcdata->destroy (mcdata->data);
b67bf81
+	
b67bf81
+	g_object_unref (mcdata->location);
b67bf81
+	g_free (mcdata);
b67bf81
+}
b67bf81
+
b67bf81
+void
b67bf81
+clock_location_make_current (ClockLocation *loc, 
b67bf81
+                             GFunc          callback,
b67bf81
+                             gpointer       data,
b67bf81
+                             GDestroyNotify destroy)
b67bf81
+{
b67bf81
+        ClockLocationPrivate *priv = PRIVATE (loc);
b67bf81
+        gchar *filename;
b67bf81
+	MakeCurrentData *mcdata;
b67bf81
+
b67bf81
+	mcdata = g_new (MakeCurrentData, 1);
b67bf81
+
b67bf81
+	mcdata->location = g_object_ref (loc);
b67bf81
+	mcdata->callback = callback;
b67bf81
+	mcdata->data = data;
b67bf81
+	mcdata->destroy = destroy;
b67bf81
+
b67bf81
+        filename = g_build_filename (SYSTEM_ZONEINFODIR, priv->timezone, NULL);
b67bf81
+        set_system_timezone_async (filename, 
b67bf81
+                                   (GFunc)make_current_cb, 
b67bf81
+				   mcdata,
b67bf81
+                                   free_make_current_data);
b67bf81
+        g_free (filename);
b67bf81
 }
b67bf81
 
b67bf81
 const gchar *
b67bf81
--- gnome-panel-2.21.91/applets/clock/clock-location-tile.c	2008-02-18 01:08:29.000000000 -0500
b67bf81
+++ hacked/applets/clock/clock-location-tile.c	2008-02-18 01:10:17.000000000 -0500
b67bf81
@@ -104,7 +104,7 @@
b67bf81
 					      NULL,
b67bf81
 					      g_cclosure_marshal_VOID__VOID,
b67bf81
 					      G_TYPE_NONE, 0);
b67bf81
-	signals[TILE_PRESSED] = g_signal_new ("timezone-set",
b67bf81
+	signals[TIMEZONE_SET] = g_signal_new ("timezone-set",
b67bf81
 					      G_TYPE_FROM_CLASS (g_obj_class),
b67bf81
 					      G_SIGNAL_RUN_FIRST,
b67bf81
 					      G_STRUCT_OFFSET (ClockLocationTileClass, timezone_set),
b67bf81
@@ -171,16 +171,15 @@
b67bf81
 }
b67bf81
 
b67bf81
 static void
b67bf81
-make_current (GtkWidget *widget, ClockLocationTile *tile)
b67bf81
+make_current_cb (gpointer data, GError *error)
b67bf81
 {
b67bf81
-        ClockLocationTilePrivate *priv = PRIVATE (tile);
b67bf81
-        GError *error = NULL;
b67bf81
-        GtkWidget *dialog;
b67bf81
+	ClockLocationTile *tile = data;
b67bf81
+	GtkWidget *dialog;
b67bf81
 
b67bf81
-        if (clock_location_make_current (priv->location, &error)) {
b67bf81
+        if (error == NULL) {
b67bf81
 		g_signal_emit (tile, signals[TIMEZONE_SET], 0);
b67bf81
         }
b67bf81
-        else if (error) {
b67bf81
+        else {
b67bf81
                 dialog = gtk_message_dialog_new (NULL,
b67bf81
                                                  0,
b67bf81
                                                  GTK_MESSAGE_ERROR,
b67bf81
@@ -195,6 +194,15 @@
b67bf81
         }
b67bf81
 }
b67bf81
 
b67bf81
+static void
b67bf81
+make_current (GtkWidget *widget, ClockLocationTile *tile)
b67bf81
+{
b67bf81
+        ClockLocationTilePrivate *priv = PRIVATE (tile);
b67bf81
+
b67bf81
+	clock_location_make_current (priv->location, 
b67bf81
+				     (GFunc)make_current_cb, tile, NULL);
b67bf81
+}
b67bf81
+
b67bf81
 static gboolean
b67bf81
 enter_or_leave_tile (GtkWidget             *widget,
b67bf81
                      GdkEventCrossing      *event,