Refactor status handling: remove status bar widget and update to use footer subtitle for status messages

This commit is contained in:
Philip Henning 2025-07-30 16:17:01 +02:00
parent 4dbf200c5f
commit 1167521355
2 changed files with 5 additions and 37 deletions

View file

@ -87,9 +87,6 @@ class HostsManagerApp(App):
yield Input(placeholder="Enter comment (optional)", id="comment-input")
yield Checkbox("Active", id="active-checkbox")
# Status bar
yield Static("", id="status", classes="status-bar")
def on_ready(self) -> None:
"""Called when the app is ready."""
self.load_hosts_file()
@ -114,30 +111,18 @@ class HostsManagerApp(App):
self.update_status(f"❌ Error loading hosts file: {e}")
def update_status(self, message: str = "") -> None:
"""Update the status bar."""
status_widget = self.query_one("#status", Static)
"""Update the footer subtitle with status information."""
if message:
# Check if this is an error message (starts with ❌)
# Set temporary status message
self.sub_title = message
if message.startswith(""):
# Use error styling for error messages
status_widget.remove_class("status-bar")
status_widget.add_class("status-error")
status_widget.update(message)
# Auto-clear error message after 5 seconds
self.set_timer(5.0, lambda: self.update_status())
else:
# Use normal styling for regular messages
status_widget.remove_class("status-error")
status_widget.add_class("status-bar")
status_widget.update(message)
# Auto-clear regular message after 3 seconds
# Auto-clear regular message after 3 seconds
self.set_timer(3.0, lambda: self.update_status())
else:
# Reset to normal status display
status_widget.remove_class("status-error")
status_widget.add_class("status-bar")
mode = "Edit mode" if self.edit_mode else "Read-only mode"
entry_count = len(self.hosts_file.entries)
active_count = len(self.hosts_file.get_active_entries())
@ -149,7 +134,7 @@ class HostsManagerApp(App):
if file_info["exists"]:
status_text += f" | {file_info['path']}"
status_widget.update(status_text)
self.sub_title = status_text
# Event handlers
def on_data_table_row_highlighted(self, event: DataTable.RowHighlighted) -> None:

View file

@ -34,23 +34,6 @@ HOSTS_MANAGER_CSS = """
text-style: italic;
}
.status-bar {
background: $surface;
color: $text;
height: 1;
padding: 0 1;
dock: bottom;
}
.status-error {
background: $error;
color: $text;
height: 1;
padding: 0 1;
text-style: bold;
dock: bottom;
}
/* DataTable styling to match background */
#entries-table {
background: $background;