--- gnome-panel-2.12.3/applets/clock/clock.c	2006-02-06 17:52:53.000000000 +0100
+++ fixed/gnome-panel-2.12.3/applets/clock/clock.c	2006-04-01 19:56:58.984729329 +0200
@@ -144,6 +144,8 @@
 	guint              timeout;
 	PanelAppletOrient  orient;
 	int                size;
+        int                width;
+        int                height;
 
 	int fixed_width;
 	int fixed_height;
@@ -178,6 +180,8 @@
                                        GtkWidget         *window,
                                        GtkWidget         *button);
 
+static void update_orient (ClockData *cd);
+
 static void
 unfix_size (ClockData *cd)
 {
@@ -286,6 +290,34 @@
         return PANGO_PIXELS (ascent + descent) + 2 * (focus_width + focus_pad + thickness);
 }
 
+static int
+calculate_minimum_width (GtkWidget        *widget,
+                         PanelAppletOrient orientation,
+                         const gchar *text)
+{
+        PangoContext *context;
+        PangoLayout  *layout;
+        int           width, height;
+        int           focus_width = 0;
+        int           focus_pad = 0;
+        
+        context = gtk_widget_get_pango_context (widget);
+
+        layout = pango_layout_new (context);
+	pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
+	pango_layout_set_text (layout, text, -1);
+	pango_layout_get_pixel_size (layout, &width, &height);
+
+        gtk_widget_style_get (widget,
+                              "focus-line-width", &focus_width,
+                              "focus-padding", &focus_pad,
+                              NULL);
+
+        width += 2*(focus_width+focus_pad+widget->style->xthickness);
+        
+        return width;
+}
+
 static gboolean
 use_two_line_format (ClockData *cd)
 {
@@ -1665,16 +1697,10 @@
 
 	cd->orient = panel_applet_get_orient (PANEL_APPLET (cd->applet));
 
-	/* Initialize label orientation */
-	if (cd->orient == PANEL_APPLET_ORIENT_LEFT)
-		gtk_label_set_angle (GTK_LABEL (cd->clockw), 270);
-	else if (cd->orient == PANEL_APPLET_ORIENT_RIGHT)
-		gtk_label_set_angle (GTK_LABEL (cd->clockw), 90);
-	else
-		gtk_label_set_angle (GTK_LABEL (cd->clockw), 0);
-
 	cd->size = panel_applet_get_size (PANEL_APPLET (cd->applet));
 
+        update_orient(cd);
+        
 	g_signal_connect (G_OBJECT(clock), "destroy",
 			  G_CALLBACK (destroy_clock),
 			  cd);
@@ -1684,24 +1710,36 @@
 
 	/* Refresh the clock so that it paints its first state */
 	refresh_clock_timeout(cd);
+        /* Also update the orientation, now that the clock has gotten it's correct content: */
+        update_orient(cd);
 }
 
-/* this is when the panel orientation changes */
+static void update_orient (ClockData *cd)
+{
+        const gchar *text;
+        int min_width;
+
+        text=gtk_label_get_text (GTK_LABEL (cd->clockw));
+        min_width=calculate_minimum_width(cd->applet, cd->orient, text);
 
+        if (cd->orient == PANEL_APPLET_ORIENT_LEFT && min_width>cd->width)
+		gtk_label_set_angle (GTK_LABEL (cd->clockw), 270);
+	else if (cd->orient == PANEL_APPLET_ORIENT_RIGHT && min_width>cd->width)
+		gtk_label_set_angle (GTK_LABEL (cd->clockw), 90);
+	else
+		gtk_label_set_angle (GTK_LABEL (cd->clockw), 0);
+}
+
+/* this is when the panel orientation changes */
 static void
 applet_change_orient (PanelApplet       *applet,
 		      PanelAppletOrient  orient,
 		      ClockData         *cd)
 {
         cd->orient = orient;
+
+        update_orient(cd);
         
-        if (cd->orient == PANEL_APPLET_ORIENT_LEFT)
-                gtk_label_set_angle (GTK_LABEL (cd->clockw), 270);
-        else if (cd->orient == PANEL_APPLET_ORIENT_RIGHT)
-                gtk_label_set_angle (GTK_LABEL (cd->clockw), 90);
-        else
-                gtk_label_set_angle (GTK_LABEL (cd->clockw), 0);
-	
         unfix_size (cd);
         update_clock (cd);
         update_popup (cd);
@@ -1744,12 +1782,18 @@
 
 /* this is when the panel size changes */
 static void
-applet_change_pixel_size (PanelApplet *applet,
-			  gint         size,
-			  ClockData   *cd)
+applet_change_pixel_size (PanelApplet   *applet,
+			  GtkAllocation *allocation,
+			  ClockData     *cd)
 {
-	cd->size = size;
+        if (cd->width == allocation->width && cd->height == allocation->height) return;
 
+	cd->width = allocation->width;
+	cd->height = allocation->height;
+        cd->size = panel_applet_get_size (applet);
+
+        update_orient(cd);
+        
         unfix_size (cd);
 	update_timeformat (cd);
 	update_clock (cd);
@@ -2294,7 +2338,7 @@
 
 	/* similiar to the above in semantics*/
 	g_signal_connect (G_OBJECT (cd->applet),
-			  "change_size",
+			  "size_allocate",
 			  G_CALLBACK (applet_change_pixel_size),
 			  cd);
 
