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
|
from gi.repository import GLib
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import warnings
|
||||||
import pyconsole
|
import pyconsole
|
||||||
#import gimpshelf, gimpui, pyconsole
|
#import gimpshelf, gimpui, pyconsole
|
||||||
|
|
||||||
|
@ -265,13 +266,16 @@ def run(procedure, config, data):
|
||||||
|
|
||||||
def save_dialog(self):
|
def save_dialog(self):
|
||||||
if not self.save_dlg:
|
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_title(dlg, _("Save Python-Fu Console Output"))
|
||||||
Gtk.Window.set_transient_for(dlg, self)
|
Gtk.Window.set_transient_for(dlg, self)
|
||||||
Gtk.Dialog.add_button(dlg, _("_Cancel"), Gtk.ResponseType.CANCEL)
|
Gtk.Dialog.add_button(dlg, _("_Cancel"), Gtk.ResponseType.CANCEL)
|
||||||
Gtk.Dialog.add_button(dlg, _("_Save"), Gtk.ResponseType.OK)
|
Gtk.Dialog.add_button(dlg, _("_Save"), Gtk.ResponseType.OK)
|
||||||
Gtk.Dialog.set_default_response(self, Gtk.ResponseType.OK)
|
Gtk.Dialog.set_default_response(self, Gtk.ResponseType.OK)
|
||||||
GimpUi.Dialog.set_alternative_button_order_from_array(dlg,
|
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings('ignore')
|
||||||
|
Gtk.FileChooserDialog.set_alternative_button_order_from_array(dlg,
|
||||||
[ Gtk.ResponseType.OK,
|
[ Gtk.ResponseType.OK,
|
||||||
Gtk.ResponseType.CANCEL ])
|
Gtk.ResponseType.CANCEL ])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue