Re: PATCH: Complete custom toolbars package (partially rewritten) [chbm chbm nu]



Hi Carlos,

On 2001.07.14 01:07 Carlos Morgado wrote:
> (haven't looked much at this one yet - not much time :(). i noticed the 
> static void populate_stock_toolbar(int bar, int id) func. it looks fully
> unmaintanable. 

That one is to provide default toolbars for the very first startup. AFter
that, they're read from config.
The way this works, to create a new toolbar for another window, you would
need to make the following changes:
- in balsa-icons.h, define the needed icon names
- in balsa-icons.c, load and register the icons
- in toolbar-factory.h, increase STOCK_TOOLBAR_COUNT by one
- in toolbar-prefs.c, define tha characteristics of the new button(s)
  (note: one button defined there can be used in several toolbars)
- in toolbar-factory.c, add an array toolbarX_legal and populate it
- in toolbar-factory.c, enter the name of the array into the toolbar_legal
array
- in toolbar-factory.c, write a clause for the new toolbar in
populate_stock_toolbar
- in your new window, add calls to set_toolbar_button_callback for all
buttons listed in toolbarX_legal
- in your new window, add a call to gnome_app_set_toolbar(), using
get_toolbar() as the toolbar
- in your new window, add a call to release_toolbars() in the destroy signal
callback

Instead if using gtk_widget_set_sensitive(main_toolbar[XXX_POS].widget, n),
use set_toolbar_button_sensitive() with the name of the icon. To directly
access the widget, use get_tool_widget(). Do _not_ store the returned
pointer, use it and discard it, because when the user changes the toolbar it
may become invalid. get_tool_widget() may return NULL, in that case the
button is not on the toolbar.
All toolbars with the same type share a list of callbacks. If
set_toolbar_button_callback() is called between the creation of 2 toolbars,
the first one will use the old callback, the second one will use the new
one, until the user makes a change to a toolbar. After that, both will use
the new callback. So it should be strictly one toolbar number to one code
module.
If a window needs to update it's own toolbar, get_toolbar() may be called
again, but the return value _must_ be discarded. get_toolbar() will use it's
internal tables to update the window's toolbar once the window has one.
gnome_app_set_toolbar must never be called twice for the same window, or the
window will have an empty toolbar dock you can't get rid of.
One window may use more than one toolbar and at any time elect to use
either, both or none.
Well, that's what it does - adding something doesn't seem too hard.

the contents of populate_stock_toolbar() and toolbarX_legal could probably
be combined into a single table and STOCK_TOOLBAR_COUNT could be derived
from that....

> also, why don't you use the menu factory ? gives you much of the stuff 
> that's in toolbar-factory.c.
> 
I don't know much about any of that, this the very first time I ever did
something with gtk/gnome. A week ago I didn't even know what gtk code looked
like. So, forgive me for not knowing there is such a thing as a menu
factory. Anyway, this one is done now and it works.

> (btw, my gcc barfs with ";;" in pedantic mode. should be legal though :|)

Yes, it should be. It's just a typo, anyway! Should I really post another
version with just that removed?

Cheers,

Melanie




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