From 7cc500ff92062187e93e102e35d4c0eddccd4971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 9 Apr 2009 12:14:31 +0200 Subject: [PATCH] Remove Tooltips because it is deprecated in PyGTK 2.12 and above --- tryton/common/common.py | 19 ++++++++++++++++++ tryton/gui/main.py | 2 +- tryton/gui/window/dbcreate.py | 20 +++++++++---------- tryton/gui/window/dbdumpdrop.py | 6 +++--- tryton/gui/window/dblogin.py | 2 +- tryton/gui/window/dbrestore.py | 10 +++++----- tryton/gui/window/view_board/action.py | 2 +- tryton/gui/window/view_board/parser.py | 2 +- .../window/view_form/view/form_gtk/binary.py | 4 ++-- .../view_form/view/form_gtk/calendar.py | 6 +++--- .../window/view_form/view/form_gtk/image.py | 4 ++-- .../view_form/view/form_gtk/many2one.py | 2 +- .../view_form/view/form_gtk/one2many.py | 2 +- .../window/view_form/view/form_gtk/parser.py | 2 +- .../view_form/view/form_gtk/reference.py | 2 +- .../gui/window/view_form/view/form_gtk/url.py | 7 ++++++- .../window/view_form/view/list_gtk/parser.py | 2 +- .../window/view_form/view/screen_container.py | 3 ++- .../view_form/widget_search/calendar.py | 4 ++-- 19 files changed, 63 insertions(+), 38 deletions(-) diff --git a/tryton/common/common.py b/tryton/common/common.py index cd7ddfcd36..b891dddeb6 100644 --- a/tryton/common/common.py +++ b/tryton/common/common.py @@ -992,6 +992,25 @@ class RPCProgress(object): raise self.exception return self.res + +class Tooltips(object): + _tooltips = None + + def set_tip(self, widget, tip_text): + if hasattr(widget, 'set_tooltip_text'): + return widget.set_tooltip_text(tip_text) + if not self._tooltips: + self._tooltips = gtk.Tooltips() + return self._tooltips.set_tip(widget, tip_text) + + def enable(self): + if self._tooltips: + self._tooltips.enable() + + def disable(self): + if self._tooltips: + self._tooltips.disable() + COLOR_SCHEMES = { 'red': '#cf1d1d', 'green': '#3fb41b', diff --git a/tryton/gui/main.py b/tryton/gui/main.py index a385fff078..6cdd9e85f5 100644 --- a/tryton/gui/main.py +++ b/tryton/gui/main.py @@ -90,7 +90,7 @@ class Main(object): if hasattr(gtk, 'accel_map_load'): gtk.accel_map_load(os.path.join(get_home_dir(), '.trytonsc')) - self.tooltips = gtk.Tooltips() + self.tooltips = common.Tooltips() toolbar = gtk.Toolbar() self.toolbar = toolbar diff --git a/tryton/gui/window/dbcreate.py b/tryton/gui/window/dbcreate.py index bbde46f82e..8c8e7d541c 100644 --- a/tryton/gui/window/dbcreate.py +++ b/tryton/gui/window/dbcreate.py @@ -30,7 +30,7 @@ class DBCreate(object): self.tooltips.set_tip(self.entry_server_connection,_("This is the URL of " \ "the Tryton server. Use server 'localhost' and port '8070' if " \ "the server is installed on this computer. Click on 'Change' to " \ - "change the address."), None) + "change the address.")) else: self.entry_serverpasswd.set_sensitive(False) self.entry_dbname.set_sensitive(False) @@ -50,7 +50,7 @@ class DBCreate(object): "3. If there is a firewall between the server and this " \ "client, make shure that the server address and port " \ "(usually 8070) are not blocked.\n" \ - "Click on 'Change' to change the address."), None) + "Click on 'Change' to change the address.")) return state def server_change(self, widget, parent): @@ -142,7 +142,7 @@ class DBCreate(object): self.dialog.set_icon(TRYTON_ICON) # This event is needed for controlling the button_create self.dialog.connect("key-press-event", self.event_show_button_create) - self.tooltips = gtk.Tooltips() + self.tooltips = common.Tooltips() self.dialog.add_button("gtk-cancel", \ gtk.RESPONSE_CANCEL) self.button_create = gtk.Button(_('C_reate')) @@ -181,7 +181,7 @@ class DBCreate(object): self.tooltips.set_tip(self.entry_server_connection, _("This is the URL of " \ "the server. Use server 'localhost' and port '8070' if " \ "the server is installed on this computer. Click on 'Change' to " \ - "change the address."), None) + "change the address.")) self.button_server_change = gtk.Button(_("C_hange"), stock=None, use_underline=True) img_button_server_change = gtk.Image() @@ -190,7 +190,7 @@ class DBCreate(object): self.button_server_change.set_image(img_button_server_change) table.attach(self.button_server_change, 2, 3, 1, 2, yoptions=False, xoptions=gtk.FILL) self.tooltips.set_tip(self.button_server_change, _("Setup the " \ - "server connection..."), None) + "server connection...")) label_serverpasswd = gtk.Label(_("Tryton Server Password:")) label_serverpasswd.set_justify(gtk.JUSTIFY_RIGHT) label_serverpasswd.set_alignment(1, 0.5) @@ -203,7 +203,7 @@ class DBCreate(object): self.tooltips.set_tip(self.entry_serverpasswd, _("This is the " \ "password of the Tryton server. It doesn't belong to a " \ "real user. This password is usually defined in the trytond " \ - "configuration."), None) + "configuration.")) self.entry_serverpasswd.connect("key-press-event", \ self.event_passwd_clear) @@ -230,7 +230,7 @@ class DBCreate(object): "database.\n" \ "Allowed characters are alphanumerical or _ (underscore)\n" \ "You need to avoid all accents, space or special characters! " \ - "Example: tryton"), None) + "Example: tryton")) handlerid = self.entry_dbname.connect("insert-text", \ self.entry_insert_text) self.entry_dbname.set_data('handlerid', handlerid) @@ -246,7 +246,7 @@ class DBCreate(object): self.tooltips.set_tip(eventbox_language, _("Choose the default " \ "language that will be installed for this database. You will " \ "be able to install new languages after installation through " \ - "the administration menu."), None) + "the administration menu.")) label_adminpasswd = gtk.Label(_("Admin password:")) label_adminpasswd.set_justify(gtk.JUSTIFY_RIGHT) label_adminpasswd.set_padding( 3, 3) @@ -259,7 +259,7 @@ class DBCreate(object): "the admin user of the new database. With these credentials you " \ "will be later able to login into the database:\n" \ "User name: admin\n" \ - "Password: "), None) + "Password: ")) table.attach(self.entry_adminpasswd, 1, 3, 7, 8) self.entry_adminpasswd.connect("key-press-event", \ self.event_passwd_clear) @@ -272,7 +272,7 @@ class DBCreate(object): self.entry_adminpasswd2.set_visibility(False) self.entry_adminpasswd2.set_activates_default(True) self.tooltips.set_tip(self.entry_adminpasswd2, _("Type the Admin " \ - "password again"), None) + "password again")) table.attach(self.entry_adminpasswd2, 1, 3, 8, 9) self.entry_adminpasswd2.connect("key-press-event", \ self.event_passwd_clear) diff --git a/tryton/gui/window/dbdumpdrop.py b/tryton/gui/window/dbdumpdrop.py index e07622f543..ef9684b182 100644 --- a/tryton/gui/window/dbdumpdrop.py +++ b/tryton/gui/window/dbdumpdrop.py @@ -89,7 +89,7 @@ class DBBackupDrop(object): self.dialog.set_has_separator(True) self.dialog.set_icon(TRYTON_ICON) self.dialog.connect("key-press-event", self.event_show_button_ok) - self.tooltips = gtk.Tooltips() + self.tooltips = common.Tooltips() self.dialog.add_button("gtk-cancel", \ gtk.RESPONSE_CANCEL) self.button_ok = gtk.Button(button_ok_text) @@ -133,7 +133,7 @@ class DBBackupDrop(object): self.tooltips.set_tip(self.entry_server_connection, _("This is the " \ "URL of the server. Use server 'localhost' and port '8070' " \ "if the server is installed on this computer. " \ - "Click on 'Change' to change the address."), None) + "Click on 'Change' to change the address.")) table.attach(self.entry_server_connection, 1, 2, 2, 3) self.button_server_change = gtk.Button(_("C_hange"), stock=None, \ @@ -172,7 +172,7 @@ class DBBackupDrop(object): self.tooltips.set_tip(self.entry_serverpasswd, _("This is the " \ "password of the Tryton server. It doesn't belong to a " \ "real user. This password is usually defined in the trytond " \ - "configuration."), None) + "configuration.")) table.attach(self.entry_serverpasswd, 1, 3, 4, 5) self.entry_serverpasswd.grab_focus() diff --git a/tryton/gui/window/dblogin.py b/tryton/gui/window/dblogin.py index 46f7aa2112..d09639f771 100644 --- a/tryton/gui/window/dblogin.py +++ b/tryton/gui/window/dblogin.py @@ -19,7 +19,7 @@ class DBLogin(object): self.dialog.set_has_separator(True) self.dialog.set_icon(TRYTON_ICON) - tooltips = gtk.Tooltips() + tooltips = common.Tooltips() button_cancel = gtk.Button(_('_Cancel')) img_cancel = gtk.Image() img_cancel.set_from_stock('tryton-cancel', gtk.ICON_SIZE_BUTTON) diff --git a/tryton/gui/window/dbrestore.py b/tryton/gui/window/dbrestore.py index 22435af4f7..4a7baaf1fc 100644 --- a/tryton/gui/window/dbrestore.py +++ b/tryton/gui/window/dbrestore.py @@ -69,7 +69,7 @@ class DBRestore(object): | gtk.WIN_POS_CENTER_ON_PARENT) vbox = gtk.VBox() self.dialog.vbox.pack_start(vbox) - self.tooltips = gtk.Tooltips() + self.tooltips = common.Tooltips() table = gtk.Table(5, 3, False) table.set_border_width(9) table.set_row_spacings(3) @@ -90,7 +90,7 @@ class DBRestore(object): self.tooltips.set_tip(self.entry_server_url, _("This is the URL of " \ "the server. Use server 'localhost' and port '8070' if " \ "the server is installed on this computer. Click on " \ - "'Change' to change the address."), None) + "'Change' to change the address.")) table.attach(self.entry_server_url, 1, 2, 0, 1) self.button_server_change = gtk.Button(_("C_hange"), stock=None, \ use_underline=True) @@ -99,7 +99,7 @@ class DBRestore(object): 'tryton-preferences-system', gtk.ICON_SIZE_BUTTON) self.button_server_change.set_image(img_button_server_change) self.tooltips.set_tip(self.button_server_change, _("Setup the " \ - "server connection..."), None) + "server connection...")) table.attach(self.button_server_change, 2, 3, 0, 1) label_server_password = gtk.Label(_("Tryton Server Password:")) label_server_password.set_justify(gtk.JUSTIFY_RIGHT) @@ -113,7 +113,7 @@ class DBRestore(object): self.tooltips.set_tip(self.entry_server_password, _("This is the " \ "password of the Tryton server. It doesn't belong to a " \ "real user. This password is usually defined in the trytond " \ - "configuration."), None) + "configuration.")) table.attach(self.entry_server_password, 1, 3, 1, 2) hseparator = gtk.HSeparator() table.attach(hseparator, 0, 3, 2, 3) @@ -136,7 +136,7 @@ class DBRestore(object): "the database to be restored.\n" \ "Allowed characters are alphanumerical or _ (underscore)\n" \ "You need to avoid all accents, space or special " \ - "characters! \nExample: tryton"), None) + "characters! \nExample: tryton")) table.attach(self.entry_db_name, 1, 3, 4, 5) label_db_name = gtk.Label(_("New Database Name:")) label_db_name.set_alignment(1, 0.5) diff --git a/tryton/gui/window/view_board/action.py b/tryton/gui/window/view_board/action.py index 1e8f2da440..40fbb9cfa5 100644 --- a/tryton/gui/window/view_board/action.py +++ b/tryton/gui/window/view_board/action.py @@ -61,7 +61,7 @@ class Action(object): self.title = gtk.Label() hbox.pack_start(self.title, expand=True, fill=True) - tooltips = gtk.Tooltips() + tooltips = common.Tooltips() hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) diff --git a/tryton/gui/window/view_board/parser.py b/tryton/gui/window/view_board/parser.py index 34d6980289..27a15ac004 100644 --- a/tryton/gui/window/view_board/parser.py +++ b/tryton/gui/window/view_board/parser.py @@ -18,7 +18,7 @@ class ParserBoard(object): attrs = common.node_attributes(root_node) if not tooltips: - tooltips = gtk.Tooltips() + tooltips = common.Tooltips() container = _container(tooltips) container.new(col=int(attrs.get('col', 4))) diff --git a/tryton/gui/window/view_form/view/form_gtk/binary.py b/tryton/gui/window/view_form/view/form_gtk/binary.py index d504e242a4..70b653b784 100644 --- a/tryton/gui/window/view_form/view/form_gtk/binary.py +++ b/tryton/gui/window/view_form/view/form_gtk/binary.py @@ -3,7 +3,7 @@ import base64 import gtk import gettext import os -from tryton.common import file_selection, message, warning +from tryton.common import file_selection, message, warning, Tooltips from interface import WidgetInterface _ = gettext.gettext @@ -15,7 +15,7 @@ class Binary(WidgetInterface): def __init__(self, window, parent, model, attrs=None): super(Binary, self).__init__(window, parent, model, attrs) - self.tooltips = gtk.Tooltips() + self.tooltips = Tooltips() self.widget = gtk.HBox(spacing=0) self.wid_text = gtk.Entry() diff --git a/tryton/gui/window/view_form/view/form_gtk/calendar.py b/tryton/gui/window/view_form/view/form_gtk/calendar.py index f4ca5c543f..5cdf2b57ea 100644 --- a/tryton/gui/window/view_form/view/form_gtk/calendar.py +++ b/tryton/gui/window/view_form/view/form_gtk/calendar.py @@ -8,7 +8,7 @@ from interface import WidgetInterface import tryton.rpc as rpc from tryton.common import DT_FORMAT, DHM_FORMAT, HM_FORMAT, message, \ TRYTON_ICON -from tryton.common import date_widget +from tryton.common import date_widget, Tooltips from tryton.translate import date_format import mx.DateTime @@ -41,7 +41,7 @@ class Calendar(WidgetInterface): self.widget.pack_start(self.but_open, expand=False, fill=False) self.widget.set_focus_chain([self.entry]) - tooltips = gtk.Tooltips() + tooltips = Tooltips() tooltips.set_tip(self.but_open, _('Open the calendar')) tooltips.enable() @@ -176,7 +176,7 @@ class DateTime(WidgetInterface): self.widget.pack_start(self.but_open, expand=False, fill=False) self.widget.set_focus_chain([self.entry]) - tooltips = gtk.Tooltips() + tooltips = Tooltips() tooltips.set_tip(self.but_open, _('Open the calendar')) tooltips.enable() diff --git a/tryton/gui/window/view_form/view/form_gtk/image.py b/tryton/gui/window/view_form/view/form_gtk/image.py index 30e838158e..077f41f306 100644 --- a/tryton/gui/window/view_form/view/form_gtk/image.py +++ b/tryton/gui/window/view_form/view/form_gtk/image.py @@ -3,7 +3,7 @@ import gtk import gettext import os from base64 import encodestring, decodestring -from tryton.common import file_selection +from tryton.common import file_selection, Tooltips from tryton.config import PIXMAPS_DIR from interface import WidgetInterface import urllib @@ -30,7 +30,7 @@ class Image(WidgetInterface): self.event.connect('drag_motion', self.drag_motion) self.event.connect('drag_data_received', self.drag_data_received) - self.tooltips = gtk.Tooltips() + self.tooltips = Tooltips() self.image = gtk.Image() self.event.add(self.image) diff --git a/tryton/gui/window/view_form/view/form_gtk/many2one.py b/tryton/gui/window/view_form/view/form_gtk/many2one.py index 9f45eb041a..5d034e3c72 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2one.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py @@ -195,7 +195,7 @@ class Many2One(WidgetInterface): self.widget.set_focus_chain([self.wid_text]) - self.tooltips = gtk.Tooltips() + self.tooltips = common.Tooltips() self.tooltips.set_tip(self.but_new, _('Create a new record')) self.tooltips.set_tip(self.but_open, _('Open a record')) self.tooltips.enable() diff --git a/tryton/gui/window/view_form/view/form_gtk/one2many.py b/tryton/gui/window/view_form/view/form_gtk/one2many.py index b33b13513a..ebcb67e780 100644 --- a/tryton/gui/window/view_form/view/form_gtk/one2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py @@ -38,7 +38,7 @@ def _create_menu(self, attrs): menubar.add(menuitem_title) hbox.pack_start(menubar, expand=True, fill=True) - tooltips = gtk.Tooltips() + tooltips = common.Tooltips() if attrs.get('add_remove'): diff --git a/tryton/gui/window/view_form/view/form_gtk/parser.py b/tryton/gui/window/view_form/view/form_gtk/parser.py index bcc3e7a619..1b952085ce 100644 --- a/tryton/gui/window/view_form/view/form_gtk/parser.py +++ b/tryton/gui/window/view_form/view/form_gtk/parser.py @@ -410,7 +410,7 @@ class ParserForm(ParserInterface): attrs = common.node_attributes(root_node) on_write = attrs.get('on_write', '') if not tooltips: - tooltips = gtk.Tooltips() + tooltips = common.Tooltips() container = _container(tooltips) if CONFIG['client.modepda']: container.new(col=1) diff --git a/tryton/gui/window/view_form/view/form_gtk/reference.py b/tryton/gui/window/view_form/view/form_gtk/reference.py index 902c49fbac..9de274665c 100644 --- a/tryton/gui/window/view_form/view/form_gtk/reference.py +++ b/tryton/gui/window/view_form/view/form_gtk/reference.py @@ -68,7 +68,7 @@ class Reference(WidgetInterface): self.widget.set_focus_chain([self.widget_combo, self.wid_text]) - tooltips = gtk.Tooltips() + tooltips = common.Tooltips() tooltips.set_tip(self.but_open, _('Search / Open a record')) tooltips.set_tip(self.but_new, _('Create a new record')) tooltips.enable() diff --git a/tryton/gui/window/view_form/view/form_gtk/url.py b/tryton/gui/window/view_form/view/form_gtk/url.py index 85fa925522..87d9e45cf2 100644 --- a/tryton/gui/window/view_form/view/form_gtk/url.py +++ b/tryton/gui/window/view_form/view/form_gtk/url.py @@ -3,6 +3,7 @@ import gettext import gtk from char import Char import webbrowser +import tryton.common as common class URL(Char): @@ -13,7 +14,7 @@ class URL(Char): attrs = {} super(URL, self).__init__(window, parent, model, attrs=attrs) - self.tooltips = gtk.Tooltips() + self.tooltips = common.Tooltips() self.button = gtk.Button() img = gtk.Image() img.set_from_stock('tryton-web-browser', gtk.ICON_SIZE_SMALL_TOOLBAR) @@ -34,6 +35,7 @@ class URL(Char): self.tooltips.enable() self.tooltips.set_tip(self.button, value) else: + self.tooltips.set_tip(self.button, '') self.tooltips.disable() def _readonly_set(self, value): @@ -65,6 +67,7 @@ class Email(URL): self.tooltips.enable() self.tooltips.set_tip(self.button, 'mailto:%s' % value) else: + self.tooltips.set_tip(self.button, '') self.tooltips.disable() @@ -82,6 +85,7 @@ class CallTo(URL): self.tooltips.enable() self.tooltips.set_tip(self.button, 'callto:%s' % value) else: + self.tooltips.set_tip(self.button, '') self.tooltips.disable() @@ -99,5 +103,6 @@ class SIP(URL): self.tooltips.enable() self.tooltips.set_tip(self.button, 'sip:%s' % value) else: + self.tooltips.set_tip(self.button, '') self.tooltips.disable() diff --git a/tryton/gui/window/view_form/view/list_gtk/parser.py b/tryton/gui/window/view_form/view/list_gtk/parser.py index 64470293fc..2188f64ff7 100644 --- a/tryton/gui/window/view_form/view/list_gtk/parser.py +++ b/tryton/gui/window/view_form/view/list_gtk/parser.py @@ -90,7 +90,7 @@ class ParserTree(ParserInterface): treeview.set_property('rules-hint', True) if not self.title: self.title = attrs.get('string', 'Unknown') - tooltips = gtk.Tooltips() + tooltips = common.Tooltips() for node in root_node.childNodes: node_attrs = node_attributes(node) diff --git a/tryton/gui/window/view_form/view/screen_container.py b/tryton/gui/window/view_form/view/screen_container.py index 406eb0715d..89549d4d40 100644 --- a/tryton/gui/window/view_form/view/screen_container.py +++ b/tryton/gui/window/view_form/view/screen_container.py @@ -1,6 +1,7 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. import gtk import gettext +import tryton.common as common _ = gettext.gettext @@ -18,7 +19,7 @@ class ScreenContainer(object): return self.vbox def add_filter(self, widget, fnct, clear_fnct): - tooltips = gtk.Tooltips() + tooltips = common.Tooltips() self.filter_vbox = gtk.VBox(spacing=0) self.filter_vbox.set_border_width(0) diff --git a/tryton/gui/window/view_form/widget_search/calendar.py b/tryton/gui/window/view_form/widget_search/calendar.py index 758c3713aa..bad815502c 100644 --- a/tryton/gui/window/view_form/widget_search/calendar.py +++ b/tryton/gui/window/view_form/widget_search/calendar.py @@ -6,7 +6,7 @@ import gettext import locale from interface import Interface from tryton.common import DT_FORMAT, TRYTON_ICON -from tryton.common import date_widget +from tryton.common import date_widget, Tooltips from tryton.translate import date_format import mx.DateTime import gobject @@ -20,7 +20,7 @@ class Calendar(Interface): super(Calendar, self).__init__(name, parent, attrs=attrs, context=context) - tooltips = gtk.Tooltips() + tooltips = Tooltips() self.widget = gtk.HBox(spacing=3) self.format = date_format()