Skip to content

Latest commit

 

History

History
144 lines (107 loc) · 4.58 KB

File metadata and controls

144 lines (107 loc) · 4.58 KB

Panel Preferences Dialog Implementation

Summary

Created ~/Workspace/Lib/hobar/src/ui/preferences.rs - A complete GTK-based panel preferences dialog for hobar Wave 7.

Files Created/Modified

Created

  • ~/Workspace/Lib/hobar/src/ui/preferences.rs (786 lines)

Modified

  • ~/Workspace/Lib/hobar/src/ui/mod.rs - Added preferences module export
  • ~/Workspace/Lib/hobar/src/lib.rs - Re-exported PanelPreferencesDialog

Implementation Details

PanelPreferencesDialog Structure

The main struct contains:

  • GTK Dialog window
  • All widget references for 4 tabs (Display, Appearance, Autohide, Items)
  • Panel ID for identification

Tabs Implemented

1. Display Tab

  • Edge Position: Radio buttons for Top/Bottom/Left/Right
  • Monitor Selection: Dropdown for multi-monitor support
  • Length Controls: Slider (0-100%) and pixel spinner
  • Size (Thickness): Slider (16-128 pixels)
  • Row Count: Spinner (1-6 rows)

2. Appearance Tab

  • Background Style: Radio buttons (None/Solid/Image)
  • Color Chooser: For solid background (auto-enabled/disabled)
  • Image Chooser: For image background (auto-enabled/disabled)
  • Opacity Sliders:
    • Background opacity (0-100%)
    • Enter opacity (pointer over panel)
    • Leave opacity (pointer away)

3. Autohide Tab

  • Behavior Mode: Radio buttons (Never/Always/Intelligently)
  • Delay Controls:
    • Show delay spinner (0-2000ms)
    • Hide delay spinner (0-2000ms)

4. Items Tab (Placeholder)

  • Label explaining future plugin management features
  • Prepared for Add Items dialog integration

Methods

Core Methods

  • new(panel_id, config) -> Self - Create dialog from config
  • run() -> Option<PanelConfig> - Show dialog, return new config or None
  • populate_from_config(&config) - Load config into widgets
  • extract_config() -> PanelConfig - Read widgets into new config
  • setup_connections() - Wire up widget signals

Builder Methods

  • build_display_tab() -> DisplayTab - Construct Display UI
  • build_appearance_tab() -> AppearanceTab - Construct Appearance UI
  • build_autohide_tab() -> AutohideTab - Construct Autohide UI
  • build_items_tab() -> ItemsTab - Construct Items UI placeholder

Future

  • connect_changed<F>(&self, callback) - Live preview (stubbed)

Tests

All tests marked #[ignore] since they require GTK initialization:

  1. test_preferences_dialog_creation - Verify dialog creates with correct defaults
  2. test_config_extraction - Verify modified settings extract correctly
  3. test_background_style_connections - Test radio button enable/disable logic
  4. test_span_extraction - Test length percentage to Span conversion

Integration

The dialog integrates with existing hobar infrastructure:

  • Config System: Uses PanelConfig, AutohideConfig, AutohideBehavior
  • Position System: Uses Position, Edge, Align, Span
  • GTK Prelude: Standard gtk-rs widget patterns

Usage Example

use hobar::ui::PanelPreferencesDialog;
use hobar::config::PanelConfig;

let config = PanelConfig::default();
let dialog = PanelPreferencesDialog::new(0, &config);

if let Some(new_config) = dialog.run() {
    // User clicked OK - save new_config
    save_config(&new_config);
} else {
    // User cancelled
}

Future Enhancements

Items marked with TODO comments in the code:

  1. Display Tab:

    • Add alignment controls (Start/Center/End)
    • Wire monitor combo to actual monitor detection
    • Implement pixel-based length input
    • Add multi-row panel support
  2. Appearance Tab:

    • Extract/apply background color
    • Extract/apply background image
    • Wire opacity controls to actual panel rendering
    • Add dark mode toggle
  3. Autohide Tab:

    • All core functionality implemented
  4. Items Tab:

    • Plugin list view with current plugins
    • Add/Remove buttons
    • Reorder controls (up/down/drag)
    • Per-plugin configuration button
    • Integration with Add Items dialog
  5. Live Preview:

    • Implement connect_changed callback wiring
    • Connect all widgets to trigger preview updates
    • Apply changes to panel in real-time

Notes

  • Widget sensitivity (enable/disable) properly managed for radio button groups
  • All unused fields marked with #[allow(dead_code)] and documented for future use
  • Code follows hobar VTR-driven development philosophy with extensive inline docs
  • Mirrors xfce4-panel preferences UI for familiarity

Compilation Status

The preferences.rs module itself compiles successfully. There are unrelated compilation errors in plugin_picker.rs (another parallel worker's module) that need to be fixed separately.