Fix deprecation warnings in dialogs
This commit is contained in:
parent
680104ed5c
commit
c7361cdd73
|
@ -983,7 +983,9 @@ class Preferences:
|
||||||
# display the dialogue and update the preference values if the accept
|
# display the dialogue and update the preference values if the accept
|
||||||
# button was pressed
|
# button was pressed
|
||||||
def runDialog(self, parent):
|
def runDialog(self, parent):
|
||||||
dialog = Gtk.Dialog(_('Preferences'), parent, Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.OK))
|
dialog = Gtk.Dialog(_('Preferences'), parent=parent, destroy_with_parent=True)
|
||||||
|
dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)
|
||||||
|
dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
|
||||||
|
|
||||||
widgets = {}
|
widgets = {}
|
||||||
w = self._buildPrefsDialog(parent, widgets, self.template)
|
w = self._buildPrefsDialog(parent, widgets, self.template)
|
||||||
|
@ -1047,31 +1049,32 @@ class Preferences:
|
||||||
return notebook
|
return notebook
|
||||||
else:
|
else:
|
||||||
n = len(template) - 1
|
n = len(template) - 1
|
||||||
table = Gtk.Table.new(2, n, False)
|
table = Gtk.Grid.new()
|
||||||
table.set_border_width(10)
|
table.set_border_width(10)
|
||||||
for i, tpl in enumerate(template[1:]):
|
for i, tpl in enumerate(template[1:]):
|
||||||
type = tpl[0]
|
type = tpl[0]
|
||||||
if type == 'FolderSet':
|
if type == 'FolderSet':
|
||||||
w = self._buildPrefsDialog(parent, widgets, tpl)
|
w = self._buildPrefsDialog(parent, widgets, tpl)
|
||||||
table.attach(w, 0, 2, i, i + 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
|
table.attach(w, 0, i, 2, 1)
|
||||||
w.show()
|
w.show()
|
||||||
elif type == 'Boolean':
|
elif type == 'Boolean':
|
||||||
button = Gtk.CheckButton.new_with_mnemonic(tpl[3])
|
button = Gtk.CheckButton.new_with_mnemonic(tpl[3])
|
||||||
button.set_active(self.bool_prefs[tpl[1]])
|
button.set_active(self.bool_prefs[tpl[1]])
|
||||||
widgets[tpl[1]] = button
|
widgets[tpl[1]] = button
|
||||||
table.attach(button, 1, 2, i, i + 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
|
table.attach(button, 1, i, 1, 1)
|
||||||
button.connect('toggled', self._toggled_cb, widgets, tpl[1])
|
button.connect('toggled', self._toggled_cb, widgets, tpl[1])
|
||||||
button.show()
|
button.show()
|
||||||
else:
|
else:
|
||||||
label = Gtk.Label.new(tpl[3] + ': ')
|
label = Gtk.Label.new(tpl[3] + ': ')
|
||||||
label.set_alignment(1.0, 0.5)
|
label.set_xalign(1.0)
|
||||||
table.attach(label, 0, 1, i, i + 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
|
label.set_yalign(0.5)
|
||||||
|
table.attach(label, 0, i, 1, 1)
|
||||||
label.show()
|
label.show()
|
||||||
if tpl[0] in [ 'Font', 'Integer' ]:
|
if tpl[0] in [ 'Font', 'Integer' ]:
|
||||||
entry = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
entry = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||||
if tpl[0] == 'Font':
|
if tpl[0] == 'Font':
|
||||||
button = FontButton()
|
button = FontButton()
|
||||||
button.set_font_name(self.string_prefs[tpl[1]])
|
button.set_font(self.string_prefs[tpl[1]])
|
||||||
else:
|
else:
|
||||||
button = Gtk.SpinButton.new(Gtk.Adjustment.new(self.int_prefs[tpl[1]], tpl[4], tpl[5], 1, 0, 0), 1.0, 0)
|
button = Gtk.SpinButton.new(Gtk.Adjustment.new(self.int_prefs[tpl[1]], tpl[4], tpl[5], 1, 0, 0), 1.0, 0)
|
||||||
widgets[tpl[1]] = button
|
widgets[tpl[1]] = button
|
||||||
|
@ -1087,7 +1090,7 @@ class Preferences:
|
||||||
entry = Gtk.Entry.new()
|
entry = Gtk.Entry.new()
|
||||||
widgets[tpl[1]] = entry
|
widgets[tpl[1]] = entry
|
||||||
entry.set_text(self.string_prefs[tpl[1]])
|
entry.set_text(self.string_prefs[tpl[1]])
|
||||||
table.attach(entry, 1, 2, i, i + 1, Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
|
table.attach(entry, 1, i, 1, 1)
|
||||||
entry.show()
|
entry.show()
|
||||||
table.show()
|
table.show()
|
||||||
return table
|
return table
|
||||||
|
@ -6716,7 +6719,9 @@ class FileChooserDialog(Gtk.FileChooserDialog):
|
||||||
FileChooserDialog.last_chosen_folder = widget.get_current_folder()
|
FileChooserDialog.last_chosen_folder = widget.get_current_folder()
|
||||||
|
|
||||||
def __init__(self, title, parent, prefs, action, accept, rev=False):
|
def __init__(self, title, parent, prefs, action, accept, rev=False):
|
||||||
Gtk.FileChooserDialog.__init__(self, title, parent, action, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, accept, Gtk.ResponseType.OK))
|
Gtk.FileChooserDialog.__init__(self, title=title, parent=parent, action=action)
|
||||||
|
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
|
||||||
|
self.add_button(accept, Gtk.ResponseType.OK)
|
||||||
self.prefs = prefs
|
self.prefs = prefs
|
||||||
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||||
hbox.set_border_width(5)
|
hbox.set_border_width(5)
|
||||||
|
@ -7750,11 +7755,11 @@ class Diffuse(Gtk.Window):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# ask the user which files should be saved
|
# ask the user which files should be saved
|
||||||
dialog = Gtk.MessageDialog(self.get_toplevel(),
|
dialog = Gtk.MessageDialog(parent=self.get_toplevel(),
|
||||||
Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
destroy_with_parent=True,
|
||||||
Gtk.MessageType.WARNING,
|
message_type=Gtk.MessageType.WARNING,
|
||||||
Gtk.ButtonsType.NONE,
|
buttons=Gtk.ButtonsType.NONE,
|
||||||
_('Some files have unsaved changes. Select the files to save before closing.'))
|
text=_('Some files have unsaved changes. Select the files to save before closing.'))
|
||||||
dialog.set_resizable(True)
|
dialog.set_resizable(True)
|
||||||
dialog.set_title(APP_NAME)
|
dialog.set_title(APP_NAME)
|
||||||
# add list of files with unsaved changes
|
# add list of files with unsaved changes
|
||||||
|
|
Loading…
Reference in New Issue