From 090e1a035e1cd1356f5ca0c9c99a998c5f473ef0 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 12 May 2009 17:52:01 +0000 Subject: [PATCH] Implement #259 show tooltip with country name in the peers tab --- ChangeLog | 5 + README | 2 +- deluge/countries.py | 256 +++++++++++++++++++++++++++++++++++ deluge/i18n/POTFILES.in | 87 ++---------- deluge/ui/gtkui/peers_tab.py | 19 +++ 5 files changed, 292 insertions(+), 77 deletions(-) create mode 100644 deluge/countries.py diff --git a/ChangeLog b/ChangeLog index 0a725500a..40c1d3481 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,11 +9,16 @@ * Implemented a cross-platform IPC method thus removing the DBUS dependency * Implement a "True" Classic Mode where there is no longer a separate daemon process * Add preferences option "Add torrent in paused state" + * Add tracker icons to the Tracker column + * Implement #259 show tooltip with country name in the peers tab ==== WebUI ==== * Move over to using Twisted-Web for the webserver. * Move to only AJAX interface built upon Ext-JS. +==== Misc ==== + * PyGTK dependency bumped to => 2.12 to use new tooltip system + === Deluge 1.1.0 - "Time gas!" (10 January 2009) === ==== Core ==== * Implement #79 ability to change outgoing port range diff --git a/README b/README index 347f30afc..b635e796c 100644 --- a/README +++ b/README @@ -52,7 +52,7 @@ Dependencies: Gtk: python-notify (libnotify python wrapper) pygame - pygtk >= 2.10 + pygtk >= 2.12 librsvg xdg-utils chardet diff --git a/deluge/countries.py b/deluge/countries.py new file mode 100644 index 000000000..a09b226f6 --- /dev/null +++ b/deluge/countries.py @@ -0,0 +1,256 @@ +# +# countries.py +# +# This file is public domain. +# + +# ISO 3166-1 country names and codes +COUNTRIES = { + 'AF': _('Afghanistan'), + 'AX': _('Aland Islands'), + 'AL': _('Albania'), + 'DZ': _('Algeria'), + 'AS': _('American Samoa'), + 'AD': _('Andorra'), + 'AO': _('Angola'), + 'AI': _('Anguilla'), + 'AQ': _('Antarctica'), + 'AG': _('Antigua and Barbuda'), + 'AR': _('Argentina'), + 'AM': _('Armenia'), + 'AW': _('Aruba'), + 'AU': _('Australia'), + 'AT': _('Austria'), + 'AZ': _('Azerbaijan'), + 'BS': _('Bahamas'), + 'BH': _('Bahrain'), + 'BD': _('Bangladesh'), + 'BB': _('Barbados'), + 'BY': _('Belarus'), + 'BE': _('Belgium'), + 'BZ': _('Belize'), + 'BJ': _('Benin'), + 'BM': _('Bermuda'), + 'BT': _('Bhutan'), + 'BO': _('Bolivia'), + 'BA': _('Bosnia and Herzegovina'), + 'BW': _('Botswana'), + 'BV': _('Bouvet Island'), + 'BR': _('Brazil'), + 'IO': _('British Indian Ocean Territory'), + 'BN': _('Brunei Darussalam'), + 'BG': _('Bulgaria'), + 'BF': _('Burkina Faso'), + 'BI': _('Burundi'), + 'KH': _('Cambodia'), + 'CM': _('Cameroon'), + 'CA': _('Canada'), + 'CV': _('Cape Verde'), + 'KY': _('Cayman Islands'), + 'CF': _('Central African Republic'), + 'TD': _('Chad'), + 'CL': _('Chile'), + 'CN': _('China'), + 'CX': _('Christmas Island'), + 'CC': _('Cocos (Keeling) Islands'), + 'CO': _('Colombia'), + 'KM': _('Comoros'), + 'CG': _('Congo'), + 'CD': _('Congo, The Democratic Republic of the'), + 'CK': _('Cook Islands'), + 'CR': _('Costa Rica'), + 'CI': _('Cote d\'Ivoire'), + 'HR': _('Croatia'), + 'CU': _('Cuba'), + 'CY': _('Cyprus'), + 'CZ': _('Czech Republic'), + 'DK': _('Denmark'), + 'DJ': _('Djibouti'), + 'DM': _('Dominica'), + 'DO': _('Dominican Republic'), + 'EC': _('Ecuador'), + 'EG': _('Egypt'), + 'SV': _('El Salvador'), + 'GQ': _('Equatorial Guinea'), + 'ER': _('Eritrea'), + 'EE': _('Estonia'), + 'ET': _('Ethiopia'), + 'FK': _('Falkland Islands (Malvinas)'), + 'FO': _('Faroe Islands'), + 'FJ': _('Fiji'), + 'FI': _('Finland'), + 'FR': _('France'), + 'GF': _('French Guiana'), + 'PF': _('French Polynesia'), + 'TF': _('French Southern Territories'), + 'GA': _('Gabon'), + 'GM': _('Gambia'), + 'GE': _('Georgia'), + 'DE': _('Germany'), + 'GB': _('United Kingdom'), + 'GH': _('Ghana'), + 'GI': _('Gibraltar'), + 'GR': _('Greece'), + 'GL': _('Greenland'), + 'GD': _('Grenada'), + 'GP': _('Guadeloupe'), + 'GU': _('Guam'), + 'GT': _('Guatemala'), + 'GG': _('Guernsey'), + 'GN': _('Guinea'), + 'GW': _('Guinea-Bissau'), + 'GY': _('Guyana'), + 'HT': _('Haiti'), + 'HM': _('Heard Island and McDonald Islands'), + 'VA': _('Holy See (Vatican City State)'), + 'HN': _('Honduras'), + 'HK': _('Hong Kong'), + 'HU': _('Hungary'), + 'IS': _('Iceland'), + 'IN': _('India'), + 'ID': _('Indonesia'), + 'IR': _('Iran, Islamic Republic of'), + 'IQ': _('Iraq'), + 'IE': _('Ireland'), + 'IM': _('Isle of Man'), + 'IL': _('Israel'), + 'IT': _('Italy'), + 'JM': _('Jamaica'), + 'JP': _('Japan'), + 'JE': _('Jersey'), + 'JO': _('Jordan'), + 'KZ': _('Kazakhstan'), + 'KE': _('Kenya'), + 'KI': _('Kiribati'), + 'KP': _('Korea, Democratic People\'s Republic of'), + 'KR': _('Korea, Republic of'), + 'KW': _('Kuwait'), + 'KG': _('Kyrgyzstan'), + 'LA': _('Lao People\'s Democratic Republic'), + 'LV': _('Latvia'), + 'LB': _('Lebanon'), + 'LS': _('Lesotho'), + 'LR': _('Liberia'), + 'LY': _('Libyan Arab Jamahiriya'), + 'LI': _('Liechtenstein'), + 'LT': _('Lithuania'), + 'LU': _('Luxembourg'), + 'MO': _('Macao'), + 'MK': _('Macedonia, The Former Yugoslav Republic of'), + 'MG': _('Madagascar'), + 'MW': _('Malawi'), + 'MY': _('Malaysia'), + 'MV': _('Maldives'), + 'ML': _('Mali'), + 'MT': _('Malta'), + 'MH': _('Marshall Islands'), + 'MQ': _('Martinique'), + 'MR': _('Mauritania'), + 'MU': _('Mauritius'), + 'YT': _('Mayotte'), + 'MX': _('Mexico'), + 'FM': _('Micronesia, Federated States of'), + 'MD': _('Moldova'), + 'MC': _('Monaco'), + 'MN': _('Mongolia'), + 'ME': _('Montenegro'), + 'MS': _('Montserrat'), + 'MA': _('Morocco'), + 'MZ': _('Mozambique'), + 'MM': _('Myanmar'), + 'NA': _('Namibia'), + 'NR': _('Nauru'), + 'NP': _('Nepal'), + 'NL': _('Netherlands'), + 'AN': _('Netherlands Antilles'), + 'NC': _('New Caledonia'), + 'NZ': _('New Zealand'), + 'NI': _('Nicaragua'), + 'NE': _('Niger'), + 'NG': _('Nigeria'), + 'NU': _('Niue'), + 'NF': _('Norfolk Island'), + 'MP': _('Northern Mariana Islands'), + 'NO': _('Norway'), + 'OM': _('Oman'), + 'PK': _('Pakistan'), + 'PW': _('Palau'), + 'PS': _('Palestinian Territory, Occupied'), + 'PA': _('Panama'), + 'PG': _('Papua New Guinea'), + 'PY': _('Paraguay'), + 'PE': _('Peru'), + 'PH': _('Philippines'), + 'PN': _('Pitcairn'), + 'PL': _('Poland'), + 'PT': _('Portugal'), + 'PR': _('Puerto Rico'), + 'QA': _('Qatar'), + 'RE': _('Reunion'), + 'RO': _('Romania'), + 'RU': _('Russian Federation'), + 'RW': _('Rwanda'), + 'BL': _('Saint Barthelemy'), + 'SH': _('Saint Helena'), + 'KN': _('Saint Kitts and Nevis'), + 'LC': _('Saint Lucia'), + 'MF': _('Saint Martin'), + 'PM': _('Saint Pierre and Miquelon'), + 'VC': _('Saint Vincent and the Grenadines'), + 'WS': _('Samoa'), + 'SM': _('San Marino'), + 'ST': _('Sao Tome and Principe'), + 'SA': _('Saudi Arabia'), + 'SN': _('Senegal'), + 'RS': _('Serbia'), + 'SC': _('Seychelles'), + 'SL': _('Sierra Leone'), + 'SG': _('Singapore'), + 'SK': _('Slovakia'), + 'SI': _('Slovenia'), + 'SB': _('Solomon Islands'), + 'SO': _('Somalia'), + 'ZA': _('South Africa'), + 'GS': _('South Georgia and the South Sandwich Islands'), + 'ES': _('Spain'), + 'LK': _('Sri Lanka'), + 'SD': _('Sudan'), + 'SR': _('Suriname'), + 'SJ': _('Svalbard and Jan Mayen'), + 'SZ': _('Swaziland'), + 'SE': _('Sweden'), + 'CH': _('Switzerland'), + 'SY': _('Syrian Arab Republic'), + 'TW': _('Taiwan, Province of China'), + 'TJ': _('Tajikistan'), + 'TZ': _('Tanzania, United Republic of'), + 'TH': _('Thailand'), + 'TL': _('Timor-Leste'), + 'TG': _('Togo'), + 'TK': _('Tokelau'), + 'TO': _('Tonga'), + 'TT': _('Trinidad and Tobago'), + 'TN': _('Tunisia'), + 'TR': _('Turkey'), + 'TM': _('Turkmenistan'), + 'TC': _('Turks and Caicos Islands'), + 'TV': _('Tuvalu'), + 'UG': _('Uganda'), + 'UA': _('Ukraine'), + 'AE': _('United Arab Emirates'), + 'GB': _('United Kingdom'), + 'US': _('United States'), + 'UM': _('United States Minor Outlying Islands'), + 'UY': _('Uruguay'), + 'UZ': _('Uzbekistan'), + 'VU': _('Vanuatu'), + 'VE': _('Venezuela'), + 'VN': _('Viet Nam'), + 'VG': _('Virgin Islands, British'), + 'VI': _('Virgin Islands, U.S.'), + 'WF': _('Wallis and Futuna'), + 'EH': _('Western Sahara'), + 'YE': _('Yemen'), + 'ZM': _('Zambia'), + 'ZW': _('Zimbabwe'), +} diff --git a/deluge/i18n/POTFILES.in b/deluge/i18n/POTFILES.in index 32f8e5504..dc829237d 100644 --- a/deluge/i18n/POTFILES.in +++ b/deluge/i18n/POTFILES.in @@ -12,7 +12,6 @@ deluge/ui/gtkui/glade/edit_trackers.glade deluge/ui/gtkui/glade/queuedtorrents.glade deluge/ui/gtkui/glade/move_storage_dialog.glade deluge/ui/gtkui/glade/connection_manager.glade -deluge/ui/gtkui/glade/wizard.glade deluge/ui/gtkui/glade/create_torrent_dialog.glade deluge/ui/gtkui/glade/dgtkpopups.glade deluge/ui/gtkui/glade/tray_menu.glade @@ -22,7 +21,6 @@ deluge/docs/source/conf.py deluge/core/autoadd.py deluge/core/preferencesmanager.py deluge/core/filtermanager.py -deluge/core/signalmanager.py deluge/core/torrentmanager.py deluge/core/daemon.py deluge/core/torrent.py @@ -33,30 +31,27 @@ deluge/core/core.py deluge/core/alertmanager.py deluge/core/rpcserver.py deluge/config.py +deluge/countries.py deluge/metafile.py deluge/pluginmanagerbase.py -deluge/SimpleXMLRPCServer.py deluge/plugins/label/label/webui.py deluge/plugins/label/label/test.py deluge/plugins/label/label/gtkui/label_config.py deluge/plugins/label/label/gtkui/sidebar_menu.py deluge/plugins/label/label/gtkui/submenu.py -deluge/plugins/label/label/gtkui/ui.py deluge/plugins/label/label/gtkui/__init__.py deluge/plugins/label/label/__init__.py deluge/plugins/label/label/core.py deluge/plugins/label/setup.py -deluge/plugins/corepluginbase.py +deluge/plugins/pluginbase.py deluge/plugins/init.py deluge/plugins/blocklist/setup.py deluge/plugins/blocklist/blocklist/webui.py deluge/plugins/blocklist/blocklist/gtkui.py -deluge/plugins/blocklist/blocklist/ui.py deluge/plugins/blocklist/blocklist/text.py deluge/plugins/blocklist/blocklist/peerguardian.py deluge/plugins/blocklist/blocklist/__init__.py deluge/plugins/blocklist/blocklist/core.py -deluge/plugins/coreclient.py deluge/plugins/__init__.py deluge/plugins/webuipluginbase.py deluge/plugins/stats/setup.py @@ -71,7 +66,7 @@ deluge/configmanager.py deluge/ui/tracker_icons.py deluge/ui/client.py deluge/ui/ui.py -deluge/ui/console/mapping.py +deluge/ui/coreconfig.py deluge/ui/console/colors.py deluge/ui/console/commands/resume.py deluge/ui/console/commands/config.py @@ -92,12 +87,10 @@ deluge/ui/gtkui/options_tab.py deluge/ui/gtkui/statusbar.py deluge/ui/gtkui/status_tab.py deluge/ui/gtkui/addtorrentdialog.py -deluge/ui/gtkui/coreconfig.py deluge/ui/gtkui/sidebar.py deluge/ui/gtkui/gtkui.py deluge/ui/gtkui/aboutdialog.py deluge/ui/gtkui/systemtray.py -deluge/ui/gtkui/dbusinterface.py deluge/ui/gtkui/files_tab.py deluge/ui/gtkui/menubar.py deluge/ui/gtkui/peers_tab.py @@ -110,7 +103,6 @@ deluge/ui/gtkui/pluginmanager.py deluge/ui/gtkui/mainwindow.py deluge/ui/gtkui/removetorrentdialog.py deluge/ui/gtkui/common.py -deluge/ui/gtkui/signals.py deluge/ui/gtkui/torrentdetails.py deluge/ui/gtkui/__init__.py deluge/ui/gtkui/edittrackersdialog.py @@ -120,72 +112,16 @@ deluge/ui/gtkui/new_release_dialog.py deluge/ui/gtkui/connectionmanager.py deluge/ui/gtkui/createtorrentdialog.py deluge/ui/gtkui/details_tab.py -deluge/ui/signalreceiver.py deluge/ui/common.py deluge/ui/__init__.py -deluge/ui/webui/components.py -deluge/ui/webui/render.py -deluge/ui/webui/page_decorators.py -deluge/ui/webui/webui.py -deluge/ui/webui/debugerror.py -deluge/ui/webui/webserver_common.py -deluge/ui/webui/config_forms.py -deluge/ui/webui/deluge_webserver.py -deluge/ui/webui/json_api.py -deluge/ui/webui/register_menu.py -deluge/ui/webui/config_tabs_deluge.py -deluge/ui/webui/lib/webpy022/request.py -deluge/ui/webui/lib/webpy022/wsgiserver/__init__.py -deluge/ui/webui/lib/webpy022/db.py -deluge/ui/webui/lib/webpy022/template.py -deluge/ui/webui/lib/webpy022/cheetah.py -deluge/ui/webui/lib/webpy022/debugerror.py -deluge/ui/webui/lib/webpy022/http.py -deluge/ui/webui/lib/webpy022/httpserver.py -deluge/ui/webui/lib/webpy022/utils.py -deluge/ui/webui/lib/webpy022/__init__.py -deluge/ui/webui/lib/webpy022/net.py -deluge/ui/webui/lib/webpy022/wsgi.py -deluge/ui/webui/lib/webpy022/webapi.py -deluge/ui/webui/lib/webpy022/form.py -deluge/ui/webui/lib/json.py -deluge/ui/webui/lib/newforms_plus.py -deluge/ui/webui/lib/egg_render.py -deluge/ui/webui/lib/static_handler.py -deluge/ui/webui/lib/__init__.py -deluge/ui/webui/lib/web.py -deluge/ui/webui/lib/newforms_portable/django/core/__init__.py -deluge/ui/webui/lib/newforms_portable/django/core/exceptions.py -deluge/ui/webui/lib/newforms_portable/django/utils/html.py -deluge/ui/webui/lib/newforms_portable/django/utils/http.py -deluge/ui/webui/lib/newforms_portable/django/utils/encoding.py -deluge/ui/webui/lib/newforms_portable/django/utils/translation.py -deluge/ui/webui/lib/newforms_portable/django/utils/safestring.py -deluge/ui/webui/lib/newforms_portable/django/utils/__init__.py -deluge/ui/webui/lib/newforms_portable/django/utils/datastructures.py -deluge/ui/webui/lib/newforms_portable/django/utils/functional.py -deluge/ui/webui/lib/newforms_portable/django/__init__.py -deluge/ui/webui/lib/newforms_portable/forms.py -deluge/ui/webui/lib/newforms_portable/models.py -deluge/ui/webui/lib/newforms_portable/widgets.py -deluge/ui/webui/lib/newforms_portable/fields.py -deluge/ui/webui/lib/newforms_portable/__init__.py -deluge/ui/webui/lib/newforms_portable/util.py -deluge/ui/webui/lib/egg_handler.py -deluge/ui/webui/utils.py -deluge/ui/webui/pages.py -deluge/ui/webui/__init__.py -deluge/ui/webui/tests/test_all.py -deluge/ui/webui/apache.py -deluge/ui/webui/web.py -deluge/ui/webui/torrent_move.py -deluge/ui/webui/config_tabs_webui.py -deluge/ui/webui/torrent_options.py -deluge/ui/webui/torrent_add.py -deluge/ui/webui/scripts/template_strings.py -deluge/ui/webui/scripts/extract_ajax_strings.py -deluge/ui/webui/scripts/copy_icons.py -deluge/ui/webui/scripts/extract_template_strings.py +deluge/ui/web/auth.py +deluge/ui/web/common.py +deluge/ui/web/gen_gettext.py +deluge/ui/web/__init__.py +deluge/ui/web/json_api.py +deluge/ui/web/pluginmanager.py +deluge/ui/web/server.py +deluge/ui/web/web.py deluge/common.py deluge/component.py deluge/main.py @@ -198,7 +134,6 @@ deluge/tests/test_tracker_icons.py deluge/tests/test_stats.py deluge/tests/test_client.py deluge/log.py -deluge/xmlrpclib.py deluge/scripts/deluge_remote.py deluge/scripts/wiki_docgen.py deluge/scripts/create_plugin.py diff --git a/deluge/ui/gtkui/peers_tab.py b/deluge/ui/gtkui/peers_tab.py index bbb30d7cf..20c948341 100644 --- a/deluge/ui/gtkui/peers_tab.py +++ b/deluge/ui/gtkui/peers_tab.py @@ -39,6 +39,7 @@ import deluge.ui.gtkui.common as common from deluge.ui.gtkui.listview import cell_data_speed as cell_data_speed from deluge.ui.gtkui.torrentdetails import Tab from deluge.log import LOG as log +from deluge.countries import COUNTRIES def cell_data_progress(column, cell, model, row, data): value = model.get_value(row, data) @@ -59,7 +60,9 @@ class PeersTab(Tab): }) self.listview = glade.get_widget("peers_listview") + self.listview.props.has_tooltip = True self.listview.connect("button-press-event", self._on_button_press_event) + self.listview.connect("query-tooltip", self._on_query_tooltip) # country pixbuf, ip, client, downspeed, upspeed, country code, int_ip, seed/peer icon, progress self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, int, int, str, float, gtk.gdk.Pixbuf, float) self.cached_flag_pixbufs = {} @@ -342,6 +345,22 @@ class PeersTab(Tab): self.peer_menu.popup(None, None, None, event.button, event.time) return True + def _on_query_tooltip(self, widget, x, y, keyboard_tip, tooltip): + if not widget.get_tooltip_context(x, y, keyboard_tip): + return False + else: + model, path, iter = widget.get_tooltip_context(x, y, keyboard_tip) + + country_code = model.get(iter, 5)[0] + if country_code != " " and country_code in COUNTRIES: + tooltip.set_text(COUNTRIES[country_code]) + # widget here is self.listview + widget.set_tooltip_cell(tooltip, path, widget.get_column(0), + None) + return True + else: + return False + def _on_menuitem_add_peer_activate(self, menuitem): """This is a callback for manually adding a peer""" log.debug("on_menuitem_add_peer")