gtk: Fixed fix-resizer. GtkWindows can shrink again.
authorMatt Birkholz <matt@birkholz.chandler.az.us>
Tue, 14 Aug 2012 19:39:40 +0000 (12:39 -0700)
committerMatt Birkholz <matt@birkholz.chandler.az.us>
Tue, 14 Aug 2012 19:39:40 +0000 (12:39 -0700)
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
src/gtk/fix-demo.scm
src/gtk/fix-layout.scm
src/gtk/gtk.pkg
src/gtk/gtkio.c.stay

index 2e732b7f6bee75593a84954f5bda37b524d20ed4..0d8e209109de753068519f14d0cb0ed83dceb02c 100644 (file)
@@ -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))
index ffe0aa6de6ad372fdfe6cab51eb38116e5435aad..58454dd09af7268cefa835a0cc2266b8b4f2a946 100644 (file)
@@ -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)
index afa5982ad5bf049282a7c18fc0fb3a06c4f7a97d..022d2d124c24c14dd35f54a7b006d45eb09d489c 100644 (file)
@@ -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 <fix-resizer>))
   (call-next-method widget)
   (%trace "; (fix-widget-realize-callback <fix-resizer>) "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)
 
index 45e0d19ad9c22db026eefa5576b0eb44210de7c6..3fb98fef5bc801f35fd194b155b0e7bb3e5148e2 100644 (file)
@@ -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> 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)
-         <scm-widget>
+         <scm-widget> guarantee-scm-widget
          set-scm-widget-set-scroll-adjustments-callback!
          set-scm-widget-minimum-size! set-scm-widget-natural-size!))
 
index a4de9d827ae197af5b3eb459663638398e402ce6..1b16ffc3e08231ed59f8b4ed536fcbb796a9fce9 100644 (file)
@@ -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