Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the XML file defining the context menu, for each radio <code>&lt;menuitem&gt;</code> set <code>type="radio"</code> and the <code>group</code> property to the name of the radio item group, like this:</p> <pre><code>&lt;Root&gt; &lt;popups&gt; &lt;popup name="button3"&gt; &lt;menuitem name="Foo" verb="DoFoo" label="Foo is awesome" type="radio" group="mygroup"/&gt; &lt;menuitem name="Bar" verb="DoBar" label="Bar is cool" type="radio" group="mygroup"/&gt; &lt;menuitem name="Baz" verb="DoBaz" label="Baz rocks" type="radio" group="mygroup"/&gt; &lt;/popup&gt; &lt;/popups&gt; &lt;/Root&gt; </code></pre> <p>You don't set up handlers to respond to the items being selected the same way you would for normal menu items. Instead, you listen for the "ui-event" signal on the BonoboUIComponent for the menu:</p> <pre><code>BonoboUIComponent *component = panel_applet_get_popup_component (applet); g_signal_connect (component, "ui-event", G_CALLBACK (popup_component_ui_event_cb), NULL); /* ... */ static void popup_component_ui_event_cb (BonoboUIComponent *component, const gchar *path, Bonobo_UIComponent_EventType type, const gchar *state_string, gpointer data) { } </code></pre> <p><code>path</code> will be the full path (see below) of the item that was clicked. <code>state_string</code> will be the new state value of the item (see below). There will be two events for each click of a radio item: one to deselect the old item, and one to select the new one.</p> <p>To manipulate the checked state of the buttons, use <code>bonobo_ui_component_set_prop</code> to set the "state" property to "0" (unchecked) or "1" (checked). To be safe, explicitly uncheck the old value; there are some corner cases where you could otherwise wind up with multiple radio items in the same group checked (particularly if the context menu hasn't yet actually been drawn).</p> <pre><code>BonoboUIComponent *component = panel_applet_get_popup_component (applet); bonobo_ui_component_set_prop (component, "/commands/Foo", "state", "1", NULL); bonobo_ui_component_set_prop (component, "/commands/Bar", "state", "0", NULL); bonobo_ui_component_set_prop (component, "/commands/Baz", "state", "0", NULL); </code></pre> <p>Note that you identify the radio item by "/commands/name", where name is the name you gave the item in the XML file.</p> <p>You <em>could</em> likewise use <code>bonobo_ui_component_get_prop</code> to look for which radio item is checked, but you're better off using the event handlers to detect when the user clicks on one.</p> <p>In general, the <a href="http://library.gnome.org/devel/libbonoboui/stable/libbonoboui-bonobo-ui-component.html" rel="nofollow noreferrer">documentation for BonoboUIComponent in libbonoboui</a> should provide more information about ways to manipulate items in the menu.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload