mirror of https://github.com/GNOME/gimp.git
plug-ins: Fix Save button in Python Console
Clicking on the Save button threw an exception as the wrong class was used to invoke the `set_alternative_button_order_from_array()` method. Since `Gtk.Dialog.set_alternative_button_order_from_array()` is deprecated and the GIMP functions with the same name suppress deprecation warnings in the C code, we suppress the warning here as well. The `warnings.catch_warnings()` function is not thread-safe according to the Python documentation, which should not pose a problem here. Also, the file chooser dialog now allows specifying a new file instead of overwriting an existing file.
This commit is contained in:
parent
57113323e2
commit
c7c1743dd0
|
@ -28,6 +28,7 @@ from gi.repository import Gio
|
|||
from gi.repository import GLib
|
||||
|
||||
import sys
|
||||
import warnings
|
||||
import pyconsole
|
||||
#import gimpshelf, gimpui, pyconsole
|
||||
|
||||
|
@ -265,15 +266,18 @@ def run(procedure, config, data):
|
|||
|
||||
def save_dialog(self):
|
||||
if not self.save_dlg:
|
||||
dlg = Gtk.FileChooserDialog()
|
||||
dlg = Gtk.FileChooserDialog(action=Gtk.FileChooserAction.SAVE)
|
||||
Gtk.Window.set_title(dlg, _("Save Python-Fu Console Output"))
|
||||
Gtk.Window.set_transient_for(dlg, self)
|
||||
Gtk.Dialog.add_button(dlg, _("_Cancel"), Gtk.ResponseType.CANCEL)
|
||||
Gtk.Dialog.add_button(dlg, _("_Save"), Gtk.ResponseType.OK)
|
||||
Gtk.Dialog.set_default_response(self, Gtk.ResponseType.OK)
|
||||
GimpUi.Dialog.set_alternative_button_order_from_array(dlg,
|
||||
[ Gtk.ResponseType.OK,
|
||||
Gtk.ResponseType.CANCEL ])
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore')
|
||||
Gtk.FileChooserDialog.set_alternative_button_order_from_array(dlg,
|
||||
[ Gtk.ResponseType.OK,
|
||||
Gtk.ResponseType.CANCEL ])
|
||||
|
||||
dlg.connect('response', self.save_response)
|
||||
|
||||
|
|
Loading…
Reference in New Issue