Yes, we realize that we need Python documentation with the appropriate level of detail. That is the goal of the Giraffe project. It will work with the GObject Introspection bindings which is the way that new Python applications should be written to use the application indicators.
Until then, the best bet is the API documentation that you've noted. It should be roughly the same though "python-ified".
The build_menu_from_desktop is a convenience function use load the entries that would otherwise be in something like a quicklist in Unity. So to get those entries you'd use build_menu_from_desktop("/my/path/myfile.desktop", "Unity")
to specify the TargetEnvironment.
This allows you to have different entries in the desktop file and have some overlap and others not.
After looking at the source to libaccountsservice you actually have to wait for the user to be loaded before accessing the user object. This acheives the result:
from gi.repository import AccountsService, GLib
current_user = GLib.get_user_name()
user = AccountsService.UserManager.get_default().get_user(current_user)
def is_loaded_cb(user, param):
print user.get_icon_file()
user.connect('notify::is-loaded', is_loaded_cb)
main_loop = GLib.MainLoop()
main_loop.run()
Alternatively, you can contact the accounts service directly and synchronously over D-Bus:
from gi.repository import GLib, Gio
current_user = GLib.get_user_name ()
bus = Gio.bus_get_sync (Gio.BusType.SYSTEM, None)
result = bus.call_sync ('org.freedesktop.Accounts',
'/org/freedesktop/Accounts',
'org.freedesktop.Accounts',
'FindUserByName',
GLib.Variant ('(s)', (current_user,)),
GLib.VariantType.new ('(o)'),
Gio.DBusCallFlags.NONE,
-1,
None)
(path,) = result.unpack ()
result = bus.call_sync ('org.freedesktop.Accounts',
path,
'org.freedesktop.DBus.Properties',
'GetAll',
GLib.Variant ('(s)', ('org.freedesktop.Accounts.User',)),
GLib.VariantType.new ('(a{sv})'),
Gio.DBusCallFlags.NONE,
-1,
None)
(props,) = result.unpack ()
print props['IconFile']
print props['RealName']
If you want to set the icon file you need to call the appropriate method:
result = bus.call_sync ('org.freedesktop.Accounts',
path,
'org.freedesktop.Accounts.User',
'SetIconFile',
GLib.Variant ('(s)', ('/tmp/somefile.png',)),
GLib.VariantType.new ('()'),
Gio.DBusCallFlags.NONE,
-1,
None)
If you need to use any other methods, browse the D-Bus interface using D-Feet (in the software center).
Best Answer
As you may have heard, in April 2017, Canonical announced that Unity and all related projects were being abandoned. This includes indicators, which were an Ubuntu specific project. As such, during the last 12 months, several parts of that, which were hosted by Canonical, have been taken down or removed from web sites, including developer documentation.
However, that documentation was simply styled to match the web site, and is the same documentation that is in the source code, and shipped in the packaging. Simply install the
libappindicator-doc
package, and you will have a local copy of the documentation. If you want it to be a little easier to browse, you can also consider installing thedevhelp
package.