From fa0805dc60dc6cc256a65520ab1a4dd35f620ce0 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Wed, 7 Oct 2009 18:15:18 +0000 Subject: [PATCH] Bug 0003063: gtk.Tooltips is deprecated -- first batch of updates svn: r13335 --- src/DataViews/GrampletView.py | 17 ++++++--------- src/DataViews/MediaView.py | 8 ++----- src/DataViews/PedigreeView.py | 12 +++++------ src/DataViews/RelationView.py | 31 +++++++++++---------------- src/Filters/SideBar/_SidebarFilter.py | 3 +-- src/gui/viewmanager.py | 26 +++------------------- 6 files changed, 30 insertions(+), 67 deletions(-) diff --git a/src/DataViews/GrampletView.py b/src/DataViews/GrampletView.py index c55d1af47..80e9dea84 100644 --- a/src/DataViews/GrampletView.py +++ b/src/DataViews/GrampletView.py @@ -175,8 +175,7 @@ def make_requested_gramplet(viewpage, name, opts, dbstate, uistate): if msg is None: msg = _("Drag Properties Button to move and click it for setup") if msg: - gui.tooltips = gtk.Tooltips() - gui.tooltips.set_tip(gui.scrolledwindow, msg) + gui.scrolledwindow.set_tooltip_text(msg) gui.tooltips_text = msg gui.make_gui_options() gui.gvoptions.hide() @@ -954,13 +953,10 @@ class GuiGramplet(object): else: tag.set_property('underline', pango.UNDERLINE_NONE) view.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(cursor) - if self.tooltips: - if ttip: - self.tooltips.set_tip(self.scrolledwindow, - ttip) - else: - self.tooltips.set_tip(self.scrolledwindow, - self.tooltips_text) + if ttip: + self.scrolledwindow.set_tooltip_text(ttip) + elif self.tooltips_text: + self.scrolledwindow.set_tooltip_text(self.tooltips_text) return False # handle event further, if necessary def on_button_press(self, view, event): @@ -1107,8 +1103,7 @@ class GrampletView(PageView.PersonNavView): # build the GUI: frame = MyScrolledWindow() msg = _("Right click to add gramplets") - self.tooltips = gtk.Tooltips() - self.tooltips.set_tip(frame, msg) + frame.set_tooltip_text(msg) frame.viewpage = self frame.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.hbox = gtk.HBox(homogeneous=True) diff --git a/src/DataViews/MediaView.py b/src/DataViews/MediaView.py index f3bb02fde..0971ddacc 100644 --- a/src/DataViews/MediaView.py +++ b/src/DataViews/MediaView.py @@ -271,13 +271,11 @@ class MediaView(PageView.ListView): ebox = gtk.EventBox() ebox.add(self.image) ebox.connect('button-press-event', self.button_press_event) + ebox.set_tooltip_text( + _('Double click image to view in an external viewer')) vbox.pack_start(ebox, False) vbox.pack_start(base, True) - self.ttips = gtk.Tooltips() - self.ttips.set_tip( - ebox, _('Double click image to view in an external viewer')) - self.selection.connect('changed', self.row_change) self._set_dnd() return vbox @@ -310,13 +308,11 @@ class MediaView(PageView.ListView): handle = self.first_selected() if not handle: self.image.clear() - self.ttips.disable() else: obj = self.dbstate.db.get_object_from_handle(handle) pix = ThumbNails.get_thumbnail_image( Utils.media_path_full(self.dbstate.db, obj.get_path())) self.image.set_from_pixbuf(pix) - self.ttips.enable() def ui_definition(self): """ diff --git a/src/DataViews/PedigreeView.py b/src/DataViews/PedigreeView.py index 38a7b7e29..299966636 100644 --- a/src/DataViews/PedigreeView.py +++ b/src/DataViews/PedigreeView.py @@ -527,8 +527,6 @@ class PedigreeView(PageView.PersonNavView): contains the interface. This containter will be inserted into a gtk.Notebook page. """ - self.tooltips = gtk.Tooltips() - self.tooltips.enable() self.notebook = gtk.Notebook() self.notebook.connect("button-press-event", self.bg_button_press_cb) @@ -876,7 +874,7 @@ class PedigreeView(PageView.PersonNavView): else: pw = PersonBoxWidget( self, self.format_helper, lst[i][0], lst[i][3], positions[i][0][3], image); if positions[i][0][3] < 7: - self.tooltips.set_tip(pw, self.format_helper.format_person(lst[i][0], 11)) + pw.set_tooltip_text(self.format_helper.format_person(lst[i][0], 11)) pw.connect("button-press-event", self.person_button_press_cb,lst[i][0].get_handle()) if positions[i][0][2] > 1: @@ -944,7 +942,7 @@ class PedigreeView(PageView.PersonNavView): if lst[i] and lst[i][2]: line.add_events(gtk.gdk.ENTER_NOTIFY_MASK) # Required for tooltip and mouse-over line.add_events(gtk.gdk.LEAVE_NOTIFY_MASK) # Required for tooltip and mouse-over - self.tooltips.set_tip(line, self.format_helper.format_relation(lst[i][2], 11)) + line.set_tooltip_text(self.format_helper.format_relation(lst[i][2], 11)) if lst[i*2+1]: line.set_data("frela", lst[i*2+1][1]) if lst[i*2+2]: @@ -978,7 +976,7 @@ class PedigreeView(PageView.PersonNavView): childlist = find_children(self.dbstate.db,lst[0][0]) if childlist: l.connect("clicked",self.on_show_child_menu) - self.tooltips.set_tip(l, _("Jump to child...")) + l.set_tooltip_text(_("Jump to child...")) else: l.set_sensitive(False) ymid = int(math.floor(ymax/2)) @@ -987,7 +985,7 @@ class PedigreeView(PageView.PersonNavView): l.add(gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_IN)) if lst[1]: l.connect("clicked",self.on_childmenu_changed,lst[1][0].handle) - self.tooltips.set_tip(l, _("Jump to father")) + l.set_tooltip_text(("Jump to father")) else: l.set_sensitive(False) ymid = int(math.floor(ymax/4)) @@ -996,7 +994,7 @@ class PedigreeView(PageView.PersonNavView): l.add(gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_IN)) if lst[2]: l.connect("clicked",self.on_childmenu_changed,lst[2][0].handle) - self.tooltips.set_tip(l, _("Jump to mother")) + l.set_tooltip_text(_("Jump to mother")) else: l.set_sensitive(False) ymid = int(math.floor(ymax/4*3)) diff --git a/src/DataViews/RelationView.py b/src/DataViews/RelationView.py index 9795d721a..a0b639700 100644 --- a/src/DataViews/RelationView.py +++ b/src/DataViews/RelationView.py @@ -431,7 +431,6 @@ class RelationshipView(PageView.PersonNavView): if self.redrawing: return False self.redrawing = True - self.tooltips = gtk.Tooltips() for old_child in self.vbox.get_children(): self.vbox.remove(old_child) @@ -539,7 +538,7 @@ class RelationshipView(PageView.PersonNavView): if Config.get(Config.RELEDITBTN): button = widgets.IconButton(self.edit_button_press, person.handle) - self.tooltips.set_tip(button, _('Edit %s') % name) + button.set_tooltip_text(_('Edit %s') % name) else: button = None hbox = widgets.LinkBox(label, button) @@ -758,28 +757,28 @@ class RelationshipView(PageView.PersonNavView): if self.reorder_sensitive: add = widgets.IconButton(self.reorder_button_press, None, gtk.STOCK_SORT_ASCENDING) - self.tooltips.set_tip(add, ord_msg) + add.set_tooltip_text(ord_msg) hbox.pack_start(add, False) add = widgets.IconButton(call_fcn, None, gtk.STOCK_ADD) - self.tooltips.set_tip(add, add_msg) + add.set_tooltip_text(add_msg) hbox.pack_start(add, False) if is_parent: add = widgets.IconButton(self.select_family, None, gtk.STOCK_INDEX) - self.tooltips.set_tip(add, sel_msg) + add.set_tooltip_text(sel_msg) hbox.pack_start(add, False) if family: edit = widgets.IconButton(self.edit_family, family.handle, gtk.STOCK_EDIT) - self.tooltips.set_tip(edit, edit_msg) + edit.set_tooltip_text(edit_msg) hbox.pack_start(edit, False) if not self.dbstate.db.readonly: delete = widgets.IconButton(del_fcn, family.handle, gtk.STOCK_REMOVE) - self.tooltips.set_tip(delete, del_msg) + delete.set_tooltip_text(del_msg) hbox.pack_start(delete, False) self.attach.attach(hbox, _BTN_START, _BTN_STOP, self.row, self.row+1) self.row += 1 @@ -884,13 +883,11 @@ class RelationshipView(PageView.PersonNavView): addchild = widgets.IconButton(self.add_child_to_fam, family.handle, gtk.STOCK_ADD) - self.tooltips.set_tip(addchild, - _('Add new child to family')) + addchile.set_tooltip_text(_('Add new child to family')) selchild = widgets.IconButton(self.sel_child_to_fam, family.handle, gtk.STOCK_INDEX) - self.tooltips.set_tip(selchild, - _('Add existing child to family')) + selchild.set_tooltip_text(_('Add existing child to family')) hbox.pack_start(addchild, False) hbox.pack_start(selchild, False) @@ -934,7 +931,7 @@ class RelationshipView(PageView.PersonNavView): if Config.get(Config.RELEDITBTN): button = widgets.IconButton(self.edit_button_press, handle) - self.tooltips.set_tip(button, _('Edit %s') % name[0]) + button.set_tooltip_text(_('Edit %s') % name[0]) else: button = None vbox.pack_start(widgets.LinkBox(link_label, button), @@ -987,7 +984,7 @@ class RelationshipView(PageView.PersonNavView): link_label.modify_bg(gtk.STATE_NORMAL, self.color) if Config.get(Config.RELEDITBTN): button = widgets.IconButton(self.edit_button_press, handle) - self.tooltips.set_tip(button, _('Edit %s') % name[0]) + button.set_tooltip_text(_('Edit %s') % name[0]) else: button = None vbox.pack_start(widgets.LinkBox(link_label, button)) @@ -1074,7 +1071,7 @@ class RelationshipView(PageView.PersonNavView): link_label.set_padding(3, 0) if child_should_be_linked and Config.get(Config.RELEDITBTN): button = widgets.IconButton(self.edit_button_press, handle) - self.tooltips.set_tip(button, _('Edit %s') % name[0]) + button.set_tooltip_text(_('Edit %s') % name[0]) else: button = None @@ -1342,13 +1339,11 @@ class RelationshipView(PageView.PersonNavView): addchild = widgets.IconButton(self.add_child_to_fam, family.handle, gtk.STOCK_ADD) - self.tooltips.set_tip(addchild, - _('Add new child to family')) + addchild.set_tooltip_text(_('Add new child to family')) selchild = widgets.IconButton(self.sel_child_to_fam, family.handle, gtk.STOCK_INDEX) - self.tooltips.set_tip(selchild, - _('Add existing child to family')) + selchild.set_tooltip_text(_('Add existing child to family')) hbox.pack_start(addchild, False) hbox.pack_start(selchild, False) self.attach.attach( diff --git a/src/Filters/SideBar/_SidebarFilter.py b/src/Filters/SideBar/_SidebarFilter.py index 1fac5cea7..93488387c 100644 --- a/src/Filters/SideBar/_SidebarFilter.py +++ b/src/Filters/SideBar/_SidebarFilter.py @@ -41,7 +41,6 @@ class SidebarFilter(object): self.table.set_row_spacings(6) self.table.set_col_spacing(0, 6) self.table.set_col_spacing(1, 6) - self.tooltips = gtk.Tooltips() self.apply_btn = gtk.Button(stock=gtk.STOCK_FIND) self.clear_btn = gtk.Button() @@ -119,7 +118,7 @@ class SidebarFilter(object): self.add_entry(name, widget) widget.connect('key-press-event', self.key_press) if tooltip: - self.tooltips.set_tip(widget, tooltip) + widget.set_tooltip_text(tooltip) def key_press(self, obj, event): if not event.state or event.state in (gtk.gdk.MOD2_MASK,): diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py index ca0ce87e9..24ec2139b 100644 --- a/src/gui/viewmanager.py +++ b/src/gui/viewmanager.py @@ -221,7 +221,6 @@ class ViewManager(CLIManager): self.button_handlers = [] self.buttons = [] self.merge_ids = [] - self.tips = gtk.Tooltips() self._key = None self.show_sidebar = Config.get(Config.VIEW) @@ -364,17 +363,7 @@ class ViewManager(CLIManager): openbtn = gtk.MenuToolButton('gramps-db') openbtn.connect('clicked', self.__open_activate) openbtn.set_sensitive(False) - open_tips = gtk.Tooltips() - openbtn.set_arrow_tooltip( - open_tips, - _("Connect to a recent database"), - _("Connect to a recent database")) - - openbtn.set_tooltip( - open_tips, - _("Manage databases"), - _("Manage databases") - ) + openbtn.set_tooltip_text(_("Connect to a recent database")) openbtn.show() return openbtn @@ -803,15 +792,6 @@ class ViewManager(CLIManager): self.notebook.set_current_page(page_no) self.__vb_handlers_unblock() - def __setup_text_tips(self, use_text): - """ - Enable/disable the text tips in the sidebar - """ - if use_text: - self.tips.disable() - else: - self.tips.enable() - def __delete_pages(self): """ Calls on_delete() for each view @@ -827,7 +807,6 @@ class ViewManager(CLIManager): self.prev_nav = PageView.NAVIGATION_NONE use_text = Config.get(Config.SIDEBAR_TEXT) - self.__setup_text_tips(use_text) index = 0 for page_def in self.views: @@ -892,7 +871,8 @@ class ViewManager(CLIManager): button.set_alignment(0, 0.5) # add the tooltip - self.tips.set_tip(button, page_title) + button.set_tooltip_text(page_title) + #self.tips.set_tip(button, page_title) # connect the signal, along with the index as user data handler_id = button.connect('clicked', self.__vb_clicked, index)