~davidc3/onehundredscopes/photo

« back to all changes in this revision

Viewing changes to src/unity-lens-photo

  • Committer: David Callé
  • Date: 2012-02-27 18:29:18 UTC
  • Revision ID: davidc@framli.eu-20120227182918-lcy2u0ee7j88vjco
Add specific Home Dash category

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
class Daemon:
32
32
 
33
 
        def __init__ (self):
34
 
                # The path for the Lens *must* also match the one in our .lens file
35
 
                #[2]
36
 
                self._lens = Unity.Lens.new ("/net/launchpad/lens/photo", "photo")
37
 
                #[3]
38
 
                self._scope = Unity.Scope.new ("/net/launchpad/lens/photo/main")
39
 
                
40
 
                #[4]
41
 
                self._lens.props.search_hint = "Search Photos"
42
 
                #[5]
43
 
                self._lens.props.visible = True;
44
 
                #[6]
45
 
                self._lens.props.search_in_global = True;
46
 
                
47
 
                # Populate categories
48
 
                cats = []
49
 
 
50
 
                cats.append (Unity.Category.new ("Recent",
51
 
                                                 Gio.ThemedIcon.new("/usr/share/icons/unity-icon-theme/places/svg/group-recent.svg"),
52
 
                                                 Unity.CategoryRenderer.VERTICAL_TILE))
53
 
                cats.append (Unity.Category.new ("On this computer",
54
 
                                                 Gio.ThemedIcon.new("/usr/share/icons/unity-icon-theme/places/svg/group-installed.svg"),
55
 
                                                 Unity.CategoryRenderer.VERTICAL_TILE))
56
 
                cats.append (Unity.Category.new ("Online",
57
 
                                                 Gio.ThemedIcon.new("/usr/share/icons/unity-icon-theme/places/svg/group-downloads.svg"),
58
 
                                                 Unity.CategoryRenderer.VERTICAL_TILE))
59
 
 
60
 
                self._lens.props.categories = cats
61
 
                
62
 
                # Populate filters
63
 
                filters = []
64
 
#               f = Unity.RadioOptionFilter.new ("events", "Recent events", Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
65
 
#               f.add_option ("", "Noël", None)
66
 
#               f.add_option ("", "lundi 28 novembre 2011", None)
67
 
#               f.add_option ("", "Blabla", None)
68
 
#               f.add_option ("", "Blabla", None)
69
 
#               f.add_option ("", "Blabla", None)
70
 
#               f.add_option ("", "Blabla", None)
71
 
#               filters.append (f)
72
 
                
73
 
                f2 = Unity.RadioOptionFilter.new ("date", "Date", Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
74
 
                f2.add_option ("7", "Last 7 days", None)
75
 
                f2.add_option ("30", "Last 30 days ", None)
76
 
                f2.add_option ("180", "Last 6 months", None)
77
 
                f2.add_option ("10000", "Older", None)
78
 
 
79
 
                filters.append (f2)
80
 
                
81
 
                f3 = Unity.RadioOptionFilter.new ("taken_by", "Taken by", Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
82
 
                f3.add_option ("me", "Me", None)
83
 
                f3.add_option ("contacts", "Friends ", None)
84
 
                filters.append (f3)
85
 
                self._lens.props.filters = filters
86
 
 
87
 
                self._lens.export ();
 
33
    def __init__ (self):
 
34
        # The path for the Lens *must* also match the one in our .lens file
 
35
        #[2]
 
36
        self._lens = Unity.Lens.new ("/net/launchpad/lens/photo", "photo")
 
37
        #[3]
 
38
        self._scope = Unity.Scope.new ("/net/launchpad/lens/photo/main")
 
39
        
 
40
        #[4]
 
41
        self._lens.props.search_hint = "Search Photos"
 
42
        #[5]
 
43
        self._lens.props.visible = True;
 
44
        #[6]
 
45
        self._lens.props.search_in_global = True;
 
46
        
 
47
        # Populate categories
 
48
        cats = []
 
49
 
 
50
        cats.append (Unity.Category.new ("Recent",
 
51
                                         Gio.ThemedIcon.new("/usr/share/icons/unity-icon-theme/places/svg/group-recent.svg"),
 
52
                                         Unity.CategoryRenderer.VERTICAL_TILE))
 
53
        cats.append (Unity.Category.new ("On this computer",
 
54
                                         Gio.ThemedIcon.new("/usr/share/icons/unity-icon-theme/places/svg/group-installed.svg"),
 
55
                                         Unity.CategoryRenderer.VERTICAL_TILE))
 
56
        cats.append (Unity.Category.new ("Online",
 
57
                                         Gio.ThemedIcon.new("/usr/share/icons/unity-icon-theme/places/svg/group-downloads.svg"),
 
58
                                         Unity.CategoryRenderer.VERTICAL_TILE))
 
59
        cats.append (Unity.Category.new ("Photos",
 
60
                                         Gio.ThemedIcon.new("/usr/share/unity/5/lens-nav-photo.svg"),
 
61
                                         Unity.CategoryRenderer.VERTICAL_TILE))
 
62
 
 
63
        self._lens.props.categories = cats
 
64
        
 
65
        # Populate filters
 
66
        filters = []
 
67
#        f = Unity.RadioOptionFilter.new ("events", "Recent events", Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
 
68
#        f.add_option ("", "Noël", None)
 
69
#        f.add_option ("", "lundi 28 novembre 2011", None)
 
70
#        f.add_option ("", "Blabla", None)
 
71
#        f.add_option ("", "Blabla", None)
 
72
#        f.add_option ("", "Blabla", None)
 
73
#        f.add_option ("", "Blabla", None)
 
74
#        filters.append (f)
 
75
        
 
76
        f2 = Unity.RadioOptionFilter.new ("date", "Date", Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
 
77
        f2.add_option ("7", "Last 7 days", None)
 
78
        f2.add_option ("30", "Last 30 days ", None)
 
79
        f2.add_option ("180", "Last 6 months", None)
 
80
        f2.add_option ("10000", "Older", None)
 
81
 
 
82
        filters.append (f2)
 
83
        
 
84
        f3 = Unity.RadioOptionFilter.new ("taken_by", "Taken by", Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
 
85
        f3.add_option ("me", "Me", None)
 
86
        f3.add_option ("contacts", "Friends ", None)
 
87
        filters.append (f3)
 
88
        self._lens.props.filters = filters
 
89
 
 
90
        self._lens.export ();
88
91
 
89
92
if __name__ == "__main__":
90
 
        session_bus_connection = Gio.bus_get_sync (Gio.BusType.SESSION, None)
91
 
        session_bus = Gio.DBusProxy.new_sync (session_bus_connection, 0, None,
92
 
                                              'org.freedesktop.DBus',
93
 
                                              '/org/freedesktop/DBus',
94
 
                                              'org.freedesktop.DBus', None)
95
 
        result = session_bus.call_sync('RequestName',
96
 
                                       GLib.Variant ("(su)", (BUS_NAME, 0x4)),
97
 
                                       0, -1, None)
98
 
                                       
99
 
        # Unpack variant response with signature "(u)". 1 means we got it.
100
 
        result = result.unpack()[0]
101
 
        
102
 
        if result != 1 :
103
 
                print >> sys.stderr, "Failed to own name %s. Bailing out." % BUS_NAME
104
 
                raise SystemExit (1)
105
 
        
106
 
        daemon = Daemon()
107
 
        GObject.MainLoop().run()
 
93
    session_bus_connection = Gio.bus_get_sync (Gio.BusType.SESSION, None)
 
94
    session_bus = Gio.DBusProxy.new_sync (session_bus_connection, 0, None,
 
95
                                          'org.freedesktop.DBus',
 
96
                                          '/org/freedesktop/DBus',
 
97
                                          'org.freedesktop.DBus', None)
 
98
    result = session_bus.call_sync('RequestName',
 
99
                                   GLib.Variant ("(su)", (BUS_NAME, 0x4)),
 
100
                                   0, -1, None)
 
101
                                   
 
102
    # Unpack variant response with signature "(u)". 1 means we got it.
 
103
    result = result.unpack()[0]
 
104
    
 
105
    if result != 1 :
 
106
        print >> sys.stderr, "Failed to own name %s. Bailing out." % BUS_NAME
 
107
        raise SystemExit (1)
 
108
    
 
109
    daemon = Daemon()
 
110
    GObject.MainLoop().run()