Commit 3ff5b3cb authored by Kai Willadsen's avatar Kai Willadsen

ui.filechooser: Update for constructor deprecations

The constructor deprecation here includes some previous special-casing
of the Gtk.Dialog's buttons kwarg, so we're handling that manually here
instead of supporting customising button types in the initialiser.
parent e8c34a99
......@@ -67,7 +67,7 @@ def trash_or_confirm(gfile: Gio.File):
def prompt_save_filename(title: str, parent: Gtk.Widget = None) -> Gio.File:
dialog = MeldFileChooserDialog(
title,
parent=get_modal_parent(parent),
transient_for=get_modal_parent(parent),
action=Gtk.FileChooserAction.SAVE,
)
dialog.set_default_response(Gtk.ResponseType.ACCEPT)
......
......@@ -31,18 +31,19 @@ class MeldFileChooserDialog(Gtk.FileChooserDialog):
__gtype_name__ = 'MeldFileChooserDialog'
def __init__(self, title=None, parent=None,
action=Gtk.FileChooserAction.OPEN,
buttons=None):
if buttons is None:
if action == Gtk.FileChooserAction.SAVE:
buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT)
else:
buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT)
Gtk.FileChooserDialog.__init__(self, title, parent, action, buttons)
def __init__(self, title=None, transient_for=None,
action=Gtk.FileChooserAction.OPEN):
Gtk.FileChooserDialog.__init__(
self, title=title, transient_for=transient_for, action=action)
if action == Gtk.FileChooserAction.SAVE:
buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT)
else:
buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT)
self.add_buttons(*buttons)
self.encoding_store = Gtk.ListStore(str, str)
self.connect("notify::action", self.action_changed_cb)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment