♻️ refactor(dashboard): consolidate hover cursor function into tile module
This commit is contained in:
3 files changed
+13
-16
No files matched your search
@@ -5,18 +5,11 @@ from fabric.widgets.centerbox import CenterBox
|
|||||||
from fabric.widgets.image import Image
|
from fabric.widgets.image import Image
|
||||||
from fabric.widgets.label import Label
|
from fabric.widgets.label import Label
|
||||||
from fabric.widgets.scrolledwindow import ScrolledWindow
|
from fabric.widgets.scrolledwindow import ScrolledWindow
|
||||||
from gi.repository import Gdk
|
|
||||||
|
|
||||||
from modules.dashboard.tile import Tile
|
from modules.dashboard.tile import Tile, add_hover_cursor
|
||||||
import utils.icons as icons
|
import utils.icons as icons
|
||||||
|
|
||||||
|
|
||||||
def add_hover_cursor(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)
|
|
||||||
|
|
||||||
|
|
||||||
class BluetoothDeviceSlot(CenterBox):
|
class BluetoothDeviceSlot(CenterBox):
|
||||||
"""A widget representing a single Bluetooth device in the dashboard."""
|
"""A widget representing a single Bluetooth device in the dashboard."""
|
||||||
|
|
||||||
|
|||||||
@@ -5,19 +5,13 @@ from fabric.widgets.centerbox import CenterBox
|
|||||||
from fabric.widgets.image import Image
|
from fabric.widgets.image import Image
|
||||||
from fabric.widgets.label import Label
|
from fabric.widgets.label import Label
|
||||||
from fabric.widgets.scrolledwindow import ScrolledWindow
|
from fabric.widgets.scrolledwindow import ScrolledWindow
|
||||||
from gi.repository import Gtk, Gdk, GLib
|
from gi.repository import Gtk, GLib
|
||||||
|
|
||||||
from modules.dashboard.tile import Tile
|
from modules.dashboard.tile import Tile, add_hover_cursor
|
||||||
from services.network import NetworkClient
|
from services.network import NetworkClient
|
||||||
import utils.icons as icons
|
import utils.icons as icons
|
||||||
|
|
||||||
|
|
||||||
def add_hover_cursor(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)
|
|
||||||
|
|
||||||
|
|
||||||
class WifiAccessPointSlot(CenterBox):
|
class WifiAccessPointSlot(CenterBox):
|
||||||
"""A widget representing a single WiFi access point in the dashboard."""
|
"""A widget representing a single WiFi access point in the dashboard."""
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,17 @@ from fabric.widgets.button import Button
|
|||||||
from fabric.widgets.label import Label
|
from fabric.widgets.label import Label
|
||||||
from fabric.widgets.stack import Stack
|
from fabric.widgets.stack import Stack
|
||||||
from fabric.widgets.revealer import Revealer
|
from fabric.widgets.revealer import Revealer
|
||||||
|
from gi.repository import Gdk
|
||||||
import utils.icons as icons
|
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)
|
||||||
|
|
||||||
|
|
||||||
class Tile(Box):
|
class Tile(Box):
|
||||||
"""
|
"""
|
||||||
A dashboard tile widget that displays an icon, label, and properties.
|
A dashboard tile widget that displays an icon, label, and properties.
|
||||||
@@ -96,6 +104,8 @@ class Tile(Box):
|
|||||||
child=Label(style_classes="tile-icon", markup=icons.arrow_head),
|
child=Label(style_classes="tile-icon", markup=icons.arrow_head),
|
||||||
on_clicked=self.handle_click,
|
on_clicked=self.handle_click,
|
||||||
)
|
)
|
||||||
|
# Add hover cursor to menu button
|
||||||
|
add_hover_cursor(self.menu_button)
|
||||||
content_children = [self.type_box, self.menu_button]
|
content_children = [self.type_box, self.menu_button]
|
||||||
else:
|
else:
|
||||||
content_children = [self.type_box]
|
content_children = [self.type_box]
|
||||||
|
|||||||
Reference in new issue
Block a user