[GTK3] Use explicitly named functions for creating menuitems

See https://wiki.gnome.org/Projects/PyGObject/InitializerDeprecations
This commit is contained in:
Calum Lind 2018-09-20 14:54:44 +01:00 committed by Calum Lind
parent 4111f94597
commit bcaaeac852
4 changed files with 15 additions and 15 deletions

View File

@ -119,7 +119,7 @@ def build_menu_radio_list(
item_text = str(value)
if suffix:
item_text += ' ' + suffix
menuitem = RadioMenuItem(group=group, label=item_text)
menuitem = RadioMenuItem.new_with_label(group, item_text)
group = menuitem
if pref_value and value == pref_value:
menuitem.set_active(True)
@ -128,7 +128,7 @@ def build_menu_radio_list(
menu.append(menuitem)
if show_notset:
menuitem = RadioMenuItem(group=group, label=notset_label)
menuitem = RadioMenuItem.new_with_label(group, notset_label)
menuitem.set_name('unlimited')
if pref_value and pref_value < notset_lessthan:
menuitem.set_active(True)
@ -138,7 +138,7 @@ def build_menu_radio_list(
if show_other:
menuitem = SeparatorMenuItem()
menu.append(menuitem)
menuitem = MenuItem(_('Other...'))
menuitem = MenuItem.new_with_label(_('Other...'))
menuitem.set_name('other')
menuitem.connect('activate', callback)
menu.append(menuitem)

View File

@ -367,7 +367,7 @@ class ListView(object):
# menu.
if column.hidden is True:
continue
menuitem = Gtk.CheckMenuItem(column.name)
menuitem = Gtk.CheckMenuItem.new_with_label(column.name)
# If the column is currently visible, make sure it's set active
# (or checked) in the menu.
if column.column.get_visible() is True:

View File

@ -76,11 +76,11 @@ class MenuBar(component.Component):
'menuitem_upload_slots',
):
submenu = Gtk.Menu()
item = Gtk.MenuItem(_('Set Unlimited'))
item = Gtk.MenuItem.new_with_label(_('Set Unlimited'))
item.set_name(menuitem)
item.connect('activate', self.on_menuitem_set_unlimited)
submenu.append(item)
item = Gtk.MenuItem(_('Other...'))
item = Gtk.MenuItem.new_with_label(_('Other...'))
item.set_name(menuitem)
item.connect('activate', self.on_menuitem_set_other)
submenu.append(item)
@ -88,20 +88,20 @@ class MenuBar(component.Component):
self.builder.get_object(menuitem).set_submenu(submenu)
submenu = Gtk.Menu()
item = Gtk.MenuItem(_('On'))
item = Gtk.MenuItem.new_with_label(_('On'))
item.connect('activate', self.on_menuitem_set_automanaged_on)
submenu.append(item)
item = Gtk.MenuItem(_('Off'))
item = Gtk.MenuItem.new_with_label(_('Off'))
item.connect('activate', self.on_menuitem_set_automanaged_off)
submenu.append(item)
submenu.show_all()
self.builder.get_object('menuitem_auto_managed').set_submenu(submenu)
submenu = Gtk.Menu()
item = Gtk.MenuItem(_('Disable'))
item = Gtk.MenuItem.new_with_label(_('Disable'))
item.connect('activate', self.on_menuitem_set_stop_seed_at_ratio_disable)
submenu.append(item)
item = Gtk.MenuItem(_('Enable...'))
item = Gtk.MenuItem.new_with_label(_('Enable...'))
item.set_name('menuitem_stop_seed_at_ratio')
item.connect('activate', self.on_menuitem_set_other)
submenu.append(item)
@ -552,13 +552,13 @@ class MenuBar(component.Component):
self.change_owner_submenu = Gtk.Menu()
self.change_owner_submenu_items = {}
maingroup = Gtk.RadioMenuItem(None, None)
maingroup = Gtk.RadioMenuItem()
self.change_owner_submenu_items[None] = Gtk.RadioMenuItem(group=maingroup)
self.change_owner_submenu_items[None] = Gtk.RadioMenuItem(maingroup)
for account in known_accounts:
username = account['username']
item = Gtk.RadioMenuItem(group=maingroup, label=username)
item = Gtk.RadioMenuItem.new_with_label(maingroup, username)
self.change_owner_submenu_items[username] = item
self.change_owner_submenu.append(item)
item.connect('toggled', self._on_change_owner_toggled, username)

View File

@ -390,9 +390,9 @@ class StoredValuesList(ValueList):
treeview.set_cursor(path, col, 0)
self.path_list_popup = Gtk.Menu()
menuitem_edit = Gtk.MenuItem('Edit path')
menuitem_edit = Gtk.MenuItem.new_with_label('Edit path')
self.path_list_popup.append(menuitem_edit)
menuitem_remove = Gtk.MenuItem('Remove path')
menuitem_remove = Gtk.MenuItem.new_with_label('Remove path')
self.path_list_popup.append(menuitem_remove)
def on_edit_clicked(widget, path):