GtkCalendar / GtkProgressBar



UI Flipping correctness patch attached.

GtkProgressBar
  adds two new directions, _WITH_TEXT and _CONTRA_TEXT,
  meanings should be obvious.

  I'm not sure if keeping the ltr and rtl ones makes sense
  in this context, but I guess we might as well...

GtkCalendar
  convert the month/day names to UTF-8, so it actually works if
  LC_ALL=fr_GB, (this depends on my previous glib patch : was 
  the 2nd version of that OK?)

  for deciding whether to flip the Calendar itself, I look at
  nl_langinfo (_NL_TIME_CAL_DIRECTION).  I'm not too keen on
  this, probably it should be based on the widget direction?

-- 
Robert
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.1440
diff -u -r1.1440 ChangeLog
--- ChangeLog	2000/10/23 16:15:23	1.1440
+++ ChangeLog	2000/10/24 00:58:37
@@ -1,3 +1,20 @@
+2000-10-23  Robert Brady  <robert suse co uk>
+
+	* gtk/gtkprogressbar.h, gtk/gtkprogressbar.c: Add new progress directions
+	GTK_PROGRESS_WITH_TEXT, GTK_PROGRESS_CONTRA_TEXT, which depend on the
+	widget direction.
+
+	* configure.in: Check for <langinfo.h>
+	
+	* gtk/gtkcalendar.c (gtk_calendar_init): Convert month and day-names to 
+	UTF-8.
+	
+	(left_x_for_column, gtk_calendar_paint_day_names): Flip the calendar if
+	_NL_TIME_CAL_DIRECTION is mode 3.  Doesn't handle mode 2 (top-to-bottom)
+	properly at the moment.
+
+	(gtk_calendar_paint_day_names): Draw day names in the right place.
+	
 Mon Oct 23 12:07:57 2000  Owen Taylor  <otaylor redhat com>
 
 	* gtk/gtkwidget.c (gtk_widget_set_style_internal): Fix problem
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gtk+/configure.in,v
retrieving revision 1.173
diff -u -r1.173 configure.in
--- configure.in	2000/10/22 16:01:19	1.173
+++ configure.in	2000/10/24 00:58:45
@@ -340,6 +340,7 @@
 AC_CHECK_HEADERS(pwd.h, AC_DEFINE(HAVE_PWD_H))
 AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
 AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
+AC_CHECK_HEADERS(langinfo.h, AC_DEFINE(HAVE_LANGINFO_H))
 
 saved_cflags="$CFLAGS"
 saved_ldflags="$LDFLAGS"
Index: gtk/gtkprogressbar.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkprogressbar.h,v
retrieving revision 1.11
diff -u -r1.11 gtkprogressbar.h
--- gtk/gtkprogressbar.h	2000/08/30 00:33:38	1.11
+++ gtk/gtkprogressbar.h	2000/10/24 00:58:45
@@ -59,7 +59,9 @@
   GTK_PROGRESS_LEFT_TO_RIGHT,
   GTK_PROGRESS_RIGHT_TO_LEFT,
   GTK_PROGRESS_BOTTOM_TO_TOP,
-  GTK_PROGRESS_TOP_TO_BOTTOM
+  GTK_PROGRESS_TOP_TO_BOTTOM,
+  GTK_PROGRESS_WITH_TEXT,
+  GTK_PROGRESS_CONTRA_TEXT,
 } GtkProgressBarOrientation;
 
 struct _GtkProgressBar
Index: gtk/gtkprogressbar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkprogressbar.c,v
retrieving revision 1.23
diff -u -r1.23 gtkprogressbar.c
--- gtk/gtkprogressbar.c	2000/07/26 11:32:45	1.23
+++ gtk/gtkprogressbar.c	2000/10/24 00:58:46
@@ -36,6 +36,7 @@
 
 #include "gtkprogressbar.h"
 #include "gtksignal.h"
+#include "gtkmain.h"
 
 
 #define MIN_HORIZONTAL_BAR_WIDTH   150
@@ -157,7 +158,7 @@
   pbar->bar_style = GTK_PROGRESS_CONTINUOUS;
   pbar->blocks = 10;
   pbar->in_block = -1;
-  pbar->orientation = GTK_PROGRESS_LEFT_TO_RIGHT;
+  pbar->orientation = GTK_PROGRESS_WITH_TEXT;
   pbar->pulse_fraction = 0.1;
   pbar->activity_pos = 0;
   pbar->activity_dir = 1;
@@ -293,7 +294,9 @@
 	  /* advance the block */
 
 	  if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
-	      pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
+	      pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT ||
+	      pbar->orientation == GTK_PROGRESS_WITH_TEXT ||
+	      pbar->orientation == GTK_PROGRESS_CONTRA_TEXT)
 	    {
               /* Update our activity step. */
               
@@ -402,7 +405,9 @@
     }
   
   if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
-      pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
+      pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT ||
+      pbar->orientation == GTK_PROGRESS_WITH_TEXT ||
+      pbar->orientation == GTK_PROGRESS_CONTRA_TEXT)
     {
       if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE)
 	{
@@ -453,11 +458,17 @@
   /* calculate start pos */
 
   if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
+      pbar->orientation == GTK_PROGRESS_WITH_TEXT ||
+      pbar->orientation == GTK_PROGRESS_CONTRA_TEXT ||
       pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
     {
       size = MAX (2, widget->allocation.width / pbar->activity_blocks);
 
-      if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
+      if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
+	  (pbar->orientation == GTK_PROGRESS_WITH_TEXT &&
+	   gtk_widget_get_direction (GTK_WIDGET(pbar) == GTK_TEXT_DIR_LTR)) ||
+	  (pbar->orientation == GTK_PROGRESS_CONTRA_TEXT &&
+	   gtk_widget_get_direction (GTK_WIDGET(pbar) == GTK_TEXT_DIR_RTL)))
 	{
 	  pbar->activity_pos = widget->style->xthickness;
 	  pbar->activity_dir = 0;
@@ -510,7 +521,9 @@
   widget = GTK_WIDGET (progress);
 
   if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
-      pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
+      pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT ||
+      pbar->orientation == GTK_PROGRESS_WITH_TEXT ||
+      pbar->orientation == GTK_PROGRESS_CONTRA_TEXT)
     space = widget->allocation.width -
       2 * widget->style->xthickness;
   else
@@ -532,7 +545,9 @@
       if (progress->activity_mode)
 	{
 	  if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
-	      pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
+	      pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT ||
+	      pbar->orientation == GTK_PROGRESS_WITH_TEXT ||
+	      pbar->orientation == GTK_PROGRESS_CONTRA_TEXT)
 	    {
 	      size = MAX (2, widget->allocation.width / pbar->activity_blocks);
 	      
@@ -566,7 +581,16 @@
       
       if (amount > 0)
 	{
-	  switch (pbar->orientation)
+	  GtkProgressBarOrientation orientation = pbar->orientation;
+	  if (orientation == GTK_PROGRESS_WITH_TEXT)
+	    orientation = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
+	      GTK_PROGRESS_LEFT_TO_RIGHT : GTK_PROGRESS_RIGHT_TO_LEFT;
+
+	  if (orientation == GTK_PROGRESS_CONTRA_TEXT)
+	    orientation = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL ?
+	      GTK_PROGRESS_RIGHT_TO_LEFT : GTK_PROGRESS_LEFT_TO_RIGHT;
+
+	  switch (orientation)
 	    {
 	      
 	    case GTK_PROGRESS_LEFT_TO_RIGHT:
Index: gtk/gtkcalendar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkcalendar.c,v
retrieving revision 1.22
diff -u -r1.22 gtkcalendar.c
--- gtk/gtkcalendar.c	2000/09/07 18:07:56	1.22
+++ gtk/gtkcalendar.c	2000/10/24 00:59:03
@@ -38,6 +38,9 @@
 #include <stdlib.h>
 #include <time.h>
 #include <stdio.h>
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
 #include "gtkcalendar.h"
 #include "gdk/gdkkeysyms.h"
 
@@ -440,7 +443,7 @@
       {
 	tmp_time= (i+3)*86400;
 	strftime ( buffer, sizeof (buffer), "%a", gmtime (&tmp_time));
-	default_abbreviated_dayname[i] = g_strdup (buffer);
+	default_abbreviated_dayname[i] = g_locale_to_utf8 (buffer);
       }
   
   if (!default_monthname[0])
@@ -448,7 +451,7 @@
       {
 	tmp_time=i*2764800;
 	strftime ( buffer, sizeof (buffer), "%B", gmtime (&tmp_time));
-	default_monthname[i] = g_strdup (buffer);
+	default_monthname[i] = g_locale_to_utf8 (buffer);
       }
   
   /* Set defaults */
@@ -570,6 +573,12 @@
   gint width;
   gint x_left;
   
+#ifdef _NL_TIME_CAL_DIRECTION
+  char *dir = nl_langinfo (_NL_TIME_CAL_DIRECTION);
+  if (dir && *dir == '3')
+    column = 6 - column;
+#endif
+
   width = GTK_CALENDAR_PRIVATE_DATA (calendar)->day_width;
   if (calendar->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS)
     x_left =  DAY_XSEP + (width + DAY_XSEP) * column;
@@ -1671,7 +1680,13 @@
   gdk_gc_set_foreground (gc, &widget->style->fg[GTK_STATE_SELECTED]);
   for (i = 0; i < 7; i++)
     {
-      day=i;
+#ifdef _NL_TIME_CAL_DIRECTION
+      char *dir = nl_langinfo (_NL_TIME_CAL_DIRECTION);
+      if (dir && *dir == '3')
+	day = 6 - i;
+      else
+#endif
+	day = i;
       if (calendar->display_flags & GTK_CALENDAR_WEEK_START_MONDAY)
 	day= (day+1)%7;
       sprintf (buffer, "%s", default_abbreviated_dayname[day]);
@@ -1684,7 +1699,7 @@
 			+ day_wid_sep * i
 			+ private_data->week_width
 			+ (day_width - logical_rect.width)/2),
-		       CALENDAR_MARGIN + DAY_YPAD + private_data->max_label_char_ascent + logical_rect.y,
+		       CALENDAR_MARGIN + DAY_YPAD + logical_rect.y,
 		       layout);
     }
   


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