rpms/gnome-panel/devel async-timezone.patch, NONE, 1.1 gnome-panel.spec, 1.260, 1.261

Matthias Clasen (mclasen) fedora-extras-commits at redhat.com
Mon Feb 18 06:16:07 UTC 2008


Author: mclasen

Update of /cvs/extras/rpms/gnome-panel/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10727

Modified Files:
	gnome-panel.spec 
Added Files:
	async-timezone.patch 
Log Message:
more intlclock fixes


async-timezone.patch:

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


Index: gnome-panel.spec
===================================================================
RCS file: /cvs/extras/rpms/gnome-panel/devel/gnome-panel.spec,v
retrieving revision 1.260
retrieving revision 1.261
diff -u -r1.260 -r1.261
--- gnome-panel.spec	18 Feb 2008 05:46:37 -0000	1.260
+++ gnome-panel.spec	18 Feb 2008 06:15:13 -0000	1.261
@@ -120,6 +120,9 @@
 # fix display of weather in the panel button
 Patch18: panel-weather.patch
 
+# make timezone setting asynchronous
+Patch19: async-timezone.patch
+
 Conflicts: gnome-power-manager < 2.15.3
 
 %description
@@ -169,6 +172,7 @@
 %patch16 -p1 -b .pref-dialogs
 %patch17 -p1 -b .set-button
 %patch18 -p1 -b .panel-weather
+%patch19 -p1 -b .async-timezone
 
 . %{SOURCE6}
 




More information about the fedora-extras-commits mailing list