From 232518f2e619412899d870d953518bb2301ab2af Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 27 Jul 2025 09:28:03 +0545 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=85=20style(dashboard):=20format=20cod?= =?UTF-8?q?e=20for=20readability=20and=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dashboard/main.py | 8 +++- modules/dashboard/tile.py | 77 ++++++++++----------------------------- 2 files changed, 26 insertions(+), 59 deletions(-) diff --git a/modules/dashboard/main.py b/modules/dashboard/main.py index 6186503..bce838e 100644 --- a/modules/dashboard/main.py +++ b/modules/dashboard/main.py @@ -88,7 +88,11 @@ class Dashboard(Box): ] def handle_tile_menu_expand(self, tile: str, toggle: bool): - print(f"Tile menu expand: {tile}, toggle: {toggle}, active_tile: {self.active_tile}") + print( + f"Tile menu expand: {tile}, toggle: {toggle}, active_tile: { + self.active_tile + }" + ) # If clicking the same tile that's already active, deactivate it if self.active_tile == tile and toggle: @@ -125,7 +129,7 @@ class Dashboard(Box): # Reset all tile toggle states for tile in self.tiles: - if hasattr(tile, 'toggle'): + if hasattr(tile, "toggle"): tile.toggle = False diff --git a/modules/dashboard/tile.py b/modules/dashboard/tile.py index 31905f3..f6378d0 100644 --- a/modules/dashboard/tile.py +++ b/modules/dashboard/tile.py @@ -32,8 +32,18 @@ import utils.icons as icons def add_hover_cursor(widget): """Add hover cursor functionality to a widget.""" widget.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK) - widget.connect("enter-notify-event", lambda w, e: w.get_window().set_cursor(Gdk.Cursor.new_from_name(w.get_display(), "pointer")) if w.get_window() else None) - widget.connect("leave-notify-event", lambda w, e: w.get_window().set_cursor(None) if w.get_window() else None) + widget.connect( + "enter-notify-event", + lambda w, e: w.get_window().set_cursor( + Gdk.Cursor.new_from_name(w.get_display(), "pointer") + ) + if w.get_window() + else None, + ) + widget.connect( + "leave-notify-event", + lambda w, e: w.get_window().set_cursor(None) if w.get_window() else None, + ) class Tile(Box): @@ -71,17 +81,12 @@ class Tile(Box): def _create_tile_icon(self, markup: str): """Create the tile's icon label.""" - self.icon = Label( - style_classes="tile-icon", - markup=markup - ) + self.icon = Label(style_classes="tile-icon", markup=markup) def _create_tile_content(self, label: str): """Create the tile's text content area.""" self.tile_label = Label( - style_classes="tile-label", - label=label, - h_align="start" + style_classes="tile-label", label=label, h_align="start" ) # Container for label and properties @@ -136,7 +141,9 @@ class Tile(Box): # Create placeholder menu (content is shown in dashboard content area) self.menu = Box( style_classes="tile-menu", - children=[Label(label="Tile content will be shown in dashboard content area")], + children=[ + Label(label="Tile content will be shown in dashboard content area") + ], ) # Stack to switch between normal and menu views @@ -161,31 +168,9 @@ class Tile(Box): # Notify dashboard to handle content switching if self.dashboard_instance: - self.dashboard_instance.handle_tile_menu_expand(self.get_name(), self.toggle) - - def mini_view(self): - """ - Switch tile to mini (compact) view. - - In mini view, the tile content is hidden and only the icon is shown. - This is used when other tiles are active. - """ - self.content_button.set_reveal_child(False) - self.icon.set_h_expand(True) - self.content_button.set_h_expand(False) - self.add_style_class("mini") - - def maxi_view(self): - """ - Switch tile to maxi (full) view. - - In maxi view, the tile shows its full content including label and properties. - This is the default state when no tiles are active. - """ - self.content_button.set_reveal_child(True) - self.icon.set_h_expand(False) - self.content_button.set_h_expand(True) - self.remove_style_class("mini") + self.dashboard_instance.handle_tile_menu_expand( + self.get_name(), self.toggle + ) class TileSpecial(Box): @@ -228,25 +213,3 @@ class TileSpecial(Box): children=[self.normal_view, self.collapsed_view], ) self.children = self.stack - - def mini_view(self): - """ - Switch to mini (collapsed) view. - - Hides the normal view and shows the compact mini view. - Uses negative margins to hide the normal view completely. - """ - self.normal_view.set_style("margin:-999px") - self.collapsed_view.set_style("margin:0px;") - self.stack.set_visible_child(self.collapsed_view) - - def maxi_view(self): - """ - Switch to maxi (normal) view. - - Hides the mini view and shows the full normal view. - Uses negative margins to hide the collapsed view completely. - """ - self.collapsed_view.set_style("margin:-999px") - self.normal_view.set_style("margin:0px;") - self.stack.set_visible_child(self.normal_view)