fix: restore working Bluetooth functionality in control center by reverting to direct initialization
Bluetooth in control center was failing with AttributeError: 'Device' object has no attribute 'get_paired'. Restored the working initialization pattern from 20 commits back where BluetoothClient is created directly during control center initialization rather than lazy loading, which avoids the device enumeration error. 🤖 Generated with [opencode](https://opencode.ai)
This commit is contained in:
1 parent
b5211b3446
commit
26587a4717
2 files changed
+11
-13
No files matched your search
@@ -87,17 +87,18 @@ class BluetoothConnections(Box):
|
|||||||
|
|
||||||
self.toggle_button = Gtk.Switch(visible=True, name="toggle-button")
|
self.toggle_button = Gtk.Switch(visible=True, name="toggle-button")
|
||||||
|
|
||||||
|
# Safely set initial state
|
||||||
self.toggle_button.set_active(self.client.enabled)
|
self.toggle_button.set_active(self.client.enabled)
|
||||||
self.toggle_button.connect(
|
self.toggle_button.connect(
|
||||||
"notify::active",
|
"notify::active",
|
||||||
lambda *_: self.client.set_enabled(self.toggle_button.get_active()),
|
lambda *_: self.client.set_enabled(self.toggle_button.get_active()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Connect client signals
|
||||||
self.client.connect(
|
self.client.connect(
|
||||||
"notify::enabled",
|
"notify::enabled",
|
||||||
lambda *_: self.toggle_button.set_active(self.client.enabled),
|
lambda *_: self.toggle_button.set_active(self.client.enabled),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Connect scanning state changes to update scan button
|
# Connect scanning state changes to update scan button
|
||||||
self.client.connect("notify::scanning", lambda *_: self.update_scan_label())
|
self.client.connect("notify::scanning", lambda *_: self.update_scan_label())
|
||||||
|
|
||||||
|
|||||||
@@ -44,16 +44,12 @@ class ModusControlCenter(Window):
|
|||||||
self._updating_volume = False
|
self._updating_volume = False
|
||||||
|
|
||||||
# Lazy loading flags
|
# Lazy loading flags
|
||||||
self._wifi_initialized = False
|
|
||||||
self._bluetooth_initialized = False
|
|
||||||
self._music_initialized = False
|
self._music_initialized = False
|
||||||
self._per_app_volume_initialized = False
|
self._per_app_volume_initialized = False
|
||||||
self._expanded_player_initialized = False
|
self._expanded_player_initialized = False
|
||||||
|
|
||||||
# Store references for cleanup
|
# Store references for cleanup
|
||||||
self._signal_connections = []
|
self._signal_connections = []
|
||||||
self._wifi_man = None
|
|
||||||
self._bluetooth_man = None
|
|
||||||
self._music_widget_content = None
|
self._music_widget_content = None
|
||||||
self._per_app_volume_widget = None
|
self._per_app_volume_widget = None
|
||||||
self._expanded_player_widget = None
|
self._expanded_player_widget = None
|
||||||
@@ -304,6 +300,13 @@ class ModusControlCenter(Window):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Initialize managers directly like working version
|
||||||
|
self.wifi_man = WifiConnections(self)
|
||||||
|
self.bluetooth_man = BluetoothConnections(self)
|
||||||
|
|
||||||
|
self.has_bluetooth_open = False
|
||||||
|
self.has_wifi_open = False
|
||||||
|
|
||||||
# Lazy-loaded widgets - create placeholders
|
# Lazy-loaded widgets - create placeholders
|
||||||
self.bluetooth_widgets = None
|
self.bluetooth_widgets = None
|
||||||
self.wifi_widgets = None
|
self.wifi_widgets = None
|
||||||
@@ -355,9 +358,6 @@ class ModusControlCenter(Window):
|
|||||||
def _ensure_bluetooth_widgets(self):
|
def _ensure_bluetooth_widgets(self):
|
||||||
"""Lazy load bluetooth widgets"""
|
"""Lazy load bluetooth widgets"""
|
||||||
if self.bluetooth_widgets is None:
|
if self.bluetooth_widgets is None:
|
||||||
if self._bluetooth_man is None:
|
|
||||||
self._bluetooth_man = BluetoothConnections(self)
|
|
||||||
|
|
||||||
self.bluetooth_widgets = Box(
|
self.bluetooth_widgets = Box(
|
||||||
orientation="vertical",
|
orientation="vertical",
|
||||||
h_expand=True,
|
h_expand=True,
|
||||||
@@ -374,7 +374,7 @@ class ModusControlCenter(Window):
|
|||||||
style_classes="menu",
|
style_classes="menu",
|
||||||
spacing=5,
|
spacing=5,
|
||||||
children=[
|
children=[
|
||||||
self._bluetooth_man,
|
self.bluetooth_man,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -387,9 +387,6 @@ class ModusControlCenter(Window):
|
|||||||
def _ensure_wifi_widgets(self):
|
def _ensure_wifi_widgets(self):
|
||||||
"""Lazy load wifi widgets"""
|
"""Lazy load wifi widgets"""
|
||||||
if self.wifi_widgets is None:
|
if self.wifi_widgets is None:
|
||||||
if self._wifi_man is None:
|
|
||||||
self._wifi_man = WifiConnections(self)
|
|
||||||
|
|
||||||
self.wifi_widgets = Box(
|
self.wifi_widgets = Box(
|
||||||
orientation="vertical",
|
orientation="vertical",
|
||||||
h_expand=True,
|
h_expand=True,
|
||||||
@@ -406,7 +403,7 @@ class ModusControlCenter(Window):
|
|||||||
style_classes="menu",
|
style_classes="menu",
|
||||||
spacing=5,
|
spacing=5,
|
||||||
children=[
|
children=[
|
||||||
self._wifi_man,
|
self.wifi_man,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in new issue
Block a user