~cwayne/onehundredscopes/utilities-precise-with-thesaurus

« back to all changes in this revision

Viewing changes to src/unity-lens-utilities

  • Committer: David Callé
  • Date: 2012-04-23 23:15:38 UTC
  • Revision ID: davidc@framli.eu-20120423231538-0our35y0szvfx8pt
Tweak the cat titles and icons

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
class Daemon:
30
30
 
31
 
        def __init__ (self):
32
 
                # The path for the Lens *must* also match the one in our .lens file
33
 
                self._lens = Unity.Lens.new ("/net/launchpad/lens/utilities", "utilities")
34
 
                
35
 
                self._lens.props.search_hint = "Use tools"
36
 
                self._lens.props.visible = False;
37
 
                self._lens.props.search_in_global = True;
38
 
                
39
 
                icon = "/usr/share/unity/lenses/utilities/utilities-lens.svg"
40
 
                
41
 
                # Populate categories
42
 
                cats = []
43
 
                cats.append (Unity.Category.new ("Calculator",
44
 
                                                 Gio.ThemedIcon.new(icon),
45
 
                                                 Unity.CategoryRenderer.VERTICAL_TILE))
46
 
                cats.append (Unity.Category.new ("Cities",
47
 
                                                 Gio.ThemedIcon.new(icon),
48
 
                                                 Unity.CategoryRenderer.VERTICAL_TILE))
 
31
    def __init__ (self):
 
32
        # The path for the Lens *must* also match the one in our .lens file
 
33
        self._lens = Unity.Lens.new ("/net/launchpad/lens/utilities", "utilities")
 
34
        
 
35
        self._lens.props.search_hint = "Use tools"
 
36
        self._lens.props.visible = False;
 
37
        self._lens.props.search_in_global = True;
 
38
        
 
39
        icon_calculator = "/usr/share/unity/lenses/utilities/lens-cat-pi.svg"
 
40
        icon_cities = "/usr/share/unity/lenses/utilities/lens-cat-place.svg"
 
41
        
 
42
        # Populate categories
 
43
        cats = []
 
44
        cats.append (Unity.Category.new ("Calculator",
 
45
                                         Gio.ThemedIcon.new(icon_calculator),
 
46
                                         Unity.CategoryRenderer.VERTICAL_TILE))
 
47
        cats.append (Unity.Category.new ("Time & Weather",
 
48
                                         Gio.ThemedIcon.new(icon_cities),
 
49
                                         Unity.CategoryRenderer.VERTICAL_TILE))
49
50
 
50
 
                self._lens.props.categories = cats
51
 
                
52
 
                # Populate filters
53
 
                filters = []
54
 
                self._lens.props.filters = filters
55
 
                self._lens.export ();
 
51
        self._lens.props.categories = cats
 
52
        
 
53
        # Populate filters
 
54
        filters = []
 
55
        self._lens.props.filters = filters
 
56
        self._lens.export ();
56
57
 
57
58
if __name__ == "__main__":
58
 
        session_bus_connection = Gio.bus_get_sync (Gio.BusType.SESSION, None)
59
 
        session_bus = Gio.DBusProxy.new_sync (session_bus_connection, 0, None,
60
 
                                              'org.freedesktop.DBus',
61
 
                                              '/org/freedesktop/DBus',
62
 
                                              'org.freedesktop.DBus', None)
63
 
        result = session_bus.call_sync('RequestName',
64
 
                                       GLib.Variant ("(su)", (BUS_NAME, 0x4)),
65
 
                                       0, -1, None)
66
 
                                       
67
 
        # Unpack variant response with signature "(u)". 1 means we got it.
68
 
        result = result.unpack()[0]
69
 
        
70
 
        if result != 1 :
71
 
                print >> sys.stderr, "Failed to own name %s. Bailing out." % BUS_NAME
72
 
                raise SystemExit (1)
73
 
        
74
 
        daemon = Daemon()
75
 
        GObject.MainLoop().run()
 
59
    session_bus_connection = Gio.bus_get_sync (Gio.BusType.SESSION, None)
 
60
    session_bus = Gio.DBusProxy.new_sync (session_bus_connection, 0, None,
 
61
                                          'org.freedesktop.DBus',
 
62
                                          '/org/freedesktop/DBus',
 
63
                                          'org.freedesktop.DBus', None)
 
64
    result = session_bus.call_sync('RequestName',
 
65
                                   GLib.Variant ("(su)", (BUS_NAME, 0x4)),
 
66
                                   0, -1, None)
 
67
                                   
 
68
    # Unpack variant response with signature "(u)". 1 means we got it.
 
69
    result = result.unpack()[0]
 
70
    
 
71
    if result != 1 :
 
72
        print >> sys.stderr, "Failed to own name %s. Bailing out." % BUS_NAME
 
73
        raise SystemExit (1)
 
74
    
 
75
    daemon = Daemon()
 
76
    GObject.MainLoop().run()