~ubuntu-branches/ubuntu/quantal/kourou/quantal

« back to all changes in this revision

Viewing changes to kourou.py

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2008-10-09 18:01:21 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20081009180121-0yd5nic0aq7azute
Tags: 0.5-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
# - Set background
20
20
# - Unknown icon instead of None?
21
21
 
22
 
import os, subprocess, gtk, gconf, hildondesktop, xdg.Menu, xdg.IconTheme
 
22
import os, subprocess, gobject, gtk, gconf, hildondesktop, xdg.Menu
 
23
import xdg.IconTheme
23
24
 
24
25
class Kourou(hildondesktop.HomeItem):
25
26
    def __init__(self):
27
28
        self.categories = {}
28
29
        self.seen = []
29
30
        self.client = gconf.client_get_default()
 
31
        self.rootwin = self.get_root_window()
30
32
        menu = xdg.Menu.parse()
31
33
        scrolled_win = gtk.ScrolledWindow()
32
34
        scrolled_win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
41
43
        iconview.modify_base(gtk.STATE_NORMAL, bgcolour)
42
44
        iconview.modify_text(gtk.STATE_NORMAL, fgcolour)
43
45
        iconview.connect("item-activated", self.on_select)
 
46
        iconview.connect("selection-changed", self.single_click_select)
44
47
        iconview.show()
45
48
        scrolled_win.add(iconview)
46
49
        scrolled_win.show()
85
88
        self.model.clear()
86
89
        if current_cat == "All":
87
90
            for cat in self.categories.keys():
88
 
                if cat == "Home" or cat == "Preferences":
 
91
                if cat in ("Home", "Preferences"):
89
92
                    continue
90
93
                for entry in self.categories[cat]:
91
94
                    self.model.append(entry)
101
104
            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon, 64, 64)
102
105
        return pixbuf
103
106
 
 
107
    def single_click_select(self, iconview):
 
108
        path = iconview.get_selected_items()
 
109
        if len(path) == 1:
 
110
            self.on_select(iconview, path[0])
 
111
 
104
112
    def on_select(self, iconview, path):
 
113
        self.busy_cursor()
105
114
        p = subprocess.Popen(self.model[path][2], shell=True)
106
115
        iconview.unselect_path(path)
 
116
        gobject.timeout_add(4000, self.normal_cursor)
 
117
 
 
118
    def normal_cursor(self):
 
119
        self.rootwin.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
 
120
 
 
121
    def busy_cursor(self):
 
122
        self.rootwin.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
107
123
 
108
124
def hd_plugin_get_objects():
109
125
    plugin = Kourou()