From 702e51dd47ff61f1d4b497a39009f0b6edc437cb Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 13 Sep 2019 11:59:29 -0500 Subject: [PATCH 1/8] Fix deprecation on Gtk.Widget.override_font and modify_font --- gramps/gui/configure.py | 11 ++----- gramps/gui/editors/editperson.py | 6 ++-- gramps/gui/widgets/labels.py | 21 ++------------ gramps/gui/widgets/monitoredwidgets.py | 30 +------------------- gramps/gui/widgets/validatedmaskedentry.py | 6 ++-- gramps/plugins/gramplet/persondetails.py | 11 +++---- gramps/plugins/gramplet/placedetails.py | 10 +++---- gramps/plugins/gramplet/repositorydetails.py | 10 ++++--- 8 files changed, 32 insertions(+), 73 deletions(-) diff --git a/gramps/gui/configure.py b/gramps/gui/configure.py index bd7050b6f..b3d03cb91 100644 --- a/gramps/gui/configure.py +++ b/gramps/gui/configure.py @@ -2162,11 +2162,9 @@ class GrampsPreferences(ConfigureDialog): scrollw.set_size_request(600, 100) text = Gtk.Label() text.set_line_wrap(True) - font_description = Pango.font_description_from_string(font) - text.modify_font(font_description) self.activate_change_font() text.set_halign(Gtk.Align.START) - text.set_text(my_characters) + text.set_markup("%s" % (font, my_characters)) scrollw.add(text) scrollw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.grid.attach(scrollw, 1, 7, 8, 1) @@ -2179,12 +2177,9 @@ class GrampsPreferences(ConfigureDialog): my_characters += symbols.get_death_symbol_for_char(death_symbl) text = Gtk.Label() text.set_line_wrap(True) - font_description = Pango.font_description_from_string(font) - text.modify_font(font_description) text.set_halign(Gtk.Align.START) - text.set_markup("" + - my_characters + - "") + text.set_markup("%s" + "" % (font, my_characters)) self.grid.attach(text, 1, 8, 8, 1) scrollw.show_all() text.show_all() diff --git a/gramps/gui/editors/editperson.py b/gramps/gui/editors/editperson.py index 15f34ed8f..fc05f3625 100644 --- a/gramps/gui/editors/editperson.py +++ b/gramps/gui/editors/editperson.py @@ -42,6 +42,7 @@ import pickle from gi.repository import Gtk from gi.repository import Gdk from gi.repository import Pango +from gi.repository.GLib import markup_escape_text #------------------------------------------------------------------------- # @@ -435,7 +436,6 @@ class EditPerson(EditPrimary): obj.connect('changed', self._changed_name) self.preview_name = self.top.get_object("full_name") - self.preview_name.override_font(Pango.FontDescription('sans bold 12')) self.surntab = SurnameTab(self.dbstate, self.uistate, self.track, self.obj.get_primary_name(), on_change=self._changed_name) @@ -550,7 +550,9 @@ class EditPerson(EditPrimary): Update the window title, and default name in name tab """ self.update_title(self.get_menu_title()) - self.preview_name.set_text(self.get_preview_name()) + self.preview_name.set_markup( + "%s" % + markup_escape_text(self.get_preview_name(), -1)) self.name_list.update_defname() def name_callback(self): diff --git a/gramps/gui/widgets/labels.py b/gramps/gui/widgets/labels.py index 3ff9be1a3..ba3f6a7dd 100644 --- a/gramps/gui/widgets/labels.py +++ b/gramps/gui/widgets/labels.py @@ -18,7 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -__all__ = ["LinkLabel", "EditLabel", "BasicLabel", "GenderLabel", +__all__ = ["LinkLabel", "EditLabel", "BasicLabel", "MarkupLabel", "DualMarkupLabel"] #------------------------------------------------------------------------- @@ -127,7 +127,7 @@ class LinkLabel(Gtk.EventBox): hbox = Gtk.Box() hbox.pack_start(self.label, False, False, 0) if label[1]: - hbox.pack_start(GenderLabel(label[1]), False, False, 0) + hbox.pack_start(Gtk.Label(label=label[1]), False, False, 0) hbox.set_spacing(4) self.add(hbox) @@ -205,20 +205,6 @@ class BasicLabel(Gtk.Label): self.set_ellipsize(ellipsize) self.show() -#------------------------------------------------------------------------- -# -# GenderLabel class -# -#------------------------------------------------------------------------- -class GenderLabel(Gtk.Label): - - def __init__(self, text): - Gtk.Label.__init__(self, label=text) - self.set_halign(Gtk.Align.START) - if win(): - pangoFont = Pango.FontDescription('Arial') - self.override_font(pangoFont) - self.show() #------------------------------------------------------------------------- # @@ -247,7 +233,6 @@ class DualMarkupLabel(Gtk.Box): label.set_use_markup(True) self.pack_start(label, False, False, 0) - b = GenderLabel(alt) - b.set_use_markup(True) + b = Gtk.Label(label=alt) self.pack_start(b, False, False, 4) self.show() diff --git a/gramps/gui/widgets/monitoredwidgets.py b/gramps/gui/widgets/monitoredwidgets.py index 00d970377..d66154ab7 100644 --- a/gramps/gui/widgets/monitoredwidgets.py +++ b/gramps/gui/widgets/monitoredwidgets.py @@ -183,36 +183,8 @@ class MonitoredEntryIndicator(MonitoredEntry): autolist=None, changed=None): MonitoredEntry.__init__(self, obj, set_val, get_val, read_only, autolist, changed) - self.origcolor = obj.get_style_context().get_color(Gtk.StateType.NORMAL) - if get_val(): - self.indicatorshown = False - else: - self.indicatorshown = True - self.indicator = indicator - self.obj.set_text(indicator) - rgba = Gdk.RGBA() - Gdk.RGBA.parse(rgba, 'grey') - self.obj.override_color(Gtk.StateType.NORMAL, rgba) - self.obj.override_font(Pango.FontDescription('sans italic')) - self.fockey = self.obj.connect('focus-in-event', - self._obj_focus) + self.obj.set_placeholder_text(indicator) - def _on_change(self, obj): - if not self.indicatorshown: - self.set_val(str(obj.get_text())) - if self.changed: - self.changed(obj) - - def _obj_focus(self, widg, eve): - """ - callback for when prefix obtains focus - """ - self.set_text('') - self.obj.override_color(Gtk.StateType.NORMAL, self.origcolor) - self.obj.override_font(Pango.FontDescription('normal')) - self.obj.disconnect(self.fockey) - self.indicatorshown = False - return False #------------------------------------------------------------------------- # diff --git a/gramps/gui/widgets/validatedmaskedentry.py b/gramps/gui/widgets/validatedmaskedentry.py index 6df9919a1..2427e55cf 100644 --- a/gramps/gui/widgets/validatedmaskedentry.py +++ b/gramps/gui/widgets/validatedmaskedentry.py @@ -191,7 +191,7 @@ class MaskedEntry(UndoableEntry): :param mask: the mask to set """ if not mask: - self.override_font(Pango.FontDescription("sans")) + # self.override_font(Pango.FontDescription("sans")) self._mask = mask return @@ -221,7 +221,9 @@ class MaskedEntry(UndoableEntry): pos += 1 self._mask_fields.append((field_begin, field_end)) - self.override_font(Pango.FontDescription("monospace")) + # The set_mask function doesn't seem to be used, except for the test + # so removing the monospace doesn't change visible functionality + # self.override_font(Pango.FontDescription("monospace")) self._really_delete_text(0, -1) self._insert_mask(0, input_length) diff --git a/gramps/plugins/gramplet/persondetails.py b/gramps/plugins/gramplet/persondetails.py index 13f64afe7..2cec52371 100644 --- a/gramps/plugins/gramplet/persondetails.py +++ b/gramps/plugins/gramplet/persondetails.py @@ -24,7 +24,7 @@ # #------------------------------------------------------------------------- from gi.repository import Gtk -from gi.repository import Pango +from gi.repository.GLib import markup_escape_text #------------------------------------------------------------------------- # @@ -61,7 +61,6 @@ class PersonDetails(Gramplet): self.photo = Photo(self.uistate.screen_height() < 1000) self.photo.show() self.name = Gtk.Label(halign=Gtk.Align.START) - self.name.override_font(Pango.FontDescription('sans bold 12')) self.name.set_selectable(True) vbox.pack_start(self.name, fill=True, expand=False, padding=7) self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) @@ -150,7 +149,9 @@ class PersonDetails(Gramplet): Display details of the active person. """ self.load_person_image(active_person) - self.name.set_text(name_displayer.display(active_person)) + self.name.set_markup( + "%s" % + markup_escape_text(name_displayer.display(active_person), -1)) self.clear_grid() self.display_alternate_names(active_person) self.display_parents(active_person) @@ -177,8 +178,8 @@ class PersonDetails(Gramplet): """ Display an empty row to separate groupd of entries. """ - label = Gtk.Label(label='') - label.override_font(Pango.FontDescription('sans 4')) + label = Gtk.Label() + label.set_markup(" ") label.set_selectable(True) label.show() self.grid.add(label) diff --git a/gramps/plugins/gramplet/placedetails.py b/gramps/plugins/gramplet/placedetails.py index b89029c9d..9a03715ba 100644 --- a/gramps/plugins/gramplet/placedetails.py +++ b/gramps/plugins/gramplet/placedetails.py @@ -23,7 +23,7 @@ # #------------------------------------------------------------------------- from gi.repository import Gtk -from gi.repository import Pango +from gi.repository.GLib import markup_escape_text #------------------------------------------------------------------------- # @@ -55,7 +55,6 @@ class PlaceDetails(Gramplet): vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.photo = Photo(self.uistate.screen_height() < 1000) self.title = Gtk.Label(halign=Gtk.Align.START) - self.title.override_font(Pango.FontDescription('sans bold 12')) self.title.set_selectable(True) vbox.pack_start(self.title, False, True, 7) self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) @@ -119,7 +118,8 @@ class PlaceDetails(Gramplet): """ self.load_place_image(place) title = place_displayer.display(self.dbstate.db, place) - self.title.set_text(title) + self.title.set_markup("%s" % + markup_escape_text(title)) self.clear_grid() self.add_row(_('Name'), place.get_name().get_value()) @@ -158,8 +158,8 @@ class PlaceDetails(Gramplet): """ Display an empty row to separate groupd of entries. """ - label = Gtk.Label(label='') - label.override_font(Pango.FontDescription('sans 4')) + label = Gtk.Label() + label.set_markup(" ") label.set_selectable(True) label.show() self.grid.add(label) diff --git a/gramps/plugins/gramplet/repositorydetails.py b/gramps/plugins/gramplet/repositorydetails.py index b23767750..61898bb0c 100644 --- a/gramps/plugins/gramplet/repositorydetails.py +++ b/gramps/plugins/gramplet/repositorydetails.py @@ -24,6 +24,7 @@ #------------------------------------------------------------------------- from gi.repository import Gtk from gi.repository import Pango +from gi.repository.GLib import markup_escape_text #------------------------------------------------------------------------- # @@ -51,7 +52,6 @@ class RepositoryDetails(Gramplet): self.top = Gtk.Box() vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.name = Gtk.Label(halign=Gtk.Align.START) - self.name.override_font(Pango.FontDescription('sans bold 12')) self.name.set_selectable(True) vbox.pack_start(self.name, fill=True, expand=False, padding=7) self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) @@ -112,7 +112,9 @@ class RepositoryDetails(Gramplet): """ Display details of the active repository. """ - self.name.set_text(repo.get_name()) + self.name.set_markup( + "%s" % + markup_escape_text(repo.get_name(), -1)) self.clear_grid() address_list = repo.get_address_list() @@ -154,8 +156,8 @@ class RepositoryDetails(Gramplet): """ Display an empty row to separate groupd of entries. """ - label = Gtk.Label(label='') - label.override_font(Pango.FontDescription('sans 4')) + label = Gtk.Label() + label.set_markup(" ") label.set_selectable(True) label.show() self.grid.add(label) From 831c7f9c66c647b99b42ad4d448097632dbf9065 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 13 Sep 2019 16:11:53 -0500 Subject: [PATCH 2/8] Fix Gtk deprecation Widget.set_padding --- gramps/gui/logger/_errorreportassistant.py | 21 ++++++++++++++------- gramps/gui/plug/export/_exportoptions.py | 15 ++++++++++----- gramps/gui/widgets/labels.py | 5 ++++- gramps/plugins/view/relview.py | 7 ++++--- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/gramps/gui/logger/_errorreportassistant.py b/gramps/gui/logger/_errorreportassistant.py index af9979693..5182ea9ad 100644 --- a/gramps/gui/logger/_errorreportassistant.py +++ b/gramps/gui/logger/_errorreportassistant.py @@ -284,7 +284,8 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): "information included in the error please remove " "it.")) label.set_halign(Gtk.Align.START) - label.set_padding(0, 4) + label.set_margin_top(4) + label.set_margin_bottom(4) label.set_line_wrap(True) swin = Gtk.ScrolledWindow() @@ -364,7 +365,8 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): "remove anything that you would rather not have " "included in the bug report.")) label.set_halign(Gtk.Align.START) - label.set_padding(0, 4) + label.set_margin_top(4) + label.set_margin_bottom(4) label.set_line_wrap(True) swin = Gtk.ScrolledWindow() @@ -441,7 +443,8 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): "can about what you were doing when the error " "occurred.")) label.set_halign(Gtk.Align.START) - label.set_padding(0, 4) + label.set_margin_top(4) + label.set_margin_bottom(4) label.set_line_wrap(True) swin = Gtk.ScrolledWindow() @@ -514,7 +517,8 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): "that it does not contain anything that you do not " "want to be sent to the developers.")) label.set_halign(Gtk.Align.START) - label.set_padding(0, 4) + label.set_margin_top(4) + label.set_margin_bottom(4) label.set_line_wrap(True) swin = Gtk.ScrolledWindow() @@ -580,7 +584,8 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): "clipboard and then open a webbrowser to file a bug report at "), URL_BUGTRACKER)) label.set_halign(Gtk.Align.START) - label.set_padding(0, 4) + label.set_margin_top(4) + label.set_margin_bottom(4) label.set_line_wrap(True) label.set_use_markup(True) @@ -589,7 +594,8 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): "and file a bug report on the Gramps bug " "tracking system.")) url_label.set_halign(Gtk.Align.START) - url_label.set_padding(0, 4) + url_label.set_margin_top(4) + url_label.set_margin_bottom(4) url_label.set_line_wrap(True) url_label.set_size_request(200, -1) @@ -613,7 +619,8 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): "the button below, paste the report and click " "submit report")) clip_label.set_halign(Gtk.Align.START) - clip_label.set_padding(0, 4) + clip_label.set_margin_top(4) + clip_label.set_margin_bottom(4) clip_label.set_line_wrap(True) clip_label.set_size_request(200, -1) diff --git a/gramps/gui/plug/export/_exportoptions.py b/gramps/gui/plug/export/_exportoptions.py index b44eb3ca8..118ec3f89 100644 --- a/gramps/gui/plug/export/_exportoptions.py +++ b/gramps/gui/plug/export/_exportoptions.py @@ -283,7 +283,8 @@ class WriterOptionBox: label = Gtk.Label(label=_('_Person Filter') + COLON) label.set_halign(Gtk.Align.START) label.set_size_request(120, -1) - label.set_padding(5, 0) + label.set_margin_start(5) + label.set_margin_end(5) label.set_use_underline(True) label.set_mnemonic_widget(self.filter_obj) box = Gtk.Box() @@ -301,7 +302,8 @@ class WriterOptionBox: label_note = Gtk.Label(label=_('_Note Filter') + COLON) label_note.set_halign(Gtk.Align.START) label_note.set_size_request(120, -1) - label_note.set_padding(5, 0) + label_note.set_margin_start(5) + label_note.set_margin_end(5) label_note.set_use_underline(True) label_note.set_mnemonic_widget(self.filter_note) box = Gtk.Box() @@ -317,7 +319,8 @@ class WriterOptionBox: label = Gtk.Label(label=_("Privacy Filter") + COLON) label.set_halign(Gtk.Align.START) label.set_size_request(120, -1) - label.set_padding(5, 0) + label.set_margin_start(5) + label.set_margin_end(5) box = Gtk.Box() box.pack_start(label, False, True, 0) box.add(self.private_check) @@ -327,7 +330,8 @@ class WriterOptionBox: label = Gtk.Label(label=_("Living Filter") + COLON) label.set_halign(Gtk.Align.START) label.set_size_request(120, -1) - label.set_padding(5, 0) + label.set_margin_start(5) + label.set_margin_end(5) box = Gtk.Box() box.pack_start(label, False, True, 0) self.restrict_option = Gtk.ComboBox() @@ -339,7 +343,8 @@ class WriterOptionBox: label = Gtk.Label(label=_('Reference Filter') + COLON) label.set_halign(Gtk.Align.START) label.set_size_request(120, -1) - label.set_padding(5, 0) + label.set_margin_start(5) + label.set_margin_end(5) box = Gtk.Box() box.pack_start(label, False, True, 0) box.pack_start(self.reference_filter, True, True, 0) diff --git a/gramps/gui/widgets/labels.py b/gramps/gui/widgets/labels.py index ba3f6a7dd..5aeaa0963 100644 --- a/gramps/gui/widgets/labels.py +++ b/gramps/gui/widgets/labels.py @@ -138,7 +138,10 @@ class LinkLabel(Gtk.EventBox): self.connect('realize', realize_cb) def set_padding(self, x, y): - self.label.set_padding(x, y) + self.label.set_margin_start(x) + self.label.set_margin_end(x) + self.label.set_margin_top(x) + self.label.set_margin_bottom(x) def enter_text(self, obj, event, handle): if self.emph: diff --git a/gramps/plugins/view/relview.py b/gramps/plugins/view/relview.py index ccfabde66..d52e701e7 100644 --- a/gramps/plugins/view/relview.py +++ b/gramps/plugins/view/relview.py @@ -1196,7 +1196,7 @@ class RelationshipView(NavigationView): label = widgets.MarkupLabel(format % escape(title), halign=Gtk.Align.END) if self._config.get('preferences.releditbtn'): - label.set_padding(0, 5) + label.set_margin_end(5) eventbox = Gtk.EventBox() if handle is not None: @@ -1286,7 +1286,7 @@ class RelationshipView(NavigationView): lbl = widgets.MarkupLabel(format % escape(title), halign=Gtk.Align.END) if self._config.get('preferences.releditbtn'): - lbl.set_padding(0, 5) + lbl.set_margin_end(5) return lbl def write_child(self, vbox, handle, index, child_should_be_linked): @@ -1333,6 +1333,7 @@ class RelationshipView(NavigationView): link_label = widgets.LinkLabel(name, link_func, handle, emph, theme=self.theme) link_label.set_padding(3, 0) + if child_should_be_linked and self._config.get( 'preferences.releditbtn'): button = widgets.IconButton(self.edit_button_press, handle) @@ -1354,7 +1355,7 @@ class RelationshipView(NavigationView): value = self.info_string(handle) if value: l = widgets.MarkupLabel(value) - l.set_padding(48, 0) + l.set_margin_start(48) vbox.add(l) def write_data(self, box, title, start_col=_SDATA_START, From 4d0e86a2e8ccbd5f3a14372f031c145b30c6f9e5 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 13 Sep 2019 16:14:13 -0500 Subject: [PATCH 3/8] Fix Gtk deprecation Widget.reparent --- gramps/gui/plug/report/_papermenu.py | 3 ++- gramps/gui/widgets/grampletbar.py | 3 ++- gramps/gui/widgets/grampletpane.py | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gramps/gui/plug/report/_papermenu.py b/gramps/gui/plug/report/_papermenu.py index 9d3dd5789..4a4c4d921 100644 --- a/gramps/gui/plug/report/_papermenu.py +++ b/gramps/gui/plug/report/_papermenu.py @@ -175,7 +175,8 @@ class PaperFrame(Gtk.Box): self.paper_grid.show_all() # Shift the grid from glade toplevel window to this box - self.paper_grid.reparent(self) + self.paper_grid.get_parent().remove(self.paper_grid) + self.add(self.paper_grid) # need to get rid of glade toplevel now that we are done with it. self.top.destroy() diff --git a/gramps/gui/widgets/grampletbar.py b/gramps/gui/widgets/grampletbar.py index 5b3431802..6c671de66 100644 --- a/gramps/gui/widgets/grampletbar.py +++ b/gramps/gui/widgets/grampletbar.py @@ -701,7 +701,8 @@ class DetachedWindow(ManagedWindow): self.gramplet.detached_width = size[0] self.gramplet.detached_height = size[1] self.gramplet.detached_window = None - self.gramplet.reparent(self.grampletbar) + self.notebook.remove(self.gramplet) + self.grampletbar.add(self.gramplet) ManagedWindow.close(self, *args) #------------------------------------------------------------------------- diff --git a/gramps/gui/widgets/grampletpane.py b/gramps/gui/widgets/grampletpane.py index e07030955..ae31d185d 100644 --- a/gramps/gui/widgets/grampletpane.py +++ b/gramps/gui/widgets/grampletpane.py @@ -246,7 +246,8 @@ class GrampletWindow(ManagedWindow): # add gramplet: if self.gramplet.pui: self.gramplet.pui.active = True - self.gramplet.mainframe.reparent(self.window.vbox) + self.gramplet.mainframe.get_parent().remove(self.gramplet.mainframe) + self.window.vbox.add(self.gramplet.mainframe) self.window.connect('response', self.handle_response) self.show() # After we show, then we hide: @@ -310,7 +311,8 @@ class GrampletWindow(ManagedWindow): expand = self.gramplet.gstate == "maximized" and self.gramplet.expand column = pane.columns[col] parent = self.gramplet.pane.get_column_frame(self.gramplet.column) - self.gramplet.mainframe.reparent(parent) + self.gramplet.mainframe.get_parent().remove(self.gramplet.mainframe) + parent.add(self.gramplet.mainframe) if self.gramplet.pui: self.gramplet.pui.active = self.gramplet.pane.pageview.active for gframe in stack: From 290d6f7287c92fbf15721ae84b223606f32fcea5 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 13 Sep 2019 16:35:22 -0500 Subject: [PATCH 4/8] Fix deprecation GObject.GError -> GLib.GError --- gramps/gen/utils/image.py | 4 ++-- gramps/gen/utils/thumbnails.py | 8 ++++---- gramps/gui/widgets/selectionwidget.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gramps/gen/utils/image.py b/gramps/gen/utils/image.py index 46e07a02a..f96d2222a 100644 --- a/gramps/gen/utils/image.py +++ b/gramps/gen/utils/image.py @@ -161,12 +161,12 @@ def image_size(source): :returns: a tuple consisting of the width and height """ from gi.repository import GdkPixbuf - from gi.repository import GObject + from gi.repository import GLib try: img = GdkPixbuf.Pixbuf.new_from_file(source) width = img.get_width() height = img.get_height() - except GObject.GError: + except GLib.GError: width = 0 height = 0 return (width, height) diff --git a/gramps/gen/utils/thumbnails.py b/gramps/gen/utils/thumbnails.py index 36c2044b1..42f7c628a 100644 --- a/gramps/gen/utils/thumbnails.py +++ b/gramps/gen/utils/thumbnails.py @@ -36,7 +36,7 @@ from hashlib import md5 # GTK/Gnome modules # #------------------------------------------------------------------------- -from gi.repository import GObject +from gi.repository import GLib from gi.repository import GdkPixbuf try: @@ -98,7 +98,7 @@ def __get_gconf_string(key): """ try: val = CLIENT.get_string(key) - except GObject.GError: + except GLib.GError: val = None return str(val) @@ -119,7 +119,7 @@ def __get_gconf_bool(key): """ try: val = CLIENT.get_bool(key) - except GObject.GError: + except GLib.GError: val = None return val @@ -318,7 +318,7 @@ def get_thumbnail_image(src_file, mtype=None, rectangle=None, size=SIZE_NORMAL): try: filename = get_thumbnail_path(src_file, mtype, rectangle, size) return GdkPixbuf.Pixbuf.new_from_file(filename) - except (GObject.GError, OSError): + except (GLib.GError, OSError): if mtype: return find_mime_type_pixbuf(mtype) else: diff --git a/gramps/gui/widgets/selectionwidget.py b/gramps/gui/widgets/selectionwidget.py index 289958524..f53dea71a 100644 --- a/gramps/gui/widgets/selectionwidget.py +++ b/gramps/gui/widgets/selectionwidget.py @@ -26,7 +26,7 @@ from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GdkPixbuf -from gi.repository import GObject +from gi.repository import GLib, GObject #------------------------------------------------------------------------- # @@ -305,7 +305,7 @@ class SelectionWidget(Gtk.ScrolledWindow): viewport_size.height) self._rescale() self.loaded = True - except (GObject.GError, OSError): + except (GLib.GError, OSError): self.show_missing() def show_missing(self): From cea48b618f1903f54eedc1f5283b8252e091f4b1 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 13 Sep 2019 16:37:55 -0500 Subject: [PATCH 5/8] Fix GObject.PARAM_READWRITE deprecation --- gramps/gui/widgets/validatedmaskedentry.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gramps/gui/widgets/validatedmaskedentry.py b/gramps/gui/widgets/validatedmaskedentry.py index 2427e55cf..89eee5e29 100644 --- a/gramps/gui/widgets/validatedmaskedentry.py +++ b/gramps/gui/widgets/validatedmaskedentry.py @@ -942,6 +942,8 @@ VALIDATION_ICON_WIDTH = 16 MANDATORY_ICON = 'dialog-information' ERROR_ICON = 'process-stop' DELAY_TIME = 2500 +READWRITE = (GObject.PARAM_READWRITE if GLib.check_version(2, 42, 0) else + GObject.ParamFlags.READWRITE) class ValidatableMaskedEntry(MaskedEntry): """ @@ -971,12 +973,12 @@ class ValidatableMaskedEntry(MaskedEntry): 'data-type': (GObject.TYPE_PYOBJECT, 'Data Type of the widget', 'Type object', - GObject.PARAM_READWRITE), + READWRITE), 'mandatory': (GObject.TYPE_BOOLEAN, 'Mandatory', 'Mandatory', False, - GObject.PARAM_READWRITE), + READWRITE), } # FIXME put the data type support back From 17f4d93363ef1028866e71d9395705f2d69e417b Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 13 Sep 2019 16:42:51 -0500 Subject: [PATCH 6/8] Fix Gtk deprecatioon ScrolledWindow.add_with_viewport --- gramps/plugins/gramplet/fanchart2waygramplet.py | 2 +- gramps/plugins/view/fanchart2wayview.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gramps/plugins/gramplet/fanchart2waygramplet.py b/gramps/plugins/gramplet/fanchart2waygramplet.py index 2666a61ea..1d8a1c553 100644 --- a/gramps/plugins/gramplet/fanchart2waygramplet.py +++ b/gramps/plugins/gramplet/fanchart2waygramplet.py @@ -70,7 +70,7 @@ class FanChart2WayGramplet(FanChart2WayGrampsGUI, Gramplet): self.on_popup)) # Replace the standard textview with the fan chart widget: self.gui.get_container_widget().remove(self.gui.textview) - self.gui.get_container_widget().add_with_viewport(self.fan) + self.gui.get_container_widget().add(self.fan) # Make sure it is visible: self.fan.show() diff --git a/gramps/plugins/view/fanchart2wayview.py b/gramps/plugins/view/fanchart2wayview.py index d536b37cd..37f815063 100644 --- a/gramps/plugins/view/fanchart2wayview.py +++ b/gramps/plugins/view/fanchart2wayview.py @@ -135,7 +135,7 @@ class FanChart2WayView(fanchart2way.FanChart2WayGrampsGUI, NavigationView): self.scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.fan.show_all() - self.scrolledwindow.add_with_viewport(self.fan) + self.scrolledwindow.add(self.fan) return self.scrolledwindow From 0f925a86f56af36bb6d033d5e725d72202ee5532 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 13 Sep 2019 16:43:56 -0500 Subject: [PATCH 7/8] Fix Gtk deprecation Menu.set_title --- gramps/gui/editors/editperson.py | 1 - gramps/gui/widgets/photo.py | 1 - gramps/plugins/gramplet/coordinates.py | 1 - gramps/plugins/lib/maps/geography.py | 2 -- gramps/plugins/view/geoclose.py | 2 -- gramps/plugins/view/geoevents.py | 4 ---- gramps/plugins/view/geofamclose.py | 2 -- gramps/plugins/view/geofamily.py | 1 - gramps/plugins/view/geomoves.py | 2 -- gramps/plugins/view/geoperson.py | 4 ---- gramps/plugins/view/geoplaces.py | 4 ---- 11 files changed, 24 deletions(-) diff --git a/gramps/gui/editors/editperson.py b/gramps/gui/editors/editperson.py index fc05f3625..beb8d2154 100644 --- a/gramps/gui/editors/editperson.py +++ b/gramps/gui/editors/editperson.py @@ -640,7 +640,6 @@ class EditPerson(EditPrimary): """ self.imgmenu = Gtk.Menu() menu = self.imgmenu - menu.set_title(_("Media Object")) obj = self.db.get_media_from_handle(photo.get_reference_handle()) if obj: add_menuitem(menu, _("View"), photo, diff --git a/gramps/gui/widgets/photo.py b/gramps/gui/widgets/photo.py index fd22c7f54..079768074 100644 --- a/gramps/gui/widgets/photo.py +++ b/gramps/gui/widgets/photo.py @@ -84,7 +84,6 @@ class Photo(Gtk.EventBox): elif is_right_click(event): if self.handle and self.uistate: self.menu = Gtk.Menu() - self.menu.set_title(_("Media Object")) add_menuitem(self.menu, _("Make Active Media"), widget, lambda obj: self.uistate.set_active(self.handle, "Media")) self.menu.popup(None, None, None, None, event.button, event.time) diff --git a/gramps/plugins/gramplet/coordinates.py b/gramps/plugins/gramplet/coordinates.py index b46387104..db1bfe14e 100644 --- a/gramps/plugins/gramplet/coordinates.py +++ b/gramps/plugins/gramplet/coordinates.py @@ -139,7 +139,6 @@ class GeoEvents(Gramplet, DbGUIElement): """ self.menu = Gtk.Menu() menu = self.menu - menu.set_title(_('Edit')) title = _('Edit the event') add_item = Gtk.MenuItem(label=title) add_item.connect("activate", self.edit_event, treeview) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index f5bd6f4f4..026a12194 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -405,7 +405,6 @@ class GeoGraphyView(OsmGps, NavigationView): self.changemap = Gtk.Menu() changemap = self.changemap - changemap.set_title(title) changemap.show() add_item.set_submenu(changemap) # show in the map menu all available providers @@ -885,7 +884,6 @@ class GeoGraphyView(OsmGps, NavigationView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Place")) diff --git a/gramps/plugins/view/geoclose.py b/gramps/plugins/view/geoclose.py index 827b08b6d..d3aac4e2c 100644 --- a/gramps/plugins/view/geoclose.py +++ b/gramps/plugins/view/geoclose.py @@ -568,7 +568,6 @@ class GeoClose(GeoGraphyView): """ self.newmenu = Gtk.Menu() menu = self.newmenu - menu.set_title("person") events = [] message = "" oldplace = "" @@ -613,7 +612,6 @@ class GeoClose(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Event")) diff --git a/gramps/plugins/view/geoevents.py b/gramps/plugins/view/geoevents.py index f5f60ab28..a0b3bc025 100644 --- a/gramps/plugins/view/geoevents.py +++ b/gramps/plugins/view/geoevents.py @@ -379,7 +379,6 @@ class GeoEvents(GeoGraphyView): def bubble_message(self, event, lat, lon, marks): self.menu = Gtk.Menu() menu = self.menu - menu.set_title("events") message = "" oldplace = "" prevmark = None @@ -390,7 +389,6 @@ class GeoEvents(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Event")) @@ -424,7 +422,6 @@ class GeoEvents(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Event")) @@ -461,7 +458,6 @@ class GeoEvents(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(_("Centering on Place")) itemoption.show() add_item.set_submenu(itemoption) oldplace = "" diff --git a/gramps/plugins/view/geofamclose.py b/gramps/plugins/view/geofamclose.py index 5fa461424..39cd524ce 100644 --- a/gramps/plugins/view/geofamclose.py +++ b/gramps/plugins/view/geofamclose.py @@ -758,7 +758,6 @@ class GeoFamClose(GeoGraphyView): """ self.menu = Gtk.Menu() menu = self.menu - menu.set_title("family") events = [] message = "" oldplace = "" @@ -802,7 +801,6 @@ class GeoFamClose(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Event")) diff --git a/gramps/plugins/view/geofamily.py b/gramps/plugins/view/geofamily.py index e1ad9c3d8..5402e3c2d 100644 --- a/gramps/plugins/view/geofamily.py +++ b/gramps/plugins/view/geofamily.py @@ -494,7 +494,6 @@ class GeoFamily(GeoGraphyView): """ self.menu = Gtk.Menu() menu = self.menu - menu.set_title("family") message = "" oldplace = "" prevmark = None diff --git a/gramps/plugins/view/geomoves.py b/gramps/plugins/view/geomoves.py index a428aacdd..405828aa1 100644 --- a/gramps/plugins/view/geomoves.py +++ b/gramps/plugins/view/geomoves.py @@ -637,7 +637,6 @@ class GeoMoves(GeoGraphyView): """ self.menu = Gtk.Menu() menu = self.menu - menu.set_title("descendance") events = [] message = "" oldplace = "" @@ -680,7 +679,6 @@ class GeoMoves(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Event")) diff --git a/gramps/plugins/view/geoperson.py b/gramps/plugins/view/geoperson.py index 3bd7c6b5e..523ae1169 100644 --- a/gramps/plugins/view/geoperson.py +++ b/gramps/plugins/view/geoperson.py @@ -485,7 +485,6 @@ class GeoPerson(GeoGraphyView): def bubble_message(self, event, lat, lon, marks): self.menu = Gtk.Menu() menu = self.menu - menu.set_title("person") message = "" oldplace = "" prevmark = None @@ -496,7 +495,6 @@ class GeoPerson(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() message = "" add_item.set_submenu(itemoption) @@ -517,7 +515,6 @@ class GeoPerson(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() message = "" add_item.set_submenu(itemoption) @@ -559,7 +556,6 @@ class GeoPerson(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Event")) diff --git a/gramps/plugins/view/geoplaces.py b/gramps/plugins/view/geoplaces.py index 24bcd648c..d054a9100 100644 --- a/gramps/plugins/view/geoplaces.py +++ b/gramps/plugins/view/geoplaces.py @@ -480,7 +480,6 @@ class GeoPlaces(GeoGraphyView): def bubble_message(self, event, lat, lon, marks): self.menu = Gtk.Menu() menu = self.menu - menu.set_title("places") message = "" prevmark = None for mark in marks: @@ -490,7 +489,6 @@ class GeoPlaces(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Place")) @@ -516,7 +514,6 @@ class GeoPlaces(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Place")) @@ -553,7 +550,6 @@ class GeoPlaces(GeoGraphyView): menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption - itemoption.set_title(_("Centering on Place")) itemoption.show() add_item.set_submenu(itemoption) oldplace = "" From 57f7502105d127213669d2d928b542b13c7e1a2d Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 13 Sep 2019 16:56:13 -0500 Subject: [PATCH 8/8] Fix deprecation of Gtk positional arguments --- gramps/gui/configure.py | 22 +++++++++------------- gramps/gui/dbloader.py | 2 +- gramps/gui/editors/editperson.py | 6 +++--- gramps/gui/editors/edittaglist.py | 2 +- gramps/gui/logger/_errorreportassistant.py | 14 +++++++------- gramps/gui/logger/_errorview.py | 2 +- gramps/gui/plug/_guioptions.py | 21 ++++++++++----------- gramps/gui/plug/_windows.py | 20 +++++++++----------- gramps/gui/plug/export/_exportassistant.py | 2 +- gramps/gui/plug/export/_exportoptions.py | 12 ++++++------ gramps/gui/plug/report/_fileentry.py | 12 +++++------- gramps/gui/plug/report/_styleeditor.py | 2 +- gramps/gui/viewmanager.py | 16 +++++++--------- gramps/gui/views/bookmarks.py | 2 +- gramps/gui/views/listview.py | 10 +++++----- gramps/gui/views/navigationview.py | 3 ++- gramps/gui/views/tags.py | 4 ++-- gramps/gui/widgets/grampletbar.py | 12 +++++------- gramps/gui/widgets/grampletpane.py | 11 +++++------ gramps/plugins/lib/maps/geography.py | 18 ++++++++---------- gramps/plugins/lib/maps/placeselection.py | 12 ++++++------ gramps/plugins/tool/check.py | 8 ++++---- gramps/plugins/tool/eventcmp.py | 10 ++++------ gramps/plugins/tool/populatesources.py | 19 ++++++++++--------- gramps/plugins/tool/testcasegenerator.py | 2 +- gramps/plugins/view/fanchart2wayview.py | 6 +++--- gramps/plugins/view/fanchartdescview.py | 6 +++--- gramps/plugins/view/fanchartview.py | 6 +++--- 28 files changed, 123 insertions(+), 139 deletions(-) diff --git a/gramps/gui/configure.py b/gramps/gui/configure.py index b3d03cb91..3b1459889 100644 --- a/gramps/gui/configure.py +++ b/gramps/gui/configure.py @@ -690,7 +690,7 @@ class GrampsPreferences(ConfigureDialog): hbox.pack_start(lwidget, False, False, 0) hbox.pack_start(self.color_scheme_box, False, False, 0) - restore_btn = Gtk.Button(_('Restore to defaults')) + restore_btn = Gtk.Button(label=_('Restore to defaults')) restore_btn.set_tooltip_text( _('Restore colors for current theme to default.')) restore_btn.connect('clicked', self.restore_colors) @@ -1827,12 +1827,10 @@ class GrampsPreferences(ConfigureDialog): Show dialog to choose media directory. """ f = Gtk.FileChooserDialog(title=_("Select media directory"), - parent=self.window, - action=Gtk.FileChooserAction.SELECT_FOLDER, - buttons=(_('_Cancel'), - Gtk.ResponseType.CANCEL, - _('_Apply'), - Gtk.ResponseType.OK)) + transient_for=self.window, + action=Gtk.FileChooserAction.SELECT_FOLDER) + f.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Apply'), Gtk.ResponseType.OK) mpath = media_path(self.dbstate.db) f.set_current_folder(os.path.dirname(mpath)) @@ -1877,12 +1875,10 @@ class GrampsPreferences(ConfigureDialog): Show dialog to choose backup directory. """ f = Gtk.FileChooserDialog(title=_("Select backup directory"), - parent=self.window, - action=Gtk.FileChooserAction.SELECT_FOLDER, - buttons=(_('_Cancel'), - Gtk.ResponseType.CANCEL, - _('_Apply'), - Gtk.ResponseType.OK)) + transient_for=self.window, + action=Gtk.FileChooserAction.SELECT_FOLDER) + f.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Apply'), Gtk.ResponseType.OK) backup_path = config.get('database.backup-path') if not backup_path: backup_path = config.get('database.path') diff --git a/gramps/gui/dbloader.py b/gramps/gui/dbloader.py index 16d0fcbc3..3525cc38f 100644 --- a/gramps/gui/dbloader.py +++ b/gramps/gui/dbloader.py @@ -380,7 +380,7 @@ class GrampsLoginDialog(ManagedWindow): self.title = _("Login") ManagedWindow.__init__(self, uistate, [], self.__class__, modal=True) - dialog = Gtk.Dialog(parent=uistate.window) + dialog = Gtk.Dialog(transient_for=uistate.window) grid = Gtk.Grid() grid.set_border_width(6) grid.set_row_spacing(6) diff --git a/gramps/gui/editors/editperson.py b/gramps/gui/editors/editperson.py index beb8d2154..a253514b4 100644 --- a/gramps/gui/editors/editperson.py +++ b/gramps/gui/editors/editperson.py @@ -1087,9 +1087,9 @@ class EditPerson(EditPrimary): class GenderDialog(Gtk.MessageDialog): def __init__(self, parent=None): Gtk.MessageDialog.__init__(self, - parent, - flags=Gtk.DialogFlags.MODAL, - type=Gtk.MessageType.QUESTION, + transient_for=parent, + modal=True, + message_type=Gtk.MessageType.QUESTION, ) self.set_icon(ICON) self.set_title('') diff --git a/gramps/gui/editors/edittaglist.py b/gramps/gui/editors/edittaglist.py index 62bb4824b..1f47e7c4f 100644 --- a/gramps/gui/editors/edittaglist.py +++ b/gramps/gui/editors/edittaglist.py @@ -101,7 +101,7 @@ class EditTagList(ManagedWindow): Create a dialog box to select tags. """ # pylint: disable-msg=E1101 - top = Gtk.Dialog(parent=self.uistate.window) + top = Gtk.Dialog(transient_for=self.uistate.window) top.vbox.set_spacing(5) columns = [('', -1, 300), diff --git a/gramps/gui/logger/_errorreportassistant.py b/gramps/gui/logger/_errorreportassistant.py index 5182ea9ad..ff95e2f0e 100644 --- a/gramps/gui/logger/_errorreportassistant.py +++ b/gramps/gui/logger/_errorreportassistant.py @@ -301,9 +301,9 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): sw_frame = Gtk.Frame() sw_frame.add(swin) - reset = Gtk.Button("Reset") + reset = Gtk.Button(label="Reset") reset.connect('clicked', self._reset_error_details) - clear = Gtk.Button("Clear") + clear = Gtk.Button(label="Clear") clear.connect('clicked', self._clear_error_details) button_box = Gtk.ButtonBox() @@ -382,9 +382,9 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): sw_frame = Gtk.Frame() sw_frame.add(swin) - reset = Gtk.Button("Reset") + reset = Gtk.Button(label="Reset") reset.connect('clicked', self._reset_sys_information) - clear = Gtk.Button("Clear") + clear = Gtk.Button(label="Clear") clear.connect('clicked', self._clear_sys_information) @@ -459,7 +459,7 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): sw_frame = Gtk.Frame() sw_frame.add(swin) - clear = Gtk.Button("Clear") + clear = Gtk.Button(label="Clear") clear.connect('clicked', self._clear_user_information) button_box = Gtk.ButtonBox() @@ -599,7 +599,7 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): url_label.set_line_wrap(True) url_label.set_size_request(200, -1) - url_button = Gtk.Button("File bug report") + url_button = Gtk.Button(label="File bug report") url_button.connect('clicked', self._start_gramps_bts_in_browser) url_button_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) url_button_vbox.pack_start(url_button, True, False, 0) @@ -624,7 +624,7 @@ class ErrorReportAssistant(ManagedWindow, Gtk.Assistant): clip_label.set_line_wrap(True) clip_label.set_size_request(200, -1) - clip_button = Gtk.Button("Copy to clipboard") + clip_button = Gtk.Button(label="Copy to clipboard") clip_button.connect('clicked', self._copy_to_clipboard) clip_button_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) clip_button_vbox.pack_start(clip_button, True, False, 0) diff --git a/gramps/gui/logger/_errorview.py b/gramps/gui/logger/_errorview.py index 84e07ab9c..f7840d45b 100644 --- a/gramps/gui/logger/_errorview.py +++ b/gramps/gui/logger/_errorview.py @@ -105,7 +105,7 @@ class ErrorView(ManagedWindow): def draw_window(self): title = "%s - Gramps" % _("Error Report") - self.top = Gtk.Dialog(title) + self.top = Gtk.Dialog(title=title) # look over the top level windows, it seems the oldest come first, so # the most recent still visible window appears to be a good choice for # a transient parent diff --git a/gramps/gui/plug/_guioptions.py b/gramps/gui/plug/_guioptions.py index 12cdd5153..4ab2aef9d 100644 --- a/gramps/gui/plug/_guioptions.py +++ b/gramps/gui/plug/_guioptions.py @@ -75,16 +75,17 @@ class LastNameDialog(ManagedWindow): def __init__(self, database, uistate, track, surnames, skip_list=set()): ManagedWindow.__init__(self, uistate, track, self, modal=True) - flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT - buttons = (_('_Cancel'), Gtk.ResponseType.REJECT, - _('_OK'), Gtk.ResponseType.ACCEPT) - self.__dlg = Gtk.Dialog(None, uistate.window, flags, buttons) + self.__dlg = Gtk.Dialog( + transient_for=uistate.window, destroy_with_parent=True, + modal=True) + self.__dlg.add_buttons(_('_Cancel'), Gtk.ResponseType.REJECT, + _('_OK'), Gtk.ResponseType.ACCEPT) self.set_window(self.__dlg, None, _('Select surname')) self.setup_configs('interface.lastnamedialog', 400, 400) # build up a container to display all of the people of interest self.__model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_INT) - self.__tree_view = Gtk.TreeView(self.__model) + self.__tree_view = Gtk.TreeView(model=self.__model) col1 = Gtk.TreeViewColumn(_('Surname'), Gtk.CellRendererText(), text=0) col2 = Gtk.TreeViewColumn(_('Count'), Gtk.CellRendererText(), text=1) col1.set_resizable(True) @@ -1739,12 +1740,10 @@ class GuiDestinationOption(Gtk.Box): else: my_action = Gtk.FileChooserAction.SAVE - fcd = Gtk.FileChooserDialog(_("Save As"), action=my_action, - parent=self.__uistate.window, - buttons=(_('_Cancel'), - Gtk.ResponseType.CANCEL, - _('_Open'), - Gtk.ResponseType.OK)) + fcd = Gtk.FileChooserDialog(title=_("Save As"), action=my_action, + transient_for=self.__uistate.window) + fcd.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Open'), Gtk.ResponseType.OK) name = os.path.abspath(self.__option.get_value()) if self.__option.get_directory_entry(): diff --git a/gramps/gui/plug/_windows.py b/gramps/gui/plug/_windows.py index 6e1af3b40..4014b12b9 100644 --- a/gramps/gui/plug/_windows.py +++ b/gramps/gui/plug/_windows.py @@ -435,12 +435,10 @@ class PluginStatus(ManagedWindow): """ Select a file from the file system. """ - fcd = Gtk.FileChooserDialog(_("Load Addon"), - parent=self.__uistate.window, - buttons=(_('_Cancel'), - Gtk.ResponseType.CANCEL, - _('_Open'), - Gtk.ResponseType.OK)) + fcd = Gtk.FileChooserDialog(title=_("Load Addon"), + transient_for=self.__uistate.window) + fcd.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Open'), Gtk.ResponseType.OK) name = self.install_addon_path.get_text() dir = os.path.dirname(name) if not os.path.isdir(dir): @@ -688,10 +686,10 @@ class PluginTrace(ManagedWindow): ) % {'str1': _("Plugin Error"), 'str2': name} ManagedWindow.__init__(self, uistate, track, self) - self.set_window(Gtk.Dialog("", uistate.window, - Gtk.DialogFlags.DESTROY_WITH_PARENT, - (_('_Close'), Gtk.ResponseType.CLOSE)), - None, title) + dlg = Gtk.Dialog(title="", transient_for=uistate.window, + destroy_with_parent=True) + dlg.add_button(_('_Close'), Gtk.ResponseType.CLOSE), + self.set_window(dlg, None, title) self.setup_configs('interface.plugintrace', 600, 400) self.window.connect('response', self.close) @@ -742,7 +740,7 @@ class ToolManagedWindowBase(ManagedWindow): self.format_menu = None self.style_button = None - window = Gtk.Dialog('Tool') + window = Gtk.Dialog(title='Tool') self.set_window(window, None, self.get_title()) #self.window.connect('response', self.close) diff --git a/gramps/gui/plug/export/_exportassistant.py b/gramps/gui/plug/export/_exportassistant.py index ac675ac9c..b21a1a45a 100644 --- a/gramps/gui/plug/export/_exportassistant.py +++ b/gramps/gui/plug/export/_exportassistant.py @@ -286,7 +286,7 @@ class ExportAssistant(ManagedWindow, Gtk.Assistant): self.set_page_complete(vbox, True) def create_page_fileselect(self): - self.chooser = Gtk.FileChooserWidget(Gtk.FileChooserAction.SAVE) + self.chooser = Gtk.FileChooserWidget(action=Gtk.FileChooserAction.SAVE) self.chooser.set_homogeneous(False) # Fix for bug #8350. #add border self.chooser.set_border_width(12) diff --git a/gramps/gui/plug/export/_exportoptions.py b/gramps/gui/plug/export/_exportoptions.py index 118ec3f89..362874c40 100644 --- a/gramps/gui/plug/export/_exportoptions.py +++ b/gramps/gui/plug/export/_exportoptions.py @@ -164,9 +164,9 @@ class WriterOptionBox: full_database_row.pack_start(label, True, True, 0) people_count = len(self.dbstate.db.get_person_handles()) # translators: leave all/any {...} untranslated - button = Gtk.Button(ngettext("{number_of} Person", - "{number_of} People", people_count - ).format(number_of=people_count) ) + button = Gtk.Button(label=ngettext("{number_of} Person", + "{number_of} People", people_count + ).format(number_of=people_count)) button.set_tooltip_text(_("Click to see preview of unfiltered data")) button.set_size_request(107, -1) button.connect("clicked", self.show_preview_data) @@ -271,9 +271,9 @@ class WriterOptionBox: from gi.repository import Gtk from ...widgets import SimpleButton # translators: leave all/any {...} untranslated - button = Gtk.Button(ngettext("{number_of} Person", - "{number_of} People", 0 - ).format(number_of=0) ) + button = Gtk.Button(label=ngettext("{number_of} Person", + "{number_of} People", 0 + ).format(number_of=0)) button.set_size_request(107, -1) button.connect("clicked", self.show_preview_data) button.proxy_name = proxy_name diff --git a/gramps/gui/plug/report/_fileentry.py b/gramps/gui/plug/report/_fileentry.py index e1fa137bc..6c3f5d0bf 100644 --- a/gramps/gui/plug/report/_fileentry.py +++ b/gramps/gui/plug/report/_fileentry.py @@ -58,13 +58,11 @@ class FileEntry(Gtk.Box): else: my_action = Gtk.FileChooserAction.SAVE - dialog = Gtk.FileChooserDialog(self.title, - self.parent, - action=my_action, - buttons=(_('_Cancel'), - Gtk.ResponseType.CANCEL, - _('_Open'), - Gtk.ResponseType.OK)) + dialog = Gtk.FileChooserDialog(title=self.title, + transient_for=self.parent, + action=my_action) + dialog.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Open'), Gtk.ResponseType.OK) name = os.path.basename(self.entry.get_text()) if self.dir: diff --git a/gramps/gui/plug/report/_styleeditor.py b/gramps/gui/plug/report/_styleeditor.py index b408ddcde..4ec94a5fc 100644 --- a/gramps/gui/plug/report/_styleeditor.py +++ b/gramps/gui/plug/report/_styleeditor.py @@ -414,7 +414,7 @@ class StyleEditor(ManagedWindow): spin.set_value(t.get_column_width(i)) self.column.append(spin) hbox.pack_start(spin, False, False, 6) - hbox.pack_start(Gtk.Label('%'), False, False, 6) + hbox.pack_start(Gtk.Label(label='%'), False, False, 6) hbox.show_all() self.vbox.pack_start(hbox, False, False, 3) diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index dbf6e8304..158c5869b 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -1649,9 +1649,9 @@ class QuickBackup(ManagedWindow): # TODO move this class into its own module self.user = user ManagedWindow.__init__(self, uistate, [], self.__class__) - window = Gtk.Dialog('', - self.uistate.window, - Gtk.DialogFlags.DESTROY_WITH_PARENT, None) + window = Gtk.Dialog(title='', + transient_for=self.uistate.window, + destroy_with_parent=True) self.set_window(window, None, _("Gramps XML Backup")) self.setup_configs('interface.quick-backup', 500, 150) close_button = window.add_button(_('_Close'), @@ -1787,12 +1787,10 @@ class QuickBackup(ManagedWindow): # TODO move this class into its own module """ fdialog = Gtk.FileChooserDialog( title=_("Select backup directory"), - parent=self.window, - action=Gtk.FileChooserAction.SELECT_FOLDER, - buttons=(_('_Cancel'), - Gtk.ResponseType.CANCEL, - _('_Apply'), - Gtk.ResponseType.OK)) + transient_for=self.window, + action=Gtk.FileChooserAction.SELECT_FOLDER) + fdialog.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Apply'), Gtk.ResponseType.OK) mpath = path_entry.get_text() if not mpath: mpath = HOME_DIR diff --git a/gramps/gui/views/bookmarks.py b/gramps/gui/views/bookmarks.py index 3e94166b2..c7ebe78d3 100644 --- a/gramps/gui/views/bookmarks.py +++ b/gramps/gui/views/bookmarks.py @@ -269,7 +269,7 @@ class BookmarksDialog(ManagedWindow): def draw_window(self): """Draw the bookmark dialog box.""" - self.top = Gtk.Dialog(parent=self.parent_window) + self.top = Gtk.Dialog(transient_for=self.parent_window) self.top.vbox.set_spacing(5) label = Gtk.Label(label='%s' % _("Organize Bookmarks")) diff --git a/gramps/gui/views/listview.py b/gramps/gui/views/listview.py index 6e93d41a7..c1d4ba3e9 100644 --- a/gramps/gui/views/listview.py +++ b/gramps/gui/views/listview.py @@ -1059,11 +1059,11 @@ class ListView(NavigationView): #################################################################### def export(self, *obj): chooser = Gtk.FileChooserDialog( - _("Export View as Spreadsheet"), - self.uistate.window, - Gtk.FileChooserAction.SAVE, - (_('_Cancel'), Gtk.ResponseType.CANCEL, - _('_Save'), Gtk.ResponseType.OK)) + title=_("Export View as Spreadsheet"), + transient_for=self.uistate.window, + action=Gtk.FileChooserAction.SAVE) + chooser.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Save'), Gtk.ResponseType.OK) chooser.set_do_overwrite_confirmation(True) combobox = Gtk.ComboBoxText() diff --git a/gramps/gui/views/navigationview.py b/gramps/gui/views/navigationview.py index c04e73104..ca979a202 100644 --- a/gramps/gui/views/navigationview.py +++ b/gramps/gui/views/navigationview.py @@ -331,7 +331,8 @@ class NavigationView(PageView): """ A dialog to move to a Gramps ID entered by the user. """ - dialog = Gtk.Dialog(_('Jump to by Gramps ID'), self.uistate.window) + dialog = Gtk.Dialog(title=_('Jump to by Gramps ID'), + transient_for=self.uistate.window) dialog.set_border_width(12) label = Gtk.Label(label='%s' % _('Jump to by Gramps ID')) diff --git a/gramps/gui/views/tags.py b/gramps/gui/views/tags.py index c3f54e658..c3923eef3 100644 --- a/gramps/gui/views/tags.py +++ b/gramps/gui/views/tags.py @@ -459,7 +459,7 @@ class OrganizeTagsDialog(ManagedWindow): Create a dialog box to organize tags. """ # pylint: disable-msg=E1101 - top = Gtk.Dialog(parent=self.parent_window) + top = Gtk.Dialog(transient_for=self.parent_window) top.vbox.set_spacing(5) label = Gtk.Label(label='%s' % _("Organize Tags")) @@ -688,7 +688,7 @@ class EditTag(ManagedWindow): Create a dialog box to enter a new tag. """ # pylint: disable-msg=E1101 - top = Gtk.Dialog(parent=self.parent_window) + top = Gtk.Dialog(transient_for=self.parent_window) top.vbox.set_spacing(5) hbox = Gtk.Box() diff --git a/gramps/gui/widgets/grampletbar.py b/gramps/gui/widgets/grampletbar.py index 6c671de66..585a6b8e0 100644 --- a/gramps/gui/widgets/grampletbar.py +++ b/gramps/gui/widgets/grampletbar.py @@ -630,13 +630,11 @@ class DetachedWindow(ManagedWindow): self.grampletbar = grampletbar self.gramplet = gramplet - ManagedWindow.__init__(self, gramplet.uistate, [], - self.title) - self.set_window(Gtk.Dialog("", gramplet.uistate.window, - Gtk.DialogFlags.DESTROY_WITH_PARENT, - (_('_Close'), Gtk.ResponseType.CLOSE)), - None, - self.title) + ManagedWindow.__init__(self, gramplet.uistate, [], self.title) + dlg = Gtk.Dialog(transient_for=gramplet.uistate.window, + destroy_with_parent = True) + dlg.add_button(_('_Close'), Gtk.ResponseType.CLOSE) + self.set_window(dlg, None, self.title) self.window.move(x_pos, y_pos) self.window.set_default_size(gramplet.detached_width, gramplet.detached_height) diff --git a/gramps/gui/widgets/grampletpane.py b/gramps/gui/widgets/grampletpane.py index ae31d185d..0ad82bf77 100644 --- a/gramps/gui/widgets/grampletpane.py +++ b/gramps/gui/widgets/grampletpane.py @@ -233,12 +233,11 @@ class GrampletWindow(ManagedWindow): self.docked_state = gramplet.gstate # Now detach it self.gramplet.set_state("detached") - ManagedWindow.__init__(self, gramplet.uistate, [], - self.title) - self.set_window(Gtk.Dialog("", gramplet.uistate.window, - Gtk.DialogFlags.DESTROY_WITH_PARENT, - (_('_Close'), Gtk.ResponseType.CLOSE)), - None, self.title) + ManagedWindow.__init__(self, gramplet.uistate, [], self.title) + dlg = Gtk.Dialog(transient_for=gramplet.uistate.window, + destroy_with_parent=True) + dlg.add_button(_('_Close'), Gtk.ResponseType.CLOSE) + self.set_window(dlg, None, self.title) cfg_name = gramplet.gname.replace(' ', '').lower() + '-gramplet' self.setup_configs('interface.' + cfg_name, gramplet.detached_width, gramplet.detached_height) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index 026a12194..356a1553b 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -988,11 +988,11 @@ class GeoGraphyView(OsmGps, NavigationView): filtering = Gtk.FileFilter() filtering.add_pattern("*.kml") kml = Gtk.FileChooserDialog( - _("Select a kml file used to add places"), + title=_("Select a kml file used to add places"), action=Gtk.FileChooserAction.OPEN, - parent=self.uistate.window, - buttons=(_('_Cancel'), Gtk.ResponseType.CANCEL, - _('_Apply'), Gtk.ResponseType.OK)) + transient_for=self.uistate.window) + kml.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Apply'), Gtk.ResponseType.OK) mpath = HOME_DIR kml.set_current_folder(os.path.dirname(mpath)) kml.set_filter(filtering) @@ -1284,13 +1284,11 @@ class GeoGraphyView(OsmGps, NavigationView): """ dummy_obj = obj selected_dir = Gtk.FileChooserDialog( - _("Select tile cache directory for offline mode"), + title=_("Select tile cache directory for offline mode"), action=Gtk.FileChooserAction.SELECT_FOLDER, - parent=self.uistate.window, - buttons=(_('_Cancel'), - Gtk.ResponseType.CANCEL, - _('_Apply'), - Gtk.ResponseType.OK)) + transient_for=self.uistate.window) + selected_dir.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Apply'), Gtk.ResponseType.OK) mpath = config.get('geography.path') if not mpath: mpath = HOME_DIR diff --git a/gramps/plugins/lib/maps/placeselection.py b/gramps/plugins/lib/maps/placeselection.py index 08f2a1d96..e21f7d8d9 100644 --- a/gramps/plugins/lib/maps/placeselection.py +++ b/gramps/plugins/lib/maps/placeselection.py @@ -115,10 +115,10 @@ class PlaceSelection(ManagedWindow, OsmGps): self.selection_layer = layer self.layer = layer self.warning = False - self.set_window( - Gtk.Dialog(_('Place Selection in a region'), uistate.window, - buttons=(_('_Close'), Gtk.ResponseType.CLOSE)), - None, _('Place Selection in a region'), None) + dlg = Gtk.Dialog(title=_('Place Selection in a region'), + transient_for=uistate.window) + dlg.add_button(_('_Close'), Gtk.ResponseType.CLOSE) + self.set_window(dlg, None, _('Place Selection in a region'), None) mylabel = _('Choose the radius of the selection.\n' 'On the map you should see a circle or an' ' oval depending on the latitude.') @@ -139,11 +139,11 @@ class PlaceSelection(ManagedWindow, OsmGps): slider.connect('value-changed', self.slider_change, self.lat, self.lon) self.window.vbox.pack_start(slider, False, True, 0) self.vadjust = Gtk.Adjustment(page_size=15) - self.scroll = Gtk.ScrolledWindow(self.vadjust) + self.scroll = Gtk.ScrolledWindow(vadjustment=self.vadjust) self.scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scroll.set_shadow_type(Gtk.ShadowType.IN) self.plist = Gtk.ListStore(str, str, str, str, str) - self.choices = Gtk.TreeView(self.plist) + self.choices = Gtk.TreeView(model=self.plist) self.scroll.add(self.choices) self.renderer = Gtk.CellRendererText() self.tvcol1 = Gtk.TreeViewColumn(_('Country'), self.renderer, markup=0) diff --git a/gramps/plugins/tool/check.py b/gramps/plugins/tool/check.py index 707602ed9..e7bfc097d 100644 --- a/gramps/plugins/tool/check.py +++ b/gramps/plugins/tool/check.py @@ -775,10 +775,10 @@ class CheckIntegrity: 'kept') fs_top = Gtk.FileChooserDialog( - "%s - Gramps" % _("Select file"), - parent=self.parent_window, - buttons=(_('_Cancel'), Gtk.ResponseType.CANCEL, - _('_OK'), Gtk.ResponseType.OK)) + title="%s - Gramps" % _("Select file"), + transient_for=self.parent_window) + fs_top.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_OK'), Gtk.ResponseType.OK) fs_top.set_current_folder(self.last_img_dir) response = fs_top.run() if response == Gtk.ResponseType.OK: diff --git a/gramps/plugins/tool/eventcmp.py b/gramps/plugins/tool/eventcmp.py index e9c0bccbb..d087ed7a4 100644 --- a/gramps/plugins/tool/eventcmp.py +++ b/gramps/plugins/tool/eventcmp.py @@ -393,12 +393,10 @@ class EventComparisonResults(ManagedWindow): def on_write_table(self, obj): f = Gtk.FileChooserDialog(_("Select filename"), - parent=self.window, - action=Gtk.FileChooserAction.SAVE, - buttons=(_('_Cancel'), - Gtk.ResponseType.CANCEL, - _('_Save'), - Gtk.ResponseType.OK)) + transient_for=self.window, + action=Gtk.FileChooserAction.SAVE) + f.add_buttons(_('_Cancel'), Gtk.ResponseType.CANCEL, + _('_Save'), Gtk.ResponseType.OK) f.set_current_folder(get_curr_dir()) status = f.run() diff --git a/gramps/plugins/tool/populatesources.py b/gramps/plugins/tool/populatesources.py index d88a4d1b1..b266018b7 100644 --- a/gramps/plugins/tool/populatesources.py +++ b/gramps/plugins/tool/populatesources.py @@ -84,15 +84,16 @@ class PopulateSources(tool.Tool, ManagedWindow): num_citations = self.options.handler.options_dict['citations'] # GUI setup: - dialog = Gtk.Dialog("Populate sources and citations tool", - self.uistate.window, - Gtk.DialogFlags.MODAL|Gtk.DialogFlags.DESTROY_WITH_PARENT, - (_('_Cancel'), Gtk.ResponseType.REJECT, - _('_OK'), Gtk.ResponseType.ACCEPT)) - label = Gtk.Label("Enter a valid number of sources and citations." - " This will create the requested number of sources," - " and for each source, will create the requested" - " number of citations.") + dialog = Gtk.Dialog(title="Populate sources and citations tool", + transient_for=self.uistate.window, + modal=True, destroy_with_parent=True) + dialog.add_buttons(_('_Cancel'), Gtk.ResponseType.REJECT, + _('_OK'), Gtk.ResponseType.ACCEPT) + label = Gtk.Label( + label="Enter a valid number of sources and citations." + " This will create the requested number of sources," + " and for each source, will create the requested" + " number of citations.") label.set_line_wrap(True) hbox1 = Gtk.Box() diff --git a/gramps/plugins/tool/testcasegenerator.py b/gramps/plugins/tool/testcasegenerator.py index 9ddf32d90..103c2db7a 100644 --- a/gramps/plugins/tool/testcasegenerator.py +++ b/gramps/plugins/tool/testcasegenerator.py @@ -272,7 +272,7 @@ class TestcaseGenerator(tool.BatchTool): def init_gui(self, uistate): title = "%s - Gramps" % _("Generate testcases") - self.top = Gtk.Dialog(title, parent=uistate.window) + self.top = Gtk.Dialog(title=title, transient_for=uistate.window) self.window = uistate.window self.top.set_default_size(400, 150) self.top.vbox.set_spacing(5) diff --git a/gramps/plugins/view/fanchart2wayview.py b/gramps/plugins/view/fanchart2wayview.py index 37f815063..55c5f8702 100644 --- a/gramps/plugins/view/fanchart2wayview.py +++ b/gramps/plugins/view/fanchart2wayview.py @@ -573,9 +573,9 @@ class CairoPrintSave(): (typically evince not installed)! """ dummy_preview = preview - dlg = Gtk.MessageDialog(parent, - flags=Gtk.DialogFlags.MODAL, - type=Gtk.MessageType.WARNING, + dlg = Gtk.MessageDialog(transient_for=parent, + modal=True, + message_type=Gtk.MessageType.WARNING, buttons=Gtk.ButtonsType.CLOSE, message_format=_('No preview available')) self.preview = dlg diff --git a/gramps/plugins/view/fanchartdescview.py b/gramps/plugins/view/fanchartdescview.py index 3607d54a2..dd9653657 100644 --- a/gramps/plugins/view/fanchartdescview.py +++ b/gramps/plugins/view/fanchartdescview.py @@ -561,9 +561,9 @@ class CairoPrintSave: (typically evince not installed)! """ dummy_preview = preview - dlg = Gtk.MessageDialog(parent, - flags=Gtk.DialogFlags.MODAL, - type=Gtk.MessageType.WARNING, + dlg = Gtk.MessageDialog(transient_for=parent, + modal=True, + message_type=Gtk.MessageType.WARNING, buttons=Gtk.ButtonsType.CLOSE, message_format=_('No preview available')) self.preview = dlg diff --git a/gramps/plugins/view/fanchartview.py b/gramps/plugins/view/fanchartview.py index da80dbf2a..0b2493dd1 100644 --- a/gramps/plugins/view/fanchartview.py +++ b/gramps/plugins/view/fanchartview.py @@ -659,9 +659,9 @@ class CairoPrintSave: (typically evince not installed)! """ dummy_preview = preview - dlg = Gtk.MessageDialog(parent, - flags=Gtk.DialogFlags.MODAL, - type=Gtk.MessageType.WARNING, + dlg = Gtk.MessageDialog(transient_for=parent, + modal=True, + message_type=Gtk.MessageType.WARNING, buttons=Gtk.ButtonsType.CLOSE, message_format=_('No preview available')) self.preview = dlg