From bc869eca8c91810c66ead464b57630ccebabaf29 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Tue, 22 Jun 2010 14:28:08 +0200 Subject: [PATCH] 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. --- src/ChangeLog | 8 ++++++++ src/gtkutil.c | 28 +++++++++++++++------------- src/gtkutil.h | 1 - src/xterm.c | 1 - 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 3d8e962e070..b52d6c1dffe 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2010-06-22 Jan Djärv + * 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. diff --git a/src/gtkutil.c b/src/gtkutil.c index c8800817b68..51b1c64c108 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -3174,17 +3174,6 @@ xg_create_scroll_bar (f, bar, scroll_callback, end_callback, scroll_bar_name) 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 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) /* 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 diff --git a/src/gtkutil.h b/src/gtkutil.h index 602228f97be..4eba4710ea3 100644 --- a/src/gtkutil.h +++ b/src/gtkutil.h @@ -163,7 +163,6 @@ extern void xg_create_scroll_bar P_ ((FRAME_PTR f, 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, diff --git a/src/xterm.c b/src/xterm.c index f195c4fbbd5..59573a5942e 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -4998,7 +4998,6 @@ x_scroll_bar_create (w, top, left, width, height) 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, -- 2.39.2