Ticket #719: deluge-1.1.0-national-flags.patch

File deluge-1.1.0-national-flags.patch, 7.3 KB (added by mtasaka, 14 years ago)

patch to display country name

  • deluge-1.1.0/deluge/ui/gtkui/peers_tab.py

    old new  
    4545    cell.set_property("value", value * 100) 
    4646    cell.set_property("text", "%.2f%%" % (value * 100)) 
    4747 
     48# Use national flags if national flags are installed 
     49def use_national_flags(): 
     50    pixmap_dir = pkg_resources.resource_filename( 
     51        "deluge", os.path.join("data", "pixmaps", "flags")) 
     52    try: 
     53        pixmap_number = len(os.listdir(pixmap_dir)) 
     54        if pixmap_number > 3 : 
     55            return True 
     56        else : 
     57            return False 
     58    except OSError: 
     59        return False 
     60 
    4861class PeersTab(Tab): 
    4962    def __init__(self): 
    5063        Tab.__init__(self) 
     
    7184        self.peers = {} 
    7285 
    7386        # Country column 
    74         column = gtk.TreeViewColumn() 
    75         render = gtk.CellRendererPixbuf() 
    76         column.pack_start(render, False) 
    77         column.add_attribute(render, "pixbuf", 0) 
     87        self.use_national_flags = use_national_flags() 
     88        if self.use_national_flags: 
     89            column = gtk.TreeViewColumn() 
     90            render = gtk.CellRendererPixbuf() 
     91            column.pack_start(render, False) 
     92            column.add_attribute(render, "pixbuf", 0) 
     93        else: 
     94            column = gtk.TreeViewColumn("Country") 
     95            render = gtk.CellRendererText() 
     96            column.pack_start(render, False) 
     97            column.add_attribute(render, "text", 5) 
    7898        column.set_sort_column_id(5) 
    7999        column.set_clickable(True) 
    80100        column.set_resizable(True) 
     
    249269    def get_flag_pixbuf(self, country): 
    250270        if country == "  ": 
    251271            return None 
     272        if not self.use_national_flags : 
     273            return None 
    252274 
    253275        if not self.cached_flag_pixbufs.has_key(country): 
    254276            # We haven't created a pixbuf for this country yet 
  • deluge-1.1.0/setup.py

    old new  
    3333import msgfmt 
    3434import os 
    3535import platform 
     36import sys 
    3637 
    3738python_version = platform.python_version()[0:3] 
    3839 
     
    202203 
    203204    _ext_modules = [libtorrent] 
    204205 
     206# Some distribution has a policy that national flags cannot 
     207# be installed. 
     208# This part parses the argument --without-national-flags 
     209# and if it is found set use_national_flags as False 
     210# 
     211use_national_flags = True 
     212for argc in range(1, len(sys.argv)): 
     213    str = sys.argv[argc] 
     214    if str == '--without-national-flags' : 
     215        use_national_flags = False 
     216        # Remove this argument 
     217        del sys.argv[argc] 
     218        break 
     219 
    205220class build_trans(cmd.Command): 
    206221    description = 'Compile .po files into .mo files' 
    207222 
     
    342357    ('share/man/man1', ['deluge/docs/man/deluge.1', 'deluge/docs/man/deluged.1']) 
    343358] 
    344359 
     360_package_data = [ 
     361    "ui/gtkui/glade/*.glade", 
     362    "data/pixmaps/*.png", 
     363    "data/pixmaps/*.svg", 
     364    "data/pixmaps/*.ico", 
     365    "data/revision", 
     366    "data/GeoIP.dat", 
     367    "plugins/*.egg", 
     368    "i18n/*.pot", 
     369    "i18n/*/LC_MESSAGES/*.mo", 
     370    "ui/webui/scripts/*", 
     371    "ui/webui/ssl/*", 
     372    "ui/webui/static/*.css", 
     373    "ui/webui/static/*.js", 
     374    "ui/webui/static/images/*.png", 
     375    "ui/webui/static/images/*.jpg", 
     376    "ui/webui/static/images/*.gif", 
     377    "ui/webui/static/images/16/*.png", 
     378    "ui/webui/templates/deluge/*", 
     379    "ui/webui/templates/classic/*", 
     380    "ui/webui/templates/white/*", 
     381    "ui/webui/templates/ajax/*.cfg", 
     382    "ui/webui/templates/ajax/*.js", 
     383    "ui/webui/templates/ajax/*.html", 
     384    "ui/webui/templates/ajax/*.css", 
     385    "ui/webui/templates/ajax/render/html/*.html", 
     386    "ui/webui/templates/ajax/render/js/*", 
     387    "ui/webui/templates/ajax/static/css/*.css", 
     388    "ui/webui/templates/ajax/static/icons/16/*.png", 
     389    "ui/webui/templates/ajax/static/icons/32/*.png", 
     390    "ui/webui/templates/ajax/static/images/*.gif", 
     391    "ui/webui/templates/ajax/static/js/*.js", 
     392    "ui/webui/templates/ajax/static/themes/classic/*.png", 
     393    "ui/webui/templates/ajax/static/themes/classic/*.css", 
     394    "ui/webui/templates/ajax/static/themes/classic/mime_icons/*.png", 
     395    "ui/webui/templates/ajax/static/themes/white/*.png", 
     396    "ui/webui/templates/ajax/static/themes/white/*.css", 
     397    "ui/webui/templates/ajax/static/themes/white/mime_icons/*.png", 
     398] 
     399if use_national_flags : 
     400    _package_data.append("data/pixmaps/flags/*.png") 
     401 
    345402# Main setup 
    346403setup( 
    347404    author = "Andrew Resch, Marcos Pinto, Martijn Voncken, Damien Churchill", 
     
    365422    include_package_data = True, 
    366423    license = "GPLv3", 
    367424    name = "deluge", 
    368     package_data = {"deluge": ["ui/gtkui/glade/*.glade", 
    369                                 "data/pixmaps/*.png", 
    370                                 "data/pixmaps/*.svg", 
    371                                 "data/pixmaps/*.ico", 
    372                                 "data/pixmaps/flags/*.png", 
    373                                 "data/revision", 
    374                                 "data/GeoIP.dat", 
    375                                 "plugins/*.egg", 
    376                                 "i18n/*.pot", 
    377                                 "i18n/*/LC_MESSAGES/*.mo", 
    378                                 "ui/webui/scripts/*", 
    379                                 "ui/webui/ssl/*", 
    380                                 "ui/webui/static/*.css", 
    381                                 "ui/webui/static/*.js", 
    382                                 "ui/webui/static/images/*.png", 
    383                                 "ui/webui/static/images/*.jpg", 
    384                                 "ui/webui/static/images/*.gif", 
    385                                 "ui/webui/static/images/16/*.png", 
    386                                 "ui/webui/templates/deluge/*", 
    387                                 "ui/webui/templates/classic/*", 
    388                                 "ui/webui/templates/white/*", 
    389                                 "ui/webui/templates/ajax/*.cfg", 
    390                                 "ui/webui/templates/ajax/*.js", 
    391                                 "ui/webui/templates/ajax/*.html", 
    392                                 "ui/webui/templates/ajax/*.css", 
    393                                 "ui/webui/templates/ajax/render/html/*.html", 
    394                                 "ui/webui/templates/ajax/render/js/*", 
    395                                 "ui/webui/templates/ajax/static/css/*.css", 
    396                                 "ui/webui/templates/ajax/static/icons/16/*.png", 
    397                                 "ui/webui/templates/ajax/static/icons/32/*.png", 
    398                                 "ui/webui/templates/ajax/static/images/*.gif", 
    399                                 "ui/webui/templates/ajax/static/js/*.js", 
    400                                 "ui/webui/templates/ajax/static/themes/classic/*.png", 
    401                                 "ui/webui/templates/ajax/static/themes/classic/*.css", 
    402                                 "ui/webui/templates/ajax/static/themes/classic/mime_icons/*.png", 
    403                                 "ui/webui/templates/ajax/static/themes/white/*.png", 
    404                                 "ui/webui/templates/ajax/static/themes/white/*.css", 
    405                                 "ui/webui/templates/ajax/static/themes/white/mime_icons/*.png", 
    406                                 ]}, 
     425    package_data = {"deluge": _package_data}, 
    407426    packages = find_packages(exclude=["plugins"]), 
    408427    url = "http://deluge-torrent.org", 
    409428    version = "1.1.0",