gnome-panel r10991 - trunk/applets/clock
- From: vuntz svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-panel r10991 - trunk/applets/clock
- Date: Mon, 7 Apr 2008 18:47:47 +0100 (BST)
Author: vuntz
Date: Mon Apr 7 18:47:46 2008
New Revision: 10991
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=10991&view=rev
Log:
2008-04-07 Vincent Untz <vuntz gnome org>
Handle multiple locations in the same timezone in a better way.
Patch by Matthias Clasen <mclasen redhat com>
Fix bug #520212.
Matthias had committed the clock.c part of this patch by accident in
commit 10968 (when converting to GtkDialog).
* clock-location-tile.[ch]: (clock_location_tile_class_init),
(make_current_cb), (enter_or_leave_tile),
(clock_location_tile_fill): remove the timezone-set signal
* clock-location.[ch]: We now have the current location.
(clock_location_class_init): add new set-current signal
(clock_location_is_current_timezone): updated for clarity
(clock_location_is_current): new
(make_current_cb): updated, to update the static variable containing
the current location
(clock_location_make_current): ditto, and don't change timezone if
we're already in the right one, just change the current location
* clock.c: (locations_changed): remove FIXME
(location_start_element): only mark the location as the current one if
it's in the current timezone. Else, this means changing the system
timezone each time the applet starts, which is kind of wrong.
Modified:
trunk/applets/clock/ChangeLog
trunk/applets/clock/clock-location-tile.c
trunk/applets/clock/clock-location-tile.h
trunk/applets/clock/clock-location.c
trunk/applets/clock/clock-location.h
trunk/applets/clock/clock.c
Modified: trunk/applets/clock/clock-location-tile.c
==============================================================================
--- trunk/applets/clock/clock-location-tile.c (original)
+++ trunk/applets/clock/clock-location-tile.c Mon Apr 7 18:47:46 2008
@@ -19,7 +19,6 @@
enum {
TILE_PRESSED,
- TIMEZONE_SET,
NEED_CLOCK_FORMAT,
LAST_SIGNAL
};
@@ -106,14 +105,6 @@
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- 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),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
signals[NEED_CLOCK_FORMAT] = g_signal_new ("need-clock-format",
G_TYPE_FROM_CLASS (g_obj_class),
G_SIGNAL_RUN_LAST,
@@ -180,13 +171,9 @@
static void
make_current_cb (gpointer data, GError *error)
{
- ClockLocationTile *tile = data;
GtkWidget *dialog;
- if (error == NULL) {
- g_signal_emit (tile, signals[TIMEZONE_SET], 0);
- }
- else {
+ if (error) {
dialog = gtk_message_dialog_new (NULL,
0,
GTK_MESSAGE_ERROR,
@@ -232,7 +219,10 @@
if (event->type == GDK_ENTER_NOTIFY) {
gint can_set;
- can_set = can_set_system_timezone ();
+ if (clock_location_is_current_timezone (priv->location))
+ can_set = 2;
+ else
+ can_set = can_set_system_timezone ();
if (can_set != 0) {
gtk_label_set_markup (GTK_LABEL (priv->current_label),
can_set == 1 ?
@@ -320,6 +310,7 @@
gtk_widget_show (priv->current_label);
gtk_widget_set_no_show_all (priv->current_button, TRUE);
gtk_container_add (GTK_CONTAINER (priv->current_button), priv->current_label);
+ /* FIXME: this needs to talk about locations, not timezones */
gtk_widget_set_tooltip_text (priv->current_button, _("Set as current timezone for this computer"));
priv->current_marker = gtk_image_new_from_icon_name ("go-home", GTK_ICON_SIZE_BUTTON);
Modified: trunk/applets/clock/clock-location-tile.h
==============================================================================
--- trunk/applets/clock/clock-location-tile.h (original)
+++ trunk/applets/clock/clock-location-tile.h Mon Apr 7 18:47:46 2008
@@ -26,7 +26,6 @@
GtkAlignmentClass parent_class;
void (* tile_pressed) (ClockLocationTile *tile);
- void (* timezone_set) (ClockLocationTile *tile);
int (* need_clock_format) (ClockLocationTile *tile);
} ClockLocationTileClass;
Modified: trunk/applets/clock/clock-location.c
==============================================================================
--- trunk/applets/clock/clock-location.c (original)
+++ trunk/applets/clock/clock-location.c Mon Apr 7 18:47:46 2008
@@ -50,6 +50,7 @@
enum {
WEATHER_UPDATED,
+ SET_CURRENT,
LAST_SIGNAL
};
@@ -231,6 +232,7 @@
}
static gchar *current_zone = NULL;
+static ClockLocation *current_location = NULL;
static GFileMonitor *monitor = NULL;
static void
@@ -408,6 +410,15 @@
_clock_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
+ location_signals[SET_CURRENT] =
+ g_signal_new ("set-current",
+ G_OBJECT_CLASS_TYPE (g_obj_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (ClockLocationClass, set_current),
+ NULL, NULL,
+ _clock_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
g_type_class_add_private (this_class, sizeof (ClockLocationPrivate));
}
@@ -481,7 +492,7 @@
G_OBJECT_CLASS (clock_location_parent_class)->finalize (g_obj);
}
-gchar *
+const gchar *
clock_location_get_name (ClockLocation *loc)
{
ClockLocationPrivate *priv = PRIVATE (loc);
@@ -628,15 +639,35 @@
}
gboolean
-clock_location_is_current (ClockLocation *loc)
+clock_location_is_current_timezone (ClockLocation *loc)
{
ClockLocationPrivate *priv = PRIVATE (loc);
const char *zone;
if ((zone = zone_from_etc_sysconfig_clock ()))
return strcmp (zone, priv->timezone) == 0;
+ else
+ return clock_location_get_offset (loc) == 0;
+}
- return clock_location_get_offset (loc) == 0;
+gboolean
+clock_location_is_current (ClockLocation *loc)
+{
+
+ if (current_location == loc)
+ return TRUE;
+ else if (current_location != NULL)
+ return FALSE;
+
+ if (clock_location_is_current_timezone (loc)) {
+ current_location = loc;
+ g_object_add_weak_pointer (G_OBJECT (current_location),
+ (gpointer *)¤t_location);
+
+ return TRUE;
+ }
+
+ return FALSE;
}
@@ -699,6 +730,15 @@
*/
g_free (current_zone);
current_zone = g_strdup (priv->timezone);
+
+ if (current_location)
+ g_object_remove_weak_pointer (G_OBJECT (current_location),
+ (gpointer *)¤t_location);
+ current_location = mcdata->location;
+ g_object_add_weak_pointer (G_OBJECT (current_location),
+ (gpointer *)¤t_location);
+ g_signal_emit (current_location, location_signals[SET_CURRENT],
+ 0, NULL);
}
if (mcdata->callback)
@@ -729,6 +769,22 @@
gchar *filename;
MakeCurrentData *mcdata;
+ if (clock_location_is_current_timezone (loc)) {
+ if (current_location)
+ g_object_remove_weak_pointer (G_OBJECT (current_location),
+ (gpointer *)¤t_location);
+ current_location = loc;
+ g_object_add_weak_pointer (G_OBJECT (current_location),
+ (gpointer *)¤t_location);
+ g_signal_emit (current_location, location_signals[SET_CURRENT],
+ 0, NULL);
+ if (callback)
+ callback (data, NULL);
+ if (destroy)
+ destroy (data);
+ return;
+ }
+
mcdata = g_new (MakeCurrentData, 1);
mcdata->location = g_object_ref (loc);
Modified: trunk/applets/clock/clock-location.h
==============================================================================
--- trunk/applets/clock/clock-location.h (original)
+++ trunk/applets/clock/clock-location.h Mon Apr 7 18:47:46 2008
@@ -27,6 +27,8 @@
GObjectClass g_object_class;
void (* weather_updated) (ClockLocation *location, WeatherInfo *info);
+
+ void (* set_current) (ClockLocation *location);
} ClockLocationClass;
GType clock_location_get_type (void);
@@ -40,7 +42,7 @@
gchar *clock_location_get_tzname (ClockLocation *loc);
-gchar *clock_location_get_name (ClockLocation *loc);
+const gchar *clock_location_get_name (ClockLocation *loc);
void clock_location_set_name (ClockLocation *loc, const gchar *name);
gchar *clock_location_get_timezone (ClockLocation *loc);
@@ -56,6 +58,7 @@
GFunc callback,
gpointer data,
GDestroyNotify destroy);
+gboolean clock_location_is_current_timezone (ClockLocation *loc);
const gchar *clock_location_get_weather_code (ClockLocation *loc);
void clock_location_set_weather_code (ClockLocation *loc, const gchar *code);
Modified: trunk/applets/clock/clock.c
==============================================================================
--- trunk/applets/clock/clock.c (original)
+++ trunk/applets/clock/clock.c Mon Apr 7 18:47:46 2008
@@ -2101,7 +2101,6 @@
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));
- /* FIXME: there's no such signal? */
g_signal_connect (loc, "set-current",
G_CALLBACK (location_set_current_cb), cd);
}
@@ -2189,7 +2188,7 @@
loc = clock_location_new (name, timezone, latitude, longitude, code, &prefs);
- if (current)
+ if (current && clock_location_is_current_timezone (loc))
clock_location_make_current (loc, NULL, NULL, NULL);
data->cities = g_list_append (data->cities, loc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]