Main application window.
| 244 | |
| 245 | |
| 246 | class DesktopPuppetWindow(Adw.ApplicationWindow): |
| 247 | """Main application window.""" |
| 248 | |
| 249 | def __init__(self, app): |
| 250 | super().__init__(application=app, title="DesktopPuppet Controller") |
| 251 | self.set_default_size(900, 700) |
| 252 | |
| 253 | self.launcher = PuppetLauncher() |
| 254 | self.controller = PuppetController() |
| 255 | self.viewer_url = None |
| 256 | self.current_model_path = None |
| 257 | self._monitor_thread = None |
| 258 | self._stop_monitor = False |
| 259 | |
| 260 | self._setup_ui() |
| 261 | self._load_models() |
| 262 | |
| 263 | def _setup_ui(self): |
| 264 | """Setup the user interface.""" |
| 265 | # Main box |
| 266 | self.main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) |
| 267 | self.set_content(self.main_box) |
| 268 | |
| 269 | # Header bar |
| 270 | header = Adw.HeaderBar() |
| 271 | self.main_box.append(header) |
| 272 | |
| 273 | # Status bar |
| 274 | self.status_bar = Adw.Banner() |
| 275 | self.status_bar.set_revealed(False) |
| 276 | self.main_box.append(self.status_bar) |
| 277 | |
| 278 | # Main content - ScrolledWindow |
| 279 | scrolled = Gtk.ScrolledWindow() |
| 280 | scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) |
| 281 | scrolled.set_vexpand(True) |
| 282 | self.main_box.append(scrolled) |
| 283 | |
| 284 | # Content box |
| 285 | content_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12) |
| 286 | content_box.set_margin_top(12) |
| 287 | content_box.set_margin_bottom(12) |
| 288 | content_box.set_margin_start(12) |
| 289 | content_box.set_margin_end(12) |
| 290 | scrolled.set_child(content_box) |
| 291 | |
| 292 | # ===== Model Selection Section ===== |
| 293 | model_group = Adw.PreferencesGroup(title="Model Selection") |
| 294 | content_box.append(model_group) |
| 295 | |
| 296 | # Model folder row |
| 297 | self.folder_row = Adw.ActionRow( |
| 298 | title="Models Folder", |
| 299 | subtitle=self.launcher.models_dir |
| 300 | ) |
| 301 | self.folder_row.add_suffix(Gtk.Image.new_from_icon_name("folder-open-symbolic")) |
| 302 | self.folder_row.set_activatable(True) |
| 303 | self.folder_row.connect("activated", self._on_browse_folder) |