Skip to content

Commit dcea1ad

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

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/diffuse/main.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,24 @@ class NotebookTab(Gtk.EventBox):
6161
def __init__(self, name: str, stock: str) -> None:
6262
Gtk.EventBox.__init__(self)
6363
self.set_visible_window(False)
64-
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
64+
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
6565
if stock is not None:
66-
image = Gtk.Image.new()
66+
image = Gtk.Image()
6767
image.set_from_stock(stock, Gtk.IconSize.MENU)
6868
hbox.pack_start(image, False, False, 5)
6969
image.show()
7070

71-
label = Gtk.Label.new(name)
71+
label = Gtk.Label(label=name)
7272
# left justify the widget
7373
label.set_xalign(0.0)
7474
label.set_yalign(0.5)
7575
hbox.pack_start(label, True, True, 0)
7676
label.show()
7777
self.label = label
7878

79-
button = Gtk.Button.new()
79+
button = Gtk.Button()
8080
button.set_relief(Gtk.ReliefStyle.NONE)
81-
image = Gtk.Image.new()
81+
image = Gtk.Image()
8282
image.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
8383
button.add(image)
8484
image.show()
@@ -134,7 +134,7 @@ def __init__(self) -> None:
134134
[Gtk.STOCK_SAVE, self.button_cb, 'save', _('Save File')],
135135
[Gtk.STOCK_SAVE_AS, self.button_cb, 'save_as', _('Save File As...')]])
136136

137-
self.label = label = Gtk.Label.new()
137+
self.label = label = Gtk.Label()
138138
label.set_selectable(True)
139139
label.set_ellipsize(Pango.EllipsizeMode.START)
140140
label.set_max_width_chars(1)
@@ -181,23 +181,23 @@ def setEdits(self, has_edits: bool) -> None:
181181
class PaneFooter(Gtk.Box):
182182
def __init__(self) -> None:
183183
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
184-
self.cursor = label = Gtk.Label.new()
184+
self.cursor = label = Gtk.Label()
185185
self.cursor.set_size_request(-1, -1)
186186
self.pack_start(label, False, False, 0)
187187

188-
separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
188+
separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
189189
self.pack_end(separator, False, False, 10)
190190

191-
self.encoding = label = Gtk.Label.new()
191+
self.encoding = label = Gtk.Label()
192192
self.pack_end(label, False, False, 0)
193193

194-
separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
194+
separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
195195
self.pack_end(separator, False, False, 10)
196196

197-
self.format = label = Gtk.Label.new()
197+
self.format = label = Gtk.Label()
198198
self.pack_end(label, False, False, 0)
199199

200-
separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
200+
separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
201201
self.pack_end(separator, False, False, 10)
202202

203203
self.set_size_request(0, self.get_size_request()[1])
@@ -905,7 +905,7 @@ def __init__(self, rc_dir):
905905
menu_bar.show()
906906

907907
# create button bar
908-
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
908+
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
909909
_append_buttons(hbox, Gtk.IconSize.LARGE_TOOLBAR, [
910910
[DIFFUSE_STOCK_NEW_2WAY_MERGE, self.new_2_way_file_merge_cb, None, _('New 2-Way File Merge')], # noqa: E501
911911
[DIFFUSE_STOCK_NEW_3WAY_MERGE, self.new_3_way_file_merge_cb, None, _('New 3-Way File Merge')], # noqa: E501
@@ -936,14 +936,14 @@ def __init__(self, rc_dir):
936936
hbox.show()
937937

938938
self.closed_tabs = []
939-
self.notebook = notebook = Gtk.Notebook.new()
939+
self.notebook = notebook = Gtk.Notebook()
940940
notebook.set_scrollable(True)
941941
notebook.connect('switch-page', self.switch_page_cb)
942942
vbox.pack_start(notebook, True, True, 0)
943943
notebook.show()
944944

945945
# Add a status bar to the bottom
946-
self.statusbar = statusbar = Gtk.Statusbar.new()
946+
self.statusbar = statusbar = Gtk.Statusbar()
947947
vbox.pack_start(statusbar, False, False, 0)
948948
statusbar.show()
949949

@@ -1056,15 +1056,15 @@ def confirmCloseViewers(self, viewers: List[FileDiffViewer]) -> bool:
10561056
dialog.set_resizable(True)
10571057
dialog.set_title(constants.APP_NAME)
10581058
# add list of files with unsaved changes
1059-
sw = Gtk.ScrolledWindow.new()
1059+
sw = Gtk.ScrolledWindow()
10601060
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
10611061
treeview = Gtk.TreeView.new_with_model(model)
1062-
r = Gtk.CellRendererToggle.new()
1062+
r = Gtk.CellRendererToggle()
10631063
r.connect('toggled', self._confirmClose_toggle_cb, model)
10641064
column = Gtk.TreeViewColumn(None, r)
10651065
column.add_attribute(r, 'active', 0)
10661066
treeview.append_column(column)
1067-
r = Gtk.CellRendererText.new()
1067+
r = Gtk.CellRendererText()
10681068
column = Gtk.TreeViewColumn(_('Tab'), r, text=1)
10691069
column.set_resizable(True)
10701070
column.set_expand(True)
@@ -1137,7 +1137,7 @@ def notebooktab_button_press_cb(self, widget, event, data):
11371137
self.remove_tab_cb(widget, data)
11381138
elif event.button == 3:
11391139
# create a popup to pick a tab for focus on RMB
1140-
menu = Gtk.Menu.new()
1140+
menu = Gtk.Menu()
11411141
nb = self.notebook
11421142
for i in range(nb.get_n_pages()):
11431143
viewer = nb.get_nth_page(i)
@@ -1685,7 +1685,7 @@ def about_cb(self, widget, data):
16851685

16861686
# convenience method for creating a menu bar according to a template
16871687
def _create_menu_bar(specs, radio, accel_group):
1688-
menu_bar = Gtk.MenuBar.new()
1688+
menu_bar = Gtk.MenuBar()
16891689
for label, spec in specs:
16901690
menu = Gtk.MenuItem.new_with_mnemonic(label)
16911691
menu.set_submenu(createMenu(spec, radio, accel_group))
@@ -1700,10 +1700,10 @@ def _create_menu_bar(specs, radio, accel_group):
17001700
def _append_buttons(box, size, specs):
17011701
for spec in specs:
17021702
if len(spec) > 0:
1703-
button = Gtk.Button.new()
1703+
button = Gtk.Button()
17041704
button.set_relief(Gtk.ReliefStyle.NONE)
17051705
button.set_can_focus(False)
1706-
image = Gtk.Image.new()
1706+
image = Gtk.Image()
17071707
image.set_from_stock(spec[0], size)
17081708
button.add(image)
17091709
image.show()
@@ -1714,7 +1714,7 @@ def _append_buttons(box, size, specs):
17141714
box.pack_start(button, False, False, 0)
17151715
button.show()
17161716
else:
1717-
separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
1717+
separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
17181718
box.pack_start(separator, False, False, 5)
17191719
separator.show()
17201720

0 commit comments

Comments
 (0)