Re: GnomeMDIChild and their views



On Sep 20, 1999, Jaka Mocnik <jaka.mocnik@kiss.uni-lj.si> wrote:
> "John R. Sheets" wrote:
> 
> 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:
[...]
> 	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);

Okay, let's see if I'm following you correctly....

Here, you have in-place view type-changing.  You create a view, and
if you don't like the current view type, you swap it out with a new
type.  The number of views doesn't change when you call set_view_type().
So still, when you create a new view, you have to either change the
view type after the fact, or keep changing the default view type each
time you want a new view type.

> 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 ;)

Well, no, it's not complicated, but it is a little cumbersome if you
plan on creating a number of different view types for the same child.
Plus, it doesn't make much semantic sense to keep changing a default
value.  Typically, you set a default, and it stays that way, and 
gets used as a fallback if you don't *override* it elsewhere.  That's
more what I'd like to see.  Something like this:

gint gnome_mdi_add_view(GnomeMDI *mdi, GnomeMDIChild *child, 
                        gpointer view_type);

If view_type is NULL, you would fall back on the default type, which
makes more sense to me.  Which suggests something like this:

gpointer gnome_mdi_child_get_default_view_type(GnomeMDIChild *child);
void gnome_mdi_child_set_default_view_type(GnomeMDIChild *child, 
                                           gpointer view_type);

Hmm, that is kinda bulky, huh?  Probably needs a more concise function
name.  And it might be better to use a gint for the type, to make it
easier to handle (i.e. less casting and pointer woes).

So, as an example, we could create a TYPE_A_NEGATIVE view, and then
two TYPE_O_NEGATIVE views:

  gnome_mdi_child_set_default_type(child, TYPE_O_NEGATIVE);
  gnome_mdi_add_view(mdi, child, TYPE_A_NEGATIVE);

  /* either way works... */
  gnome_mdi_add_view(mdi, child, NULL);
  gnome_mdi_add_view(mdi, child, TYPE_O_NEGATIVE);

Does this make sense?  Granted, it does create a non-compatible
API change, with the extra parameter on gnome_mdi_add_view(), but
I think it's well worth it for the added flexibility and ease of 
use.

John



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