"Simple" gnome applets in Unity - stickynotes
I guess this is a related question to Can I use GNOME applets in Unity? (moved by suggestion of @Jorge Castro)
I'd like to use stickynotes_applet
in Unity.. Now in Gnome, this applet gets added to a bar, then I have to click it to create a new note, and I can call preferences to have the notes stick on the desktop - which is all I need.
Obviously, as mentioned here, it will not be possible to use this applet directly in Unity; but basically, all I'd need to do is to raise the Preferences window (so as to make the notes stick), and to somehow issue a command for a new note (which would otherwise be performed by a click on the applet icon in the Gnome bar).
I have tried running '/usr/lib/gnome-applets/stickynotes_applet
' and seemingly it runs, although no applet icon is shown (which is expected), and no any other windows either (which I otherwise hoped will show :) ).
So I was wandering - given that this applet doesn't (seem to) have anything special related to desktop - is there a command line way to basically run this applet, issue a 'Show Preferences' command to it, and issue a new note command to it within a Unity environment (currently I can call tomboy
from command line and it works - but its windows are too clunky for my taste)?
(and bonus question - how would you start an applet related window only from the command line in classic Gnome?)
Desktop integration doesn't matter all that much to me - I'd run this manually from the command line gladly, as long as I get small compact notes that stay on the desktop (as long as the process is active)..
Thanks for any comments,
Cheers!
You could have a small gnome-panel running your applet only. See How do I use the GNOME Panel in Unity?
I came back to this problem again (still on Natty); so I thought I'd post my results.
First, I started looking up if you can run Gnome applets from the command line, and in a separate window - turns out, this was a technique for debugging Python applets;
- First I stumbled upon this: Zaur Nasibov's Beginner's guide to creating a GNOME applet with Python (Part I)
- Then I went into patching
invest-applet
(which is in Python) so it again works on Natty; patch can be found in Bug #775387 “Invest-applet fails to start after upgrade to Natty...” : Bugs : “gnome-applets” package : Ubuntu - Finally, I developed a Python script, that instantiates an
invest-applet
object when called from the command line, and puts it in its own window - and this happens to work in Unity:
This is the script:
import sys
import gtk
import pygtk
pygtk.require('2.0')
# sudo apt-get install python-gnomeapplet
import gnomeapplet
import CORBA # must have import gnomeapplet before!
import bonobo
import bonobo.ui
import bonobo.activation
bcontrol = bonobo.activation.activate_from_id('OAFIID:Invest_Applet', 0, False)
win = bonobo.ui.Window("foo", "FOOOOO")
buiwid = bonobo.ui.widget_new_control_from_objref(bcontrol, win.get_ui_container().corba_objref())
win.set_contents(buiwid)
win.show_all()
win.connect("destroy", lambda x: sys.exit(0))
bonobo.ui.main()
... and the extended script (with debug output, and a ton of messy comments) is in gtk_bonobo_applet_widget.py.
This is exactly what I wanted, and at first, I thought that it would be applicable to all applets - at least in Natty (and among them stickynotes
); but alas, no:
Now, Natty is a bit specific, because it is the last Gnome 2 Ubuntu - however, it also features (the first) Unity. As such:
- some applets are based on (or exposing a)
bonobo
/CORBA
interface (in Python, viagnomeapplet
); those, likeinvest-applet
orbrightness-applet
, can use the above technique to be raised in their own window - and can be queried throughlibbonobo2-bin
tools (likeactivation-client
) - other applets, like
stickynotes
, have migrated toward GSettings/DBUS base (interface)
In fact, stickynotes
migrated from bonobo
to dbus
shortly before Natty came out (in the revision Port to new libpanel-applet API); which is obvious by the replacement of the PANEL_APPLET_BONOBO_FACTORY
macro with PANEL_APPLET_OUT_PROCESS_FACTORY
. Arguably, if one checks out the last revision of stickynotes
based on bonobo
and builds it - one should also be able to use the above technique to instantiate the applet in a separate window, and run it from there, even without gnome-panel
.
I would have otherwise believed, that all applets (or rather, applet developing frameworks) should have the capability to run in a separate window like that - if not for any other reason, then to facilitate debugging of applets during development. And given that some applets have command line switches for running in a separate window (both the "beginner's guide" above, and also invest-applet
, feature such switches) - I hoped maybe stickynotes
features such command line arguments too; however, I did grep through its source files - and alas, I cannot find any mention of command line options.
But then, I wondered - why this migration? Well, it is because bonobo
is (or rather, has been) deprecated for a while now:
AppletsDbusMigration - GNOME Live!: (2009)
Gnome Panel drop the libbonobo dependency recently (see bug #572131).
gnome-devel-list mailing list - What will replace bonobo? (2009)
Dbus is not a direct replacement for bonobo. There is no exact replacement of bonobo as such.
...
However, the main usecase of bonobo, which is embedding one application in another (say mine-sweeper in gnumeric, or (slighly more useful) a dia diagram in gnumeric) just is not used all that much.
gnome-components mailing list 'Re: What will replace bonobo?' (2005)
> About DBUS it's hard to say that it will be replacement some day.
> First problem is that it's not component system, just message passing API.
Trust me, there are definitely plans to implement an IDL compiler of some sort to imitate CORBA-style RPC on top of D-BUS messages. It will happen sooner or later.
Well, shucks - I myself think, the "embedding one application in another" was very useful in this case - to run (at least some) applets in Unity, with support for them removed :)
Of course, it was a more-less a "lucky" arrangement of desktop packages in Natty that allowed for that (given that it is still Gnome 2 and still has the bonobo
libraries) - obviously, later versions that are Gnome 3 based have bonobo
removed completely - and the above Python-script-instantiation-in-a-window technique will most definitely not work there :/
The final question is - could we similarly use a Python script, but with bindings for dbus
, to achieve something similar to the above bonobo
based script?
Closest I got to that, is with the script gtk_dbus_applet_widget.py, however, that script doesn't raise an applet in a window - and cannot even add an applet to the bar! The only thing it can do, is talk to the applet "factory" via dbus
, and instruct it to create an applet; but this applet remains simply as data somewhere on the filesystem (and it persists across reboots!), and never becomes instantiated as a Gnome widget... And given the comments above, I doubt something like that is currently (well, on Natty at least) possible with dbus
.
In conclusion - I guess this, along with the gnome-panel
technique, exhausts the possibilities of frivolously running applets under Unity in Natty.
Rhinote has keyboard shortcuts