[Rhythmbox-devel] gmenu, plugins and you

I'm going to release a new version of Rhythmbox this weekend. People
who watch commits will know that since 2.98 I've converted everything
to use GMenu rather than GtkUIManager and GtkAction and friends. This
of course has some implications for plugins.

As part of this, the menu structure changed a little. The traditional
menu bar is gone, replaced by an app menu (or an app menu button in
environments that don't support that). Not all of the menu bar went
into the app menu. The 'control' menu was redundant, so it just
disappeared (its accelerator keys remain). The 'edit' menu moved into
source toolbars. Parts of the 'music' menu went elsewhere too. This of
course has some implications for plugins.

Popup menus in the source list also went away, since they were mostly
short, redundant, or both, and they're not particularly discoverable.
Instead, source-specific actions should go in a source toolbar. A
toolbar at the bottom of the source list handles some common actions
such as adding a new instance of a source (playlists, network shares
etc.), deleting a source (playlists again) or ejecting a device. This
of course has some implications for plugins.

Plugins now have two courses of action:
- add items to other menus (rb_application_add_plugin_menu_item())
- create source toolbars in the form of GMenus (RBSource toolbar-menu property)

Plugin menu items go in specific places (not just anywhere you like,
as with GtkUIManager merges), which you can locate by looking for menu
sections with rb-plugin-menu-link attributes. They mostly match the
name of the toolbar or popup they're inside. Plugins specify an item
id (only used to remove the item later), the item itself as a
GMenuItem instance, and the name of the plugin menu to add it to.

Of course, plugins must also create and register any actions they want
to expose in menus. They can be added to the application instance
(available through g_application_get_default()) or the window, using
g_action_map_add_action(). The menu item then refers to the action by
name, prefixing it with "app." if added to the application or "win."
if added to the window.

Source toolbars can include submenus, which show up as menu buttons,
can bind buttons to properties and signals of the source itself, and
can link to existing menus, such as the 'edit' menu. Most of this is
Rhythmbox specific, using custom GMenu attributes (rb-menu-link,
rb-property-bind, rb-signal-bind, rb-plugin-menu-link).

The library source toolbar demonstrates most of these things:

As always, the in-tree plugins should serve as useful examples for most of this.

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