initial version after renaming bliss things
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
#! /usr/bin/python
|
||||
|
||||
# Set Python path up to load from the source code dir if we're running out
|
||||
# of the source tree, otherwise point at the installed code
|
||||
import sys, os
|
||||
execpath = os.path.dirname(__file__)
|
||||
if os.path.isfile(os.path.join(execpath, "..", "configure.ac")):
|
||||
print "Running from source tree"
|
||||
sys.path.insert (0, os.path.join(execpath, ".."))
|
||||
else:
|
||||
sys.path.insert (0, os.path.join("@DATADIR@", "unity-lens-bliss"))
|
||||
del execpath
|
||||
|
||||
import bliss.apps
|
||||
from gi.repository import GLib, GObject, Gio
|
||||
|
||||
# NOTE: If we used the normal 'dbus' module for Python we'll get
|
||||
# slightly odd results because it uses a default connection
|
||||
# to the session bus that is different from the default connection
|
||||
# GDBus (hence libunity) will use. Meaning that the daemon name
|
||||
# will be owned by a connection different from the one all our
|
||||
# Dee + Unity magic is working on...
|
||||
# Still waiting for nice GDBus bindings to land:
|
||||
# http://www.piware.de/2011/01/na-zdravi-pygi/
|
||||
|
||||
#
|
||||
# The primary bus name we grab *must* match what we specify in our .lens file
|
||||
#
|
||||
BUS_NAME = "net.launchpad.UnityLensBliss.Lens"
|
||||
|
||||
session_bus_connection = Gio.bus_get_sync (Gio.BusType.SESSION, None)
|
||||
session_bus = Gio.DBusProxy.new_sync (session_bus_connection, 0, None,
|
||||
'org.freedesktop.DBus',
|
||||
'/org/freedesktop/DBus',
|
||||
'org.freedesktop.DBus', None)
|
||||
result = session_bus.call_sync('RequestName',
|
||||
GLib.Variant ("(su)", (BUS_NAME, 0x4)),
|
||||
0, -1, None)
|
||||
|
||||
# Unpack variant response with signature "(u)". 1 means we got it.
|
||||
result = result.unpack()[0]
|
||||
|
||||
if result != 1 :
|
||||
print >> sys.stderr, "Failed to own name %s. Bailing out." % BUS_NAME
|
||||
raise SystemExit (1)
|
||||
|
||||
def create_lens ():
|
||||
# The path for the Lens *must* also match the one in our .lens file
|
||||
from gi.repository import Unity
|
||||
lens = Unity.Lens.new ("/net/launchpad/unitylensbliss/lens", "bliss")
|
||||
|
||||
lens.props.search_hint = "Search for apps"
|
||||
lens.props.visible = True;
|
||||
lens.props.search_in_global = True;
|
||||
|
||||
# Populate categories
|
||||
cats = []
|
||||
cats.append (Unity.Category.new ("Applications",
|
||||
Gio.ThemedIcon.new("keyboard"),
|
||||
Unity.CategoryRenderer.VERTICAL_TILE))
|
||||
lens.props.categories = cats
|
||||
|
||||
# Populate filters
|
||||
lens.props.filters = []
|
||||
|
||||
return lens
|
||||
|
||||
lens = create_lens ()
|
||||
lens.add_local_scope (bliss.apps.Scope())
|
||||
# add more local scopes here (remote dbus scopes added automagically)
|
||||
lens.export ()
|
||||
|
||||
GObject.MainLoop().run()
|
||||
Reference in New Issue
Block a user