diff options
author | Matthias Clasen <mclasen@fedoraproject.org> | 2008-02-18 06:15:13 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@fedoraproject.org> | 2008-02-18 06:15:13 +0000 |
commit | b67bf81901f12fa6bf1149493d24a3272bb71758 (patch) | |
tree | 9ddfa15d9616048a3b22b4791aca665ccc7de6e3 | |
parent | a12f50864f61e496de42a92fe098e3d8cc85d396 (diff) | |
download | gnome-panel-b67bf81901f12fa6bf1149493d24a3272bb71758.tar.gz gnome-panel-b67bf81901f12fa6bf1149493d24a3272bb71758.tar.xz gnome-panel-b67bf81901f12fa6bf1149493d24a3272bb71758.zip |
more intlclock fixesgnome-panel-2_21_91-4_fc9
-rw-r--r-- | async-timezone.patch | 368 | ||||
-rw-r--r-- | gnome-panel.spec | 4 | ||||
-rw-r--r-- | panel-weather.patch | 271 |
3 files changed, 643 insertions, 0 deletions
diff --git a/async-timezone.patch b/async-timezone.patch new file mode 100644 index 0000000..7a3ce7c --- /dev/null +++ b/async-timezone.patch @@ -0,0 +1,368 @@ +--- 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, diff --git a/gnome-panel.spec b/gnome-panel.spec index c744c23..bc4e278 100644 --- a/gnome-panel.spec +++ b/gnome-panel.spec @@ -120,6 +120,9 @@ Patch17: set-button.patch # 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 @@ Panel Applets using the libpanel-applet library. %patch16 -p1 -b .pref-dialogs %patch17 -p1 -b .set-button %patch18 -p1 -b .panel-weather +%patch19 -p1 -b .async-timezone . %{SOURCE6} diff --git a/panel-weather.patch b/panel-weather.patch new file mode 100644 index 0000000..97cc508 --- /dev/null +++ b/panel-weather.patch @@ -0,0 +1,271 @@ +diff -up gnome-panel-2.21.91/applets/clock/clock.c.panel-weather gnome-panel-2.21.91/applets/clock/clock.c +--- gnome-panel-2.21.91/applets/clock/clock.c.panel-weather 2008-02-17 21:54:50.000000000 -0500 ++++ gnome-panel-2.21.91/applets/clock/clock.c 2008-02-17 22:06:23.000000000 -0500 +@@ -211,6 +211,7 @@ struct _ClockData { + + static void update_clock (ClockData * cd); + static void update_tooltip (ClockData * cd); ++static void update_panel_weather (ClockData *cd); + static int clock_timeout_callback (gpointer data); + static float get_itime (time_t current_time); + +@@ -1131,8 +1132,6 @@ create_cities_section (ClockData *cd) + G_CALLBACK (location_tile_pressed_cb), cd); + g_signal_connect (city, "timezone-set", + G_CALLBACK (location_tile_timezone_set_cb), cd); +- g_signal_connect (city, "weather-updated", +- G_CALLBACK (location_tile_weather_updated_cb), cd); + g_signal_connect (city, "need-clock-format", + G_CALLBACK (location_tile_need_clock_format_cb), cd); + +@@ -1299,7 +1298,6 @@ create_main_clock_button (void) + GtkWidget *button; + + button = gtk_toggle_button_new (); +- gtk_container_set_resize_mode (GTK_CONTAINER (button), GTK_RESIZE_IMMEDIATE); + gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); + + force_no_focus_padding (button); +@@ -1408,6 +1406,8 @@ create_clock_widget (ClockData *cd) + cd->orient = -1; + cd->size = panel_applet_get_size (PANEL_APPLET (cd->applet)); + ++ update_panel_weather (cd); ++ + /* Refresh the clock so that it paints its first state */ + refresh_clock_timeout (cd); + applet_change_orient (PANEL_APPLET (cd->applet), +@@ -1974,9 +1974,6 @@ show_date_changed (GConfClient *client, + static void + update_panel_weather (ClockData *cd) + { +- GtkWidget *weatherbox; +- +- weatherbox = gtk_widget_get_parent (cd->panel_weather_icon); + if (cd->show_weather) + gtk_widget_show (cd->panel_weather_icon); + else +@@ -1988,9 +1985,11 @@ update_panel_weather (ClockData *cd) + gtk_widget_hide (cd->panel_temperature_label); + + if (cd->show_weather || cd->show_temperature) +- gtk_widget_show (weatherbox); ++ gtk_widget_show (cd->weather_obox); + else +- gtk_widget_hide (weatherbox); ++ gtk_widget_hide (cd->weather_obox); ++ ++ gtk_widget_queue_resize (cd->applet); + } + + static void +@@ -2036,17 +2035,64 @@ show_temperature_changed (GConfClient * + } + + static void +-set_locations (ClockData *cd, GList *locations) ++location_weather_updated_cb (ClockLocation *location, ++ WeatherInfo *info, ++ gpointer data) + { +- free_locations (cd); ++ ClockData *cd = data; ++ const gchar *icon_name; ++ const gchar *temp; ++ GtkIconTheme *theme; ++ GdkPixbuf *pixbuf; + +- cd->locations = locations; ++ if (!info || !weather_info_is_valid (info)) ++ return; + +- if (cd->map_widget) +- clock_map_refresh (CLOCK_MAP (cd->map_widget)); ++ if (!clock_location_is_current (location)) ++ return; ++ ++ icon_name = weather_info_get_icon_name (info); ++ theme = gtk_icon_theme_get_default (); ++ pixbuf = gtk_icon_theme_load_icon (theme, icon_name, 16, 0, NULL); ++ ++ temp = weather_info_get_temp_summary (info); ++ ++ gtk_image_set_from_pixbuf (GTK_IMAGE (cd->panel_weather_icon), pixbuf); ++ gtk_label_set_text (GTK_LABEL (cd->panel_temperature_label), temp); ++} ++ ++static void ++locations_changed (ClockData *cd) ++{ ++ GList *l; ++ ClockLocation *loc; ++ glong id; ++ ++ for (l = cd->locations; l; l = l->next) { ++ loc = l->data; ++ ++ id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (loc), "weather-updated")); ++ if (id == 0) { ++ id = g_signal_connect (loc, "weather-updated", ++ G_CALLBACK (location_weather_updated_cb), cd); ++ g_object_set_data (G_OBJECT (loc), "weather-updated", GINT_TO_POINTER (id)); ++ } ++ } ++ ++ if (cd->map_widget) ++ clock_map_refresh (CLOCK_MAP (cd->map_widget)); + + if (cd->clock_vbox) +- create_cities_section (cd); ++ create_cities_section (cd); ++} ++ ++ ++static void ++set_locations (ClockData *cd, GList *locations) ++{ ++ free_locations (cd); ++ cd->locations = locations; ++ locations_changed (cd); + } + + typedef struct { +@@ -2948,7 +2994,6 @@ run_prefs_edit_save (GtkButton *button, + clock_location_set_coords (loc, lat, lon); + clock_location_set_weather_code (loc, weather_code); + } else { +- GList *locs; + WeatherPrefs prefs; + + prefs.temperature_unit = cd->temperature_unit; +@@ -2956,9 +3001,8 @@ run_prefs_edit_save (GtkButton *button, + + loc = clock_location_new (name, clock_zoneinfo_get_name (info), lat, lon, weather_code, &prefs); + +- locs = g_list_copy (cd->locations); +- locs = g_list_append (locs, loc); +- set_locations (cd, locs); ++ cd->locations = g_list_append (cd->locations, loc); ++ locations_changed (cd); + } + + save_cities_store (cd); +@@ -3522,14 +3566,13 @@ remove_tree_row (GtkTreeModel *model, Gt + { + ClockData *cd = data; + ClockLocation *loc = NULL; +- GList *list = g_list_copy (cd->locations); + + gtk_tree_model_get (model, iter, COL_CITY_LOC, &loc, -1); + +- list = g_list_remove (list, loc); +- + gtk_list_store_remove (cd->cities_store, iter); +- set_locations (cd, list); ++ cd->locations = g_list_remove (cd->locations, loc); ++ locations_changed (cd); ++ g_object_unref (loc); + + save_cities_store (cd); + } +diff -up gnome-panel-2.21.91/applets/clock/clock-location-tile.c.panel-weather gnome-panel-2.21.91/applets/clock/clock-location-tile.c +--- gnome-panel-2.21.91/applets/clock/clock-location-tile.c.panel-weather 2008-02-17 21:54:42.000000000 -0500 ++++ gnome-panel-2.21.91/applets/clock/clock-location-tile.c 2008-02-17 22:06:39.000000000 -0500 +@@ -20,7 +20,6 @@ G_DEFINE_TYPE (ClockLocationTile, clock_ + enum { + TILE_PRESSED, + TIMEZONE_SET, +- WEATHER_UPDATED, + NEED_CLOCK_FORMAT, + LAST_SIGNAL + }; +@@ -113,17 +112,6 @@ clock_location_tile_class_init (ClockLoc + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); +- signals[WEATHER_UPDATED] = g_signal_new ("weather-updated", +- G_TYPE_FROM_CLASS (g_obj_class), +- G_SIGNAL_RUN_FIRST, +- G_STRUCT_OFFSET (ClockLocationTileClass, weather_updated), +- NULL, +- NULL, +- _clock_marshal_VOID__OBJECT_STRING, +- G_TYPE_NONE, 2, +- G_TYPE_OBJECT, +- G_TYPE_STRING); +- + signals[NEED_CLOCK_FORMAT] = g_signal_new ("need-clock-format", + G_TYPE_FROM_CLASS (g_obj_class), + G_SIGNAL_RUN_LAST, +@@ -377,12 +365,6 @@ copy_tm (struct tm *from, struct tm *to) + to->tm_yday = from->tm_yday; + } + +-static void +-emit_weather_updated (ClockLocationTile *this, GdkPixbuf *weather_icon, const char *temperature) +-{ +- g_signal_emit (this, signals[WEATHER_UPDATED], 0, weather_icon, temperature); +-} +- + static char * + format_time (struct tm *now, + char *tzname, +@@ -447,23 +429,12 @@ clock_location_tile_refresh (ClockLocati + ClockLocationTilePrivate *priv = PRIVATE (this); + gchar *tmp, *tzname; + struct tm now; +- long offset, hours, minutes; ++ long offset; + int format; + + g_return_if_fail (IS_CLOCK_LOCATION_TILE (this)); + + if (clock_location_is_current (priv->location)) { +- if (!GTK_WIDGET_VISIBLE (priv->current_marker)) { +- GdkPixbuf *pixbuf; +- const gchar *temp = NULL; +- +- pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (priv->weather_icon)); +- if (clock_location_get_weather_info (priv->location)) +- temp = weather_info_get_temp_summary (clock_location_get_weather_info (priv->location)); +- +- emit_weather_updated (this, pixbuf, temp); +- } +- + gtk_widget_hide (priv->current_button); + gtk_widget_show (priv->current_marker); + } +@@ -582,7 +553,6 @@ update_weather_icon (ClockLocation *loc, + GdkPixbuf *pixbuf = NULL; + GtkIconTheme *theme = NULL; + const gchar *icon_name; +- const gchar *temp = NULL; + + if (!info || !weather_info_is_valid (info)) + return; +@@ -591,14 +561,9 @@ update_weather_icon (ClockLocation *loc, + theme = gtk_icon_theme_get_default (); + pixbuf = gtk_icon_theme_load_icon (theme, icon_name, 16, 0, NULL); + +- temp = weather_info_get_temp_summary (info); +- + if (pixbuf) { + gtk_image_set_from_pixbuf (GTK_IMAGE (priv->weather_icon), pixbuf); + gtk_alignment_set_padding (GTK_ALIGNMENT (gtk_widget_get_parent (priv->weather_icon)), 0, 0, 0, 6); +- if (clock_location_is_current (loc)) { +- emit_weather_updated (tile, pixbuf, temp); +- } + } + } + +diff -up gnome-panel-2.21.91/applets/clock/clock-location-tile.h.panel-weather gnome-panel-2.21.91/applets/clock/clock-location-tile.h +--- gnome-panel-2.21.91/applets/clock/clock-location-tile.h.panel-weather 2008-02-17 21:54:33.000000000 -0500 ++++ gnome-panel-2.21.91/applets/clock/clock-location-tile.h 2008-02-17 21:54:59.000000000 -0500 +@@ -27,7 +27,6 @@ typedef struct + + void (* tile_pressed) (ClockLocationTile *tile); + void (* timezone_set) (ClockLocationTile *tile); +- void (* weather_updated) (ClockLocationTile *tile, GdkPixbuf *weather_icon, const char *temperature); + int (* need_clock_format) (ClockLocationTile *tile); + } ClockLocationTileClass; + |