From 0d623bb8dc4c6f0bb04a637d413fbe43b3728572 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Tue, 14 Aug 2012 12:39:40 -0700 Subject: [PATCH] gtk: Fixed fix-resizer. GtkWindows can shrink again. Restrict fix-resizer to scm-widgets and use set-scm-widget-natural- size! to frob them. Using GtkScrollingWindows and applying queue_ resize to both got resizes happening just as with set-size-request, withOUT forcing any widget's minimum size. --- src/gtk/Includes/gtkwidget.cdecl | 3 +++ src/gtk/fix-demo.scm | 4 ++-- src/gtk/fix-layout.scm | 33 +++++++++++++++++++++----------- src/gtk/gtk.pkg | 4 +--- src/gtk/gtkio.c.stay | 11 ++--------- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/gtk/Includes/gtkwidget.cdecl b/src/gtk/Includes/gtkwidget.cdecl index 2e732b7f6..0d8e20910 100644 --- a/src/gtk/Includes/gtkwidget.cdecl +++ b/src/gtk/Includes/gtkwidget.cdecl @@ -34,6 +34,9 @@ gtk/gtkwidget.h |# (extern void gtk_widget_queue_resize (widget (* GtkWidget))) +(extern void gtk_widget_queue_resize_no_redraw + (widget (* GtkWidget))) + (extern void gtk_widget_set_can_focus (widget (* GtkWidget)) (can_focus gboolean)) diff --git a/src/gtk/fix-demo.scm b/src/gtk/fix-demo.scm index ffe0aa6de..58454dd09 100644 --- a/src/gtk/fix-demo.scm +++ b/src/gtk/fix-demo.scm @@ -54,8 +54,8 @@ USA. (gtk-container-add scroller1 layout1) (gtk-container-add vgrid scroller1) - (set-fix-resizer-before! resizer scroller1) - (set-fix-resizer-after! resizer scroller2) + (set-fix-resizer-before! resizer layout1) + (set-fix-resizer-after! resizer layout2) (gtk-container-add vgrid resizer) (gtk-container-add scroller2 layout2) (gtk-container-add vgrid scroller2) diff --git a/src/gtk/fix-layout.scm b/src/gtk/fix-layout.scm index afa5982ad..022d2d124 100644 --- a/src/gtk/fix-layout.scm +++ b/src/gtk/fix-layout.scm @@ -653,11 +653,11 @@ USA. ;; Inferred from aspect ratio. (stack-vertical? define standard) - ;; The widget that is above or left of this widget. - (before define standard initial-value #f) + ;; The scm-widget that is above or left of this widget. + (%before define standard initial-value #f) - ;; The widget that is below or right of this widget. - (after define standard initial-value #f) + ;; The scm-widget that is below or right of this widget. + (%after define standard initial-value #f) ;; #t while a gtk_grab_add is in effect. (dragging? define standard initial-value #f)) @@ -675,6 +675,18 @@ USA. (error "Ambiguous verticality:" w h widget)))))) (set-fix-resizer-stack-vertical?! widget vertical?))) +(define fix-resizer-before fix-resizer-%before) + +(define (set-fix-resizer-before! resizer before) + (guarantee-scm-widget before 'set-fix-resizer-before!) + (set-fix-resizer-%before! resizer before)) + +(define fix-resizer-after fix-resizer-%after) + +(define (set-fix-resizer-after! resizer after) + (guarantee-scm-widget after 'set-fix-resizer-after!) + (set-fix-resizer-%after! resizer after)) + (define-method fix-widget-realize-callback ((widget )) (call-next-method widget) (%trace "; (fix-widget-realize-callback ) "widget"\n") @@ -751,16 +763,15 @@ USA. (let ((w (fix:+ (car w.h-before) dx)) (h (fix:+ (cdr w.h-before) dy))) (%trace "; resizing "before" to "w"x"h"\n") - (set-scm-widget-natural-size! (gtk-bin-child before) - w h)) + (set-scm-widget-natural-size! before w h)) (let ((w (fix:- (car w.h-after) dx)) (h (fix:- (cdr w.h-after) dy))) (%trace "; resizing "after" to "w"x"h"\n") - (set-scm-widget-natural-size! (gtk-bin-child after) - w h)) - (C-call "gtk_container_resize_children" - (gobject-alien - (gtk-widget-parent resizer))))))) + (set-scm-widget-natural-size! after w h)) + (C-call "gtk_widget_queue_resize_no_redraw" + (gobject-alien before)) + (C-call "gtk_widget_queue_resize_no_redraw" + (gobject-alien after)))))) (if (fix-resizer-stack-vertical? resizer) diff --git a/src/gtk/gtk.pkg b/src/gtk/gtk.pkg index 45e0d19ad..3fb98fef5 100644 --- a/src/gtk/gtk.pkg +++ b/src/gtk/gtk.pkg @@ -172,8 +172,6 @@ USA. gtk-container-children gtk-bin-child gtk-container-add gtk-container-remove gtk-container-set-border-width - ;;gtk-container-set-resize-mode - ;;gtk-container-check-resize gtk-window? guarantee-gtk-window gtk-window-new gtk-window-type @@ -217,7 +215,7 @@ USA. (import (gtk gtk-widget) set-gtk-widget-destroy-callback!) (export (gtk) - + guarantee-scm-widget set-scm-widget-set-scroll-adjustments-callback! set-scm-widget-minimum-size! set-scm-widget-natural-size!)) diff --git a/src/gtk/gtkio.c.stay b/src/gtk/gtkio.c.stay index a4de9d827..1b16ffc3e 100644 --- a/src/gtk/gtkio.c.stay +++ b/src/gtk/gtkio.c.stay @@ -250,7 +250,7 @@ do_scheme (GSource *source) { gchar * fdstr, * text; - text = g_strdup_printf ("Scheme time-slice: %d\n", slice_counter); + text = g_strdup_printf ("Scheme time-slice: %d", slice_counter); gtk_label_set_text (GTK_LABEL (slice_label), text); g_free (text); @@ -544,14 +544,7 @@ open_slice_window (void) gtk_window_set_type_hint (GTK_WINDOW (slice_window), GDK_WINDOW_TYPE_HINT_UTILITY); gtk_widget_show_all (slice_window); - - /* If G_PRIORITY_LOW is too low, and the deprecated - GTK_RESIZE_IMMEDIATE is still available, this also worked: - - gtk_container_set_resize_mode (GTK_CONTAINER (slice_window), - GTK_RESIZE_IMMEDIATE); */ - - gtk_window_parse_geometry (GTK_WINDOW (slice_window), "250x50+0-40"); + gtk_window_parse_geometry (GTK_WINDOW (slice_window), "-0-0"); } static void -- 2.25.1