Re: GnomeMDIChild and their views



"John R. Sheets" wrote:

> So the child would carry a GList of ViewContainer's, rather than
> directly carrying a list of the views?  An extra layer of widgets?
> Or would the ViewContainer be derived from GtkObject like the
> other MDI components?
no, no, no... you don't have to change anything in the MDI; I was
thinking more along the lines of:

you create a view with:

	GtkWidget *create_view(GnomeMDIChild *c, gpointer d) {
		view = gtk_frame_new(NULL);
		set_view_type(view, (gint)d);
	}
	
	gnome_mdi_generic_child_set_view_creator(c, create_view,
						 (gpointer)TYPE_O_NEGATIVE);

then, at one point, you add a view of a child:

	gnome_mdi_add_view(mdi, c);

if you don't wan't it to be of type TYPE_O_NEGATIVE, you do:
	view = gnome_mdi_get_active_view(mdi);
	set_view_type(view, TYPE_A_NEGATIVE);

and void set_view_type(GtkWidget *view, int type) looks like:
	{
		GtkWidget *real_view

		if(GTK_BIN(view)->child)
			gtk_container_remove(view, GTK_BIN(view)->child);
		switch(type) {
		case TYPE_O_NEGATIVE:
			real_view = type0negative_new();
			gtk_widget_show(real_view);
			gtk_container_add(view, real_view);
			break;
		...
	}

or you can set a default view by connecting a handler for mdi "add_view"
signal
and passing it your type of view as the user data:

	gint add_view_handler(GnomeMDI *mdi, GtkWidget *view, gpointer data) {
		set_view_type(view, (gint)data);
	}

	gtk_signal_connect(mdi, "add_view", add_view_handler, TYPE_O_NEGATIVE);

and instead of a type constant, you could use a pointer to a global
variable and store
your default view type there and change it at will. I don't think this
is extremely complicated ;)

but, of course, for 2.0, I gladly accept improvements to the API that
would make this more straightforward...

any clearer now?

> Hmm, what would be the namespace of the set_view_type() function?
> gnome_mdi_set_view_type()...or would it make sense to create a
> GnomeMDIView object now, too?
there would be no gnome_mdi_set_view_type(): the above code does just
that - right now.

> Do you have any other thoughts about what might go into GnomeMDI 2.0?
I'll come up with some ;)

regards,
	jaKa

-- 

email: jaka.mocnik@kiss.uni-lj.si
w3:    http://pluton.ijs.si/~jaka



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