~nataliabidart/software-center/fix-986563

« back to all changes in this revision

Viewing changes to softwarecenter/view/viewswitcher.py

prototype side view

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
from gettext import gettext as _
33
33
 
 
34
from softwarecenter.enums import *
 
35
from softwarecenter.db.database import StoreDatabase
34
36
from softwarecenter.backend.transactionswatcher import TransactionsWatcher
35
37
from widgets.animatedimage import CellRendererAnimatedImage, AnimatedImage
36
38
 
44
46
    }
45
47
 
46
48
 
47
 
    def __init__(self, datadir, icons, store=None):
 
49
    def __init__(self, datadir, db, icons, store=None):
48
50
        super(ViewSwitcher, self).__init__()
49
51
        self.datadir = datadir
50
52
        self.icons = icons
51
53
        if not store:
52
 
            store = ViewSwitcherList(datadir, icons)
 
54
            store = ViewSwitcherList(datadir, db, icons)
53
55
            # FIXME: this is just set here for app.py, make the
54
56
            #        transactions-changed signal part of the view api
55
57
            #        instead of the model
132
134
    # columns
133
135
    (COL_ICON,
134
136
     COL_NAME,
135
 
     COL_ACTION) = range(3)
 
137
     COL_ACTION,
 
138
     COL_ACTION_DETAILS) = range(4)
136
139
 
137
140
    # items in the treeview
138
141
    (ACTION_ITEM_AVAILABLE,
149
152
                                              (int, )),
150
153
                     }
151
154
 
152
 
    def __init__(self, datadir, icons):
153
 
        gtk.TreeStore.__init__(self, AnimatedImage, str, int)
 
155
    def __init__(self, datadir, db, icons):
 
156
        gtk.TreeStore.__init__(self, AnimatedImage, str, int, str)
154
157
        TransactionsWatcher.__init__(self)
155
158
        self.icons = icons
156
159
        self.datadir = datadir
 
160
        self.db = db
157
161
        # pending transactions
158
162
        self._pending = 0
159
163
        # setup the normal stuff
162
166
        else:
163
167
            icon = AnimatedImage(self.icons.load_icon("gtk-missing-image", 
164
168
                                                      self.ICON_SIZE, 0))
165
 
        piter = self.append(None, [icon, _("Get Software"), self.ACTION_ITEM_AVAILABLE])
 
169
        piter = self.append(None, [icon, _("Get Software"), self.ACTION_ITEM_AVAILABLE, ""])
166
170
        
167
171
        if self.icons.lookup_icon("distributor-logo", self.ICON_SIZE, 0):
168
172
            icon = AnimatedImage(self.icons.load_icon("distributor-logo", self.ICON_SIZE, 0))
170
174
            # icon not present in theme, probably because running uninstalled
171
175
            icon = AnimatedImage(self.icons.load_icon("gtk-missing-image", 
172
176
                                                      self.ICON_SIZE, 0))
173
 
        self.append(piter, [icon, _("Free Software"), self.ACTION_ITEM_AVAILABLE])
 
177
        
 
178
        # add labels
 
179
        for it in self.db.xapiandb.allterms("XOL"):
 
180
            term = it.term[3:]
 
181
            if not term:
 
182
                term = _("Unknown")
 
183
            self.append(piter, [icon, term, self.ACTION_ITEM_AVAILABLE, ""])
174
184
        
175
185
        icon = AnimatedImage(self.icons.load_icon("computer", self.ICON_SIZE, 0))
176
 
        self.append(None, [icon, _("Installed Software"), self.ACTION_ITEM_INSTALLED])
 
186
        self.append(None, [icon, _("Installed Software"), self.ACTION_ITEM_INSTALLED, ""])
177
187
        icon = AnimatedImage(None)
178
 
        self.append(None, [icon, "<span size='1'> </span>", self.ACTION_ITEM_SEPARATOR_1])
 
188
        self.append(None, [icon, "<span size='1'> </span>", self.ACTION_ITEM_SEPARATOR_1, ""])
179
189
 
180
190
    def on_transactions_changed(self, current, queue):
181
191
        #print "check_pending"
217
227
 
218
228
    scroll = gtk.ScrolledWindow()
219
229
    icons = gtk.icon_theme_get_default()
220
 
    view = ViewSwitcher(datadir, icons)
 
230
 
 
231
    xapian_base_path = XAPIAN_BASE_PATH
 
232
    pathname = os.path.join(xapian_base_path, "xapian")
 
233
    cache = apt.Cache(apt.progress.OpTextProgress())
 
234
    db = StoreDatabase(pathname, cache)
 
235
    db.open()
 
236
 
 
237
    view = ViewSwitcher(datadir, db, icons)
221
238
 
222
239
    box = gtk.VBox()
223
240
    box.pack_start(scroll)