Merge pull request #41 from tneele/deprecation-warnings
Resolve some deprecation warnings
This commit is contained in:
commit
517eba8926
|
@ -721,9 +721,9 @@ def norm_encoding(e):
|
||||||
return e.replace('-', '_').lower()
|
return e.replace('-', '_').lower()
|
||||||
|
|
||||||
# widget to help pick an encoding
|
# widget to help pick an encoding
|
||||||
class EncodingMenu(Gtk.HBox):
|
class EncodingMenu(Gtk.Box):
|
||||||
def __init__(self, prefs, autodetect=False):
|
def __init__(self, prefs, autodetect=False):
|
||||||
Gtk.HBox.__init__(self)
|
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
self.combobox = combobox = Gtk.ComboBoxText.new()
|
self.combobox = combobox = Gtk.ComboBoxText.new()
|
||||||
self.encodings = prefs.getEncodings()[:]
|
self.encodings = prefs.getEncodings()[:]
|
||||||
for e in self.encodings:
|
for e in self.encodings:
|
||||||
|
@ -745,9 +745,9 @@ class EncodingMenu(Gtk.HBox):
|
||||||
return self.encodings[i]
|
return self.encodings[i]
|
||||||
|
|
||||||
# text entry widget with a button to help pick file names
|
# text entry widget with a button to help pick file names
|
||||||
class FileEntry(Gtk.HBox):
|
class FileEntry(Gtk.Box):
|
||||||
def __init__(self, parent, title):
|
def __init__(self, parent, title):
|
||||||
Gtk.HBox.__init__(self)
|
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
self.toplevel = parent
|
self.toplevel = parent
|
||||||
self.title = title
|
self.title = title
|
||||||
self.entry = entry = Gtk.Entry.new()
|
self.entry = entry = Gtk.Entry.new()
|
||||||
|
@ -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.HBox.new(False, 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
|
||||||
|
@ -1229,7 +1232,7 @@ def appendButtons(box, size, specs):
|
||||||
box.pack_start(button, False, False, 0)
|
box.pack_start(button, False, False, 0)
|
||||||
button.show()
|
button.show()
|
||||||
else:
|
else:
|
||||||
separator = Gtk.VSeparator.new()
|
separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
|
||||||
box.pack_start(separator, False, False, 5)
|
box.pack_start(separator, False, False, 5)
|
||||||
separator.show()
|
separator.show()
|
||||||
|
|
||||||
|
@ -2711,11 +2714,11 @@ class ScrolledWindow(Gtk.Grid):
|
||||||
vport.set_hexpand(True)
|
vport.set_hexpand(True)
|
||||||
vport.show()
|
vport.show()
|
||||||
|
|
||||||
self.vbar = bar = Gtk.VScrollbar.new(vadj)
|
self.vbar = bar = Gtk.Scrollbar.new(Gtk.Orientation.VERTICAL, vadj)
|
||||||
self.attach(bar, 1, 0, 1, 1)
|
self.attach(bar, 1, 0, 1, 1)
|
||||||
bar.show()
|
bar.show()
|
||||||
|
|
||||||
self.hbar = bar = Gtk.HScrollbar.new(hadj)
|
self.hbar = bar = Gtk.Scrollbar.new(Gtk.Orientation.HORIZONTAL, hadj)
|
||||||
self.attach(bar, 0, 1, 1, 1)
|
self.attach(bar, 0, 1, 1, 1)
|
||||||
bar.show()
|
bar.show()
|
||||||
|
|
||||||
|
@ -6650,12 +6653,14 @@ GObject.signal_new('format-changed', FileDiffViewer, GObject.SignalFlags.RUN_LAS
|
||||||
# dialogue used to search for text
|
# dialogue used to search for text
|
||||||
class SearchDialog(Gtk.Dialog):
|
class SearchDialog(Gtk.Dialog):
|
||||||
def __init__(self, parent, pattern=None, history=None):
|
def __init__(self, parent, pattern=None, history=None):
|
||||||
Gtk.Dialog.__init__(self, _('Find...'), parent, Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
|
Gtk.Dialog.__init__(self, title=_('Find...'), parent=parent, destroy_with_parent=True)
|
||||||
|
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)
|
||||||
|
self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
|
||||||
|
|
||||||
vbox = Gtk.VBox.new(False, 0)
|
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||||
vbox.set_border_width(10)
|
vbox.set_border_width(10)
|
||||||
|
|
||||||
hbox = Gtk.HBox.new(False, 0)
|
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||||
label = Gtk.Label.new(_('Search For: '))
|
label = Gtk.Label.new(_('Search For: '))
|
||||||
hbox.pack_start(label, False, False, 0)
|
hbox.pack_start(label, False, False, 0)
|
||||||
label.show()
|
label.show()
|
||||||
|
@ -6716,9 +6721,11 @@ 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.HBox.new(False, 0)
|
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||||
hbox.set_border_width(5)
|
hbox.set_border_width(5)
|
||||||
label = Gtk.Label.new(_('Encoding: '))
|
label = Gtk.Label.new(_('Encoding: '))
|
||||||
hbox.pack_start(label, False, False, 0)
|
hbox.pack_start(label, False, False, 0)
|
||||||
|
@ -6755,12 +6762,14 @@ class FileChooserDialog(Gtk.FileChooserDialog):
|
||||||
# dialogue used to search for text
|
# dialogue used to search for text
|
||||||
class NumericDialog(Gtk.Dialog):
|
class NumericDialog(Gtk.Dialog):
|
||||||
def __init__(self, parent, title, text, val, lower, upper, step=1, page=0):
|
def __init__(self, parent, title, text, val, lower, upper, step=1, page=0):
|
||||||
Gtk.Dialog.__init__(self, title, parent, Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
|
Gtk.Dialog.__init__(self, title=title, parent=parent, destroy_with_parent=True)
|
||||||
|
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)
|
||||||
|
self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
|
||||||
|
|
||||||
vbox = Gtk.VBox.new(False, 0)
|
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||||
vbox.set_border_width(10)
|
vbox.set_border_width(10)
|
||||||
|
|
||||||
hbox = Gtk.HBox.new(False, 0)
|
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||||
label = Gtk.Label.new(text)
|
label = Gtk.Label.new(text)
|
||||||
hbox.pack_start(label, False, False, 0)
|
hbox.pack_start(label, False, False, 0)
|
||||||
label.show()
|
label.show()
|
||||||
|
@ -6817,7 +6826,7 @@ class NotebookTab(Gtk.EventBox):
|
||||||
def __init__(self, name, stock):
|
def __init__(self, name, stock):
|
||||||
Gtk.EventBox.__init__(self)
|
Gtk.EventBox.__init__(self)
|
||||||
self.set_visible_window(False)
|
self.set_visible_window(False)
|
||||||
hbox = Gtk.HBox.new(False, 0)
|
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||||
if stock is not None:
|
if stock is not None:
|
||||||
image = Gtk.Image.new()
|
image = Gtk.Image.new()
|
||||||
image.set_from_stock(stock, Gtk.IconSize.MENU)
|
image.set_from_stock(stock, Gtk.IconSize.MENU)
|
||||||
|
@ -6825,7 +6834,8 @@ class NotebookTab(Gtk.EventBox):
|
||||||
image.show()
|
image.show()
|
||||||
self.label = label = Gtk.Label.new(name)
|
self.label = label = Gtk.Label.new(name)
|
||||||
# left justify the widget
|
# left justify the widget
|
||||||
label.set_alignment(0, 0.5)
|
label.set_xalign(0.0)
|
||||||
|
label.set_yalign(0.5)
|
||||||
hbox.pack_start(label, True, True, 0)
|
hbox.pack_start(label, True, True, 0)
|
||||||
label.show()
|
label.show()
|
||||||
self.button = button = Gtk.Button.new()
|
self.button = button = Gtk.Button.new()
|
||||||
|
@ -6945,19 +6955,19 @@ class Diffuse(Gtk.Window):
|
||||||
self.cursor.set_size_request(-1, -1)
|
self.cursor.set_size_request(-1, -1)
|
||||||
self.pack_start(label, False, False, 0)
|
self.pack_start(label, False, False, 0)
|
||||||
|
|
||||||
separator = Gtk.VSeparator.new()
|
separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
|
||||||
self.pack_end(separator, False, False, 10)
|
self.pack_end(separator, False, False, 10)
|
||||||
|
|
||||||
self.encoding = label = Gtk.Label.new()
|
self.encoding = label = Gtk.Label.new()
|
||||||
self.pack_end(label, False, False, 0)
|
self.pack_end(label, False, False, 0)
|
||||||
|
|
||||||
separator = Gtk.VSeparator.new()
|
separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
|
||||||
self.pack_end(separator, False, False, 10)
|
self.pack_end(separator, False, False, 10)
|
||||||
|
|
||||||
self.format = label = Gtk.Label.new()
|
self.format = label = Gtk.Label.new()
|
||||||
self.pack_end(label, False, False, 0)
|
self.pack_end(label, False, False, 0)
|
||||||
|
|
||||||
separator = Gtk.VSeparator.new()
|
separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
|
||||||
self.pack_end(separator, False, False, 10)
|
self.pack_end(separator, False, False, 10)
|
||||||
|
|
||||||
self.set_size_request(0, self.get_size_request()[1])
|
self.set_size_request(0, self.get_size_request()[1])
|
||||||
|
@ -7440,8 +7450,8 @@ class Diffuse(Gtk.Window):
|
||||||
self.connect('delete-event', self.delete_cb)
|
self.connect('delete-event', self.delete_cb)
|
||||||
accel_group = Gtk.AccelGroup()
|
accel_group = Gtk.AccelGroup()
|
||||||
|
|
||||||
# create a VBox for our contents
|
# create a Box for our contents
|
||||||
vbox = Gtk.VBox()
|
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
|
||||||
# create some custom icons for merging
|
# create some custom icons for merging
|
||||||
DIFFUSE_STOCK_NEW_2WAY_MERGE = 'diffuse-new-2way-merge'
|
DIFFUSE_STOCK_NEW_2WAY_MERGE = 'diffuse-new-2way-merge'
|
||||||
|
@ -7611,7 +7621,7 @@ class Diffuse(Gtk.Window):
|
||||||
menu_bar.show()
|
menu_bar.show()
|
||||||
|
|
||||||
# create button bar
|
# create button bar
|
||||||
hbox = Gtk.HBox.new(False, 0)
|
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||||
appendButtons(hbox, Gtk.IconSize.LARGE_TOOLBAR, [
|
appendButtons(hbox, Gtk.IconSize.LARGE_TOOLBAR, [
|
||||||
[ DIFFUSE_STOCK_NEW_2WAY_MERGE, self.new_2_way_file_merge_cb, None, _('New 2-Way File Merge') ],
|
[ DIFFUSE_STOCK_NEW_2WAY_MERGE, self.new_2_way_file_merge_cb, None, _('New 2-Way File Merge') ],
|
||||||
[ DIFFUSE_STOCK_NEW_3WAY_MERGE, self.new_3_way_file_merge_cb, None, _('New 3-Way File Merge') ],
|
[ DIFFUSE_STOCK_NEW_3WAY_MERGE, self.new_3_way_file_merge_cb, None, _('New 3-Way File Merge') ],
|
||||||
|
@ -7750,11 +7760,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