libxfce4panel could position panel plugin menus

Diego Ongaro ongardie at
Fri Sep 21 01:00:58 CEST 2007

Many plugins use popup menus as their primary UI widget. To name a
few, there's xfdesktop (the Xfce Menu), launchers, window list, notes,
and places. Currently, each panel plugin with a popup menu needs to
call xfce_panel_plugin_register_menu(), then gtk_menu_popup(), and
most importantly, implement its own menu positioning function.

I think libxfce4panel should provide more support for this common
functionality. By wrapping gtk_menu_popup() with a new
xfce_panel_plugin_popup_menu(), libxfce4panel could take over the job
of positioning the menu. This has at least three clear advantages:

1) Less code for new plugins using popup menus
2) Less maintenance and duplication of effort among plugins
3) Improved consistency, especially for floating panels

Regarding the behavior of where to popup the menu, Mike and I agree
that the Xfce Menu does a good job right now for fixed panels. For
floating panels, however, it pops the menu up just where the cursor
is, which isn't great.

Mike developed a new algorithm for the notes plugin (not yet in the
svn repo) on Tuesday that is simple and has what we agree is
good/proper behavior under all panel configurations. It needs two
things to do its magic:

1) an XfcePanelPlugin instance so that it can get the orientation of the panel
2) the button/toggle button/widget that caused the menu to open and is
where the menu should originate

Today, I copied Mike's code for the places plugin. I used the
user_data field of the GtkMenuPositionFunc for (1) and retrieve (2)
via gtk_menu_get_attach_widget(). At this point, the only thing making
that function specific to the places-plugin is the function's name. I
think something very close to this is what we'd want libxfce4panel to
do. See pview_cb_menu_position() in
xfce4-places-plugin/trunk/panel-plugin/view.c [1].

Your thoughts?

Diego Ongaro


More information about the Xfce4-dev mailing list