changeset 109037:3e9a832a5533

Hide scroll bar when window is too small to avoid Gtk+ warning. * gtkutil.c (xg_update_scrollbar_pos): Show/hide scroll bar as needed if height is less than scroll bar min size. (xg_show_scroll_bar): Remove, show moved to xg_update_scrollbar_pos. * gtkutil.h (xg_show_scroll_bar): : Remove. * xterm.c (x_scroll_bar_create): Remove call to xg_show_scroll_bar.
author Jan D. <jan.h.d@swipnet.se>
date Tue, 22 Jun 2010 14:28:08 +0200
parents 439784267ae2
children fc2c0625a14a 3cf8b3dca100 266c496c7220
files src/ChangeLog src/gtkutil.c src/gtkutil.h src/xterm.c
diffstat 4 files changed, 23 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Jun 22 01:10:26 2010 -0700
+++ b/src/ChangeLog	Tue Jun 22 14:28:08 2010 +0200
@@ -1,5 +1,13 @@
 2010-06-22  Jan Djärv  <jan.h.d@swipnet.se>
 
+	* xterm.c (x_scroll_bar_create): Remove call to xg_show_scroll_bar.
+
+	* gtkutil.h (xg_show_scroll_bar): : Remove.
+
+	* gtkutil.c (xg_update_scrollbar_pos): Show/hide scroll bar as needed
+	if height is less than scroll bar min size.
+	(xg_show_scroll_bar): Remove, show moved to xg_update_scrollbar_pos.
+
 	* xfns.c (x_default_font_parameter): Try to open font from system
 	before using it (bug#6478).  Rename got_from_gconf to got_from_system.
 
--- a/src/gtkutil.c	Tue Jun 22 01:10:26 2010 -0700
+++ b/src/gtkutil.c	Tue Jun 22 14:28:08 2010 +0200
@@ -3174,17 +3174,6 @@
   bar->x_window = scroll_id;
 }
 
-/* Make the scroll bar represented by SCROLLBAR_ID visible.  */
-
-void
-xg_show_scroll_bar (scrollbar_id)
-     int scrollbar_id;
-{
-  GtkWidget *w = xg_get_widget_from_map (scrollbar_id);
-  if (w)
-    gtk_widget_show_all (gtk_widget_get_parent (w));
-}
-
 /* Remove the scroll bar represented by SCROLLBAR_ID from the frame F.  */
 
 void
@@ -3243,10 +3232,23 @@
 
       /* Move and resize to new values.  */
       gtk_fixed_move (GTK_FIXED (wfixed), wparent, left, top);
-      gtk_widget_set_size_request (wscroll, width, height);
+      gint msl;
+      gtk_widget_style_get (wscroll, "min-slider-length", &msl, NULL);
+      if (msl > height)
+        {
+          /* No room.  Hide scroll bar as some themes output a warning if
+             the height is less than the min size.  */
+          gtk_widget_hide (wparent);
+          gtk_widget_hide (wscroll);
+        }
+      else
+        {
+          gtk_widget_show_all (wparent);
+          gtk_widget_set_size_request (wscroll, width, height);
+        }
       gtk_widget_queue_draw (wfixed);
       gdk_window_process_all_updates ();
-      if (oldx != -1) 
+      if (oldx != -1 && oldw > 0 && oldh > 0)
         {
           /* Clear under old scroll bar position.  This must be done after
              the gtk_widget_queue_draw and gdk_window_process_all_updates
--- a/src/gtkutil.h	Tue Jun 22 01:10:26 2010 -0700
+++ b/src/gtkutil.h	Tue Jun 22 14:28:08 2010 +0200
@@ -163,7 +163,6 @@
                                       GCallback scroll_callback,
                                       GCallback end_callback,
                                       char *scroll_bar_name));
-extern void xg_show_scroll_bar P_ ((int scrollbar_id));
 extern void xg_remove_scroll_bar P_ ((FRAME_PTR f, int scrollbar_id));
 
 extern void xg_update_scrollbar_pos P_ ((FRAME_PTR f,
--- a/src/xterm.c	Tue Jun 22 01:10:26 2010 -0700
+++ b/src/xterm.c	Tue Jun 22 14:28:08 2010 +0200
@@ -4998,7 +4998,6 @@
                              left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
                              width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
                              max (height, 1));
-    xg_show_scroll_bar (bar->x_window);
 #else /* not USE_GTK */
     Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
     XtConfigureWidget (scroll_bar,