Dynamic Quicklists in Unity

It has been quite some time since the Unity launcher API was opened; and though dynamic quicklists didn’t work until the release of Unity 3.6.4 (fix courtesy the awesome Michael Terry), many applications in Natty now have support for quicklists, both static and dynamic. Examples of applications using quicklists: Gwibber, Deja-Dup, GNOME-Screenshot, etc.

Last month I worked on adding Unity launcher quicklist support to Firefox , and now I’m working on adding it to update-manager. Provided that I don’t get stopped by major hurdles (UI freeze is in effect, I need to get an exception for each such change), my next stop would be *burp* Banshee!

You too can easily add quicklist support to your own applications. The guide here is highly helpful. As an example, below is the patch I wrote to enable quicklist support in Update Manager:

=== modified file 'UpdateManager/UpdateManager.py'
--- UpdateManager/UpdateManager.py    2011-04-06 07:43:01 +0000
+++ UpdateManager/UpdateManager.py    2011-04-12 09:33:28 +0000
@@ -297,6 +297,34 @@
     self.alert_watcher.connect("battery-alert", self._on_battery_alert)
     self.alert_watcher.connect("network-3g-alert", self._on_network_3g_alert)

+    # Create Unity launcher quicklist
+    try:
+        from gi.repository import Unity, Dbusmenu
+       
+        um_launcher_entry = Unity.LauncherEntry.get_for_desktop_id ("update-manager.desktop")
+        quicklist = Dbusmenu.Menuitem.new()
+
+        update_menu_item = Dbusmenu.Menuitem.new()
+        update_menu_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Check for Updates"))
+        update_menu_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True)
+        update_menu_item.connect ("item-activated", self.on_button_reload_clicked, None)
+        quicklist.child_append(update_menu_item)
+
+        install_all_updates_menu_item = Dbusmenu.Menuitem.new()
+        install_all_updates_menu_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL,
+                                                     _("Install All Available Updates"))
+        install_all_updates_menu_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True)
+        install_all_updates_menu_item.connect ("item-activated", self.install_all_updates, None)
+        quicklist.child_append (install_all_updates_menu_item)
+
+        um_launcher_entry.set_property ("quicklist", quicklist)
+    except ImportError:
+        pass
+
+  def install_all_updates (self, widget, data = None):
+    self.select_all_updgrades (None)
+    self.on_button_install_clicked (None)
+
   def on_initial_focus_in(self, widget, event):
     """callback run on initial focus-in (if started unmapped)"""
     widget.unstick()

Thanks to GObject-Introspection the Unity and dbusmenu libraries are available for all languages out there which support GObject-Introspection (Vala, Python, etc do it already).

Quicklists aren’t anything too big, but they speed up your workflow a lot (atleast it did so in my case :) ). Add support for these in your application to make your application rock in Ubuntu 11.04!

About these ads

About Bilal Akhtar

14 year old schoolboy, Ubuntu Developer, Zend Certified Engineer in the PHP language, and likes to code in almost any language that you could name.
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

6 Responses to Dynamic Quicklists in Unity

  1. Vadim P. says:

    Really, really nice.

  2. Ubuntu is reliable OS.

  3. Tiago says:

    Hi!
    Can you help me add counter to update manager?
    What should I do your code?

  4. oimon says:

    I’d love to see quicklists for the terminal app that allowed you to choose from an open list of terminal sessions (as docky does it) – is that possible?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s