Re: Docking widget ready for libegg



Hey,

First of all, I'd like to thank Biswa for trying to push the dock widget
into libegg/gtk.  It's something I should probably have done long ago.

On Fri, 2003-04-11 at 10:00, Biswapesh Chattopadhyay wrote:
> On Fri, 2003-04-11 at 18:16, Sven Neumann wrote:
> > > Actually, that's how it is (more-or-less) - see the layout manager API,
> > > esp. the following calls:
> > > -----------------------------------------------------------------------
> > > gboolean         egg_dock_layout_load_layout    (EggDockLayout *layout,
> > >                                                  const gchar   *name);
> > >
> > > void             egg_dock_layout_save_layout    (EggDockLayout *layout,
> > >                                                  const gchar   *name);
> > > ----------------------------------------------------------------------
> > >
> > > You can consider the above calls to be "hooks" to be called by the
> > > client to save the layout at an appropriate location (say
> > > '~/.<appname>/docklayout.xml')

These functions save/load the dock layout to/from the DockLayout object
itself, which keeps an xmlDoc with several layouts.  Probably the
DockLayout object is a bit overkill for most applications because of
this.  In general you'll want to keep track of just one layout.  The
multiple layout stuff is mostly useful for applications such as IDEs
where you might want to have different tools visible depending on the
task you're doing.

> > are there hooks for custom serialization and deserialization as well?
> > At least for GIMP I wouldn't like to save the dock-layout to a
> > different file but include it in sessionrc (just like we do with
> > GimpDock right now).
> > 
> > I'd also prefer not to use XML but the sexp syntax we use for all our
> > config files. In order to do that, we'd need access to all the string
> > identifiers but I guess that you handle this using GObject properties
> > and registered enums anyway.
> 
> Hmm - no you can't do that right now - I'll think of something for this
> kind of stuff. Do you have any concrete API suggestions ?
> 
> I'm out this weekend - hopefully, I'll get some work done on this on
> Monday. That should give people enough time to study the API and suggest
> improvements.

Layout serialization is done by walking the widget hierarchy from the
toplevel docks (egg_dock_master_foreach_toplevel ()).  Each dock object
exposes the properties useful for docking by setting the
EGG_DOCK_PARAM_EXPORT flag in the installed properties.  

Serialization/deserialization of those properties is done with
g_value_transform () to/from a special EggDockParam string-like type. 
That type and the transformation functions are registered in
egg-dock-object.c.

Serialization of a dock object type itself is done using
egg_dock_object_type_from_nick/nick_from_type.  I did it this way
(instead of using g_type_from_name(), etc.) so applications could
override default docking widgets.  Might be overkill too.

Serialization of the layout is straightforward except for placeholders
which require special treatment since they don't appear in the widget
hierarchy (see egg_dock_layout_save, add_placeholder and
egg_dock_layout_foreach_object_save in egg-dock-layout.c).

Deserialization is a bit more complicated because of some special cases,
such as handling automatic/non-automatic dock items, setting some
properties after docking an item's children, etc. (see
egg_dock_layout_load, egg_dock_layout_recursive_build and
egg_dock_layout_setup_object in egg-dock-layout.c).

HTH,
Gustavo





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