Re: GtkBuilder Public API - Last call



Hi,

Johan Dahlin wrote:
Havoc Pennington wrote:
Is the Hello, World simplest use case as short and simple as it possibly
could be? That's always a handy final litmus test for an API.

How do you do an hello world in a ui toolkit?
Should it include signals? How many widgets?


For this purpose I think the idea is to emulate how a simple/typical app with no special needs would use the API.

builder_new + add_from_file could be combined into one constructor,
I've been thinking about that, which would make it easier to
port applications using libglade which has such an api.

This makes sense to me, since pretty much every app would tend to have the builder_new()/add_from_file() sequence, so why not save some typing there. new_from_file() is also a common GTK convention. Adding multiple files seems like a relatively unusual thing to do.

For the other stuff:
 - set_translation_domain - is for libraries mostly right?
   (if it's for apps it seems a gtk-wide or glib-wide way to
    do this could make sense, vs. gtkbuilder-specific)
 - connect_signals - for apps who will use this feature, they're
   going to type this line every time... new_from_file_and_connect()?
   kinda clunky. But it sucks to have a boilerplate line everyone
   has to type.
 - get_object - getting multiple objects seems like the normal case,
   so piling one object name it into the convenience function seems
   wrong

A possible convenience API could be to have a global singleton builder or a hash of per-file builders and then something like:

 GtkWindow *window;
 GtkWindow *other_window;

 if (!gtk_builder_load_objects (DATADIR "/filename.glade",
                                GTK_BUILDER_FLAGS_CONNECT_SIGNALS,
                                "main-window", &window,
                                "other-window", &other_window,
                                NULL))
    g_error("My files are missing!");

That could be pretty nice perhaps.

Havoc




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