Changeset 7c808a
- Timestamp:
- 01/16/2014 07:54:20 PM (12 years ago)
- 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)
- Location:
- deluge
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/common.py
rd260f6 r7c808a 116 116 } 117 117 118 118 119 def get_version(): 119 120 """ … … 126 127 return pkg_resources.require("Deluge")[0].version 127 128 129 128 130 def get_default_config_dir(filename=None): 129 131 """ 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 131 134 :type filename: string 132 135 :returns: a file path to the config directory and optional filename … … 140 143 if not appDataPath: 141 144 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") 143 147 appDataReg = _winreg.QueryValueEx(hkey, "AppData") 144 148 appDataPath = appDataReg[0] … … 155 159 sys.exit(1) 156 160 161 157 162 def get_default_download_dir(): 158 163 """ … … 169 174 for line in open(userdir_file, 'r'): 170 175 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('"')) 173 177 if os.path.isdir(download_dir): 174 178 return download_dir … … 178 182 return os.environ.get("HOME") 179 183 184 180 185 def windows_check(): 181 186 """ … … 188 193 return platform.system() in ('Windows', 'Microsoft') 189 194 195 190 196 def vista_check(): 191 197 """ … … 198 204 return platform.release() == "Vista" 199 205 206 200 207 def osx_check(): 201 208 """ … … 207 214 """ 208 215 return platform.system() == "Darwin" 216 209 217 210 218 def get_pixmap(fname): … … 219 227 """ 220 228 return resource_filename("deluge", os.path.join("ui", "data", "pixmaps", fname)) 229 221 230 222 231 def resource_filename(module, path): … … 231 240 ) 232 241 242 233 243 def open_file(path): 234 244 """ … … 246 256 subprocess.Popen(["xdg-open", "%s" % path]) 247 257 258 248 259 def open_url_in_browser(url): 249 260 """ … … 263 274 mib_txt = "MiB" 264 275 gib_txt = "GiB" 276 265 277 266 278 def translate_strings(): … … 269 281 mib_txt = _("MiB") 270 282 gib_txt = _("GiB") 283 271 284 272 285 def fsize(fsize_b): … … 297 310 return "%d %s" % (fsize_b, byte_txt) 298 311 312 299 313 def fsize_short(fsize_b): 300 314 """ … … 321 335 return "%.1f %s" % (fsize_gb, _("G")) 322 336 337 323 338 def fpcnt(dec): 324 339 """ … … 337 352 """ 338 353 return '%.2f%%' % (dec * 100) 354 339 355 340 356 def fspeed(bps): … … 362 378 return "%.1f %s" % (fspeed_gb, _("GiB/s")) 363 379 380 364 381 def fpeer(num_peers, total_peers): 365 382 """ … … 385 402 else: 386 403 return "%d" % num_peers 404 387 405 388 406 def ftime(seconds): … … 425 443 return '%dy %dw' % (years, weeks) 426 444 445 427 446 def fdate(seconds): 428 447 """ … … 438 457 return "" 439 458 return time.strftime("%x %X", time.localtime(seconds)) 459 440 460 441 461 def is_url(url): … … 455 475 """ 456 476 return url.partition('://')[0] in ("http", "https", "ftp", "udp") 477 457 478 458 479 def is_magnet(uri): … … 476 497 return True 477 498 return False 499 478 500 479 501 def create_magnet_uri(infohash, name=None, trackers=[]): … … 502 524 return uri 503 525 526 504 527 def get_path_size(path): 505 528 """ … … 524 547 dir_size += os.path.getsize(filename) 525 548 return dir_size 549 526 550 527 551 def free_space(path): … … 547 571 block_size = disk_data.f_frsize 548 572 return disk_data.f_bavail * block_size 573 549 574 550 575 def is_ip(ip): … … 586 611 return False 587 612 613 588 614 def path_join(*parts): 589 615 """ … … 612 638 ) 613 639 640 614 641 def xml_decode(string): 615 642 """ … … 625 652 return string 626 653 654 627 655 def xml_encode(string): 628 656 """ … … 637 665 string = string.replace(char, escape) 638 666 return string 667 639 668 640 669 def decode_string(s, encoding="utf8"): … … 673 702 return u'' 674 703 704 675 705 def utf8_encoded(s, encoding="utf8"): 676 706 """ … … 690 720 s = s.encode("utf8") 691 721 return s 722 692 723 693 724 class VersionSplit(object): … … 716 747 match = re.search(VERSION_RE, ver) 717 748 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('.')] 720 751 else: 721 752 ver = ver.lower() … … 760 791 AUTH_LEVEL_DEFAULT = AUTH_LEVEL_NORMAL 761 792 793 762 794 def create_auth_file(): 763 import stat, configmanager 795 import stat 796 import configmanager 764 797 auth_file = configmanager.get_config_dir("auth") 765 798 # Check for auth file and create if necessary … … 772 805 os.chmod(auth_file, stat.S_IREAD | stat.S_IWRITE) 773 806 807 774 808 def create_localclient_account(append=False): 775 import configmanager, random 809 import configmanager 810 import random 776 811 auth_file = configmanager.get_config_dir("auth") 777 812 if not os.path.exists(auth_file): … … 793 828 794 829 830 def get_translations_path(): 831 """Get the absolute path to the directory containing translation files""" 832 return resource_filename("deluge", "i18n") 833 834 835 def 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 897 def 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 795 917 # Initialize gettext 796 def setup_translations(setup_pygtk=False): 797 translations_path = resource_filename("deluge", "i18n") 918 def setup_translations(setup_gettext=True, setup_pygtk=False): 919 translations_path = get_translations_path() 920 domain = "deluge" 798 921 log.info("Setting up translations from %s", translations_path) 799 922 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: 809 925 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 810 936 import gtk 811 937 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 814 959 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 820 961 821 962 def unicode_argv(): -
deluge/main.py
rd260f6 r7c808a 65 65 def start_ui(): 66 66 """Entry point for ui script""" 67 deluge.common.setup_translations()68 69 67 # Setup the argument parser 70 68 parser = OptionParser(usage="%prog [options] [actions]") -
deluge/ui/gtkui/glade/preferences_dialog.ui
rd260f6 r7c808a 321 321 </data> 322 322 </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> 323 331 <object class="GtkDialog" id="pref_dialog"> 324 332 <property name="can_focus">False</property> … … 345 353 <object class="GtkButton" id="button_cancel"> 346 354 <property name="label">gtk-cancel</property> 347 <property name="use_action_appearance">False</property>348 355 <property name="visible">True</property> 349 356 <property name="can_focus">True</property> … … 361 368 <object class="GtkButton" id="button_apply"> 362 369 <property name="label">gtk-apply</property> 363 <property name="use_action_appearance">False</property>364 370 <property name="visible">True</property> 365 371 <property name="can_focus">True</property> … … 377 383 <object class="GtkButton" id="button_ok"> 378 384 <property name="label">gtk-ok</property> 379 <property name="use_action_appearance">False</property>380 385 <property name="visible">True</property> 381 386 <property name="can_focus">True</property> … … 493 498 <object class="GtkRadioButton" id="radio_classic"> 494 499 <property name="label" translatable="yes">Standalone</property> 495 <property name="use_action_appearance">False</property>496 500 <property name="visible">True</property> 497 501 <property name="can_focus">True</property> … … 510 514 <object class="GtkRadioButton" id="radio_thinclient"> 511 515 <property name="label" translatable="yes">Thin Client</property> 512 <property name="use_action_appearance">False</property>513 516 <property name="visible">True</property> 514 517 <property name="can_focus">True</property> … … 567 570 <object class="GtkCheckButton" id="chk_show_rate_in_title"> 568 571 <property name="label" translatable="yes">Show session speed in titlebar</property> 569 <property name="use_action_appearance">False</property>570 572 <property name="visible">True</property> 571 573 <property name="can_focus">True</property> … … 582 584 <object class="GtkCheckButton" id="chk_focus_main_window_on_add"> 583 585 <property name="label" translatable="yes">Focus window when adding torrent</property> 584 <property name="use_action_appearance">False</property>585 586 <property name="visible">True</property> 586 587 <property name="can_focus">True</property> … … 593 594 <property name="fill">True</property> 594 595 <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 bar604 will increase the bandwidth used between client605 and daemon(does not apply in classic mode).606 Use at your own risk if you wish to help us debug607 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's615 status tab (<b>EXPERIMENTAL!!!</b>)</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>624 596 </packing> 625 597 </child> … … 653 625 <child> 654 626 <object class="GtkColorButton" id="completed_color"> 655 <property name="use_action_appearance">False</property>656 627 <property name="visible">True</property> 657 628 <property name="can_focus">True</property> … … 664 635 <property name="left_attach">1</property> 665 636 <property name="right_attach">2</property> 666 <property name="x_options" ></property>637 <property name="x_options"/> 667 638 </packing> 668 639 </child> … … 682 653 <child> 683 654 <object class="GtkColorButton" id="downloading_color"> 684 <property name="use_action_appearance">False</property>685 655 <property name="visible">True</property> 686 656 <property name="can_focus">True</property> … … 695 665 <property name="top_attach">1</property> 696 666 <property name="bottom_attach">2</property> 697 <property name="x_options" ></property>667 <property name="x_options"/> 698 668 </packing> 699 669 </child> … … 713 683 <child> 714 684 <object class="GtkColorButton" id="waiting_color"> 715 <property name="use_action_appearance">False</property>716 685 <property name="visible">True</property> 717 686 <property name="can_focus">True</property> … … 726 695 <property name="top_attach">2</property> 727 696 <property name="bottom_attach">3</property> 728 <property name="x_options" ></property>697 <property name="x_options"/> 729 698 </packing> 730 699 </child> … … 744 713 <child> 745 714 <object class="GtkColorButton" id="missing_color"> 746 <property name="use_action_appearance">False</property>747 715 <property name="visible">True</property> 748 716 <property name="can_focus">True</property> … … 757 725 <property name="top_attach">3</property> 758 726 <property name="bottom_attach">4</property> 759 <property name="x_options" ></property>727 <property name="x_options"/> 760 728 </packing> 761 729 </child> … … 763 731 <object class="GtkButton" id="revert_color_completed"> 764 732 <property name="label">gtk-revert-to-saved</property> 765 <property name="use_action_appearance">False</property>766 733 <property name="visible">True</property> 767 734 <property name="sensitive">False</property> … … 776 743 <property name="left_attach">2</property> 777 744 <property name="right_attach">3</property> 778 <property name="x_options" ></property>745 <property name="x_options"/> 779 746 </packing> 780 747 </child> … … 782 749 <object class="GtkButton" id="revert_color_downloading"> 783 750 <property name="label">gtk-revert-to-saved</property> 784 <property name="use_action_appearance">False</property>785 751 <property name="visible">True</property> 786 752 <property name="sensitive">False</property> … … 797 763 <property name="top_attach">1</property> 798 764 <property name="bottom_attach">2</property> 799 <property name="x_options" ></property>765 <property name="x_options"/> 800 766 </packing> 801 767 </child> … … 803 769 <object class="GtkButton" id="revert_color_waiting"> 804 770 <property name="label">gtk-revert-to-saved</property> 805 <property name="use_action_appearance">False</property>806 771 <property name="visible">True</property> 807 772 <property name="sensitive">False</property> … … 818 783 <property name="top_attach">2</property> 819 784 <property name="bottom_attach">3</property> 820 <property name="x_options" ></property>785 <property name="x_options"/> 821 786 </packing> 822 787 </child> … … 824 789 <object class="GtkButton" id="revert_color_missing"> 825 790 <property name="label">gtk-revert-to-saved</property> 826 <property name="use_action_appearance">False</property>827 791 <property name="visible">True</property> 828 792 <property name="sensitive">False</property> … … 839 803 <property name="top_attach">3</property> 840 804 <property name="bottom_attach">4</property> 841 <property name="x_options" ></property>805 <property name="x_options"/> 842 806 </packing> 843 807 </child> … … 857 821 <property name="expand">False</property> 858 822 <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 832 will increase the bandwidth used between client 833 and daemon(does not apply in classic mode). 834 Use at your own risk if you wish to help us debug 835 this 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 843 status tab (<b>EXPERIMENTAL!!!</b>)</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> 859 851 <property name="position">2</property> 860 852 </packing> … … 902 894 <object class="GtkCheckButton" id="chk_show_dialog"> 903 895 <property name="label" translatable="yes">Always show</property> 904 <property name="use_action_appearance">False</property>905 896 <property name="visible">True</property> 906 897 <property name="can_focus">True</property> … … 922 913 <object class="GtkCheckButton" id="chk_focus_dialog"> 923 914 <property name="label" translatable="yes">Bring the dialog to focus</property> 924 <property name="use_action_appearance">False</property>925 915 <property name="visible">True</property> 926 916 <property name="can_focus">True</property> … … 978 968 <object class="GtkCheckButton" id="chk_use_tray"> 979 969 <property name="label" translatable="yes">Enable system tray icon</property> 980 <property name="use_action_appearance">False</property>981 970 <property name="visible">True</property> 982 971 <property name="can_focus">False</property> … … 1000 989 <object class="GtkCheckButton" id="chk_min_on_close"> 1001 990 <property name="label" translatable="yes">Minimize to tray on close</property> 1002 <property name="use_action_appearance">False</property>1003 991 <property name="visible">True</property> 1004 992 <property name="sensitive">False</property> … … 1024 1012 <object class="GtkCheckButton" id="chk_start_in_tray"> 1025 1013 <property name="label" translatable="yes">Start in tray</property> 1026 <property name="use_action_appearance">False</property>1027 1014 <property name="visible">True</property> 1028 1015 <property name="sensitive">False</property> … … 1048 1035 <object class="GtkCheckButton" id="chk_enable_appindicator"> 1049 1036 <property name="label" translatable="yes">Enable Application Indicator</property> 1050 <property name="use_action_appearance">False</property>1051 1037 <property name="visible">True</property> 1052 1038 <property name="sensitive">False</property> … … 1073 1059 <object class="GtkCheckButton" id="chk_lock_tray"> 1074 1060 <property name="label" translatable="yes">Password protect system tray</property> 1075 <property name="use_action_appearance">False</property>1076 1061 <property name="visible">True</property> 1077 1062 <property name="sensitive">False</property> … … 1163 1148 <property name="padding">5</property> 1164 1149 <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"><b>Languge</b></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> 1165 1218 </packing> 1166 1219 </child> … … 1250 1303 <object class="GtkCheckButton" id="chk_move_completed"> 1251 1304 <property name="label" translatable="yes">Move completed to:</property> 1252 <property name="use_action_appearance">False</property>1253 1305 <property name="visible">True</property> 1254 1306 <property name="can_focus">True</property> … … 1266 1318 <object class="GtkCheckButton" id="chk_copy_torrent_file"> 1267 1319 <property name="label" translatable="yes">Copy of .torrent files to:</property> 1268 <property name="use_action_appearance">False</property>1269 1320 <property name="visible">True</property> 1270 1321 <property name="can_focus">True</property> … … 1282 1333 <object class="GtkCheckButton" id="chk_del_copy_torrent_file"> 1283 1334 <property name="label" translatable="yes">Delete copy of torrent file on remove</property> 1284 <property name="use_action_appearance">False</property>1285 1335 <property name="visible">True</property> 1286 1336 <property name="can_focus">True</property> … … 1408 1458 <object class="GtkRadioButton" id="radio_full_allocation"> 1409 1459 <property name="label" translatable="yes">Use Full Allocation</property> 1410 <property name="use_action_appearance">False</property>1411 1460 <property name="visible">True</property> 1412 1461 <property name="can_focus">True</property> … … 1426 1475 <object class="GtkRadioButton" id="radio_compact_allocation"> 1427 1476 <property name="label" translatable="yes">Use Compact Allocation</property> 1428 <property name="use_action_appearance">False</property>1429 1477 <property name="visible">True</property> 1430 1478 <property name="can_focus">True</property> … … 1483 1531 <object class="GtkCheckButton" id="chk_prioritize_first_last_pieces"> 1484 1532 <property name="label" translatable="yes">Prioritize first and last pieces of torrent</property> 1485 <property name="use_action_appearance">False</property>1486 1533 <property name="visible">True</property> 1487 1534 <property name="can_focus">True</property> … … 1499 1546 <object class="GtkCheckButton" id="chk_sequential_download"> 1500 1547 <property name="label" translatable="yes">Sequential download</property> 1501 <property name="use_action_appearance">False</property>1502 1548 <property name="visible">True</property> 1503 1549 <property name="can_focus">True</property> … … 1520 1566 <object class="GtkCheckButton" id="chk_add_paused"> 1521 1567 <property name="label" translatable="yes">Add torrents in Paused state</property> 1522 <property name="use_action_appearance">False</property>1523 1568 <property name="visible">True</property> 1524 1569 <property name="can_focus">True</property> … … 1764 1809 <object class="GtkCheckButton" id="chk_random_port"> 1765 1810 <property name="label" translatable="yes">Random</property> 1766 <property name="use_action_appearance">False</property>1767 1811 <property name="visible">True</property> 1768 1812 <property name="can_focus">True</property> … … 1839 1883 <object class="GtkButton" id="button_testport"> 1840 1884 <property name="label" translatable="yes">Test Active Port</property> 1841 <property name="use_action_appearance">False</property>1842 1885 <property name="visible">True</property> 1843 1886 <property name="can_focus">True</property> … … 1991 2034 <object class="GtkCheckButton" id="chk_random_outgoing_ports"> 1992 2035 <property name="label" translatable="yes">Random</property> 1993 <property name="use_action_appearance">False</property>1994 2036 <property name="visible">True</property> 1995 2037 <property name="can_focus">True</property> … … 2214 2256 <object class="GtkCheckButton" id="chk_upnp"> 2215 2257 <property name="label" translatable="yes">UPnP</property> 2216 <property name="use_action_appearance">False</property>2217 2258 <property name="visible">True</property> 2218 2259 <property name="can_focus">True</property> … … 2230 2271 <object class="GtkCheckButton" id="chk_natpmp"> 2231 2272 <property name="label" translatable="yes">NAT-PMP</property> 2232 <property name="use_action_appearance">False</property>2233 2273 <property name="visible">True</property> 2234 2274 <property name="can_focus">True</property> … … 2248 2288 <object class="GtkCheckButton" id="chk_utpex"> 2249 2289 <property name="label" translatable="yes">Peer Exchange</property> 2250 <property name="use_action_appearance">False</property>2251 2290 <property name="visible">True</property> 2252 2291 <property name="can_focus">True</property> … … 2265 2304 <object class="GtkCheckButton" id="chk_lt_tex"> 2266 2305 <property name="label" translatable="yes">Tracker Exchange</property> 2267 <property name="use_action_appearance">False</property>2268 2306 <property name="visible">True</property> 2269 2307 <property name="can_focus">True</property> … … 2284 2322 <object class="GtkCheckButton" id="chk_lsd"> 2285 2323 <property name="label" translatable="yes">LSD</property> 2286 <property name="use_action_appearance">False</property>2287 2324 <property name="visible">True</property> 2288 2325 <property name="can_focus">True</property> … … 2300 2337 <object class="GtkCheckButton" id="chk_dht"> 2301 2338 <property name="label" translatable="yes">DHT</property> 2302 <property name="use_action_appearance">False</property>2303 2339 <property name="visible">True</property> 2304 2340 <property name="can_focus">True</property> … … 2710 2746 <object class="GtkCheckButton" id="chk_ignore_limits_on_local_network"> 2711 2747 <property name="label" translatable="yes">Ignore limits on local network</property> 2712 <property name="use_action_appearance">False</property>2713 2748 <property name="visible">True</property> 2714 2749 <property name="can_focus">True</property> … … 2733 2768 <object class="GtkCheckButton" id="chk_rate_limit_ip_overhead"> 2734 2769 <property name="label" translatable="yes">Rate limit IP overhead</property> 2735 <property name="use_action_appearance">False</property>2736 2770 <property name="visible">True</property> 2737 2771 <property name="can_focus">True</property> … … 3046 3080 <object class="GtkCheckButton" id="chk_show_new_releases"> 3047 3081 <property name="label" translatable="yes">Be alerted about new releases</property> 3048 <property name="use_action_appearance">False</property>3049 3082 <property name="visible">True</property> 3050 3083 <property name="can_focus">True</property> … … 3122 3155 <object class="GtkCheckButton" id="chk_send_info"> 3123 3156 <property name="label" translatable="yes">Yes, please send anonymous statistics</property> 3124 <property name="use_action_appearance">False</property>3125 3157 <property name="visible">True</property> 3126 3158 <property name="can_focus">True</property> … … 3256 3288 <child> 3257 3289 <object class="GtkButton" id="button_associate_magnet"> 3258 <property name="use_action_appearance">False</property>3259 3290 <property name="visible">True</property> 3260 3291 <property name="can_focus">True</property> … … 3469 3500 <object class="GtkCheckButton" id="chk_allow_remote_connections"> 3470 3501 <property name="label" translatable="yes">Allow Remote Connections</property> 3471 <property name="use_action_appearance">False</property>3472 3502 <property name="visible">True</property> 3473 3503 <property name="can_focus">True</property> … … 3511 3541 <object class="GtkCheckButton" id="chk_new_releases"> 3512 3542 <property name="label" translatable="yes">Periodically check the website for new releases</property> 3513 <property name="use_action_appearance">False</property>3514 3543 <property name="visible">True</property> 3515 3544 <property name="can_focus">True</property> … … 3574 3603 <object class="GtkButton" id="accounts_add"> 3575 3604 <property name="label">gtk-add</property> 3576 <property name="use_action_appearance">False</property>3577 3605 <property name="visible">True</property> 3578 3606 <property name="can_focus">True</property> … … 3590 3618 <object class="GtkButton" id="accounts_edit"> 3591 3619 <property name="label">gtk-edit</property> 3592 <property name="use_action_appearance">False</property>3593 3620 <property name="visible">True</property> 3594 3621 <property name="sensitive">False</property> … … 3607 3634 <object class="GtkButton" id="accounts_delete"> 3608 3635 <property name="label">gtk-delete</property> 3609 <property name="use_action_appearance">False</property>3610 3636 <property name="visible">True</property> 3611 3637 <property name="sensitive">False</property> … … 3744 3770 <object class="GtkCheckButton" id="chk_queue_new_top"> 3745 3771 <property name="label" translatable="yes">Queue new torrents to top</property> 3746 <property name="use_action_appearance">False</property>3747 3772 <property name="visible">True</property> 3748 3773 <property name="can_focus">True</property> … … 3817 3842 <property name="left_attach">1</property> 3818 3843 <property name="right_attach">2</property> 3819 <property name="x_options" ></property>3844 <property name="x_options"/> 3820 3845 </packing> 3821 3846 </child> … … 3838 3863 <property name="top_attach">2</property> 3839 3864 <property name="bottom_attach">3</property> 3840 <property name="x_options" ></property>3865 <property name="x_options"/> 3841 3866 </packing> 3842 3867 </child> … … 3883 3908 <property name="top_attach">1</property> 3884 3909 <property name="bottom_attach">2</property> 3885 <property name="x_options" ></property>3910 <property name="x_options"/> 3886 3911 </packing> 3887 3912 </child> … … 3909 3934 <object class="GtkCheckButton" id="chk_dont_count_slow_torrents"> 3910 3935 <property name="label" translatable="yes">Do not count slow torrents</property> 3911 <property name="use_action_appearance">False</property>3912 3936 <property name="visible">True</property> 3913 3937 <property name="can_focus">True</property> … … 3924 3948 <object class="GtkCheckButton" id="chk_auto_manage_prefer_seeds"> 3925 3949 <property name="label" translatable="yes">Prefer Seeding over Downloading</property> 3926 <property name="use_action_appearance">False</property>3927 3950 <property name="visible">True</property> 3928 3951 <property name="can_focus">True</property> … … 4034 4057 <property name="left_attach">1</property> 4035 4058 <property name="right_attach">2</property> 4036 <property name="x_options" ></property>4059 <property name="x_options"/> 4037 4060 </packing> 4038 4061 </child> … … 4055 4078 <property name="top_attach">1</property> 4056 4079 <property name="bottom_attach">2</property> 4057 <property name="x_options" ></property>4080 <property name="x_options"/> 4058 4081 </packing> 4059 4082 </child> … … 4075 4098 <property name="top_attach">2</property> 4076 4099 <property name="bottom_attach">3</property> 4077 <property name="x_options" ></property>4100 <property name="x_options"/> 4078 4101 </packing> 4079 4102 </child> … … 4093 4116 <object class="GtkCheckButton" id="chk_seed_ratio"> 4094 4117 <property name="label" translatable="yes">Stop seeding when share ratio reaches:</property> 4095 <property name="use_action_appearance">False</property>4096 4118 <property name="visible">True</property> 4097 4119 <property name="can_focus">True</property> … … 4141 4163 <object class="GtkCheckButton" id="chk_remove_ratio"> 4142 4164 <property name="label" translatable="yes">Remove torrent when share ratio reached</property> 4143 <property name="use_action_appearance">False</property>4144 4165 <property name="visible">True</property> 4145 4166 <property name="sensitive">False</property> … … 4413 4434 <property name="right_attach">2</property> 4414 4435 <property name="x_options">GTK_FILL</property> 4415 <property name="y_options" ></property>4436 <property name="y_options"/> 4416 4437 </packing> 4417 4438 </child> … … 4425 4446 <packing> 4426 4447 <property name="x_options">GTK_FILL</property> 4427 <property name="y_options" ></property>4448 <property name="y_options"/> 4428 4449 </packing> 4429 4450 </child> … … 4618 4639 <property name="right_attach">2</property> 4619 4640 <property name="x_options">GTK_FILL</property> 4620 <property name="y_options" ></property>4641 <property name="y_options"/> 4621 4642 </packing> 4622 4643 </child> … … 4630 4651 <packing> 4631 4652 <property name="x_options">GTK_FILL</property> 4632 <property name="y_options" ></property>4653 <property name="y_options"/> 4633 4654 </packing> 4634 4655 </child> … … 4823 4844 <property name="right_attach">2</property> 4824 4845 <property name="x_options">GTK_FILL</property> 4825 <property name="y_options" ></property>4846 <property name="y_options"/> 4826 4847 </packing> 4827 4848 </child> … … 4835 4856 <packing> 4836 4857 <property name="x_options">GTK_FILL</property> 4837 <property name="y_options" ></property>4858 <property name="y_options"/> 4838 4859 </packing> 4839 4860 </child> … … 4902 4923 <property name="bottom_attach">3</property> 4903 4924 <property name="x_options">GTK_FILL</property> 4904 <property name="y_options" ></property>4925 <property name="y_options"/> 4905 4926 </packing> 4906 4927 </child> … … 4935 4956 <property name="bottom_attach">4</property> 4936 4957 <property name="x_options">GTK_FILL</property> 4937 <property name="y_options" ></property>4958 <property name="y_options"/> 4938 4959 </packing> 4939 4960 </child> … … 4966 4987 <property name="bottom_attach">5</property> 4967 4988 <property name="x_options">GTK_FILL</property> 4968 <property name="y_options" ></property>4989 <property name="y_options"/> 4969 4990 </packing> 4970 4991 </child> … … 5031 5052 <property name="right_attach">2</property> 5032 5053 <property name="x_options">GTK_FILL</property> 5033 <property name="y_options" ></property>5054 <property name="y_options"/> 5034 5055 </packing> 5035 5056 </child> … … 5043 5064 <packing> 5044 5065 <property name="x_options">GTK_FILL</property> 5045 <property name="y_options" ></property>5066 <property name="y_options"/> 5046 5067 </packing> 5047 5068 </child> … … 5057 5078 <property name="bottom_attach">2</property> 5058 5079 <property name="x_options">GTK_FILL</property> 5059 <property name="y_options" ></property>5080 <property name="y_options"/> 5060 5081 </packing> 5061 5082 </child> … … 5220 5241 <property name="left_attach">1</property> 5221 5242 <property name="right_attach">2</property> 5222 <property name="x_options" ></property>5243 <property name="x_options"/> 5223 5244 </packing> 5224 5245 </child> … … 5242 5263 <property name="top_attach">1</property> 5243 5264 <property name="bottom_attach">2</property> 5244 <property name="x_options" ></property>5265 <property name="x_options"/> 5245 5266 </packing> 5246 5267 </child> … … 5350 5371 <property name="left_attach">1</property> 5351 5372 <property name="right_attach">2</property> 5352 <property name="x_options" ></property>5373 <property name="x_options"/> 5353 5374 </packing> 5354 5375 </child> … … 5364 5385 <property name="top_attach">1</property> 5365 5386 <property name="bottom_attach">2</property> 5366 <property name="x_options" ></property>5387 <property name="x_options"/> 5367 5388 </packing> 5368 5389 </child> … … 5378 5399 <property name="top_attach">2</property> 5379 5400 <property name="bottom_attach">3</property> 5380 <property name="x_options" ></property>5401 <property name="x_options"/> 5381 5402 </packing> 5382 5403 </child> … … 5469 5490 <property name="left_attach">1</property> 5470 5491 <property name="right_attach">2</property> 5471 <property name="x_options" ></property>5492 <property name="x_options"/> 5472 5493 </packing> 5473 5494 </child> … … 5483 5504 <property name="top_attach">1</property> 5484 5505 <property name="bottom_attach">2</property> 5485 <property name="x_options" ></property>5506 <property name="x_options"/> 5486 5507 </packing> 5487 5508 </child> … … 5497 5518 <property name="top_attach">3</property> 5498 5519 <property name="bottom_attach">4</property> 5499 <property name="x_options" ></property>5520 <property name="x_options"/> 5500 5521 </packing> 5501 5522 </child> … … 5525 5546 <property name="top_attach">2</property> 5526 5547 <property name="bottom_attach">3</property> 5527 <property name="x_options" ></property>5548 <property name="x_options"/> 5528 5549 </packing> 5529 5550 </child> … … 5601 5622 <property name="left_attach">1</property> 5602 5623 <property name="right_attach">2</property> 5603 <property name="x_options" ></property>5624 <property name="x_options"/> 5604 5625 </packing> 5605 5626 </child> … … 5615 5636 <property name="top_attach">1</property> 5616 5637 <property name="bottom_attach">2</property> 5617 <property name="x_options" ></property>5638 <property name="x_options"/> 5618 5639 </packing> 5619 5640 </child> … … 5647 5668 <object class="GtkButton" id="button_cache_refresh"> 5648 5669 <property name="label">gtk-refresh</property> 5649 <property name="use_action_appearance">False</property>5650 5670 <property name="visible">True</property> 5651 5671 <property name="can_focus">True</property> … … 5821 5841 <property name="top_attach">4</property> 5822 5842 <property name="bottom_attach">5</property> 5823 <property name="y_options" ></property>5843 <property name="y_options"/> 5824 5844 </packing> 5825 5845 </child> … … 5835 5855 <property name="top_attach">1</property> 5836 5856 <property name="bottom_attach">2</property> 5837 <property name="y_options" ></property>5857 <property name="y_options"/> 5838 5858 </packing> 5839 5859 </child> … … 5847 5867 <property name="left_attach">1</property> 5848 5868 <property name="right_attach">2</property> 5849 <property name="y_options" ></property>5869 <property name="y_options"/> 5850 5870 </packing> 5851 5871 </child> … … 5876 5896 <property name="bottom_attach">2</property> 5877 5897 <property name="x_options">GTK_FILL</property> 5878 <property name="y_options" ></property>5898 <property name="y_options"/> 5879 5899 </packing> 5880 5900 </child> … … 5888 5908 <packing> 5889 5909 <property name="x_options">GTK_FILL</property> 5890 <property name="y_options" ></property>5910 <property name="y_options"/> 5891 5911 </packing> 5892 5912 </child> … … 5930 5950 <property name="top_attach">3</property> 5931 5951 <property name="bottom_attach">4</property> 5932 <property name="y_options" ></property>5952 <property name="y_options"/> 5933 5953 </packing> 5934 5954 </child> … … 5944 5964 <property name="top_attach">2</property> 5945 5965 <property name="bottom_attach">3</property> 5946 <property name="y_options" ></property>5966 <property name="y_options"/> 5947 5967 </packing> 5948 5968 </child> … … 5985 6005 <child> 5986 6006 <object class="GtkButton" id="button_plugin_install"> 5987 <property name="use_action_appearance">False</property>5988 6007 <property name="visible">True</property> 5989 6008 <property name="can_focus">True</property> … … 6032 6051 <child> 6033 6052 <object class="GtkButton" id="button_rescan_plugins"> 6034 <property name="use_action_appearance">False</property>6035 6053 <property name="visible">True</property> 6036 6054 <property name="can_focus">True</property> … … 6090 6108 <child> 6091 6109 <object class="GtkButton" id="button_find_plugins"> 6092 <property name="use_action_appearance">False</property>6093 6110 <property name="visible">True</property> 6094 6111 <property name="can_focus">True</property> -
deluge/ui/gtkui/gtkui.py
rd260f6 r7c808a 115 115 "pref_dialog_height": None, 116 116 "window_pane_position": -1, 117 "tray_download_speed_list" 118 "tray_upload_speed_list" 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], 119 119 "connection_limit_list": [50, 100, 200, 300, 500], 120 120 "enabled_plugins": [], … … 152 152 "pieces_color_completed": [4883, 26985, 56540], 153 153 "focus_main_window_on_add": True, 154 "language": None, 154 155 } 155 156 … … 157 158 class GtkUI(object): 158 159 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 160 164 # Setup signals 161 165 try: … … 164 168 self.gnome_prog = gnome.init("Deluge", deluge.common.get_version()) 165 169 self.gnome_client = gnome.ui.master_client() 170 166 171 def on_die(*args): 167 172 reactor.stop() … … 175 180 from win32con import CTRL_CLOSE_EVENT 176 181 from win32con import CTRL_SHUTDOWN_EVENT 182 177 183 def win_handler(ctrl_type): 178 184 log.debug("ctrl_type: %s", ctrl_type) … … 185 191 import gtkosx_application 186 192 self.osxapp = gtkosx_application.gtkosx_application_get() 193 187 194 def on_die(*args): 188 195 reactor.stop() 189 196 self.osxapp.connect("NSApplicationWillTerminate", on_die) 190 197 191 192 198 # Set process name again to fix gtk issue 193 199 setproctitle(getproctitle()) … … 207 213 # shutdown the daemon. 208 214 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"]) 209 219 210 220 # Start the IPC Interface before anything else.. Just in case we are … … 215 225 # Initialize gdk threading 216 226 gtk.gdk.threads_init() 217 218 227 219 228 # We make sure that the UI components start once we get a core URI … … 328 337 if "No module named libtorrent" in e.message: 329 338 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\ 332 341 To use Deluge standalone (Classic mode) please install libtorrent.")).run() 333 342 self.started_in_classic = False … … 345 354 _("There was an error starting the core component which is required to run Deluge in Classic Mode.\n\n\ 346 355 Please see the details below for more information."), details=traceback.format_exc(tb[2])).run() 356 347 357 def on_ed_response(response): 348 358 d = dialogs.YesNoDialog( 349 359 _("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() 351 362 self.started_in_classic = False 352 363 d.addCallback(on_dialog_response) … … 407 418 reason.value.message, reason.value.username 408 419 ) 420 409 421 def dialog_finished(response_id, host, port): 410 422 if response_id == gtk.RESPONSE_OK: … … 447 459 self.connectionmanager.show() 448 460 449 450 461 def __on_disconnect(self): 451 462 """ -
deluge/ui/gtkui/menubar_osx.py
rd260f6 r7c808a 18 18 # You should have received a copy of the GNU General Public License 19 19 # along with deluge. If not, write to: 20 # 21 # 22 # 20 # The Free Software Foundation, Inc., 21 # 51 Franklin Street, Fifth Floor 22 # Boston, MA 02110-1301, USA. 23 23 # 24 24 # In addition, as a special exception, the copyright holders give … … 33 33 # 34 34 # 35 import gtk , gtk.glade35 import gtk 36 36 37 37 from deluge.configmanager import ConfigManager 38 38 39 39 40 def 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 42 44 43 45 def 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 45 48 46 49 def menubar_osx(gtkui, osxapp): 47 48 glade = window.main_glade 49 menubar = glade.get_widget("menubar")50 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] 51 54 52 55 config = ConfigManager("gtkui.conf") 53 56 54 55 56 57 58 file_menu = glade.get_widget("menu_file").get_submenu()59 60 61 62 63 64 65 for item in range(2, len(file_items)):# remove quits66 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]) 67 70 68 menu_widget = glade.get_widget("menu_edit")69 70 71 72 73 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) 74 77 75 76 77 78 conn_item = edit_items[1] 79 accel_meta(conn_item, group, 'm') 80 edit_menu.remove(conn_item) 78 81 79 82 menubar.remove(menu_widget) 80 83 81 help_menu = glade.get_widget("menu_help").get_submenu()82 83 84 85 help_menu.remove(help_items[3])# separator84 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 86 89 87 88 89 90 91 92 93 94 95 96 97 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 63 63 } 64 64 65 65 66 class Preferences(component.Component): 66 67 def __init__(self): … … 181 182 "on_revert_color_missing_clicked": self._on_revert_color_missing_clicked, 182 183 "on_pref_dialog_configure_event": self.on_pref_dialog_configure_event, 184 "on_checkbutton_language_toggled": self._on_checkbutton_language_toggled, 183 185 }) 184 186 … … 194 196 195 197 self.setup_path_choosers() 198 self.load_languages() 196 199 197 200 def setup_path_choosers(self): … … 210 213 self.copy_torrents_to_hbox.add(self.copy_torrent_files_path_chooser) 211 214 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) 212 240 213 241 def __del__(self): … … 261 289 self.liststore.foreach(check_row, name) 262 290 # Remove the page and row 263 if self.page_num_to_remove !=None:291 if self.page_num_to_remove is not None: 264 292 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: 266 294 self.liststore.remove(self.iter_to_remove) 267 295 … … 274 302 'Bandwidth'""" 275 303 self.window_open = True 276 if page !=None:304 if page is not None: 277 305 for (index, string) in self.liststore: 278 306 if page == string: … … 322 350 323 351 def _show(self): 324 self.is_connected = self.core_config != {} and self.core_config !=None352 self.is_connected = self.core_config != {} and self.core_config is not None 325 353 core_widgets = { 326 354 "chk_move_completed": ("active", "move_completed"), … … 431 459 value = self.core_config[value] 432 460 elif modifier: 433 value = {"active": False, "not_active": False, "value": 0, "text": "", "path_chooser": "" 461 value = {"active": False, "not_active": False, "value": 0, "text": "", "path_chooser": ""}[modifier] 434 462 435 463 if modifier == "active": … … 645 673 new_gtkui_config["lock_tray"] = \ 646 674 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() 649 676 if passhex != "c07eb5a8c0dc7bb81c217b67f11c3b7a5e95ffd7": 650 677 new_gtkui_config["tray_password"] = passhex … … 724 751 component.get("PluginManager").run_on_apply_prefs() 725 752 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 726 776 # GtkUI 727 777 for key in new_gtkui_config.keys(): … … 752 802 self.show() 753 803 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: 755 805 def on_response(response): 756 806 if response == gtk.RESPONSE_NO: … … 767 817 ) 768 818 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: 770 820 dialog = dialogs.InformationDialog( 771 821 _("Attention"), … … 808 858 w = self.gtkui_config["pref_dialog_width"] 809 859 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: 811 861 self.pref_dialog.resize(w, h) 812 862 … … 828 878 829 879 dependents = { 830 831 832 833 834 835 836 837 838 839 840 841 842 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 } 849 899 850 900 def update_dependent_widgets(name, value): … … 936 986 def _on_button_plugin_install_clicked(self, widget): 937 987 log.debug("_on_button_plugin_install_clicked") 938 chooser = gtk.FileChooserDialog(_("Select the Plugin"), 988 chooser = gtk.FileChooserDialog( 989 _("Select the Plugin"), 939 990 self.pref_dialog, 940 991 gtk.FILE_CHOOSER_ACTION_OPEN, 941 992 buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, 942 gtk.RESPONSE_OK)) 993 gtk.RESPONSE_OK) 994 ) 943 995 944 996 chooser.set_transient_for(self.pref_dialog) … … 1029 1081 def _on_button_associate_magnet_clicked(self, widget): 1030 1082 common.associate_magnet_links(True) 1031 1032 1083 1033 1084 def _get_accounts_tab_data(self): … … 1152 1203 _("Error Updating Account"), 1153 1204 _("An error ocurred while updating account"), 1154 1205 parent=self.pref_dialog, details=failure.getErrorMessage() 1155 1206 ).run() 1156 1207 … … 1208 1259 colors_widget.set_visible(widget.get_active()) 1209 1260 1261 def _on_checkbutton_language_toggled(self, widget): 1262 self.language_combo.set_sensitive(not self.language_checkbox.get_active()) 1263 1210 1264 def _on_completed_color_set(self, widget): 1211 1265 self.__set_color("completed") -
deluge/ui/ui.py
rd260f6 r7c808a 48 48 setproctitle = lambda t: None 49 49 50 50 51 def version_callback(option, opt_str, value, parser): 51 52 print os.path.basename(sys.argv[0]) + ": " + deluge.common.get_version() … … 65 66 warnings.filterwarnings('ignore', category=DeprecationWarning, module='twisted') 66 67 68 67 69 class _UI(object): 68 70 … … 70 72 self.__name = name 71 73 72 if name == "gtk":73 deluge.common.setup_translations(setup_pygtk=True)74 else:75 deluge.common.setup_translations()76 77 74 self.__parser = OptionParser(usage="%prog [options] [actions]") 78 75 self.__parser.add_option("-v", "--version", action="callback", callback=version_callback, 79 76 help="Show program's version number and exit") 80 group = OptionGroup(self.__parser, _("Common Options"))77 group = OptionGroup(self.__parser, "Common Options") 81 78 group.add_option("-c", "--config", dest="config", 82 79 help="Set the config folder location", action="store", type="str") … … 134 131 sys.exit(1) 135 132 133 # Setup gettext 134 deluge.common.setup_translations() 135 136 136 setproctitle("deluge-%s" % self.__name) 137 137 … … 141 141 log.info("Starting %s ui..", self.__name) 142 142 143 143 144 class UI: 144 145 def __init__(self, options, args, ui_args): … … 146 147 log = logging.getLogger(__name__) 147 148 log.debug("UI init..") 149 150 # Setup gettext 151 deluge.common.setup_translations() 148 152 149 153 # Set the config directory … … 182 186 last_frame = stack[-1] 183 187 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) 185 190 else: 186 191 log.exception(e)
Note:
See TracChangeset
for help on using the changeset viewer.