Changeset 7c808a


Ignore:
Timestamp:
01/16/2014 07:54:20 PM (12 years ago)
Author:
Calum Lind <calumlind+deluge@gmail.com>
Branches:
2.0.x, develop, master
Children:
0a41b86
Parents:
d260f6
git-author:
bendikro <bendikro@gmail.com> (01/13/2014 12:48:00 AM)
git-committer:
Calum Lind <calumlind+deluge@gmail.com> (01/16/2014 07:54:20 PM)
Message:

Added language option to Preferences

Changing translation tested and works on:

  • Windows 7
  • OSX 10.8
  • Ubuntu 13.04
  • Updated the OSX menubar to gtkbuilder
  • Added language names to the Language dropdown in Preferences
Location:
deluge
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • deluge/common.py

    rd260f6 r7c808a  
    116116}
    117117
     118
    118119def get_version():
    119120    """
     
    126127    return pkg_resources.require("Deluge")[0].version
    127128
     129
    128130def get_default_config_dir(filename=None):
    129131    """
    130     :param filename: if None, only the config path is returned, if provided, a path including the filename will be returned
     132    :param filename: if None, only the config path is returned, if provided,
     133                     a path including the filename will be returned
    131134    :type filename: string
    132135    :returns: a file path to the config directory and optional filename
     
    140143            if not appDataPath:
    141144                import _winreg
    142                 hkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders")
     145                hkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
     146                                       "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders")
    143147                appDataReg = _winreg.QueryValueEx(hkey, "AppData")
    144148                appDataPath = appDataReg[0]
     
    155159        sys.exit(1)
    156160
     161
    157162def get_default_download_dir():
    158163    """
     
    169174            for line in open(userdir_file, 'r'):
    170175                if not line.startswith('#') and 'XDG_DOWNLOAD_DIR' in line:
    171                         download_dir = os.path.expandvars(\
    172                                         line.partition("=")[2].rstrip().strip('"'))
     176                        download_dir = os.path.expandvars(line.partition("=")[2].rstrip().strip('"'))
    173177                        if os.path.isdir(download_dir):
    174178                            return download_dir
     
    178182        return os.environ.get("HOME")
    179183
     184
    180185def windows_check():
    181186    """
     
    188193    return platform.system() in ('Windows', 'Microsoft')
    189194
     195
    190196def vista_check():
    191197    """
     
    198204    return platform.release() == "Vista"
    199205
     206
    200207def osx_check():
    201208    """
     
    207214    """
    208215    return platform.system() == "Darwin"
     216
    209217
    210218def get_pixmap(fname):
     
    219227    """
    220228    return resource_filename("deluge", os.path.join("ui", "data", "pixmaps", fname))
     229
    221230
    222231def resource_filename(module, path):
     
    231240    )
    232241
     242
    233243def open_file(path):
    234244    """
     
    246256        subprocess.Popen(["xdg-open", "%s" % path])
    247257
     258
    248259def open_url_in_browser(url):
    249260    """
     
    263274mib_txt = "MiB"
    264275gib_txt = "GiB"
     276
    265277
    266278def translate_strings():
     
    269281    mib_txt = _("MiB")
    270282    gib_txt = _("GiB")
     283
    271284
    272285def fsize(fsize_b):
     
    297310        return "%d %s" % (fsize_b, byte_txt)
    298311
     312
    299313def fsize_short(fsize_b):
    300314    """
     
    321335    return "%.1f %s" % (fsize_gb, _("G"))
    322336
     337
    323338def fpcnt(dec):
    324339    """
     
    337352    """
    338353    return '%.2f%%' % (dec * 100)
     354
    339355
    340356def fspeed(bps):
     
    362378    return "%.1f %s" % (fspeed_gb, _("GiB/s"))
    363379
     380
    364381def fpeer(num_peers, total_peers):
    365382    """
     
    385402    else:
    386403        return "%d" % num_peers
     404
    387405
    388406def ftime(seconds):
     
    425443    return '%dy %dw' % (years, weeks)
    426444
     445
    427446def fdate(seconds):
    428447    """
     
    438457        return ""
    439458    return time.strftime("%x %X", time.localtime(seconds))
     459
    440460
    441461def is_url(url):
     
    455475    """
    456476    return url.partition('://')[0] in ("http", "https", "ftp", "udp")
     477
    457478
    458479def is_magnet(uri):
     
    476497        return True
    477498    return False
     499
    478500
    479501def create_magnet_uri(infohash, name=None, trackers=[]):
     
    502524    return uri
    503525
     526
    504527def get_path_size(path):
    505528    """
     
    524547            dir_size += os.path.getsize(filename)
    525548    return dir_size
     549
    526550
    527551def free_space(path):
     
    547571        block_size = disk_data.f_frsize
    548572        return disk_data.f_bavail * block_size
     573
    549574
    550575def is_ip(ip):
     
    586611        return False
    587612
     613
    588614def path_join(*parts):
    589615    """
     
    612638)
    613639
     640
    614641def xml_decode(string):
    615642    """
     
    625652    return string
    626653
     654
    627655def xml_encode(string):
    628656    """
     
    637665        string = string.replace(char, escape)
    638666    return string
     667
    639668
    640669def decode_string(s, encoding="utf8"):
     
    673702    return u''
    674703
     704
    675705def utf8_encoded(s, encoding="utf8"):
    676706    """
     
    690720        s = s.encode("utf8")
    691721    return s
     722
    692723
    693724class VersionSplit(object):
     
    716747        match = re.search(VERSION_RE, ver)
    717748        if match:
    718             group = [(x if x is not None else '') for x in match.group(1,2,3,4,8)]
    719             vs = [''.join(group[0:2]),''.join(group[2:4]), group[4].lstrip('.')]
     749            group = [(x if x is not None else '') for x in match.group(1, 2, 3, 4, 8)]
     750            vs = [''.join(group[0:2]), ''.join(group[2:4]), group[4].lstrip('.')]
    720751        else:
    721752            ver = ver.lower()
     
    760791AUTH_LEVEL_DEFAULT = AUTH_LEVEL_NORMAL
    761792
     793
    762794def create_auth_file():
    763     import stat, configmanager
     795    import stat
     796    import configmanager
    764797    auth_file = configmanager.get_config_dir("auth")
    765798    # Check for auth file and create if necessary
     
    772805        os.chmod(auth_file, stat.S_IREAD | stat.S_IWRITE)
    773806
     807
    774808def create_localclient_account(append=False):
    775     import configmanager, random
     809    import configmanager
     810    import random
    776811    auth_file = configmanager.get_config_dir("auth")
    777812    if not os.path.exists(auth_file):
     
    793828
    794829
     830def get_translations_path():
     831    """Get the absolute path to the directory containing translation files"""
     832    return resource_filename("deluge", "i18n")
     833
     834
     835def set_env_variable(name, value):
     836    '''
     837    :param name: environment variable name
     838    :param value: environment variable value
     839
     840    This function ensures that changes to an environment variable are applied
     841    to each copy of the environment variables used by a process. Starting from
     842    Python 2.4, os.environ changes only apply to the copy Python keeps (os.environ)
     843    and are no longer automatically applied to the other copies for the process.
     844
     845    On Microsoft Windows, each process has multiple copies of the environment
     846    variables, one managed by the OS and one managed by the C library. We also
     847    need to take care of the fact that the C library used by Python is not
     848    necessarily the same as the C library used by pygtk and friends. This because
     849    the latest releases of pygtk and friends are built with mingw32 and are thus
     850    linked against msvcrt.dll. The official gtk+ binaries have always been built
     851    in this way.
     852
     853    Basen on _putenv in TransUtils.py from sourceforge project gramps
     854    http://sourceforge.net/p/gramps/code/HEAD/tree/branches/maintenance/gramps32/src/TransUtils.py
     855    '''
     856    # Update Python's copy of the environment variables
     857    os.environ[name] = value
     858
     859    if windows_check():
     860        from ctypes import windll
     861        from ctypes import cdll
     862        from ctypes.util import find_msvcrt
     863
     864        # Update the copy maintained by Windows (so SysInternals Process Explorer sees it)
     865        try:
     866            result = windll.kernel32.SetEnvironmentVariableW(name, value)
     867            if result == 0:
     868                raise Warning
     869        except Exception:
     870            log.warning('Failed to set Env Var \'%s\' (\'kernel32.SetEnvironmentVariableW\')' % name)
     871        else:
     872            log.debug('Set Env Var \'%s\' to \'%s\' (\'kernel32.SetEnvironmentVariableW\')' % (name, value))
     873
     874        # Update the copy maintained by msvcrt (used by gtk+ runtime)
     875        try:
     876            result = cdll.msvcrt._putenv('%s=%s' % (name, value))
     877            if result != 0:
     878                raise Warning
     879        except Exception:
     880            log.warning('Failed to set Env Var \'%s\' (\'msvcrt._putenv\')' % name)
     881        else:
     882            log.debug('Set Env Var \'%s\' to \'%s\' (\'msvcrt._putenv\')' % (name, value))
     883
     884        # Update the copy maintained by whatever c runtime is used by Python
     885        try:
     886            msvcrt = find_msvcrt()
     887            msvcrtname = str(msvcrt).split('.')[0] if '.' in msvcrt else str(msvcrt)
     888            result = cdll.LoadLibrary(msvcrt)._putenv('%s=%s' % (name, value))
     889            if result != 0:
     890                raise Warning
     891        except Exception:
     892            log.warning('Failed to set Env Var \'%s\' (\'%s._putenv\')' % (name, msvcrtname))
     893        else:
     894            log.debug('Set Env Var \'%s\' to \'%s\' (\'%s._putenv\')' % (name, value, msvcrtname))
     895
     896
     897def set_language(lang):
     898    """
     899    Set the language to use.
     900
     901    gettext and GtkBuilder will load the translations from the specified
     902    language.
     903
     904    :param lang: the language, e.g. "en", "de" or "en_GB"
     905    :type lang: str
     906    """
     907    lang = str(lang)
     908    # Necessary to set there environment variables for GtkBuilder
     909    set_env_variable('LANGUAGE', lang)  # Windows/Linux
     910    set_env_variable('LANG', lang)  # For OSX
     911
     912    translations_path = get_translations_path()
     913    ro = gettext.translation("deluge", localedir=translations_path, languages=[lang])
     914    ro.install()
     915
     916
    795917# Initialize gettext
    796 def setup_translations(setup_pygtk=False):
    797     translations_path = resource_filename("deluge", "i18n")
     918def setup_translations(setup_gettext=True, setup_pygtk=False):
     919    translations_path = get_translations_path()
     920    domain = "deluge"
    798921    log.info("Setting up translations from %s", translations_path)
    799922
    800     try:
    801         if hasattr(locale, "bindtextdomain"):
    802             locale.bindtextdomain("deluge", translations_path)
    803         if hasattr(locale, "textdomain"):
    804             locale.textdomain("deluge")
    805         gettext.install("deluge", translations_path, unicode=True)
    806         if setup_pygtk:
    807             # Even though we're not using glade anymore, let's set it up so that
    808             # plugins still using it get properly translated.
     923    if setup_pygtk:
     924        try:
    809925            log.info("Setting up GTK translations from %s", translations_path)
     926
     927            if windows_check():
     928                import ctypes
     929                libintl = ctypes.cdll.intl
     930                libintl.bindtextdomain(domain, translations_path.encode(sys.getfilesystemencoding()))
     931                libintl.textdomain(domain)
     932                libintl.bind_textdomain_codeset(domain, "UTF-8")
     933                libintl.gettext.restype = ctypes.c_char_p
     934
     935            # Use glade for plugins that still uses it
    810936            import gtk
    811937            import gtk.glade
    812             gtk.glade.bindtextdomain("deluge", translations_path)
    813             gtk.glade.textdomain("deluge")
     938            gtk.glade.bindtextdomain(domain, translations_path)
     939            gtk.glade.textdomain(domain)
     940        except Exception, e:
     941            log.error("Unable to initialize glade translation!")
     942            log.exception(e)
     943    if setup_gettext:
     944        try:
     945            if hasattr(locale, "bindtextdomain"):
     946                locale.bindtextdomain(domain, translations_path)
     947            if hasattr(locale, "textdomain"):
     948                locale.textdomain(domain)
     949
     950            gettext.bindtextdomain(domain, translations_path)
     951            gettext.bind_textdomain_codeset(domain, 'UTF-8')
     952            gettext.textdomain(domain)
     953            gettext.install(domain, translations_path, unicode=True)
     954        except Exception, e:
     955            log.error("Unable to initialize gettext/locale!")
     956            log.exception(e)
     957            import __builtin__
     958            __builtin__.__dict__["_"] = lambda x: x
    814959        translate_strings()
    815     except Exception, e:
    816         log.error("Unable to initialize gettext/locale!")
    817         log.exception(e)
    818         import __builtin__
    819         __builtin__.__dict__["_"] = lambda x: x
     960
    820961
    821962def unicode_argv():
  • deluge/main.py

    rd260f6 r7c808a  
    6565def start_ui():
    6666    """Entry point for ui script"""
    67     deluge.common.setup_translations()
    68 
    6967    # Setup the argument parser
    7068    parser = OptionParser(usage="%prog [options] [actions]")
  • deluge/ui/gtkui/glade/preferences_dialog.ui

    rd260f6 r7c808a  
    321321    </data>
    322322  </object>
     323  <object class="GtkListStore" id="liststore8">
     324    <columns>
     325      <!-- column-name language_code -->
     326      <column type="gchararray"/>
     327      <!-- column-name language_name -->
     328      <column type="gchararray"/>
     329    </columns>
     330  </object>
    323331  <object class="GtkDialog" id="pref_dialog">
    324332    <property name="can_focus">False</property>
     
    345353              <object class="GtkButton" id="button_cancel">
    346354                <property name="label">gtk-cancel</property>
    347                 <property name="use_action_appearance">False</property>
    348355                <property name="visible">True</property>
    349356                <property name="can_focus">True</property>
     
    361368              <object class="GtkButton" id="button_apply">
    362369                <property name="label">gtk-apply</property>
    363                 <property name="use_action_appearance">False</property>
    364370                <property name="visible">True</property>
    365371                <property name="can_focus">True</property>
     
    377383              <object class="GtkButton" id="button_ok">
    378384                <property name="label">gtk-ok</property>
    379                 <property name="use_action_appearance">False</property>
    380385                <property name="visible">True</property>
    381386                <property name="can_focus">True</property>
     
    493498                                          <object class="GtkRadioButton" id="radio_classic">
    494499                                            <property name="label" translatable="yes">Standalone</property>
    495                                             <property name="use_action_appearance">False</property>
    496500                                            <property name="visible">True</property>
    497501                                            <property name="can_focus">True</property>
     
    510514                                          <object class="GtkRadioButton" id="radio_thinclient">
    511515                                            <property name="label" translatable="yes">Thin Client</property>
    512                                             <property name="use_action_appearance">False</property>
    513516                                            <property name="visible">True</property>
    514517                                            <property name="can_focus">True</property>
     
    567570                                          <object class="GtkCheckButton" id="chk_show_rate_in_title">
    568571                                            <property name="label" translatable="yes">Show session speed in titlebar</property>
    569                                             <property name="use_action_appearance">False</property>
    570572                                            <property name="visible">True</property>
    571573                                            <property name="can_focus">True</property>
     
    582584                                          <object class="GtkCheckButton" id="chk_focus_main_window_on_add">
    583585                                            <property name="label" translatable="yes">Focus window when adding torrent</property>
    584                                             <property name="use_action_appearance">False</property>
    585586                                            <property name="visible">True</property>
    586587                                            <property name="can_focus">True</property>
     
    593594                                            <property name="fill">True</property>
    594595                                            <property name="position">1</property>
    595                                           </packing>
    596                                         </child>
    597                                         <child>
    598                                           <object class="GtkCheckButton" id="piecesbar_toggle">
    599                                             <property name="use_action_appearance">False</property>
    600                                             <property name="visible">True</property>
    601                                             <property name="can_focus">True</property>
    602                                             <property name="receives_default">False</property>
    603                                             <property name="tooltip_text" translatable="yes">Besides being experimental, using the pieces bar
    604 will increase the bandwidth used between client
    605 and daemon(does not apply in classic mode).
    606 Use at your own risk if you wish to help us debug
    607 this new feature.</property>
    608                                             <property name="draw_indicator">True</property>
    609                                             <signal name="toggled" handler="on_piecesbar_toggle_toggled" swapped="no"/>
    610                                             <child>
    611                                               <object class="GtkLabel" id="label62">
    612                                                 <property name="visible">True</property>
    613                                                 <property name="can_focus">False</property>
    614                                                 <property name="label" translatable="yes">Show a pieces bar in the torrent's
    615 status tab (&lt;b&gt;EXPERIMENTAL!!!&lt;/b&gt;)</property>
    616                                                 <property name="use_markup">True</property>
    617                                               </object>
    618                                             </child>
    619                                           </object>
    620                                           <packing>
    621                                             <property name="expand">True</property>
    622                                             <property name="fill">True</property>
    623                                             <property name="position">2</property>
    624596                                          </packing>
    625597                                        </child>
     
    653625                                                    <child>
    654626                                                      <object class="GtkColorButton" id="completed_color">
    655                                                         <property name="use_action_appearance">False</property>
    656627                                                        <property name="visible">True</property>
    657628                                                        <property name="can_focus">True</property>
     
    664635                                                        <property name="left_attach">1</property>
    665636                                                        <property name="right_attach">2</property>
    666                                                         <property name="x_options"></property>
     637                                                        <property name="x_options"/>
    667638                                                      </packing>
    668639                                                    </child>
     
    682653                                                    <child>
    683654                                                      <object class="GtkColorButton" id="downloading_color">
    684                                                         <property name="use_action_appearance">False</property>
    685655                                                        <property name="visible">True</property>
    686656                                                        <property name="can_focus">True</property>
     
    695665                                                        <property name="top_attach">1</property>
    696666                                                        <property name="bottom_attach">2</property>
    697                                                         <property name="x_options"></property>
     667                                                        <property name="x_options"/>
    698668                                                      </packing>
    699669                                                    </child>
     
    713683                                                    <child>
    714684                                                      <object class="GtkColorButton" id="waiting_color">
    715                                                         <property name="use_action_appearance">False</property>
    716685                                                        <property name="visible">True</property>
    717686                                                        <property name="can_focus">True</property>
     
    726695                                                        <property name="top_attach">2</property>
    727696                                                        <property name="bottom_attach">3</property>
    728                                                         <property name="x_options"></property>
     697                                                        <property name="x_options"/>
    729698                                                      </packing>
    730699                                                    </child>
     
    744713                                                    <child>
    745714                                                      <object class="GtkColorButton" id="missing_color">
    746                                                         <property name="use_action_appearance">False</property>
    747715                                                        <property name="visible">True</property>
    748716                                                        <property name="can_focus">True</property>
     
    757725                                                        <property name="top_attach">3</property>
    758726                                                        <property name="bottom_attach">4</property>
    759                                                         <property name="x_options"></property>
     727                                                        <property name="x_options"/>
    760728                                                      </packing>
    761729                                                    </child>
     
    763731                                                      <object class="GtkButton" id="revert_color_completed">
    764732                                                        <property name="label">gtk-revert-to-saved</property>
    765                                                         <property name="use_action_appearance">False</property>
    766733                                                        <property name="visible">True</property>
    767734                                                        <property name="sensitive">False</property>
     
    776743                                                        <property name="left_attach">2</property>
    777744                                                        <property name="right_attach">3</property>
    778                                                         <property name="x_options"></property>
     745                                                        <property name="x_options"/>
    779746                                                      </packing>
    780747                                                    </child>
     
    782749                                                      <object class="GtkButton" id="revert_color_downloading">
    783750                                                        <property name="label">gtk-revert-to-saved</property>
    784                                                         <property name="use_action_appearance">False</property>
    785751                                                        <property name="visible">True</property>
    786752                                                        <property name="sensitive">False</property>
     
    797763                                                        <property name="top_attach">1</property>
    798764                                                        <property name="bottom_attach">2</property>
    799                                                         <property name="x_options"></property>
     765                                                        <property name="x_options"/>
    800766                                                      </packing>
    801767                                                    </child>
     
    803769                                                      <object class="GtkButton" id="revert_color_waiting">
    804770                                                        <property name="label">gtk-revert-to-saved</property>
    805                                                         <property name="use_action_appearance">False</property>
    806771                                                        <property name="visible">True</property>
    807772                                                        <property name="sensitive">False</property>
     
    818783                                                        <property name="top_attach">2</property>
    819784                                                        <property name="bottom_attach">3</property>
    820                                                         <property name="x_options"></property>
     785                                                        <property name="x_options"/>
    821786                                                      </packing>
    822787                                                    </child>
     
    824789                                                      <object class="GtkButton" id="revert_color_missing">
    825790                                                        <property name="label">gtk-revert-to-saved</property>
    826                                                         <property name="use_action_appearance">False</property>
    827791                                                        <property name="visible">True</property>
    828792                                                        <property name="sensitive">False</property>
     
    839803                                                        <property name="top_attach">3</property>
    840804                                                        <property name="bottom_attach">4</property>
    841                                                         <property name="x_options"></property>
     805                                                        <property name="x_options"/>
    842806                                                      </packing>
    843807                                                    </child>
     
    857821                                            <property name="expand">False</property>
    858822                                            <property name="fill">False</property>
     823                                            <property name="position">2</property>
     824                                          </packing>
     825                                        </child>
     826                                        <child>
     827                                          <object class="GtkCheckButton" id="piecesbar_toggle">
     828                                            <property name="visible">True</property>
     829                                            <property name="can_focus">True</property>
     830                                            <property name="receives_default">False</property>
     831                                            <property name="tooltip_text" translatable="yes">Besides being experimental, using the pieces bar
     832will increase the bandwidth used between client
     833and daemon(does not apply in classic mode).
     834Use at your own risk if you wish to help us debug
     835this new feature.</property>
     836                                            <property name="draw_indicator">True</property>
     837                                            <signal name="toggled" handler="on_piecesbar_toggle_toggled" swapped="no"/>
     838                                            <child>
     839                                              <object class="GtkLabel" id="label62">
     840                                                <property name="visible">True</property>
     841                                                <property name="can_focus">False</property>
     842                                                <property name="label" translatable="yes">Show a pieces bar in the torrent's
     843status tab (&lt;b&gt;EXPERIMENTAL!!!&lt;/b&gt;)</property>
     844                                                <property name="use_markup">True</property>
     845                                              </object>
     846                                            </child>
     847                                          </object>
     848                                          <packing>
     849                                            <property name="expand">True</property>
     850                                            <property name="fill">True</property>
    859851                                            <property name="position">2</property>
    860852                                          </packing>
     
    902894                                          <object class="GtkCheckButton" id="chk_show_dialog">
    903895                                            <property name="label" translatable="yes">Always show</property>
    904                                             <property name="use_action_appearance">False</property>
    905896                                            <property name="visible">True</property>
    906897                                            <property name="can_focus">True</property>
     
    922913                                              <object class="GtkCheckButton" id="chk_focus_dialog">
    923914                                                <property name="label" translatable="yes">Bring the dialog to focus</property>
    924                                                 <property name="use_action_appearance">False</property>
    925915                                                <property name="visible">True</property>
    926916                                                <property name="can_focus">True</property>
     
    978968                                          <object class="GtkCheckButton" id="chk_use_tray">
    979969                                            <property name="label" translatable="yes">Enable system tray icon</property>
    980                                             <property name="use_action_appearance">False</property>
    981970                                            <property name="visible">True</property>
    982971                                            <property name="can_focus">False</property>
     
    1000989                                              <object class="GtkCheckButton" id="chk_min_on_close">
    1001990                                                <property name="label" translatable="yes">Minimize to tray on close</property>
    1002                                                 <property name="use_action_appearance">False</property>
    1003991                                                <property name="visible">True</property>
    1004992                                                <property name="sensitive">False</property>
     
    10241012                                              <object class="GtkCheckButton" id="chk_start_in_tray">
    10251013                                                <property name="label" translatable="yes">Start in tray</property>
    1026                                                 <property name="use_action_appearance">False</property>
    10271014                                                <property name="visible">True</property>
    10281015                                                <property name="sensitive">False</property>
     
    10481035                                              <object class="GtkCheckButton" id="chk_enable_appindicator">
    10491036                                                <property name="label" translatable="yes">Enable Application Indicator</property>
    1050                                                 <property name="use_action_appearance">False</property>
    10511037                                                <property name="visible">True</property>
    10521038                                                <property name="sensitive">False</property>
     
    10731059                                              <object class="GtkCheckButton" id="chk_lock_tray">
    10741060                                                <property name="label" translatable="yes">Password protect system tray</property>
    1075                                                 <property name="use_action_appearance">False</property>
    10761061                                                <property name="visible">True</property>
    10771062                                                <property name="sensitive">False</property>
     
    11631148                                <property name="padding">5</property>
    11641149                                <property name="position">5</property>
     1150                              </packing>
     1151                            </child>
     1152                            <child>
     1153                              <object class="GtkFrame" id="frame2">
     1154                                <property name="visible">True</property>
     1155                                <property name="can_focus">False</property>
     1156                                <property name="label_xalign">0</property>
     1157                                <property name="shadow_type">none</property>
     1158                                <child>
     1159                                  <object class="GtkAlignment" id="alignment2">
     1160                                    <property name="visible">True</property>
     1161                                    <property name="can_focus">False</property>
     1162                                    <property name="left_padding">12</property>
     1163                                    <child>
     1164                                      <object class="GtkHBox" id="hbox8">
     1165                                        <property name="visible">True</property>
     1166                                        <property name="can_focus">False</property>
     1167                                        <child>
     1168                                          <object class="GtkCheckButton" id="checkbutton_language">
     1169                                            <property name="label" translatable="yes">System Default</property>
     1170                                            <property name="visible">True</property>
     1171                                            <property name="can_focus">True</property>
     1172                                            <property name="receives_default">False</property>
     1173                                            <property name="draw_indicator">True</property>
     1174                                            <signal name="toggled" handler="on_checkbutton_language_toggled" swapped="no"/>
     1175                                          </object>
     1176                                          <packing>
     1177                                            <property name="expand">True</property>
     1178                                            <property name="fill">True</property>
     1179                                            <property name="position">0</property>
     1180                                          </packing>
     1181                                        </child>
     1182                                        <child>
     1183                                          <object class="GtkComboBox" id="combobox_language">
     1184                                            <property name="visible">True</property>
     1185                                            <property name="can_focus">False</property>
     1186                                            <property name="model">liststore8</property>
     1187                                            <property name="active">0</property>
     1188                                            <child>
     1189                                              <object class="GtkCellRendererText" id="cellrenderertext8"/>
     1190                                              <attributes>
     1191                                                <attribute name="text">1</attribute>
     1192                                              </attributes>
     1193                                            </child>
     1194                                          </object>
     1195                                          <packing>
     1196                                            <property name="expand">True</property>
     1197                                            <property name="fill">True</property>
     1198                                            <property name="position">1</property>
     1199                                          </packing>
     1200                                        </child>
     1201                                      </object>
     1202                                    </child>
     1203                                  </object>
     1204                                </child>
     1205                                <child type="label">
     1206                                  <object class="GtkLabel" id="label5">
     1207                                    <property name="visible">True</property>
     1208                                    <property name="can_focus">False</property>
     1209                                    <property name="label" translatable="yes">&lt;b&gt;Languge&lt;/b&gt;</property>
     1210                                    <property name="use_markup">True</property>
     1211                                  </object>
     1212                                </child>
     1213                              </object>
     1214                              <packing>
     1215                                <property name="expand">False</property>
     1216                                <property name="fill">True</property>
     1217                                <property name="position">6</property>
    11651218                              </packing>
    11661219                            </child>
     
    12501303                                          <object class="GtkCheckButton" id="chk_move_completed">
    12511304                                            <property name="label" translatable="yes">Move completed to:</property>
    1252                                             <property name="use_action_appearance">False</property>
    12531305                                            <property name="visible">True</property>
    12541306                                            <property name="can_focus">True</property>
     
    12661318                                          <object class="GtkCheckButton" id="chk_copy_torrent_file">
    12671319                                            <property name="label" translatable="yes">Copy of .torrent files to:</property>
    1268                                             <property name="use_action_appearance">False</property>
    12691320                                            <property name="visible">True</property>
    12701321                                            <property name="can_focus">True</property>
     
    12821333                                          <object class="GtkCheckButton" id="chk_del_copy_torrent_file">
    12831334                                            <property name="label" translatable="yes">Delete copy of torrent file on remove</property>
    1284                                             <property name="use_action_appearance">False</property>
    12851335                                            <property name="visible">True</property>
    12861336                                            <property name="can_focus">True</property>
     
    14081458                                          <object class="GtkRadioButton" id="radio_full_allocation">
    14091459                                            <property name="label" translatable="yes">Use Full Allocation</property>
    1410                                             <property name="use_action_appearance">False</property>
    14111460                                            <property name="visible">True</property>
    14121461                                            <property name="can_focus">True</property>
     
    14261475                                          <object class="GtkRadioButton" id="radio_compact_allocation">
    14271476                                            <property name="label" translatable="yes">Use Compact Allocation</property>
    1428                                             <property name="use_action_appearance">False</property>
    14291477                                            <property name="visible">True</property>
    14301478                                            <property name="can_focus">True</property>
     
    14831531                                          <object class="GtkCheckButton" id="chk_prioritize_first_last_pieces">
    14841532                                            <property name="label" translatable="yes">Prioritize first and last pieces of torrent</property>
    1485                                             <property name="use_action_appearance">False</property>
    14861533                                            <property name="visible">True</property>
    14871534                                            <property name="can_focus">True</property>
     
    14991546                                          <object class="GtkCheckButton" id="chk_sequential_download">
    15001547                                            <property name="label" translatable="yes">Sequential download</property>
    1501                                             <property name="use_action_appearance">False</property>
    15021548                                            <property name="visible">True</property>
    15031549                                            <property name="can_focus">True</property>
     
    15201566                                          <object class="GtkCheckButton" id="chk_add_paused">
    15211567                                            <property name="label" translatable="yes">Add torrents in Paused state</property>
    1522                                             <property name="use_action_appearance">False</property>
    15231568                                            <property name="visible">True</property>
    15241569                                            <property name="can_focus">True</property>
     
    17641809                                              <object class="GtkCheckButton" id="chk_random_port">
    17651810                                                <property name="label" translatable="yes">Random</property>
    1766                                                 <property name="use_action_appearance">False</property>
    17671811                                                <property name="visible">True</property>
    17681812                                                <property name="can_focus">True</property>
     
    18391883                                              <object class="GtkButton" id="button_testport">
    18401884                                                <property name="label" translatable="yes">Test Active Port</property>
    1841                                                 <property name="use_action_appearance">False</property>
    18421885                                                <property name="visible">True</property>
    18431886                                                <property name="can_focus">True</property>
     
    19912034                                          <object class="GtkCheckButton" id="chk_random_outgoing_ports">
    19922035                                            <property name="label" translatable="yes">Random</property>
    1993                                             <property name="use_action_appearance">False</property>
    19942036                                            <property name="visible">True</property>
    19952037                                            <property name="can_focus">True</property>
     
    22142256                                          <object class="GtkCheckButton" id="chk_upnp">
    22152257                                            <property name="label" translatable="yes">UPnP</property>
    2216                                             <property name="use_action_appearance">False</property>
    22172258                                            <property name="visible">True</property>
    22182259                                            <property name="can_focus">True</property>
     
    22302271                                          <object class="GtkCheckButton" id="chk_natpmp">
    22312272                                            <property name="label" translatable="yes">NAT-PMP</property>
    2232                                             <property name="use_action_appearance">False</property>
    22332273                                            <property name="visible">True</property>
    22342274                                            <property name="can_focus">True</property>
     
    22482288                                          <object class="GtkCheckButton" id="chk_utpex">
    22492289                                            <property name="label" translatable="yes">Peer Exchange</property>
    2250                                             <property name="use_action_appearance">False</property>
    22512290                                            <property name="visible">True</property>
    22522291                                            <property name="can_focus">True</property>
     
    22652304                                          <object class="GtkCheckButton" id="chk_lt_tex">
    22662305                                            <property name="label" translatable="yes">Tracker Exchange</property>
    2267                                             <property name="use_action_appearance">False</property>
    22682306                                            <property name="visible">True</property>
    22692307                                            <property name="can_focus">True</property>
     
    22842322                                          <object class="GtkCheckButton" id="chk_lsd">
    22852323                                            <property name="label" translatable="yes">LSD</property>
    2286                                             <property name="use_action_appearance">False</property>
    22872324                                            <property name="visible">True</property>
    22882325                                            <property name="can_focus">True</property>
     
    23002337                                          <object class="GtkCheckButton" id="chk_dht">
    23012338                                            <property name="label" translatable="yes">DHT</property>
    2302                                             <property name="use_action_appearance">False</property>
    23032339                                            <property name="visible">True</property>
    23042340                                            <property name="can_focus">True</property>
     
    27102746                                              <object class="GtkCheckButton" id="chk_ignore_limits_on_local_network">
    27112747                                                <property name="label" translatable="yes">Ignore limits on local network</property>
    2712                                                 <property name="use_action_appearance">False</property>
    27132748                                                <property name="visible">True</property>
    27142749                                                <property name="can_focus">True</property>
     
    27332768                                              <object class="GtkCheckButton" id="chk_rate_limit_ip_overhead">
    27342769                                                <property name="label" translatable="yes">Rate limit IP overhead</property>
    2735                                                 <property name="use_action_appearance">False</property>
    27362770                                                <property name="visible">True</property>
    27372771                                                <property name="can_focus">True</property>
     
    30463080                                              <object class="GtkCheckButton" id="chk_show_new_releases">
    30473081                                                <property name="label" translatable="yes">Be alerted about new releases</property>
    3048                                                 <property name="use_action_appearance">False</property>
    30493082                                                <property name="visible">True</property>
    30503083                                                <property name="can_focus">True</property>
     
    31223155                                              <object class="GtkCheckButton" id="chk_send_info">
    31233156                                                <property name="label" translatable="yes">Yes, please send anonymous statistics</property>
    3124                                                 <property name="use_action_appearance">False</property>
    31253157                                                <property name="visible">True</property>
    31263158                                                <property name="can_focus">True</property>
     
    32563288                                    <child>
    32573289                                      <object class="GtkButton" id="button_associate_magnet">
    3258                                         <property name="use_action_appearance">False</property>
    32593290                                        <property name="visible">True</property>
    32603291                                        <property name="can_focus">True</property>
     
    34693500                                      <object class="GtkCheckButton" id="chk_allow_remote_connections">
    34703501                                        <property name="label" translatable="yes">Allow Remote Connections</property>
    3471                                         <property name="use_action_appearance">False</property>
    34723502                                        <property name="visible">True</property>
    34733503                                        <property name="can_focus">True</property>
     
    35113541                                      <object class="GtkCheckButton" id="chk_new_releases">
    35123542                                        <property name="label" translatable="yes">Periodically check the website for new releases</property>
    3513                                         <property name="use_action_appearance">False</property>
    35143543                                        <property name="visible">True</property>
    35153544                                        <property name="can_focus">True</property>
     
    35743603                                              <object class="GtkButton" id="accounts_add">
    35753604                                                <property name="label">gtk-add</property>
    3576                                                 <property name="use_action_appearance">False</property>
    35773605                                                <property name="visible">True</property>
    35783606                                                <property name="can_focus">True</property>
     
    35903618                                              <object class="GtkButton" id="accounts_edit">
    35913619                                                <property name="label">gtk-edit</property>
    3592                                                 <property name="use_action_appearance">False</property>
    35933620                                                <property name="visible">True</property>
    35943621                                                <property name="sensitive">False</property>
     
    36073634                                              <object class="GtkButton" id="accounts_delete">
    36083635                                                <property name="label">gtk-delete</property>
    3609                                                 <property name="use_action_appearance">False</property>
    36103636                                                <property name="visible">True</property>
    36113637                                                <property name="sensitive">False</property>
     
    37443770                                              <object class="GtkCheckButton" id="chk_queue_new_top">
    37453771                                                <property name="label" translatable="yes">Queue new torrents to top</property>
    3746                                                 <property name="use_action_appearance">False</property>
    37473772                                                <property name="visible">True</property>
    37483773                                                <property name="can_focus">True</property>
     
    38173842                                                    <property name="left_attach">1</property>
    38183843                                                    <property name="right_attach">2</property>
    3819                                                     <property name="x_options"></property>
     3844                                                    <property name="x_options"/>
    38203845                                                  </packing>
    38213846                                                </child>
     
    38383863                                                    <property name="top_attach">2</property>
    38393864                                                    <property name="bottom_attach">3</property>
    3840                                                     <property name="x_options"></property>
     3865                                                    <property name="x_options"/>
    38413866                                                  </packing>
    38423867                                                </child>
     
    38833908                                                    <property name="top_attach">1</property>
    38843909                                                    <property name="bottom_attach">2</property>
    3885                                                     <property name="x_options"></property>
     3910                                                    <property name="x_options"/>
    38863911                                                  </packing>
    38873912                                                </child>
     
    39093934                                              <object class="GtkCheckButton" id="chk_dont_count_slow_torrents">
    39103935                                                <property name="label" translatable="yes">Do not count slow torrents</property>
    3911                                                 <property name="use_action_appearance">False</property>
    39123936                                                <property name="visible">True</property>
    39133937                                                <property name="can_focus">True</property>
     
    39243948                                              <object class="GtkCheckButton" id="chk_auto_manage_prefer_seeds">
    39253949                                                <property name="label" translatable="yes">Prefer Seeding over Downloading</property>
    3926                                                 <property name="use_action_appearance">False</property>
    39273950                                                <property name="visible">True</property>
    39283951                                                <property name="can_focus">True</property>
     
    40344057                                                    <property name="left_attach">1</property>
    40354058                                                    <property name="right_attach">2</property>
    4036                                                     <property name="x_options"></property>
     4059                                                    <property name="x_options"/>
    40374060                                                  </packing>
    40384061                                                </child>
     
    40554078                                                    <property name="top_attach">1</property>
    40564079                                                    <property name="bottom_attach">2</property>
    4057                                                     <property name="x_options"></property>
     4080                                                    <property name="x_options"/>
    40584081                                                  </packing>
    40594082                                                </child>
     
    40754098                                                    <property name="top_attach">2</property>
    40764099                                                    <property name="bottom_attach">3</property>
    4077                                                     <property name="x_options"></property>
     4100                                                    <property name="x_options"/>
    40784101                                                  </packing>
    40794102                                                </child>
     
    40934116                                                  <object class="GtkCheckButton" id="chk_seed_ratio">
    40944117                                                    <property name="label" translatable="yes">Stop seeding when share ratio reaches:</property>
    4095                                                     <property name="use_action_appearance">False</property>
    40964118                                                    <property name="visible">True</property>
    40974119                                                    <property name="can_focus">True</property>
     
    41414163                                                  <object class="GtkCheckButton" id="chk_remove_ratio">
    41424164                                                    <property name="label" translatable="yes">Remove torrent when share ratio reached</property>
    4143                                                     <property name="use_action_appearance">False</property>
    41444165                                                    <property name="visible">True</property>
    41454166                                                    <property name="sensitive">False</property>
     
    44134434                                                <property name="right_attach">2</property>
    44144435                                                <property name="x_options">GTK_FILL</property>
    4415                                                 <property name="y_options"></property>
     4436                                                <property name="y_options"/>
    44164437                                              </packing>
    44174438                                            </child>
     
    44254446                                              <packing>
    44264447                                                <property name="x_options">GTK_FILL</property>
    4427                                                 <property name="y_options"></property>
     4448                                                <property name="y_options"/>
    44284449                                              </packing>
    44294450                                            </child>
     
    46184639                                                <property name="right_attach">2</property>
    46194640                                                <property name="x_options">GTK_FILL</property>
    4620                                                 <property name="y_options"></property>
     4641                                                <property name="y_options"/>
    46214642                                              </packing>
    46224643                                            </child>
     
    46304651                                              <packing>
    46314652                                                <property name="x_options">GTK_FILL</property>
    4632                                                 <property name="y_options"></property>
     4653                                                <property name="y_options"/>
    46334654                                              </packing>
    46344655                                            </child>
     
    48234844                                                <property name="right_attach">2</property>
    48244845                                                <property name="x_options">GTK_FILL</property>
    4825                                                 <property name="y_options"></property>
     4846                                                <property name="y_options"/>
    48264847                                              </packing>
    48274848                                            </child>
     
    48354856                                              <packing>
    48364857                                                <property name="x_options">GTK_FILL</property>
    4837                                                 <property name="y_options"></property>
     4858                                                <property name="y_options"/>
    48384859                                              </packing>
    48394860                                            </child>
     
    49024923                                                <property name="bottom_attach">3</property>
    49034924                                                <property name="x_options">GTK_FILL</property>
    4904                                                 <property name="y_options"></property>
     4925                                                <property name="y_options"/>
    49054926                                              </packing>
    49064927                                            </child>
     
    49354956                                                <property name="bottom_attach">4</property>
    49364957                                                <property name="x_options">GTK_FILL</property>
    4937                                                 <property name="y_options"></property>
     4958                                                <property name="y_options"/>
    49384959                                              </packing>
    49394960                                            </child>
     
    49664987                                                <property name="bottom_attach">5</property>
    49674988                                                <property name="x_options">GTK_FILL</property>
    4968                                                 <property name="y_options"></property>
     4989                                                <property name="y_options"/>
    49694990                                              </packing>
    49704991                                            </child>
     
    50315052                                                <property name="right_attach">2</property>
    50325053                                                <property name="x_options">GTK_FILL</property>
    5033                                                 <property name="y_options"></property>
     5054                                                <property name="y_options"/>
    50345055                                              </packing>
    50355056                                            </child>
     
    50435064                                              <packing>
    50445065                                                <property name="x_options">GTK_FILL</property>
    5045                                                 <property name="y_options"></property>
     5066                                                <property name="y_options"/>
    50465067                                              </packing>
    50475068                                            </child>
     
    50575078                                                <property name="bottom_attach">2</property>
    50585079                                                <property name="x_options">GTK_FILL</property>
    5059                                                 <property name="y_options"></property>
     5080                                                <property name="y_options"/>
    50605081                                              </packing>
    50615082                                            </child>
     
    52205241                                                    <property name="left_attach">1</property>
    52215242                                                    <property name="right_attach">2</property>
    5222                                                     <property name="x_options"></property>
     5243                                                    <property name="x_options"/>
    52235244                                                  </packing>
    52245245                                                </child>
     
    52425263                                                    <property name="top_attach">1</property>
    52435264                                                    <property name="bottom_attach">2</property>
    5244                                                     <property name="x_options"></property>
     5265                                                    <property name="x_options"/>
    52455266                                                  </packing>
    52465267                                                </child>
     
    53505371                                                            <property name="left_attach">1</property>
    53515372                                                            <property name="right_attach">2</property>
    5352                                                             <property name="x_options"></property>
     5373                                                            <property name="x_options"/>
    53535374                                                            </packing>
    53545375                                                            </child>
     
    53645385                                                            <property name="top_attach">1</property>
    53655386                                                            <property name="bottom_attach">2</property>
    5366                                                             <property name="x_options"></property>
     5387                                                            <property name="x_options"/>
    53675388                                                            </packing>
    53685389                                                            </child>
     
    53785399                                                            <property name="top_attach">2</property>
    53795400                                                            <property name="bottom_attach">3</property>
    5380                                                             <property name="x_options"></property>
     5401                                                            <property name="x_options"/>
    53815402                                                            </packing>
    53825403                                                            </child>
     
    54695490                                                            <property name="left_attach">1</property>
    54705491                                                            <property name="right_attach">2</property>
    5471                                                             <property name="x_options"></property>
     5492                                                            <property name="x_options"/>
    54725493                                                            </packing>
    54735494                                                            </child>
     
    54835504                                                            <property name="top_attach">1</property>
    54845505                                                            <property name="bottom_attach">2</property>
    5485                                                             <property name="x_options"></property>
     5506                                                            <property name="x_options"/>
    54865507                                                            </packing>
    54875508                                                            </child>
     
    54975518                                                            <property name="top_attach">3</property>
    54985519                                                            <property name="bottom_attach">4</property>
    5499                                                             <property name="x_options"></property>
     5520                                                            <property name="x_options"/>
    55005521                                                            </packing>
    55015522                                                            </child>
     
    55255546                                                            <property name="top_attach">2</property>
    55265547                                                            <property name="bottom_attach">3</property>
    5527                                                             <property name="x_options"></property>
     5548                                                            <property name="x_options"/>
    55285549                                                            </packing>
    55295550                                                            </child>
     
    56015622                                                            <property name="left_attach">1</property>
    56025623                                                            <property name="right_attach">2</property>
    5603                                                             <property name="x_options"></property>
     5624                                                            <property name="x_options"/>
    56045625                                                            </packing>
    56055626                                                            </child>
     
    56155636                                                            <property name="top_attach">1</property>
    56165637                                                            <property name="bottom_attach">2</property>
    5617                                                             <property name="x_options"></property>
     5638                                                            <property name="x_options"/>
    56185639                                                            </packing>
    56195640                                                            </child>
     
    56475668                                                      <object class="GtkButton" id="button_cache_refresh">
    56485669                                                        <property name="label">gtk-refresh</property>
    5649                                                         <property name="use_action_appearance">False</property>
    56505670                                                        <property name="visible">True</property>
    56515671                                                        <property name="can_focus">True</property>
     
    58215841                                                        <property name="top_attach">4</property>
    58225842                                                        <property name="bottom_attach">5</property>
    5823                                                         <property name="y_options"></property>
     5843                                                        <property name="y_options"/>
    58245844                                                      </packing>
    58255845                                                    </child>
     
    58355855                                                        <property name="top_attach">1</property>
    58365856                                                        <property name="bottom_attach">2</property>
    5837                                                         <property name="y_options"></property>
     5857                                                        <property name="y_options"/>
    58385858                                                      </packing>
    58395859                                                    </child>
     
    58475867                                                        <property name="left_attach">1</property>
    58485868                                                        <property name="right_attach">2</property>
    5849                                                         <property name="y_options"></property>
     5869                                                        <property name="y_options"/>
    58505870                                                      </packing>
    58515871                                                    </child>
     
    58765896                                                        <property name="bottom_attach">2</property>
    58775897                                                        <property name="x_options">GTK_FILL</property>
    5878                                                         <property name="y_options"></property>
     5898                                                        <property name="y_options"/>
    58795899                                                      </packing>
    58805900                                                    </child>
     
    58885908                                                      <packing>
    58895909                                                        <property name="x_options">GTK_FILL</property>
    5890                                                         <property name="y_options"></property>
     5910                                                        <property name="y_options"/>
    58915911                                                      </packing>
    58925912                                                    </child>
     
    59305950                                                        <property name="top_attach">3</property>
    59315951                                                        <property name="bottom_attach">4</property>
    5932                                                         <property name="y_options"></property>
     5952                                                        <property name="y_options"/>
    59335953                                                      </packing>
    59345954                                                    </child>
     
    59445964                                                        <property name="top_attach">2</property>
    59455965                                                        <property name="bottom_attach">3</property>
    5946                                                         <property name="y_options"></property>
     5966                                                        <property name="y_options"/>
    59475967                                                      </packing>
    59485968                                                    </child>
     
    59856005                                <child>
    59866006                                  <object class="GtkButton" id="button_plugin_install">
    5987                                     <property name="use_action_appearance">False</property>
    59886007                                    <property name="visible">True</property>
    59896008                                    <property name="can_focus">True</property>
     
    60326051                                <child>
    60336052                                  <object class="GtkButton" id="button_rescan_plugins">
    6034                                     <property name="use_action_appearance">False</property>
    60356053                                    <property name="visible">True</property>
    60366054                                    <property name="can_focus">True</property>
     
    60906108                                <child>
    60916109                                  <object class="GtkButton" id="button_find_plugins">
    6092                                     <property name="use_action_appearance">False</property>
    60936110                                    <property name="visible">True</property>
    60946111                                    <property name="can_focus">True</property>
  • deluge/ui/gtkui/gtkui.py

    rd260f6 r7c808a  
    115115    "pref_dialog_height": None,
    116116    "window_pane_position": -1,
    117     "tray_download_speed_list" : [5.0, 10.0, 30.0, 80.0, 300.0],
    118     "tray_upload_speed_list" : [5.0, 10.0, 30.0, 80.0, 300.0],
     117    "tray_download_speed_list": [5.0, 10.0, 30.0, 80.0, 300.0],
     118    "tray_upload_speed_list": [5.0, 10.0, 30.0, 80.0, 300.0],
    119119    "connection_limit_list": [50, 100, 200, 300, 500],
    120120    "enabled_plugins": [],
     
    152152    "pieces_color_completed": [4883, 26985, 56540],
    153153    "focus_main_window_on_add": True,
     154    "language": None,
    154155}
    155156
     
    157158class GtkUI(object):
    158159    def __init__(self, args):
    159         self.daemon_bps = (0,0,0)
     160        self.daemon_bps = (0, 0, 0)
     161        # Setup btkbuilder/glade translation
     162        deluge.common.setup_translations(setup_gettext=False, setup_pygtk=True)
     163
    160164        # Setup signals
    161165        try:
     
    164168            self.gnome_prog = gnome.init("Deluge", deluge.common.get_version())
    165169            self.gnome_client = gnome.ui.master_client()
     170
    166171            def on_die(*args):
    167172                reactor.stop()
     
    175180            from win32con import CTRL_CLOSE_EVENT
    176181            from win32con import CTRL_SHUTDOWN_EVENT
     182
    177183            def win_handler(ctrl_type):
    178184                log.debug("ctrl_type: %s", ctrl_type)
     
    185191            import gtkosx_application
    186192            self.osxapp = gtkosx_application.gtkosx_application_get()
     193
    187194            def on_die(*args):
    188195                reactor.stop()
    189196            self.osxapp.connect("NSApplicationWillTerminate", on_die)
    190197
    191 
    192198        # Set process name again to fix gtk issue
    193199        setproctitle(getproctitle())
     
    207213        # shutdown the daemon.
    208214        self.started_in_classic = self.config["classic_mode"]
     215
     216        # Set language
     217        if not self.config["language"] is None:
     218            deluge.common.set_language(self.config["language"])
    209219
    210220        # Start the IPC Interface before anything else.. Just in case we are
     
    215225        # Initialize gdk threading
    216226        gtk.gdk.threads_init()
    217 
    218227
    219228        # We make sure that the UI components start once we get a core URI
     
    328337                    if "No module named libtorrent" in e.message:
    329338                        d = dialogs.YesNoDialog(
    330                         _("Enable Thin Client Mode?"),
    331                         _("Thin client mode is only available because libtorrent is not installed.\n\n\
     339                            _("Enable Thin Client Mode?"),
     340                            _("Thin client mode is only available because libtorrent is not installed.\n\n\
    332341To use Deluge standalone (Classic mode) please install libtorrent.")).run()
    333342                        self.started_in_classic = False
     
    345354                    _("There was an error starting the core component which is required to run Deluge in Classic Mode.\n\n\
    346355Please see the details below for more information."), details=traceback.format_exc(tb[2])).run()
     356
    347357                def on_ed_response(response):
    348358                    d = dialogs.YesNoDialog(
    349359                        _("Turn off Classic Mode?"),
    350                         _("Since there was an error starting in Classic Mode would you like to continue by turning it off?")).run()
     360                        _("Since there was an error starting in Classic Mode would you like to continue by turning it off?")
     361                    ).run()
    351362                    self.started_in_classic = False
    352363                    d.addCallback(on_dialog_response)
     
    407418                                    reason.value.message, reason.value.username
    408419                                )
     420
    409421                                def dialog_finished(response_id, host, port):
    410422                                    if response_id == gtk.RESPONSE_OK:
     
    447459                self.connectionmanager.show()
    448460
    449 
    450461    def __on_disconnect(self):
    451462        """
  • deluge/ui/gtkui/menubar_osx.py

    rd260f6 r7c808a  
    1818# You should have received a copy of the GNU General Public License
    1919# along with deluge.    If not, write to:
    20 #       The Free Software Foundation, Inc.,
    21 #       51 Franklin Street, Fifth Floor
    22 #       Boston, MA  02110-1301, USA.
     20#   The Free Software Foundation, Inc.,
     21#   51 Franklin Street, Fifth Floor
     22#   Boston, MA  02110-1301, USA.
    2323#
    2424#    In addition, as a special exception, the copyright holders give
     
    3333#
    3434#
    35 import gtk, gtk.glade
     35import gtk
    3636
    3737from deluge.configmanager import ConfigManager
    3838
     39
    3940def accel_swap(item, group, skey, smod, dkey, dmod):
    40         item.remove_accelerator(group, ord(skey), smod)
    41         item.add_accelerator("activate", group, ord(dkey), dmod, gtk.ACCEL_VISIBLE)
     41    item.remove_accelerator(group, ord(skey), smod)
     42    item.add_accelerator("activate", group, ord(dkey), dmod, gtk.ACCEL_VISIBLE)
     43
    4244
    4345def accel_meta(item, group, key):
    44         accel_swap(item, group, key, gtk.gdk.CONTROL_MASK, key, gtk.gdk.META_MASK)
     46    accel_swap(item, group, key, gtk.gdk.CONTROL_MASK, key, gtk.gdk.META_MASK)
     47
    4548
    4649def menubar_osx(gtkui, osxapp):
    47         window = gtkui.mainwindow
    48         glade  = window.main_glade
    49         menubar = glade.get_widget("menubar")
    50         group = gtk.accel_groups_from_object(window.window)[0]
     50    window = gtkui.mainwindow
     51    main_builder = window.get_builder()
     52    menubar = main_builder.get_object("menubar")
     53    group = gtk.accel_groups_from_object(window.window)[0]
    5154
    52         config = ConfigManager("gtkui.conf")
     55    config = ConfigManager("gtkui.conf")
    5356
    54         # NOTE: accel maps doesn't work with glade file format
    55         # because of libglade not setting MenuItem accel groups
    56         # That's why we remove / set accelerators by hand... (dirty)
    57         # Clean solution: migrate glades files to gtkbuilder format
    58         file_menu = glade.get_widget("menu_file").get_submenu()
    59         file_items = file_menu.get_children()
    60         accel_meta(file_items[0], group, 'o')
    61         accel_meta(file_items[1], group, 'n')
    62         quit_all_item = file_items[3]
    63         accel_swap(quit_all_item, group, 'q', gtk.gdk.SHIFT_MASK | gtk.gdk.CONTROL_MASK,
    64                                                                                   'q', gtk.gdk.SHIFT_MASK | gtk.gdk.META_MASK)
    65         for item in range(2, len(file_items)): # remove quits
    66                 file_menu.remove(file_items[item])
     57    # NOTE: accel maps doesn't work with glade file format
     58    # because of libglade not setting MenuItem accel groups
     59    # That's why we remove / set accelerators by hand... (dirty)
     60    # Clean solution: migrate glades files to gtkbuilder format
     61    file_menu = main_builder.get_object("menu_file").get_submenu()
     62    file_items = file_menu.get_children()
     63    accel_meta(file_items[0], group, 'o')
     64    accel_meta(file_items[1], group, 'n')
     65    quit_all_item = file_items[3]
     66    accel_swap(quit_all_item, group, 'q', gtk.gdk.SHIFT_MASK | gtk.gdk.CONTROL_MASK,
     67               'q', gtk.gdk.SHIFT_MASK | gtk.gdk.META_MASK)
     68    for item in range(2, len(file_items)): # remove quits
     69        file_menu.remove(file_items[item])
    6770
    68         menu_widget = glade.get_widget("menu_edit")
    69         edit_menu = menu_widget.get_submenu()
    70         edit_items = edit_menu.get_children()
    71         pref_item = edit_items[0]
    72         accel_swap(pref_item, group, 'p', gtk.gdk.CONTROL_MASK, ',', gtk.gdk.META_MASK)
    73         edit_menu.remove(pref_item)
     71    menu_widget = main_builder.get_object("menu_edit")
     72    edit_menu = menu_widget.get_submenu()
     73    edit_items = edit_menu.get_children()
     74    pref_item = edit_items[0]
     75    accel_swap(pref_item, group, 'p', gtk.gdk.CONTROL_MASK, ',', gtk.gdk.META_MASK)
     76    edit_menu.remove(pref_item)
    7477
    75         conn_item = edit_items[1]
    76         accel_meta(conn_item, group, 'm')
    77         edit_menu.remove(conn_item)
     78    conn_item = edit_items[1]
     79    accel_meta(conn_item, group, 'm')
     80    edit_menu.remove(conn_item)
    7881
    79         menubar.remove(menu_widget)
     82    menubar.remove(menu_widget)
    8083
    81         help_menu = glade.get_widget("menu_help").get_submenu()
    82         help_items = help_menu.get_children()
    83         about_item = help_items[4]
    84         help_menu.remove(about_item)
    85         help_menu.remove(help_items[3]) # separator
     84    help_menu = main_builder.get_object("menu_help").get_submenu()
     85    help_items = help_menu.get_children()
     86    about_item = help_items[4]
     87    help_menu.remove(about_item)
     88    help_menu.remove(help_items[3]) # separator
    8689
    87         menubar.hide()
    88         osxapp.set_menu_bar(menubar)
    89         # populate app menu
    90         osxapp.insert_app_menu_item(about_item, 0)
    91         osxapp.insert_app_menu_item(gtk.SeparatorMenuItem(), 1)
    92         osxapp.insert_app_menu_item(pref_item, 2)
    93         if not config["classic_mode"]:
    94                 osxapp.insert_app_menu_item(conn_item, 3)
    95         if quit_all_item.get_visible():
    96                 osxapp.insert_app_menu_item(gtk.SeparatorMenuItem(), 4)
    97                 osxapp.insert_app_menu_item(quit_all_item, 5)
     90    menubar.hide()
     91    osxapp.set_menu_bar(menubar)
     92    # populate app menu
     93    osxapp.insert_app_menu_item(about_item, 0)
     94    osxapp.insert_app_menu_item(gtk.SeparatorMenuItem(), 1)
     95    osxapp.insert_app_menu_item(pref_item, 2)
     96    if not config["classic_mode"]:
     97        osxapp.insert_app_menu_item(conn_item, 3)
     98    if quit_all_item.get_visible():
     99        osxapp.insert_app_menu_item(gtk.SeparatorMenuItem(), 4)
     100        osxapp.insert_app_menu_item(quit_all_item, 5)
  • deluge/ui/gtkui/preferences.py

    rd260f6 r7c808a  
    6363}
    6464
     65
    6566class Preferences(component.Component):
    6667    def __init__(self):
     
    181182            "on_revert_color_missing_clicked": self._on_revert_color_missing_clicked,
    182183            "on_pref_dialog_configure_event": self.on_pref_dialog_configure_event,
     184            "on_checkbutton_language_toggled": self._on_checkbutton_language_toggled,
    183185        })
    184186
     
    194196
    195197        self.setup_path_choosers()
     198        self.load_languages()
    196199
    197200    def setup_path_choosers(self):
     
    210213        self.copy_torrents_to_hbox.add(self.copy_torrent_files_path_chooser)
    211214        self.copy_torrents_to_hbox.show_all()
     215
     216    def load_languages(self):
     217        from deluge.ui import languages  # Import here so that gettext has been setup first
     218        translations_path = deluge.common.get_translations_path()
     219        for root, dirs, files in os.walk(translations_path):
     220            # Get the dirs
     221            break
     222        self.language_combo = self.builder.get_object("combobox_language")
     223        self.language_checkbox = self.builder.get_object("checkbutton_language")
     224        lang_model = self.language_combo.get_model()
     225
     226        index = -1
     227        for i, lang_code in enumerate(sorted(dirs)):
     228            name = "%s (Language name missing)" % lang_code
     229            if lang_code in languages.LANGUAGES:
     230                name = languages.LANGUAGES[lang_code]
     231            lang_model.append([lang_code, name])
     232            if self.gtkui_config["language"] == lang_code:
     233                index = i
     234
     235        if self.gtkui_config["language"] is None:
     236            self.language_checkbox.set_active(True)
     237            self.language_combo.set_sensitive(False)
     238        elif index != -1:
     239            self.language_combo.set_active(index)
    212240
    213241    def __del__(self):
     
    261289        self.liststore.foreach(check_row, name)
    262290        # Remove the page and row
    263         if self.page_num_to_remove != None:
     291        if self.page_num_to_remove is not None:
    264292            self.notebook.remove_page(self.page_num_to_remove)
    265         if self.iter_to_remove != None:
     293        if self.iter_to_remove is not None:
    266294            self.liststore.remove(self.iter_to_remove)
    267295
     
    274302        'Bandwidth'"""
    275303        self.window_open = True
    276         if page != None:
     304        if page is not None:
    277305            for (index, string) in self.liststore:
    278306                if page == string:
     
    322350
    323351    def _show(self):
    324         self.is_connected = self.core_config != {} and self.core_config != None
     352        self.is_connected = self.core_config != {} and self.core_config is not None
    325353        core_widgets = {
    326354            "chk_move_completed": ("active", "move_completed"),
     
    431459                    value = self.core_config[value]
    432460            elif modifier:
    433                 value = {"active": False, "not_active": False, "value": 0, "text": "", "path_chooser": "" }[modifier]
     461                value = {"active": False, "not_active": False, "value": 0, "text": "", "path_chooser": ""}[modifier]
    434462
    435463            if modifier == "active":
     
    645673        new_gtkui_config["lock_tray"] = \
    646674            self.builder.get_object("chk_lock_tray").get_active()
    647         passhex = sha_hash(\
    648             self.builder.get_object("txt_tray_password").get_text()).hexdigest()
     675        passhex = sha_hash(self.builder.get_object("txt_tray_password").get_text()).hexdigest()
    649676        if passhex != "c07eb5a8c0dc7bb81c217b67f11c3b7a5e95ffd7":
    650677            new_gtkui_config["tray_password"] = passhex
     
    724751        component.get("PluginManager").run_on_apply_prefs()
    725752
     753        # Lanuage
     754        if self.language_checkbox.get_active():
     755            new_gtkui_config["language"] = None
     756        else:
     757            active = self.language_combo.get_active()
     758            if active == -1:
     759                dialog = dialogs.InformationDialog(
     760                    _("Attention"),
     761                    _("You must choose a language")
     762                )
     763                dialog.run()
     764                return
     765            else:
     766                model = self.language_combo.get_model()
     767                new_gtkui_config["language"] = model.get(model.get_iter(active), 0)[0]
     768
     769        if new_gtkui_config["language"] != self.gtkui_config["language"]:
     770            dialog = dialogs.InformationDialog(
     771                _("Attention"),
     772                _("You must now restart the deluge UI for the changes to take effect.")
     773            )
     774            dialog.run()
     775
    726776        # GtkUI
    727777        for key in new_gtkui_config.keys():
     
    752802            self.show()
    753803
    754         if classic_mode_was_set == True and new_gtkui_in_classic_mode == False:
     804        if classic_mode_was_set and not new_gtkui_in_classic_mode:
    755805            def on_response(response):
    756806                if response == gtk.RESPONSE_NO:
     
    767817            )
    768818            dialog.run().addCallback(on_response)
    769         elif classic_mode_was_set == False and new_gtkui_in_classic_mode == True:
     819        elif not classic_mode_was_set and new_gtkui_in_classic_mode:
    770820            dialog = dialogs.InformationDialog(
    771821                _("Attention"),
     
    808858        w = self.gtkui_config["pref_dialog_width"]
    809859        h = self.gtkui_config["pref_dialog_height"]
    810         if w != None and h != None:
     860        if w is not None and h is not None:
    811861            self.pref_dialog.resize(w, h)
    812862
     
    828878
    829879        dependents = {
    830                 "chk_show_dialog": {"chk_focus_dialog": True},
    831                 "chk_random_port": {"spin_port_min": False,
    832                                     "spin_port_max": False},
    833                 "chk_random_outgoing_ports": {"spin_outgoing_port_min": False,
    834                                               "spin_outgoing_port_max": False},
    835                 "chk_use_tray": {"chk_min_on_close": True,
    836                                  "chk_start_in_tray": True,
    837                                  "chk_enable_appindicator": True,
    838                                  "chk_lock_tray": True},
    839                 "chk_lock_tray": {"txt_tray_password": True,
    840                                   "password_label": True},
    841                 "radio_open_folder_custom": {"combo_file_manager": False,
    842                                              "txt_open_folder_location": True},
    843                 "chk_move_completed" : {"move_completed_path_chooser" : True},
    844                 "chk_copy_torrent_file" : {"torrentfiles_location_path_chooser" : True,
    845                                            "chk_del_copy_torrent_file" : True},
    846                 "chk_seed_ratio" : {"spin_share_ratio": True,
    847                                     "chk_remove_ratio" : True}
    848             }
     880            "chk_show_dialog": {"chk_focus_dialog": True},
     881            "chk_random_port": {"spin_port_min": False,
     882                                "spin_port_max": False},
     883            "chk_random_outgoing_ports": {"spin_outgoing_port_min": False,
     884                                          "spin_outgoing_port_max": False},
     885            "chk_use_tray": {"chk_min_on_close": True,
     886                             "chk_start_in_tray": True,
     887                             "chk_enable_appindicator": True,
     888                             "chk_lock_tray": True},
     889            "chk_lock_tray": {"txt_tray_password": True,
     890                              "password_label": True},
     891            "radio_open_folder_custom": {"combo_file_manager": False,
     892                                         "txt_open_folder_location": True},
     893            "chk_move_completed": {"move_completed_path_chooser": True},
     894            "chk_copy_torrent_file": {"torrentfiles_location_path_chooser": True,
     895                                      "chk_del_copy_torrent_file": True},
     896            "chk_seed_ratio": {"spin_share_ratio": True,
     897                               "chk_remove_ratio": True}
     898        }
    849899
    850900        def update_dependent_widgets(name, value):
     
    936986    def _on_button_plugin_install_clicked(self, widget):
    937987        log.debug("_on_button_plugin_install_clicked")
    938         chooser = gtk.FileChooserDialog(_("Select the Plugin"),
     988        chooser = gtk.FileChooserDialog(
     989            _("Select the Plugin"),
    939990            self.pref_dialog,
    940991            gtk.FILE_CHOOSER_ACTION_OPEN,
    941992            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
    942                         gtk.RESPONSE_OK))
     993                     gtk.RESPONSE_OK)
     994        )
    943995
    944996        chooser.set_transient_for(self.pref_dialog)
     
    10291081    def _on_button_associate_magnet_clicked(self, widget):
    10301082        common.associate_magnet_links(True)
    1031 
    10321083
    10331084    def _get_accounts_tab_data(self):
     
    11521203                    _("Error Updating Account"),
    11531204                    _("An error ocurred while updating account"),
    1154                       parent=self.pref_dialog, details=failure.getErrorMessage()
     1205                    parent=self.pref_dialog, details=failure.getErrorMessage()
    11551206                ).run()
    11561207
     
    12081259        colors_widget.set_visible(widget.get_active())
    12091260
     1261    def _on_checkbutton_language_toggled(self, widget):
     1262        self.language_combo.set_sensitive(not self.language_checkbox.get_active())
     1263
    12101264    def _on_completed_color_set(self, widget):
    12111265        self.__set_color("completed")
  • deluge/ui/ui.py

    rd260f6 r7c808a  
    4848    setproctitle = lambda t: None
    4949
     50
    5051def version_callback(option, opt_str, value, parser):
    5152    print os.path.basename(sys.argv[0]) + ": " + deluge.common.get_version()
     
    6566    warnings.filterwarnings('ignore', category=DeprecationWarning, module='twisted')
    6667
     68
    6769class _UI(object):
    6870
     
    7072        self.__name = name
    7173
    72         if name == "gtk":
    73             deluge.common.setup_translations(setup_pygtk=True)
    74         else:
    75             deluge.common.setup_translations()
    76 
    7774        self.__parser = OptionParser(usage="%prog [options] [actions]")
    7875        self.__parser.add_option("-v", "--version", action="callback", callback=version_callback,
    7976            help="Show program's version number and exit")
    80         group = OptionGroup(self.__parser, _("Common Options"))
     77        group = OptionGroup(self.__parser, "Common Options")
    8178        group.add_option("-c", "--config", dest="config",
    8279            help="Set the config folder location", action="store", type="str")
     
    134131                sys.exit(1)
    135132
     133        # Setup gettext
     134        deluge.common.setup_translations()
     135
    136136        setproctitle("deluge-%s" % self.__name)
    137137
     
    141141        log.info("Starting %s ui..", self.__name)
    142142
     143
    143144class UI:
    144145    def __init__(self, options, args, ui_args):
     
    146147        log = logging.getLogger(__name__)
    147148        log.debug("UI init..")
     149
     150        # Setup gettext
     151        deluge.common.setup_translations()
    148152
    149153        # Set the config directory
     
    182186            last_frame = stack[-1]
    183187            if last_frame[0] == __file__:
    184                 log.error("Unable to find the requested UI: %s.  Please select a different UI with the '-u' option or alternatively use the '-s' option to select a different default UI.", selected_ui)
     188                log.error("Unable to find the requested UI: %s.  Please select a different UI with the '-u' option \
     189                          or alternatively use the '-s' option to select a different default UI.", selected_ui)
    185190            else:
    186191                log.exception(e)
Note: See TracChangeset for help on using the changeset viewer.