[patch] set_uposition




Windows being descendents of GtkBin, can only have one child widget.
However, if you use a container class, such as an HBox, that can have
multiple children, in theory set_uposition should work. In practice, a
one line bug-fix is needed to gtkwidget.c:

===========
*** ../../gtk+owt-081197/gtk/gtkwidget.c	Sun Aug 10 13:54:06 1997
--- gtkwidget.c	Wed Sep 10 00:58:08 1997
***************
*** 1035,1041 ****
  	real_allocation.y = aux_info->y;
      }
  
!   gtk_signal_emit (GTK_OBJECT (widget), widget_signals[SIZE_ALLOCATE], allocation);
  }
  
  /*****************************************
--- 1044,1050 ----
  	real_allocation.y = aux_info->y;
      }
  
!   gtk_signal_emit (GTK_OBJECT (widget), widget_signals[SIZE_ALLOCATE], &real_allocation);
  }
  
  /*****************************************
===========

With this patch the following works for me: (translation from
perl to Guile left as an excercise for the reader)

===========
#!/usr/bin/perl -w

use Gtk;

$window = new Gtk::Window "TOPLEVEL";
$window->set_title("Placement");
$window->border_width (10);

$window->signal_connect ("destroy", sub { Gtk->exit(0) });
$window->set_usize (200,200);

$bag = new Gtk::HBox (0, 0);
$window->add ($bag);
$bag->show;

# note use of set_alignment
$label = new Gtk::Label "Label1";
$bag->pack_start ($label, 1, 1, 0);
$label->set_uposition (50,50);
$label->set_alignment (0.0, 0.0);
$label->show;

$label = new Gtk::Label "Label2";
$bag->pack_start ($label, 1, 1, 0);
$label->show;
$label->set_uposition (75,75);
$label->set_alignment (0.0, 0.0);

$window->show;

Gtk->main;
=============

Regards,
                                        Owen Taylor



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