[patch] Buglets in gtkhscale.c and gtkrange.c



In the course of writing a tutorial section on the range widgets, I found
a couple of minor 'look and feel' bugs.  I've attached a tiny patch against
the sources in anon-CVS (should also apply to 1.0.5) which fixes them to
my satisfaction.

gtkhscale.c:

Basically, if you set value_position to GTK_POS_TOP or GTK_POS_BOTTOM and
the number of digits to more than 3 or so, the value gets clipped when you
move the slider to the ends of the scale.

Plus, one of the calls to gdk_window_get_size() was unnecessary :-)

gtkrange.c:

If you change the page_size on a GtkAdjustment and emit the "changed" signal,
GtkScale widgets that are attached to that adjustment aren't changed to
reflect the difference in the range of allowable values.

Cheers

-- 
          David Huggins-Daines - bn711@freenet.carleton.ca
           PGP public key #63A8B719 on public key servers
    fingerprint=4F 38 A2 34 E1 E0 B7 6E  C3 DA 6C E3 C6 6A 05 62
                         XP -> XP X' -> X XP
--- gtk+/gtk/gtkrange.c	Thu Jul 30 23:22:32 1998
+++ gtk+/gtk/gtkrange.c.new	Thu Jul 30 23:23:24 1998
@@ -1348,6 +1348,13 @@
 	  adjustment->value = adjustment->lower;
 	  gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "value_changed");
 	}
+      else if (adjustment->value > (adjustment->upper -
+				    adjustment->page_size))
+	{
+	  adjustment->value = (adjustment->upper -
+			       adjustment->page_size);
+	  gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "value_changed");
+	} 
     }
 
   if ((range->old_value != adjustment->value) ||
--- gtk+/gtk/gtkhscale.c	Thu Jul 30 23:22:30 1998
+++ gtk+/gtk/gtkhscale.c.new	Thu Jul 30 23:23:24 1998
@@ -377,9 +377,16 @@
 	  gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
 	  gdk_window_get_position (GTK_RANGE (scale)->trough, NULL, &y);
 	  gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
-	  gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
 
 	  x += (width - text_width) / 2;
+	  if (x < 1) x = 1;
+	  else if (width < text_width) {
+	    gdk_window_get_size
+	      (GTK_RANGE (scale)->trough, &width, NULL);
+	    if ((x + text_width) > width)
+	      x = width - text_width;
+	  }
+	    
 	  y -= GTK_WIDGET (scale)->style->font->descent;
 	  break;
 	case GTK_POS_BOTTOM:
@@ -389,6 +396,14 @@
 	  gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
 
 	  x += (width - text_width) / 2;
+	  if (x < 1) x = 1;
+	  else if (width < text_width) {
+	    gdk_window_get_size
+	      (GTK_RANGE (scale)->trough, &width, NULL);
+	    if ((x + text_width) > width)
+	      x = width - text_width;
+	  }   
+
 	  y += height + GTK_WIDGET (scale)->style->font->ascent;
 	  break;
 	}


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