[evolution-patches] Patch for #15638



Makes 12-hour time format in appointment editor not be zero-padded.

--
Hans Petter
? evolution-datetime-12hour.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/ChangeLog,v
retrieving revision 1.105
diff -u -p -r1.105 ChangeLog
--- ChangeLog	27 Aug 2003 03:38:13 -0000	1.105
+++ ChangeLog	28 Aug 2003 00:53:17 -0000
@@ -1,3 +1,10 @@
+2003-08-27  Hans Petter Jansson  <hpj ximian com>
+
+	Fixes #15638.
+
+	* misc/e-dateedit.c (rebuild_time_popup): Make 12-hour time format
+	not be zero-padded. Right-align time labels so digits line up.
+
 2003-08-27  Bolian Yin <bolian yin sun com>
 
 	* misc/Makefile.am: add dependency on a11y/widgets.
Index: misc/e-dateedit.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-dateedit.c,v
retrieving revision 1.35
diff -u -p -r1.35 e-dateedit.c
--- misc/e-dateedit.c	13 Jul 2003 19:29:03 -0000	1.35
+++ misc/e-dateedit.c	28 Aug 2003 00:53:18 -0000
@@ -1375,7 +1375,7 @@ rebuild_time_popup			(EDateEdit	*dedit)
 {
 	EDateEditPrivate *priv;
 	GtkList *list;
-	GtkWidget *listitem;
+	GtkWidget *listitem, *label;
 	char buffer[40], *format;
 	struct tm tmp_tm;
 	gint hour, min;
@@ -1416,8 +1416,20 @@ rebuild_time_popup			(EDateEdit	*dedit)
 
 			e_utf8_strftime (buffer, sizeof (buffer), format, &tmp_tm);
 
-			listitem = gtk_list_item_new_with_label (buffer);
-			gtk_widget_show (listitem);
+			/* For 12-hour am/pm format, we want space padding, not zero padding. This
+			 * can be done with strftime's %l, but it's a potentially unportable extension. */
+			if (!priv->use_24_hour_format && buffer [0] == '0')
+				buffer [0] = ' ';
+
+			/* We need to make sure labels are right-aligned, since we want digits to line up,
+			 * and with a nonproportional font, the width of a space != width of a digit.
+			 * Technically, only 12-hour format needs this, but we do it always, for consistency. */
+			listitem = gtk_list_item_new ();
+			label = gtk_label_new (buffer);
+			gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+			gtk_container_add (GTK_CONTAINER (listitem), label);
+
+			gtk_widget_show_all (listitem);
 			gtk_container_add (GTK_CONTAINER (list), listitem);
 		}
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]