programmatically adding panel plugins
Brian J. Tarricone
bjt23 at cornell.edu
Fri Aug 3 08:59:31 CEST 2007
Hey Jasper & Nick,
I'm working on something where I'm thinking about the possibility of
wanting to be able to add a plugin to the panel from inside the app,
without the user having to use the 'Add New Item' dialog. The app is
running all the time, and say perhaps in its preferences there's a
checkbox like "Show status in Xfce Panel". If the user checks the
checkbox, I want to go ahead and add some nifty status display plugin
to a panel. Let's assume for the moment that this plugin is too
complicated to just be a simple systray icon.
Obviously this isn't possible right now, but does it sound like
something that might be useful and one of you might want to work on?
I figure the easiest way would be to have something in libxfce4panel
like:
XfcePanelPlugin *
xfce_panel_plugin_add_external(const char *plugin_command,
gint panel_num,
gint position);
where 'plugin_command' is what would usually be in the X-XFCE-Exec line
in a normally-registered plugin's .desktop file. The panel_num and
position parameters aren't really crucial (and I imagine one could pass
-1 for them to say "I don't care"). The idea here is that I'd want to
not have to install it like a regular plugin (so the user couldn't add
it manually. The nice thing about this from the panel's perspective, I
guess, is that it's just returning an XfceExternalPanelPlugin and isn't
really doing anything special. It's just getting its info on how to
load the plugin from the API call rather than the .desktop file.
There's another option that I think I like better; I imagine it's
probably more work to implement in the panel, though. Something like:
XfcePanelPlugin *xfce_panel_plugin_add_foreign(gint panel_num,
gint position);
Again, panel_num and position aren't critical. In this case, When an
app calls this function, the panel would create a plugin GtkSocket, and
pass back the window id to the calling app, where libxfce4panel would
create a new 'XfceForeignPanelPlugin' object that knows how to create
the required GtkPlug. Actually, yes, I like this option way better;
this way I wouldn't have to use some IPC mechanism to let the panel
plugin talk to the main app.
Also, for this to be maximally useful, I'd probably need some more API,
such as:
guint xfce_panel_get_n_panels();
guint xfce_panel_get_n_items(gint panel_num); [1]
void xfce_panel_plugin_remove_external(XfcePanelPlugin *plugin);
void xfce_panel_plugin_remove_foreign(XfcePanelPlugin *plugin);
... and maybe other stuff I haven't thought about.
[1] I guess this is the same as xfce_itembar_get_n_items(), but makes
it so the caller doesn't have to know anything about XfceItembar
This functionality isn't a critical part of my app, otherwise I'd look
into implementing this in the panel myself. If nobody cares or gets
around to it for a while, though, I might give it a go after the
important parts of my app are done.
Anyway... sorry for the long email. Thoughts?
-brian
P.S. I'd say what the app is, but I don't want people to be
disappointed in the slightly-likely event that I get busy and never
actually write it :-( .
More information about the Xfce4-dev
mailing list