--- gnome-panel-2.14.1/applets/clock/clock.c	2006-06-25 15:59:11.519432690 +0200
+++ fixed/gnome-panel-2.14.1/applets/clock/clock.c	2006-06-25 15:36:20.023830399 +0200
@@ -145,6 +145,8 @@ struct _ClockData {
 	guint              timeout;
 	PanelAppletOrient  orient;
 	int                size;
+	int                width;
+	int                height;
 
 	int fixed_width;
 	int fixed_height;
@@ -180,6 +182,7 @@ static void display_about_dialog      (B
 static void position_calendar_popup   (ClockData         *cd,
                                        GtkWidget         *window,
                                        GtkWidget         *button);
+static void update_orient (ClockData *cd);
 
 static void
 unfix_size (ClockData *cd)
@@ -189,6 +192,36 @@ unfix_size (ClockData *cd)
 	gtk_widget_queue_resize (cd->toggle);
 }
 
+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);
+	g_object_unref (G_OBJECT (layout));
+	layout = NULL;
+
+	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 void
 set_tooltip (GtkWidget  *applet,
 	     GtkWidget  *widget,
@@ -434,6 +467,7 @@ update_clock (ClockData * cd)
                 set_tooltip (cd->applet, cd->toggle, _("Click to view month calendar"));
 #endif
         }
+	update_orient (cd);
 }
 
 static void
@@ -1693,14 +1727,6 @@ create_clock_widget (ClockData *cd)
 
 	cd->orient = panel_applet_get_orient (PANEL_APPLET (cd->applet));
 
-	/* Initialize label orientation */
-	if (cd->orient == PANEL_APPLET_ORIENT_RIGHT)
-		gtk_label_set_angle (GTK_LABEL (cd->clockw), 90);
-	else if (cd->orient == PANEL_APPLET_ORIENT_LEFT)
-		gtk_label_set_angle (GTK_LABEL (cd->clockw), 270);
-	else
-		gtk_label_set_angle (GTK_LABEL (cd->clockw), 0);
-
 	cd->size = panel_applet_get_size (PANEL_APPLET (cd->applet));
 
 	g_signal_connect (G_OBJECT(clock), "destroy",
@@ -1714,8 +1740,23 @@ create_clock_widget (ClockData *cd)
 	refresh_clock_timeout(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,
@@ -1723,13 +1764,6 @@ applet_change_orient (PanelApplet       
 {
         cd->orient = orient;
         
-        if (cd->orient == PANEL_APPLET_ORIENT_RIGHT)
-                gtk_label_set_angle (GTK_LABEL (cd->clockw), 90);
-        else if (cd->orient == PANEL_APPLET_ORIENT_LEFT)
-                gtk_label_set_angle (GTK_LABEL (cd->clockw), 270);
-        else
-                gtk_label_set_angle (GTK_LABEL (cd->clockw), 0);
-	
         unfix_size (cd);
         update_clock (cd);
         update_popup (cd);
@@ -1737,22 +1771,15 @@ applet_change_orient (PanelApplet       
 
 /* this is when the panel size changes */
 static void
-applet_change_pixel_size (PanelApplet   *applet,
+applet_change_pixel_size (PanelApplet	*applet,
 			  GtkAllocation *allocation,
-			  ClockData     *cd)
+			  ClockData	*cd)
 {
-	int new_size;
-
-        if (cd->orient == PANEL_APPLET_ORIENT_LEFT ||
-	    cd->orient == PANEL_APPLET_ORIENT_RIGHT)
-		new_size = allocation->width;
-	else
-		new_size = allocation->height;
-
-	if (cd->size == new_size)
-		return;
+	if (cd->width == allocation->width && cd->height == allocation->height) return;
 
-	cd->size = new_size;
+	cd->width = allocation->width;
+	cd->height = allocation->height;
+	cd->size = panel_applet_get_size (applet);
 
         unfix_size (cd);
 	update_timeformat (cd);
@@ -2307,7 +2334,7 @@ fill_clock_applet (PanelApplet *applet)
 			  cd);
 
 	g_signal_connect (G_OBJECT (cd->applet),
-			  "size-allocate",
+			  "size_allocate",
 			  G_CALLBACK (applet_change_pixel_size),
 			  cd);
 
