Skip to content

Commit 63ce9ca

Browse files
committed
Don't use new() in preferences.py
1 parent d9c0efc commit 63ce9ca

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

src/diffuse/preferences.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ def runDialog(self, parent: Gtk.Widget) -> None:
306306
def _buildPrefsDialog(self, parent, widgets, template):
307307
tpl_section = template[0]
308308
if tpl_section == 'FolderSet':
309-
notebook = Gtk.Notebook.new()
309+
notebook = Gtk.Notebook()
310310
notebook.set_border_width(10)
311311
i = 1
312312
while i < len(template):
313-
label = Gtk.Label.new(template[i])
313+
label = Gtk.Label(label=template[i])
314314
i += 1
315315
w = self._buildPrefsDialog(parent, widgets, template[i])
316316
i += 1
@@ -319,7 +319,7 @@ def _buildPrefsDialog(self, parent, widgets, template):
319319
label.show()
320320
return notebook
321321

322-
table = Gtk.Grid.new()
322+
table = Gtk.Grid()
323323
table.set_border_width(10)
324324
for i, tpl in enumerate(template[1:]):
325325
tpl_section = tpl[0]
@@ -335,21 +335,28 @@ def _buildPrefsDialog(self, parent, widgets, template):
335335
button.connect('toggled', self._toggled_cb, widgets, tpl[1])
336336
button.show()
337337
else:
338-
label = Gtk.Label.new(tpl[3] + ': ')
338+
label = Gtk.Label(label=tpl[3] + ': ')
339339
label.set_xalign(1.0)
340340
label.set_yalign(0.5)
341341
table.attach(label, 0, i, 1, 1)
342342
label.show()
343343
if tpl[0] in ['Font', 'Integer']:
344-
entry = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
344+
entry = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
345345
if tpl[0] == 'Font':
346346
button = Gtk.FontButton()
347347
button.set_font(self.string_prefs[tpl[1]])
348348
else:
349-
button = Gtk.SpinButton.new(
350-
Gtk.Adjustment.new(self.int_prefs[tpl[1]], tpl[4], tpl[5], 1, 0, 0),
351-
1.0,
352-
0)
349+
adj = Gtk.Adjustment(
350+
value=self.int_prefs[tpl[1]],
351+
lower=tpl[4],
352+
upper=tpl[5],
353+
step_increment=1,
354+
page_increment=0,
355+
page_size=0)
356+
button = Gtk.SpinButton(
357+
adjustment=adj,
358+
climb_rate=1.0,
359+
digits=0)
353360
widgets[tpl[1]] = button
354361
entry.pack_start(button, False, False, 0)
355362
button.show()
@@ -360,7 +367,7 @@ def _buildPrefsDialog(self, parent, widgets, template):
360367
elif tpl[0] == 'File':
361368
entry = _FileEntry(parent, tpl[3])
362369
else:
363-
entry = Gtk.Entry.new()
370+
entry = Gtk.Entry()
364371
widgets[tpl[1]] = entry
365372
entry.set_text(self.string_prefs[tpl[1]])
366373
table.attach(entry, 1, i, 1, 1)
@@ -443,11 +450,11 @@ def __init__(self, parent: Gtk.Widget, title: str) -> None:
443450
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
444451
self.toplevel = parent
445452
self.title = title
446-
self.entry = entry = Gtk.Entry.new()
453+
self.entry = entry = Gtk.Entry()
447454
self.pack_start(entry, True, True, 0)
448455
entry.show()
449-
button = Gtk.Button.new()
450-
image = Gtk.Image.new()
456+
button = Gtk.Button()
457+
image = Gtk.Image()
451458
image.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.MENU)
452459
button.add(image)
453460
image.show()

0 commit comments

Comments
 (0)