From 2a1db6b52214ea916e499f3dbd8915a7808c793e Mon Sep 17 00:00:00 2001 From: Papoteur Date: Wed, 15 May 2024 22:52:18 +0200 Subject: Fix deprecation warning on gtk.dialog creation --- src/msec/msecgui.py | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/src/msec/msecgui.py b/src/msec/msecgui.py index 19bd387..97424fd 100755 --- a/src/msec/msecgui.py +++ b/src/msec/msecgui.py @@ -339,20 +339,11 @@ class MsecGui: curperms = self.permconfig # creating preview window + dialog = Gtk.Dialog(_('Saving changes...'), self.window, Gtk.DialogFlags.MODAL) + dialog.add_action_widget(Gtk.Button(label=_('Cancel')), Gtk.ResponseType.CANCEL) if ask_ignore: - dialog = Gtk.Dialog(_("Saving changes.."), - self.window, Gtk.DialogFlags.MODAL, - (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, - _("Ignore and quit"), Gtk.ResponseType.REJECT, - Gtk.STOCK_OK, Gtk.ResponseType.OK) - ) - else: - dialog = Gtk.Dialog(_("Saving changes.."), - self.window, Gtk.DialogFlags.MODAL, - (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, - Gtk.STOCK_OK, Gtk.ResponseType.OK) - ) - + dialog.add_action_widget(Gtk.Button(label=_("Ignore and quit")), Gtk.ResponseType.REJECT) + dialog.add_action_widget(Gtk.Button(label=_('OK')), Gtk.ResponseType.OK) dialog.set_default_size(640, 300) dialog.set_default_response(Gtk.ResponseType.OK) @@ -693,10 +684,8 @@ class MsecGui: data = fd.readlines() except: data = [_("Unable to read log file: %s") % sys.exc_info()[1]] - dialog = Gtk.Dialog(_("Periodic check results"), - self.window, - 0, - (Gtk.STOCK_OK, Gtk.ResponseType.OK)) + dialog = Gtk.Dialog((_("Periodic check results"), parent=self.window, flags=0) + dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) dialog.set_size_request(640, 280) view = Gtk.TextView() buffer = view.get_buffer() @@ -1427,10 +1416,9 @@ class MsecGui: title = _("Adding new exception") # asks for new parameter value - dialog = Gtk.Dialog(title, - self.window, 0, - (Gtk.STOCK_OK, Gtk.ResponseType.OK, - Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) + dialog = Gtk.Dialog(title, parent=self.window, flags=0) + dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK, + Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) label = Gtk.Label(label=_("Editing exception. Please select the correspondent msec check and exception value\n")) label.set_line_wrap(True) label.set_use_markup(True) @@ -1505,10 +1493,9 @@ class MsecGui: force = "force" # asks for new parameter value - dialog = Gtk.Dialog(title, - self.window, 0, - (Gtk.STOCK_OK, Gtk.ResponseType.OK, - Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) + dialog = Gtk.Dialog(title, parent=self.window, flags=0) + dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK, + Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) label = Gtk.Label(label=_("Changing permissions on %s") % (file or _("new file"))) label.set_line_wrap(True) label.set_use_markup(True) @@ -1643,9 +1630,9 @@ class MsecGui: # asks for new parameter value dialog = Gtk.Dialog(_("Select new value for %s") % (param), - self.window, 0, - (Gtk.STOCK_OK, Gtk.ResponseType.OK, - Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) + parent=self.window, flags=0) + dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK, + Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) # option title label = Gtk.Label(label="%s\n" % param) label.set_use_markup(True) -- cgit v1.2.1