GtkLayout resizing like a GtkFixed ?



hi 
i have used a GtkFixed for displaying some user movable widgets.
which can also be GtkLayouts containing user movable widgets.

now i use a GtkLayout because it seems to be faster and i will need to
draw onto the GdkWindow
in the future.

here is gtk_layout_size_request 

-------------------------------------------------snip----------------

static void     
gtk_layout_size_request (GtkWidget     *widget,
                         GtkRequisition *requisition)
{ 
  GList *tmp_list;
  GtkLayout *layout;
  
  g_return_if_fail (GTK_IS_LAYOUT (widget));

  layout = GTK_LAYOUT (widget); 
  
  requisition->width = 0;
  requisition->height = 0;
  
  tmp_list = layout->children;
                    
  while (tmp_list)  
    {               
      GtkLayoutChild *child = tmp_list->data;
      GtkRequisition child_requisition;
       
      tmp_list = tmp_list->next;     
                         
      gtk_widget_size_request (child->widget, &child_requisition);
    }
}


-------------------------------------------------------------snap-------

This always returns (0,0) as a requistion.
But at least it calls "size-request" on all child_widgets.

I have connected my own size-request which is this:

-------------------------------------------------------------snip-------

PRIVATE void mylayout_size_request( GtkContainer *container,
GtkRequisition *requisition ) {

    GList *listX = gtk_container_get_children( container );
  
    requisition->width = 0;
    requisition->height = 0;
    
    for( listX=list; listX != NULL; listX = g_list_next( listX ) ) {
    
        GtkWidget *widget = listX->data;
        gint x,y,w,h;

        gtk_container_child_get( container, widget, "x", &x, NULL );
        gtk_container_child_get( container, widget, "y", &y, NULL ); 

        //** gtk_widget_get_size_request() always returns (-1,-1) why is
that ?
        //gtk_widget_get_size_request( widget, &w, &h );
 
        //** This does not work if the widget is not mapped.
        w=widget->allocation.width;
        h=widget->allocation.height;

 
        //g_print( "(x,y) = %d,%d  (w,h) = (%d,%d) \n", x,y,w,h );
        
        if( x+w > requisition->width ) requisition->width = x+w;
        if( y+h > requisition->height ) requisition->height = y+h;

    }
    gtk_layout_set_size( GTK_LAYOUT( container ), requisition->width,
requisition->height );
    //gtk_widget_set_usize( GTK_WIDGET( container ), maxw, maxh );

    //g_signal_stop_emission_by_name( G_OBJECT(container),
"check_resize" );
}


-------------------------------------------------------------snap-------

This works when moving a widget around and all widgets are mapped.
but if the layout is not shown and i put widgets onto it (when i load
from a file)
the childs are not allocated and this does not work.

i have to move a control on the layout to make it resize correctly.

when are configure events emitted ?
or what signal should i connect gtk_widget_queue_resize() to
make the layout like a fixed ?

-- 
Torben Hohn
http://galan.sourceforge.net




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