rpms/gnome-panel/devel current.patch, NONE, 1.1 gnome-panel.spec, 1.271, 1.272

Matthias Clasen (mclasen) fedora-extras-commits at redhat.com
Tue Mar 4 00:06:34 UTC 2008


Author: mclasen

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

Modified Files:
	gnome-panel.spec 
Added Files:
	current.patch 
Log Message:
Make the clock applet handle multiple locations in the
same timezone meaningfully


current.patch:

--- NEW FILE current.patch ---
diff -up gnome-panel-2.21.92/applets/clock/clock-location.h.current gnome-panel-2.21.92/applets/clock/clock-location.h
--- gnome-panel-2.21.92/applets/clock/clock-location.h.current	2008-02-26 08:17:49.000000000 -0500
+++ gnome-panel-2.21.92/applets/clock/clock-location.h	2008-03-03 17:53:43.000000000 -0500
@@ -27,6 +27,8 @@ typedef struct
         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 @@ ClockLocation *clock_location_new_from_e
 
 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 @@ void clock_location_make_current (ClockL
 				  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);
diff -up gnome-panel-2.21.92/applets/clock/clock-location-tile.c.current gnome-panel-2.21.92/applets/clock/clock-location-tile.c
--- gnome-panel-2.21.92/applets/clock/clock-location-tile.c.current	2008-03-03 13:52:38.000000000 -0500
+++ gnome-panel-2.21.92/applets/clock/clock-location-tile.c	2008-03-03 18:59:59.000000000 -0500
@@ -19,7 +19,6 @@ G_DEFINE_TYPE (ClockLocationTile, clock_
 
 enum {
 	TILE_PRESSED,
-	TIMEZONE_SET,
 	NEED_CLOCK_FORMAT,
 	LAST_SIGNAL
 };
@@ -106,14 +105,6 @@ clock_location_tile_class_init (ClockLoc
 					      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 @@ press_on_tile      (GtkWidget           
 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 @@ enter_or_leave_tile (GtkWidget          
 	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 ?
@@ -317,6 +307,7 @@ clock_location_tile_fill (ClockLocationT
         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);
diff -up gnome-panel-2.21.92/applets/clock/clock.c.current gnome-panel-2.21.92/applets/clock/clock.c
--- gnome-panel-2.21.92/applets/clock/clock.c.current	2008-03-03 15:51:48.000000000 -0500
+++ gnome-panel-2.21.92/applets/clock/clock.c	2008-03-03 19:01:31.000000000 -0500
@@ -237,6 +237,7 @@ static void applet_change_orient (PanelA
 				  ClockData         *cd);
 
 static void edit_hide (GtkWidget *unused, ClockData *cd);
+static void save_cities_store (ClockData *cd);
 
 static void
 unfix_size (ClockData *cd)
@@ -962,8 +963,8 @@ sort_locations_by_name (gconstpointer a,
         ClockLocation *loc_a = (ClockLocation *) a;
         ClockLocation *loc_b = (ClockLocation *) b;
 
-        char *name_a = clock_location_get_name (loc_a);
-        char *name_b = clock_location_get_name (loc_b);
+        const char *name_a = clock_location_get_name (loc_a);
+        const char *name_b = clock_location_get_name (loc_b);
 
         return strcmp (name_a, name_b);
 }
@@ -1069,15 +1070,6 @@ location_tile_pressed_cb (ClockLocationT
 }
 
 static void
-location_tile_timezone_set_cb (ClockLocationTile *tile, gpointer data)
-{
-        ClockData *cd = data;
-
-        clock_map_refresh (CLOCK_MAP (cd->map_widget));
-	update_location_tiles (cd);
-}
-
-static void
 location_tile_weather_updated_cb (ClockLocationTile *tile, GdkPixbuf *weather_icon, const char *temperature, gpointer data)
 {
         ClockData *cd = data;
@@ -1131,8 +1123,6 @@ create_cities_section (ClockData *cd)
                 city = clock_location_tile_new (loc, CLOCK_FACE_SMALL);
                 g_signal_connect (city, "tile-pressed",
                                   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, "need-clock-format",
                                   G_CALLBACK (location_tile_need_clock_format_cb), cd);
 
@@ -2064,6 +2054,21 @@ location_weather_updated_cb (ClockLocati
 }
 
 static void
+location_set_current_cb (ClockLocation *loc, 
+			 gpointer       data)
+{
+	ClockData *cd = data;
+	WeatherInfo *info;
+
+	info = clock_location_get_weather_info (loc);
+	location_weather_updated_cb (loc, info, cd);
+
+        clock_map_refresh (CLOCK_MAP (cd->map_widget));
+        update_location_tiles (cd);
+	save_cities_store (cd);	
+}
+
+static void
 locations_changed (ClockData *cd)
 {
 	GList *l;
@@ -2078,6 +2083,8 @@ locations_changed (ClockData *cd)
 			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));
+			g_signal_connect (loc, "set-current", 
+					  G_CALLBACK (location_set_current_cb), cd);
 		}
 	}
 
@@ -2122,6 +2129,7 @@ location_start_element (GMarkupParseCont
         gfloat latitude = 0.0;
         gfloat longitude = 0.0;
 	gchar *code = NULL;
+	gboolean current = FALSE;
 
         int index = 0;
 
@@ -2147,6 +2155,11 @@ location_start_element (GMarkupParseCont
                 } else if (strcmp (att_name, "code") == 0) {
                         code = (gchar *)attribute_values[index];
                 }
+		else if (strcmp (att_name, "current") == 0) {
+			if (strcmp (attribute_values[index], "true") == 0) {
+				current = TRUE;
+			}
+		}
         }
 
         setlocale (LC_NUMERIC, "");
@@ -2157,6 +2170,9 @@ location_start_element (GMarkupParseCont
 
         loc = clock_location_new (name, timezone, latitude, longitude, code, &prefs);
 
+	if (current)
+		clock_location_make_current (loc, NULL, NULL, NULL);
+
         data->cities = g_list_append (data->cities, loc);
 }
 
@@ -2912,13 +2928,14 @@ loc_to_string (ClockLocation *loc)
         clock_location_get_coords (loc, &latitude, &longitude);
 
         prev_locale = setlocale (LC_NUMERIC, "POSIX");
-
+	
         ret = g_markup_printf_escaped
-                ("<location name=\"%s\" timezone=\"%s\" latitude=\"%f\" longitude=\"%f\" code=\"%s\"/>",
+                ("<location name=\"%s\" timezone=\"%s\" latitude=\"%f\" longitude=\"%f\" code=\"%s\" current=\"%s\"/>",
                  clock_location_get_name (loc),
                  clock_location_get_timezone (loc),
                  latitude, longitude,
-		 clock_location_get_weather_code (loc));
+		 clock_location_get_weather_code (loc),
+		 clock_location_is_current (loc) ? "true" : "false");
 
         setlocale (LC_NUMERIC, "");
 
diff -up gnome-panel-2.21.92/applets/clock/clock-location-tile.h.current gnome-panel-2.21.92/applets/clock/clock-location-tile.h
--- gnome-panel-2.21.92/applets/clock/clock-location-tile.h.current	2008-03-03 18:58:50.000000000 -0500
+++ gnome-panel-2.21.92/applets/clock/clock-location-tile.h	2008-03-03 18:58:58.000000000 -0500
@@ -26,7 +26,6 @@ typedef struct
         GtkAlignmentClass parent_class;
 
 	void (* tile_pressed) (ClockLocationTile *tile);
-	void (* timezone_set) (ClockLocationTile *tile);
         int  (* need_clock_format) (ClockLocationTile *tile);
 } ClockLocationTileClass;
 
diff -up gnome-panel-2.21.92/applets/clock/clock-location.c.current gnome-panel-2.21.92/applets/clock/clock-location.c
--- gnome-panel-2.21.92/applets/clock/clock-location.c.current	2008-02-26 08:17:49.000000000 -0500
+++ gnome-panel-2.21.92/applets/clock/clock-location.c	2008-03-03 19:01:45.000000000 -0500
@@ -51,6 +51,7 @@ typedef struct {
 
 enum {
 	WEATHER_UPDATED,
+	SET_CURRENT,
 	LAST_SIGNAL
 };
 
@@ -232,6 +233,7 @@ guess_zone_from_tree (const gchar *local
 }
 
 static gchar *current_zone = NULL;
+static ClockLocation *current_location = NULL;
 static GFileMonitor *monitor = NULL;
 
 static void
@@ -409,6 +411,15 @@ clock_location_class_init (ClockLocation
 			      _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));
 }
 
@@ -482,7 +493,7 @@ clock_location_finalize (GObject *g_obj)
         G_OBJECT_CLASS (clock_location_parent_class)->finalize (g_obj);
 }
 
-gchar *
+const gchar *
 clock_location_get_name (ClockLocation *loc)
 {
         ClockLocationPrivate *priv = PRIVATE (loc);
@@ -629,15 +640,37 @@ clock_location_localtime (ClockLocation 
 }
 
 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 ()))
+	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 *)&current_location);
+
+		return TRUE;
+	}
+
+	return FALSE;
 }
 
 
@@ -700,6 +733,15 @@ make_current_cb (gpointer data, GError *
  	 	 */
 		g_free (current_zone);
 		current_zone = g_strdup (priv->timezone);
+
+		if (current_location)
+			g_object_remove_weak_pointer (G_OBJECT (current_location), 
+						      (gpointer *)&current_location);
+		current_location = mcdata->location;
+		g_object_add_weak_pointer (G_OBJECT (current_location), 
+					   (gpointer *)&current_location);
+		g_signal_emit (current_location, location_signals[SET_CURRENT],
+			       0, NULL);
 	}
 
 	if (mcdata->callback)
@@ -730,6 +772,22 @@ clock_location_make_current (ClockLocati
         gchar *filename;
 	MakeCurrentData *mcdata;
 
+	if (clock_location_is_current_timezone (loc)) {
+		if (current_location)
+			g_object_remove_weak_pointer (G_OBJECT (current_location), 
+						      (gpointer *)&current_location);
+		current_location = loc;
+		g_object_add_weak_pointer (G_OBJECT (current_location), 
+					   (gpointer *)&current_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);


Index: gnome-panel.spec
===================================================================
RCS file: /cvs/extras/rpms/gnome-panel/devel/gnome-panel.spec,v
retrieving revision 1.271
retrieving revision 1.272
diff -u -r1.271 -r1.272
--- gnome-panel.spec	3 Mar 2008 18:02:59 -0000	1.271
+++ gnome-panel.spec	4 Mar 2008 00:05:50 -0000	1.272
@@ -22,7 +22,7 @@
 Summary: GNOME panel
 Name: gnome-panel
 Version: 2.21.92
-Release: 3%{?dist}
+Release: 4%{?dist}
 URL: http://www.gnome.org
 Source0: http://download.gnome.org/sources/gnome-panel/2.21/%{name}-%{version}.tar.bz2
 
@@ -114,6 +114,8 @@
 # http://bugzilla.gnome.org/show_bug.cgi?id=520111
 Patch24: gnome-panel-2.21.92-allow-spurious-view-done-signals.patch
 
+Patch25: current.patch
+
 Conflicts: gnome-power-manager < 2.15.3
 
 %description
@@ -162,6 +164,7 @@
 %patch22 -p1 -b .polkit-fix
 %patch23 -p1 -b .sunrise
 %patch24 -p1 -b .allow-spurious-view-done-signals
+%patch25 -p1 -b .current
 
 . %{SOURCE6}
 
@@ -346,6 +349,10 @@
 %{_datadir}/gtk-doc/html/*
 
 %changelog
+* Mon Mar  3 2008 Matthias Clasen <mclasen at redhat.com> - 2.21.92-4
+- Make the clock applet handle multiple locations in the 
+  same timezone meaningfully
+
 * Mon Mar  3 2008 Matthias Clasen <mclasen at redhat.com> - 2.21.92-3
 - Some upstream clock applet fixes
 




More information about the fedora-extras-commits mailing list