~ubuntu-branches/ubuntu/quantal/software-center/quantal-updates

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/models/appstore2.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt, Michael Vogt, Anthony Lenton, Gary Lasker, Natalia Bidart
  • Date: 2012-03-09 08:55:46 UTC
  • Revision ID: package-import@ubuntu.com-20120309085546-p7p4ppu59ishighc
Tags: 5.1.12
[ Michael Vogt ]
* lp:~mvo/software-center/webcam-string-fix:
- small fix to support the debtagshw updated tags for hardware::camera
  (split into webcam,digicam now)
* lp:~mvo/software-center/trivial-nm-state-override:
  - support the SOFTWARE_CENTER_NET_CONNECTED environment value to
    force the connected state as a stopgap workaround for bug 911706
* lp:~mvo/software-center/lp941361:
  - adds a general make_string_from_list() helper to build (somewhat)
    i18n friendly human readable strings easily (LP: #941361)
* lp:~mvo/software-center/expunge-cache:
  - merge os.nice() addition
* lp:~mvo/software-center/lp789596:
  - better (less scary) string for updates from third-party
    venders (LP: #789596)
* lp:~mvo/software-center/fix-refresh-of-whats-new:
  - fix missing refresh of the what's new content on a database
    reopen so that new content from the agent appears as soon
    as it finishes the update
* lp:~mvo/software-center/review-fixes:
  - ensure ui is correctly updated after submitting/modifying review
* lp:~mvo/software-center/simulate-slow-network:
  - add a small helper to simulate a slow network connection to
    see if we have hidden latencies in the UI when the network
    is (really) slow
* lp:~mvo/software-center/top-rated-refresh:
  - ensure that the top-rated apps are refreshed when we have new data
* lp:~mvo/software-center/apptreeview-tweaks:
  - fix 'load_range" errors when navigating the installed view
    (LP: #913675), and do some nice needed refactoring/cleanup

[ Anthony Lenton ]
* lp:~elachuni/software-center/dont-store:
  - consolidate Ubunty SSO logins to use "Ubuntu Software Center", fixes
    inconsistent UI and storing of two keys in they keyring, as well as
    being prompted to log in twice the first time that you review an app
* lp:~elachuni/software-center/pep8-test,
  lp:~elachuni/software-center/pep8-test-part2,
  lp:~elachuni/software-center/pep8-test-part3,
  lp:~elachuni/software-center/pep8-test-part4:
  - add a unit test to check code statically for pep8 compliance and update
    more and more of the code to meet it

[ Gary Lasker ]
* lp:~gary-lasker/software-center/fix-crash-lp944875:
  - Fix an intermittent crash that can happen if the installed view pane
    has not been built yet when a call to show the spinner is made as a
    result of a refresh (LP: #944875)
* lp:~gary-lasker/software-center/list-view-icon-coordinates-lp947624:
  - This branch adds support for providing the correct icon size and 
    on-screen coordinates values in the Unity launcher integration dbus 
    call when an installation is initiated via the list view
    (LP: #947624)
* lp:~gary-lasker/software-center/enable-published-date-unit-test:
  - unit test change only, enable the published-date unit test that was
    disabled pending deployment of support on the staging server

[ Natalia Bidart ]
* lp:~nataliabidart/software-center/one-auth:
  - use consistently the same app name for every Ubuntu SSO call to
    ensure SSO tokens are handled properly

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
from softwarecenter.utils import ExecutionTime, SimpleFileDownloader, split_icon_ext
32
32
from softwarecenter.backend import get_install_backend
33
33
from softwarecenter.backend.reviews import get_review_loader
34
 
from softwarecenter.db.database import Application
35
34
from softwarecenter.paths import SOFTWARE_CENTER_ICON_CACHE_DIR
36
35
 
37
36
import softwarecenter.paths
74
73
        return
75
74
 
76
75
 
77
 
class _AppPropertiesHelper(GObject.GObject):
 
76
class AppPropertiesHelper(GObject.GObject):
78
77
    """ Baseclass that contains common functions for our
79
78
        liststore/treestore, only useful for subclassing
80
79
    """
86
85
                           ),
87
86
        }
88
87
 
89
 
    def __init__(self):
 
88
    def __init__(self, db, cache, icons, icon_size=48, global_icon_cache=False):
90
89
        GObject.GObject.__init__(self)
 
90
        self.db = db
 
91
        self.cache = cache
 
92
 
 
93
        # get all categories
 
94
        cat_parser = CategoriesParser(db)
 
95
        self.all_categories = cat_parser.parse_applications_menu(
 
96
            softwarecenter.paths.APP_INSTALL_PATH)
 
97
 
 
98
        # reviews stats loader
 
99
        self.review_loader = get_review_loader(cache, db)
 
100
 
 
101
        # icon jazz
 
102
        self.icons = icons
 
103
        self.icon_size = icon_size
 
104
 
 
105
        # cache the 'missing icon' used in the treeview for apps without an icon
 
106
        self._missing_icon = icons.load_icon(Icons.MISSING_APP, icon_size, 0)
 
107
        if global_icon_cache:
 
108
            self.icon_cache = _app_icon_cache
 
109
        else:
 
110
            self.icon_cache = {}
 
111
        return
91
112
 
92
113
    def _download_icon_and_show_when_ready(self, url, pkgname, icon_file_name):
93
114
        LOG.debug("did not find the icon locally, must download %s" % icon_file_name)
138
159
        return self.db.get_pkgname(doc)
139
160
 
140
161
    def get_application(self, doc):
141
 
        appname = doc.get_value(XapianValues.APPNAME)
142
 
        pkgname = self.db.get_pkgname(doc)
143
 
        # TODO: requests
144
 
        return Application(appname, pkgname, "")
 
162
        return self.db.get_application(doc)
145
163
 
146
164
    def get_appname(self, doc):
147
 
        appname = doc.get_value(XapianValues.APPNAME)
148
 
        if not appname:
149
 
            appname = self.db.get_summary(doc)
150
 
        else:
151
 
            if self.db.is_appname_duplicated(appname):
152
 
                appname = "%s (%s)" % (appname, self.get_pkgname(doc))
153
 
        return appname
 
165
        app = self.db.get_application(doc)
 
166
        return app.get_display_name(self.db, doc)
154
167
 
155
168
    def get_markup(self, doc):
156
 
        appname = doc.get_value(XapianValues.APPNAME)
 
169
        app = self.db.get_application(doc)
157
170
 
158
 
        if not appname:
 
171
        # the logic is that "apps" are displayed normally
 
172
        # but "packages" are displayed with their summary as name
 
173
        if app.appname:
 
174
            appname = self.get_appname(doc)
 
175
            summary = self.db.get_summary(doc)
 
176
        else:
159
177
            appname = self.db.get_summary(doc)
160
178
            summary = self.get_pkgname(doc)
161
 
        else:
162
 
            if self.db.is_appname_duplicated(appname):
163
 
                appname = "%s (%s)" % (appname, self.get_pkgname(doc))
164
 
 
165
 
            summary = self.db.get_summary(doc)
166
179
 
167
180
        return "%s\n<small>%s</small>" % (
168
181
                 GObject.markup_escape_text(appname),
239
252
        else:
240
253
            return ''
241
254
 
242
 
class AppPropertiesHelper(_AppPropertiesHelper):
243
 
 
244
 
    def __init__(self, db, cache, icons, icon_size=48, global_icon_cache=False):
245
 
        super(AppPropertiesHelper, self).__init__()
246
 
        self.db = db
247
 
        self.cache = cache
248
 
 
249
 
        cat_parser = CategoriesParser(db)
250
 
        self.all_categories = cat_parser.parse_applications_menu(
251
 
            softwarecenter.paths.APP_INSTALL_PATH)
252
 
 
253
 
        # reviews stats loader
254
 
        self.review_loader = get_review_loader(cache, db)
255
 
 
256
 
        # icon jazz
257
 
        self.icons = icons
258
 
        self.icon_size = icon_size
259
 
        # cache the 'missing icon' used in the treeview for apps without an icon
260
 
        self._missing_icon = icons.load_icon(Icons.MISSING_APP,
261
 
                                             icon_size, 0)
262
 
 
263
 
        if global_icon_cache:
264
 
            self.icon_cache = _app_icon_cache
265
 
        else:
266
 
            self.icon_cache = {}
267
 
        return
268
 
 
269
255
    def get_icon_at_size(self, doc, width, height):
270
256
        pixbuf = self.get_icon(doc)
271
257
        pixbuf = pixbuf.scale_simple(width, height,
272
258
                                     GdkPixbuf.InterpType.BILINEAR)
273
259
        return pixbuf
274
260
 
275
 
    def get_transaction_progress(self, doc):
276
 
        raise NotImplemented
277
 
 
278
 
 
279
 
class AppGenericStore(_AppPropertiesHelper):
 
261
 
 
262
class AppGenericStore(AppPropertiesHelper):
280
263
 
281
264
    # column types
282
265
    COL_TYPES = (GObject.TYPE_PYOBJECT,)
291
274
    LOAD_INITIAL   = 75
292
275
 
293
276
    def __init__(self, db, cache, icons, icon_size, global_icon_cache):
294
 
        # the usual suspects
295
 
        self.db = db
296
 
        self.cache = cache
297
 
 
298
 
        # reviews stats loader
299
 
        self.review_loader = get_review_loader(cache, db)
 
277
        AppPropertiesHelper.__init__(self, db, cache, icons, icon_size, 
 
278
                                     global_icon_cache)
300
279
 
301
280
        # backend stuff
302
281
        self.backend = get_install_backend()
307
286
        # keep track of paths for transactions in progress
308
287
        self.transaction_path_map = {}
309
288
 
310
 
        # icon jazz
311
 
        self.icons = icons
312
 
        self.icon_size = icon_size
313
 
 
314
 
        if global_icon_cache:
315
 
            self.icon_cache = _app_icon_cache
316
 
        else:
317
 
            self.icon_cache = {}
318
 
 
319
289
        # active row path
320
290
        self.active_row = None
321
291
 
322
 
        # cache the 'missing icon' used in the treeview for apps without an icon
323
 
        self._missing_icon = icons.load_icon(Icons.MISSING_APP, icon_size, 0)
324
 
 
325
292
        self._in_progress = False
326
293
        self._break = False
327
294
 
396
363
            GObject.idle_add(buffer_icons)
397
364
        return
398
365
 
 
366
    def load_range(self, indices, step):
 
367
        # stub
 
368
        return
 
369
 
399
370
class AppListStore(Gtk.ListStore, AppGenericStore):
400
371
    """ use for flat applist views. for large lists this appends rows approx
401
372
        three times faster than the AppTreeStore equivalent
526
497
        self.transaction_path_map = {}
527
498
        Gtk.TreeStore.clear(self)
528
499
        return
 
500