GtkList & scrolled windows + yet another signal proposal



hi all,

i'm currently working on the second item of the gtk bug list:
 * Lists should scroll to center the recently selected item if it isn't
    visible.

this requires the gtklist widget to know wether it's immediate
parent is a scrolled window or not.
now we can take two approaches here, either have a function that needs
to be called for the gtklist/gtkscrolledwindow after the container_add()
function, something like::

sw = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set (sw,
                "GtkWIdget::visible", TRUE,
                "GtkWIdget::parent", whatever_the_parent_is,
                NULL);
list = gtk_widget_new (gtk_list_get_type (),
		       "GtkWidget::visible", TRUE,
		       "GtkWidget::parent", sw,
		       NULL);
gtk_list_set_scrolled_window (list, sw);

which will have proplems with gtk_widget_{re|un}parent() and require
the user to invoke gtk_list_set_scrolled_window (list, NULL);
or we can have this done automatically while the widget is added to the
parent:
upon container_add() a GtkContainer::add signal is emitted, now the
scrolled window could check wether it's child is a gtklist and then
it could call the gtk_list_set_scrolled_window() function for us.
but i consider this somewhat ugly, since it's not up to the scrolled
window to have hints implemented for the various child types which
there might be.
so the best way to implement this is to have the gtklist widget
setup it's scrolled window stuff upon adding to the parent itself.
now this involves one problem: a child widget doesn't know when
it gets added to a parent.
so i think there is a need for yet another widget signal: GtkWidget::parent_set.

this signal will be invoked at the end of gtk_widget_set_parent() and at
the beginning of gtk_widget_unparent().
the signal will have the following semantics:
	void (*set_parent) (GtkWidget *widget, GtkContainer *parent);
where parent is allowed to be NULL.

any comments? objections? (owen? ;)



---
ciaoTJ



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