~kiwinote/software-center/bug439613bug530194

« back to all changes in this revision

Viewing changes to softwarecenter/view/appdetailsview.py

  • Committer: Michael Vogt
  • Date: 2009-12-08 10:19:30 UTC
  • mfrom: (179.1.102 andrew)
  • Revision ID: michael.vogt@ubuntu.com-20091208101930-vm0lh85cgsmnbs0z
merge lp:~rugby471/software-center/software-store-andrew,
many thanks

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import gobject
24
24
import gtk
25
25
import logging
26
 
import pango
27
26
import os
28
27
import re
29
28
import socket
31
30
import subprocess
32
31
import sys
33
32
import tempfile
34
 
import time
35
33
import threading
36
34
import urllib
37
35
import xapian
40
38
 
41
39
if os.path.exists("./softwarecenter/enums.py"):
42
40
    sys.path.insert(0, ".")
 
41
 
43
42
from softwarecenter.enums import *
44
43
from softwarecenter.version import *
45
44
from softwarecenter.db.database import StoreDatabase
60
59
    APP_ICON_PADDING = 8
61
60
 
62
61
    # FIXME: use relative path here
63
 
    INSTALLED_ICON = "/usr/share/icons/hicolor/24x24/emblems/software-center-installed.png"
 
62
    INSTALLED_ICON = "/usr/share/software-center/emblems/software-center-installed.png"
64
63
    IMAGE_LOADING = "/usr/share/icons/hicolor/32x32/animations/softwarecenter-loading.gif"
65
64
    IMAGE_LOADING_INSTALLED = "/usr/share/icons/hicolor/32x32/animations/softwarecenter-loading-installed.gif"
66
65
 
160
159
 
161
160
    def clear(self):
162
161
        " clear the current view "
163
 
        self.load_string("","text/plain","ascii","file:/")
164
 
        while gtk.events_pending():
 
162
        self.load_string("", "text/plain", "ascii", "file:/")
 
163
        while gtk.events_pending(): 
165
164
            gtk.main_iteration()
166
165
 
167
166
    # substitute functions called during page display
192
191
        description = self.pkg.description
193
192
        #bullets (*)
194
193
        regx = re.compile("((\*) .*)")
195
 
        description = re.sub(regx, r'<p>\1</p>', description)
 
194
        description = re.sub(regx, r'<li>\1</li>', description)
 
195
        description = self.add_ul_tags(description)
196
196
        
197
197
        #bullets (-)
198
198
        regx = re.compile("((\-) .*)")
199
 
        description = re.sub(regx, r'<p>\1</p>', description)
 
199
        description = re.sub(regx, r'<li>\1</li>', description)
 
200
        description = self.add_ul_tags(description)
200
201
        
201
202
        #line breaks
202
203
        regx = re.compile("(\n\n)")
204
205
        
205
206
        # urls
206
207
        regx = re.compile("((ftp|http|https):\/\/[a-zA-Z0-9\/\\\:\?\%\.\&\;=#\-\_\!\+\~]*)")
207
 
        description = re.sub(regx, r'<a href="\1">\1</a>', description)
 
208
        
 
209
        return re.sub(regx, r'<a href="\1">\1</a>', description)
 
210
 
 
211
    def add_ul_tags(self, description):
 
212
        n = description.find("<li>")
 
213
        if not n == -1:
 
214
            description[n:n+3].replace("<li>", "<ul><li>")
 
215
            description = description[0:n] + description[n:n+3].replace("<li>", "<ul><li>") + description[n+3:]
 
216
            description_list_tmp = []
 
217
            len_description = range(len(description))
 
218
            len_description.reverse()
 
219
        
 
220
            for letter in len_description:
 
221
                description_list_tmp.append(description[letter])
 
222
                
 
223
            description_list_tmp = "".join(description_list_tmp)
 
224
            n = len(description) - description_list_tmp.find(">il/<")
 
225
            return description[0:n] + description[n-5:n].replace("</li>", "</li></ul>") + description[n:]
208
226
        return description
 
227
 
209
228
    def wksub_iconpath_loading(self):
210
229
        if (self.cache.has_key(self.pkgname) and
211
230
            self.cache[self.pkgname].isInstalled):
319
338
        url = self.distro.SCREENSHOT_LARGE_URL % self.pkgname
320
339
        title = _("%s - Screenshot") % self.appname
321
340
        d = ShowImageDialog(title, url,
322
 
                            self.IMAGE_LOADING_INSTALLED,
 
341
                            self.icons.lookup_icon("process-working", 32, ()).get_filename(),
 
342
                            self.icons.lookup_icon("process-working", 32, ()).get_base_size(),
323
343
                            self.distro.IMAGE_FULL_MISSING)
324
344
        d.run()
325
345
        d.destroy()
342
362
        depends = self.cache.get_installed_rdepends(self.pkg)
343
363
        if depends:
344
364
            iconpath = self.get_icon_filename(self.iconname, self.APP_ICON_SIZE)
 
365
            
345
366
            if not dialogs.confirm_remove(None, primary, self.cache,
346
367
                                        button_text, iconpath, depends):
347
368
                self._set_action_button_sensitive(True)
379
400
        #  WEBKIT_NAVIGATION_RESPONSE_DOWNLOAD
380
401
        # } WebKitNavigationResponse;
381
402
        uri = request.get_uri()
382
 
        if uri.startswith("http:"):
383
 
            subprocess.call(["gnome-open", uri])
 
403
        if uri.startswith("http:") or uri.startswith("https:") or uri.startswith("www"):
 
404
            subprocess.call(["xdg-open", uri])
384
405
            return 1
385
406
        return 0
386
407
 
421
442
        action_button_value = ""
422
443
        if self.pkg:
423
444
            pkg = self.pkg
424
 
            if pkg.installed and pkg.isUpgradable:
425
 
                action_button_label = _("Upgrade")
426
 
                action_button_value = "upgrade"
427
 
            elif pkg.installed:
 
445
            # Don't handle upgrades yet
 
446
            #if pkg.installed and pkg.isUpgradable:
 
447
            #    action_button_label = _("Upgrade")
 
448
            #    action_button_value = "upgrade"
 
449
            if pkg.installed:
428
450
                action_button_label = _("Remove")
429
451
                action_button_value = "remove"
430
452
            else:
469
491
if __name__ == "__main__":
470
492
    logging.basicConfig(level=logging.DEBUG)
471
493
 
472
 
    import sys
473
 
 
474
494
    if len(sys.argv) > 1:
475
495
        datadir = sys.argv[1]
476
496
    elif os.path.exists("./data"):