LauncherAPI

Differences between revisions 10 and 11
Revision 10 as of 2011-02-10 06:12:22
Size: 3406
Editor: cpe-069-134-033-233
Comment:
Revision 11 as of 2011-02-14 13:39:33
Size: 4550
Editor: 188
Comment: Add a Dislaimer, TOC, and make clear that libunity is unstable API
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:

<<TableOfContents()>>
Line 11: Line 13:
== Disclaimer ==

The APIs described in this document are subject to change. We are trying very hard to bring you a powerful, fun, and coherent API to instrument the Unity shell from top to bottom. We acknowledge that this is a non trivial task and we might not get it Just Right (TM) in the first cut, and since we really want to give you, dear app developer, the best, we have to make reservations for API breaks until we've really nailed it down.

When everyone is happy we will guarantee API and ABI stability, but not just yet. Sorry :-)
Line 13: Line 21:
Each launcher icon can be controlled remotely by a discrete LauncherEntry object. New launcher entry object may be created by call `unity_launcher_entry_get_for_desktop_id (char *id);` where id is the name of the desktop file shipped by the application you wish to control. For example evolution ships "evolution.desktop" or empathy ships "empathy.desktop" ||<#ffeeee> (!) '''The libunity API does not currently have any ABI or API stability guarantees''' ||
Line 15: Line 23:
LauncherEntries are able to control 3 major components of a Launcher Icon: The recommended and supported way to take control of your launcher icon is to use the API provided by '''libunity'''. This library wraps a low level DBus protocol which is documented below.

Each launcher icon can be controlled remotely by a discrete {{{LauncherEntry}}} object. New launcher entry object may be created by call `unity_launcher_entry_get_for_desktop_id (char *id);` where id is the name of the desktop file shipped by the application you wish to control. For example evolution ships {{{"evolution.desktop"}}} or empathy ships {{{"empathy.desktop"}}}.

{{{LauncherEntry}}}es are able to control 3 major components of a Launcher Icon:
Line 21: Line 33:
unity_launcher_entry_set_count (UnityLauncherEntry *self, int count); unity_launcher_entry_set_count (UnityLauncherEntry *self, gint64 count);
Line 40: Line 52:

The {{{progress}}} value should be between {{{0.0}}} and {{{1.0}}}.
Line 64: Line 78:
    var l = new Unity.LauncherEntry ("evolution.desktop");     var l = Unity.LauncherEntry.get_for_desktop_id ("evolution.desktop");
Line 69: Line 83:
    
    /* set the progress of the icon */
    l.progress = 0.8;

    /* Set progress to 42% done */
    l.progress = 0.42;
Line 73: Line 87:

    /* Set an emblem as well (this is not shown the in the screenshot above) */
    l.emblem = new ThemedIcon ("emblem-important");
    l.emblem_visible = true;
Line 88: Line 106:

Launcher API

We support adding quicklists, counters, and progress bars for apps in the Unity Launcher:

unityapi.png

Disclaimer

The APIs described in this document are subject to change. We are trying very hard to bring you a powerful, fun, and coherent API to instrument the Unity shell from top to bottom. We acknowledge that this is a non trivial task and we might not get it Just Right (TM) in the first cut, and since we really want to give you, dear app developer, the best, we have to make reservations for API breaks until we've really nailed it down.

When everyone is happy we will guarantee API and ABI stability, but not just yet. Sorry Smile :-)

Using the Launcher API

Info (!) The libunity API does not currently have any ABI or API stability guarantees

The recommended and supported way to take control of your launcher icon is to use the API provided by libunity. This library wraps a low level DBus protocol which is documented below.

Each launcher icon can be controlled remotely by a discrete LauncherEntry object. New launcher entry object may be created by call unity_launcher_entry_get_for_desktop_id (char *id); where id is the name of the desktop file shipped by the application you wish to control. For example evolution ships "evolution.desktop" or empathy ships "empathy.desktop".

LauncherEntryes are able to control 3 major components of a Launcher Icon:

Count

The first aspect they can control is the count associated with the icon. The count may be set by calling

unity_launcher_entry_set_count (UnityLauncherEntry *self, gint64 count);

This will remotely prime the count, then calling

unity_launcher_entry_set_count_visible (UnityLauncherEntry *self, gboolean visible)

can toggle its visible status. Updates to the count and other properties are live, unsetting and resetting the visibility is not require nor is it encouraged.

Progress

progress can be set by

unity_launcher_entry_set_progress (UnityLauncherEntry *self, gdouble progress)

and made visible by calling

unity_launcher_entry_set_progress_visible (UnityLauncherEntry *self, gbloolean visible);

The progress value should be between 0.0 and 1.0.

Quicklists

Quicklists may also be created and appended to the launcher. To create a quicklist a root node must first be created as a container, and then child nodes are added to it. This final result may be packed into the launcher which is then shipped over the bus to Unity. Updates to the quicklist are also live. Rather than describe the entire API, an example of using quicklist (as well as progress and count) is provided below using the vala bindings.

It is important to note that the main loop must be invoked for the program to actual work. Libunity requires the usage of the main loop as work may be done async.

Filing Bugs

  • https://launchpad.net/libunity

  • If you're having a problem with the launcher not displaying or incrementing, then it's probably a libunity problem. If the rendering is wrong, it's probably a unity bug and not libunity.
  • Contact Us

Example Code

Vala Example

/* Compile with: valac --pkg unity --pkg dee-1.0 --pkg gee-1.0 --pkg Dbusmenu-Glib-0.4 launcherexample.vala */
namespace LauncherExample {

  public static void main ()
  {
    /* Pretend to be evolution for the sake of the example */
    var l = Unity.LauncherEntry.get_for_desktop_id ("evolution.desktop");

    /* Show a count of 124 on the icon */
    l.count = 124;
    l.count_visible = true;

    /* Set progress to 42% done */
    l.progress = 0.42;
    l.progress_visible = true;

    /* Set an emblem as well (this is not shown the in the screenshot above) */
    l.emblem = new ThemedIcon ("emblem-important");
    l.emblem_visible = true;
    
    /* We also want a quicklist */
    var ql = new Dbusmenu.Menuitem ();
    var item1 = new Dbusmenu.Menuitem ();
    item1.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Item 1");
    var item2 = new Dbusmenu.Menuitem ();
    item2.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Item 2");
    ql.child_append (item1);
    ql.child_append (item2);
    l.quicklist = ql;

    new MainLoop().run();
  }
  
}

Unity/LauncherAPI (last edited 2013-08-09 12:17:35 by 3v1n0)