Re: my libglade hacks



On Wed, Oct 24, 2001 at 10:30:30PM -0400, Michael Meeks wrote:
> On Wed, 24 Oct 2001, George wrote:
> > Or, if people write sane code they have type checks when getting a
> > widget from libglade.  I have a piece of code called glade-helper in
> > vicious-extensions, which does a type check and informs the user in a
> > dialog that the installation is corrupted if it doesn't get the right
> > widget type.
> 
>         Yes - that'd be really useful in some ways; we used to have a lot
> of problems like this in gnumeric before we started installing the glade
> files in versioned directories. More useful than the precice type would be
> simply to check that a set of named widgets exist in the XML file, and
> will return non-NULL when we suck them out.

That could work as well.  Actually prolly doing both would be good.  First
on loading a file give a set of widgets, second on each get check type
automatically.   The biggest thing is that it needs to tell the user that
something is wrong.  For a GUI user it's impossible to tell what went wrong
when the app dies.  If it tells him his installation is fucked, he knows who
to blame it on.

The good thing about checking when you are getting/using the widget is that
you don't forget to update that check.  The disadvantage is that the warning
only comes up when you reach that part of the code, not when you load the
file / start the app.

I think an approach such as (two methods)

GladeXML *xml;
xml = load_check ("file.glade", "toplevel", TOPLEVEL_WIDGET_TYPE,
                  "extra_widget_check", EXTRA_WIDGET_TYPE,
                  "extra_widget2_check", EXTRA_WIDGET2_TYPE,
	          NULL);

... somewhere else ...

GtkWidget *w;
w = get_check (xml, "some_widget", SOME_WIDGET_TYPE);


Where the get_check would have the semantics of glade-helper function
(guaranteed return)

James?  Any comments?

George

-- 
George <jirka 5z com>
   Computers are useless. They can only give you answers.
                       -- Pablo Picasso



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