mirror of
https://github.com/libratbag/piper.git
synced 2026-02-20 07:33:50 -05:00
mouseperspective: update profile list when a profile is set to active
This fixes profile list becoming wrong when you change active profile with ratbagctl.
This commit is contained in:
@@ -83,10 +83,6 @@ class MousePerspective(Gtk.Overlay):
|
||||
self._set_profile(active_profile)
|
||||
|
||||
self.button_profile.set_visible(len(device.profiles) > 1)
|
||||
name = active_profile.name
|
||||
if not name:
|
||||
name = f"Profile {active_profile.index}"
|
||||
self.label_profile.set_label(name)
|
||||
|
||||
# Find the first profile that is enabled. If there is none, disable the
|
||||
# add button.
|
||||
@@ -103,12 +99,21 @@ class MousePerspective(Gtk.Overlay):
|
||||
)
|
||||
row = ProfileRow(profile)
|
||||
self.listbox_profiles.insert(row, profile.index)
|
||||
if profile is active_profile:
|
||||
|
||||
self._select_profile_row(self._profile)
|
||||
|
||||
def _select_profile_row(self, profile: RatbagdProfile) -> None:
|
||||
for row in self.listbox_profiles.get_children():
|
||||
if row.profile is profile:
|
||||
self.listbox_profiles.select_row(row)
|
||||
self.label_profile.set_label(row.name)
|
||||
break
|
||||
|
||||
def _set_profile(self, profile: RatbagdProfile) -> None:
|
||||
assert self._device is not None
|
||||
|
||||
self._select_profile_row(profile)
|
||||
|
||||
self._profile = profile
|
||||
|
||||
self.stack.foreach(Gtk.Widget.destroy)
|
||||
@@ -165,7 +170,6 @@ class MousePerspective(Gtk.Overlay):
|
||||
self, listbox: Gtk.ListBox, row: Gtk.ListBoxRow
|
||||
) -> None:
|
||||
row.set_active()
|
||||
self.label_profile.set_label(row.name)
|
||||
|
||||
@Gtk.Template.Callback("_on_add_profile_button_clicked")
|
||||
def _on_add_profile_button_clicked(self, button: Gtk.Button) -> None:
|
||||
|
||||
@@ -51,3 +51,7 @@ class ProfileRow(Gtk.ListBoxRow):
|
||||
@GObject.Property
|
||||
def name(self) -> str:
|
||||
return self.title.get_text()
|
||||
|
||||
@GObject.Property
|
||||
def profile(self) -> RatbagdProfile:
|
||||
return self._profile
|
||||
|
||||
Reference in New Issue
Block a user