From 093847ba43a8bca86c21844ae8b39ef197fa8290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 16 Jan 2014 22:12:52 +0100 Subject: [PATCH] Remove old workaround for PyGTK < 2.22 review2681003 --- tryton/client.py | 3 +-- tryton/common/common.py | 8 ++------ tryton/common/completion.py | 3 +-- tryton/common/date_widget.py | 9 ++++----- tryton/gui/main.py | 12 ++++-------- .../gui/window/view_form/view/form_gtk/calendar.py | 3 +-- .../gui/window/view_form/view/form_gtk/dictionary.py | 3 +-- .../gui/window/view_form/view/form_gtk/selection.py | 4 +--- tryton/gui/window/view_form/view/list_gtk/parser.py | 4 +--- tryton/gui/window/view_form/view/screen_container.py | 9 +++------ tryton/gui/window/win_form.py | 3 +-- tryton/gui/window/wizard.py | 3 +-- 12 files changed, 21 insertions(+), 43 deletions(-) diff --git a/tryton/client.py b/tryton/client.py index 82d0583f22..6c4f2ae97a 100644 --- a/tryton/client.py +++ b/tryton/client.py @@ -116,8 +116,7 @@ class TrytonClient(object): gtk.main() except KeyboardInterrupt: CONFIG.save() - if hasattr(gtk, 'accel_map_save'): - gtk.accel_map_save(os.path.join(get_config_dir(), 'accel.map')) + gtk.accel_map_save(os.path.join(get_config_dir(), 'accel.map')) if __name__ == "__main__": CLIENT = TrytonClient() diff --git a/tryton/common/common.py b/tryton/common/common.py index 20ad7918ca..6cb1c56fde 100644 --- a/tryton/common/common.py +++ b/tryton/common/common.py @@ -633,12 +633,8 @@ class WarningDialog(UniqueDialog): def build_dialog(self, parent, message, title, buttons=gtk.BUTTONS_OK): dialog = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, buttons) - if hasattr(dialog, 'format_secondary_markup'): - dialog.set_markup('%s' % (to_xml(title))) - dialog.format_secondary_markup(to_xml(message)) - else: - dialog.set_markup( - '%s\n%s' % (to_xml(title), to_xml(message))) + dialog.set_markup('%s' % (to_xml(title))) + dialog.format_secondary_markup(to_xml(message)) return dialog warning = WarningDialog() diff --git a/tryton/common/completion.py b/tryton/common/completion.py index 2f5b3d702b..441d422fdd 100644 --- a/tryton/common/completion.py +++ b/tryton/common/completion.py @@ -17,8 +17,7 @@ def get_completion(): completion.set_match_func(lambda *a: True) completion.set_model(gtk.ListStore(str, int)) completion.set_text_column(0) - if hasattr(completion.props, 'popup_set_width'): - completion.props.popup_set_width = False + completion.props.popup_set_width = False completion.insert_action_markup(0, _('Search...')) completion.insert_action_markup(1, _('Create...')) return completion diff --git a/tryton/common/date_widget.py b/tryton/common/date_widget.py index ded569d8cb..569e1f6df7 100644 --- a/tryton/common/date_widget.py +++ b/tryton/common/date_widget.py @@ -61,11 +61,10 @@ class DateEntry(gtk.Entry): self.connect('focus-in-event', self._focus_in) self.connect('focus-out-event', self._focus_out) - if hasattr(self, 'set_icon_from_stock'): - self.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'tryton-find') - self.set_icon_tooltip_text(gtk.ENTRY_ICON_SECONDARY, - _('Open the calendar ')) - self.connect('icon-press', DateEntry.cal_open) + self.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'tryton-find') + self.set_icon_tooltip_text(gtk.ENTRY_ICON_SECONDARY, + _('Open the calendar ')) + self.connect('icon-press', DateEntry.cal_open) self._interactive_input = True self.idle_set_position(0) diff --git a/tryton/gui/main.py b/tryton/gui/main.py index eb8c32f3c2..fe5e3a24c6 100644 --- a/tryton/gui/main.py +++ b/tryton/gui/main.py @@ -130,8 +130,7 @@ class Main(object): gtk.accel_map_add_entry('/Form/Search', gtk.keysyms.F, gtk.gdk.CONTROL_MASK) - if hasattr(gtk, 'accel_map_load'): - gtk.accel_map_load(os.path.join(get_config_dir(), 'accel.map')) + gtk.accel_map_load(os.path.join(get_config_dir(), 'accel.map')) self.tooltips = common.Tooltips() @@ -293,8 +292,7 @@ class Main(object): text_cell = gtk.CellRendererText() global_search_completion.pack_start(text_cell) global_search_completion.add_attribute(text_cell, "markup", 1) - if hasattr(global_search_completion.props, 'popup_set_width'): - global_search_completion.props.popup_set_width = True + global_search_completion.props.popup_set_width = True self.global_search_entry.set_completion(global_search_completion) self.global_search_entry.set_icon_from_stock(gtk.ENTRY_ICON_PRIMARY, 'gtk-find') @@ -1090,8 +1088,7 @@ class Main(object): CONFIG['client.default_width'] = Main.get_main()._width CONFIG['client.default_height'] = Main.get_main()._height CONFIG.save() - if hasattr(gtk, 'accel_map_save'): - gtk.accel_map_save(os.path.join(get_config_dir(), 'accel.map')) + gtk.accel_map_save(os.path.join(get_config_dir(), 'accel.map')) cls.tryton_client.quit_mainloop() @@ -1186,8 +1183,7 @@ class Main(object): label_menu = gtk.Label(page.name) label_menu.set_alignment(0.0, 0.5) self.notebook.insert_page_menu(page.widget, hbox, label_menu, page_id) - if hasattr(self.notebook, 'set_tab_reorderable'): - self.notebook.set_tab_reorderable(page.widget, True) + self.notebook.set_tab_reorderable(page.widget, True) self.notebook.set_current_page(page_id) def _sig_remove_book(self, widget, page_widget): 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 7292c7e0cc..c3c767d513 100644 --- a/tryton/gui/window/view_form/view/form_gtk/calendar.py +++ b/tryton/gui/window/view_form/view/form_gtk/calendar.py @@ -89,8 +89,7 @@ class Time(Calendar): def __init__(self, field_name, model_name, attrs=None): super(Time, self).__init__(field_name, model_name, attrs=attrs) - if hasattr(self.entry, 'set_icon_from_stock'): - self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, None) + self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, None) def get_format(self, record, field): return field.time_format(record) diff --git a/tryton/gui/window/view_form/view/form_gtk/dictionary.py b/tryton/gui/window/view_form/view/form_gtk/dictionary.py index 42090b8ff3..f958067a15 100644 --- a/tryton/gui/window/view_form/view/form_gtk/dictionary.py +++ b/tryton/gui/window/view_form/view/form_gtk/dictionary.py @@ -104,8 +104,7 @@ class DictSelectionEntry(DictEntry): widget.set_text_column(0) widget.child.set_width_chars(width) completion = gtk.EntryCompletion() - if hasattr(completion, 'set_inline_selection'): - completion.set_inline_selection(True) + completion.set_inline_selection(True) completion.set_model(model) widget.child.set_completion(completion) completion.set_text_column(0) diff --git a/tryton/gui/window/view_form/view/form_gtk/selection.py b/tryton/gui/window/view_form/view/form_gtk/selection.py index 8eb24f44e7..c5ad774088 100644 --- a/tryton/gui/window/view_form/view/form_gtk/selection.py +++ b/tryton/gui/window/view_form/view/form_gtk/selection.py @@ -29,9 +29,7 @@ class PopdownMixin(object): entry.set_model(model) entry.set_text_column(0) completion = gtk.EntryCompletion() - #Only available in PyGTK 2.6 and above. - if hasattr(completion, 'set_inline_selection'): - completion.set_inline_selection(True) + completion.set_inline_selection(True) completion.set_model(model) entry.child.set_completion(completion) if self._selection: 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 847f780e49..c04e6deb9d 100644 --- a/tryton/gui/window/view_form/view/list_gtk/parser.py +++ b/tryton/gui/window/view_form/view/list_gtk/parser.py @@ -938,9 +938,7 @@ class Selection(Char, SelectionMixin): if hasattr(editable, 'set_text_column'): editable.set_text_column(0) completion = gtk.EntryCompletion() - #Only available in PyGTK 2.6 and above. - if hasattr(completion, 'set_inline_selection'): - completion.set_inline_selection(True) + completion.set_inline_selection(True) completion.set_model(model) editable.get_child().set_completion(completion) completion.set_text_column(0) diff --git a/tryton/gui/window/view_form/view/screen_container.py b/tryton/gui/window/view_form/view/screen_container.py index c6c7f26f6a..ca5d47763d 100644 --- a/tryton/gui/window/view_form/view/screen_container.py +++ b/tryton/gui/window/view_form/view/screen_container.py @@ -103,10 +103,8 @@ class ScreenContainer(object): self.completion.set_model(gtk.ListStore(str)) self.completion.set_text_column(0) self.completion.props.inline_completion = True - if hasattr(self.completion.props, 'inline_selection'): - self.completion.props.inline_selection = True - if hasattr(self.completion.props, 'popup_set_width'): - self.completion.props.popup_set_width = False + self.completion.props.inline_selection = True + self.completion.props.popup_set_width = False self.completion.set_match_func(lambda *a: True) self.completion.connect('match-selected', self.match_selected) self.search_entry.connect('activate', self.activate) @@ -431,8 +429,7 @@ class ScreenContainer(object): self.search_window.set_title('Tryton') self.search_window.set_icon(TRYTON_ICON) self.search_window.set_decorated(False) - if hasattr(self.search_window, 'set_deletable'): - self.search_window.set_deletable(False) + self.search_window.set_deletable(False) self.search_window.connect('key-press-event', key_press) vbox = gtk.VBox() fields = [f for f in self.screen.domain_parser.fields.itervalues() diff --git a/tryton/gui/window/win_form.py b/tryton/gui/window/win_form.py index 314bff6630..015628e45f 100644 --- a/tryton/gui/window/win_form.py +++ b/tryton/gui/window/win_form.py @@ -38,8 +38,7 @@ class WinForm(NoModal): self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.win.set_icon(TRYTON_ICON) self.win.set_has_separator(False) - if hasattr(self.win, 'set_deletable'): - self.win.set_deletable(False) + self.win.set_deletable(False) self.win.connect('close', self.close) self.win.connect('response', self.response) diff --git a/tryton/gui/window/wizard.py b/tryton/gui/window/wizard.py index 869ec06f98..3e37106691 100644 --- a/tryton/gui/window/wizard.py +++ b/tryton/gui/window/wizard.py @@ -295,8 +295,7 @@ class WizardDialog(Wizard, NoModal): gtk.DIALOG_DESTROY_WITH_PARENT) self.dia.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.dia.set_icon(TRYTON_ICON) - if hasattr(self.dia, 'set_deletable'): - self.dia.set_deletable(False) + self.dia.set_deletable(False) self.dia.connect('close', self.close) self.dia.connect('response', self.response) self.dia.connect('state-changed', self.state_changed)