Unable to explicitly set GtkModelButton role
Steps to reproduce
- Create ModelButton with a stateful
action-name
and arole
- Try using the
pygobject
widget props attribute - Try using the
set_property
method
def _set_profile_menu(self):
self.profile_menu_button_label.set_label(App().session.active.profile_name)
if len(App().session.available_profiles) > 1:
self.profile_menu = Gtk.PopoverMenu()
profile_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, margin=10)
self.profile_menu.add(profile_box)
for profile in App().session.available_profiles:
if profile != App().session.active.profile_name:
profile_menu_item = Gtk.ModelButton(
text=profile, role=Gtk.ButtonRole.NORMAL,
action_name="app.switch_profile", action_target=GLib.Variant.new_string(profile))
profile_menu_item.props.role = Gtk.ButtonRole.NORMAL
profile_menu_item.set_property('role', Gtk.ButtonRole.NORMAL)
profile_box.add(profile_menu_item)
profile_box.show_all()
self.profile_menu_button.set_popover(self.profile_menu)
Current behavior
GtkModelButton still assumes role from
action-name
Expected outcome
Explicitly set role
property is preserved.
Version information
- Arch Linux
gtk3 3.22.29+4+gb485cf91b5-1
python-gobject 3.28.1-1
Additional information
Trying to override the radio CSS node (even interactively), documented here, has no effect. Is this worthy of an additional bug report? i.e.
modelbutton radio {
opacity: 0;
}
Workaround
I have worked around this by calling the set_property
method in a realize
signal handler for each button.I am not sure if this is good practice.