verbs.




	Verbs are supposed to provide an easy way for an embedded
component to export a number of simple non-parameterized actions which
the component can perform.  The example I've used in the past is "Next
page".

	The component wants to make the verb programmatically
available to its container, as well as making it available to the user
in a simple menu.  Note that this is distinct from full-fledged
menu/toolbar merging, which is already solved in Bonobo.

	The way it currently works is that the component builds a verb
list containing each verb's name, translated label, and translated
hint (short description of the verb's behavior).  Then, the container
will execute the verb on one of the component's Views.

	Now, with this system, programmatic access to the verbs is
just fine.  The container queries the component for its list of
supported verbs and then executes a given verb if it is available.

	You may remember that in the past, we were overload verbs to
pass simple messages to the component to handle in-place activation
and other embedding tasks.  We determined that this was not a good
idea and that code has been removed.

	So what we'd like to do is to export the verb list so that the
verbs can appear in a simple context menu.  If the context menu is
produced on the component side, everything is just fine.

	If the user right-clicks on an inactive embedded view,
however, we'd like the container to be able to construct a nice popup
menu containing the component's verbs.  But this is, once again, a
menu construction issue; the current system does not address, for
example, pixmaps, verb nesting, etc.  Here's one possible way to solve
this problem from the container's side:

	/*
	 * Create the popup menu.
	 */
	popup_uih = gnome_ui_handler_new ();
	gnome_ui_handler_create_popup_menu (popup_uih);

	/*
	 * Ask the embedded component to fill the popup
	 * menu with the verbs.
	 */
	gnome_view_frame_fill_verb_menu (view_frame, popup_uih);

	/*
	 * Display the menu.
	 */
	gnome_ui_handler_do_popup_menu (popup_uih);

	gtk_object_unref (GTK_OBJECT (popup_uih));

The embedded component would get a callback with a GNOME_UIHandler
attached.  It would simply build a menu in the GNOME_UIHandler just as
it would build any menu.

	This might add some unneeded complexity to verbs, though.  It
makes me wonder: what are verbs for, anyways?

	The other solution is to have the container construct a simple
menu with translated labels and hints, but no pixmaps or nesting, out
of the component's verb list.  One downside here is basically that you
don't get the pixmaps; admittedly relatively minor.  I already provide
a nice mechanism in the View to dispatch a verb to a View-local
callback, so that the user doesn't have to write that strcmp() code
himself.

Nat



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