refactor(notch): inherit NotchPill, accept idle_widget
This commit is contained in:
1 file changed
+8
-54
@@ -1,7 +1,5 @@
|
|||||||
from fabric.utils import Gdk, GLib, Gtk, logger
|
from fabric.utils import Gdk, GLib, Gtk, logger
|
||||||
from fabric.widgets.box import Box
|
from fabric.widgets.box import Box
|
||||||
from fabric.widgets.centerbox import CenterBox
|
|
||||||
from fabric.widgets.shapes import Corner
|
|
||||||
from fabric.widgets.stack import Stack
|
from fabric.widgets.stack import Stack
|
||||||
|
|
||||||
from services.modus import screen_recorder_service
|
from services.modus import screen_recorder_service
|
||||||
@@ -13,22 +11,13 @@ from window.panel.notch.indicators import (
|
|||||||
MicrophoneIndicator,
|
MicrophoneIndicator,
|
||||||
NumLockIndicator,
|
NumLockIndicator,
|
||||||
)
|
)
|
||||||
|
from window.panel.notch.pill import NotchPill
|
||||||
from window.panel.notch.player import NotchPlayer
|
from window.panel.notch.player import NotchPlayer
|
||||||
from window.panel.notch.recording import RecordingIndicator
|
from window.panel.notch.recording import RecordingIndicator
|
||||||
|
|
||||||
|
|
||||||
class Notch(Box):
|
class Notch(NotchPill):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, idle_widget=None, **kwargs):
|
||||||
super().__init__(
|
|
||||||
name="panel-notch-wrap",
|
|
||||||
orientation="h",
|
|
||||||
spacing=0,
|
|
||||||
v_align="center",
|
|
||||||
h_align="center",
|
|
||||||
h_expand=False,
|
|
||||||
**kwargs,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.recording_indicator = RecordingIndicator()
|
self.recording_indicator = RecordingIndicator()
|
||||||
self.recording_indicator.set_hexpand(True)
|
self.recording_indicator.set_hexpand(True)
|
||||||
self.recording_indicator.set_halign(Gtk.Align.FILL)
|
self.recording_indicator.set_halign(Gtk.Align.FILL)
|
||||||
@@ -37,9 +26,10 @@ class Notch(Box):
|
|||||||
self.player_widget.set_hexpand(True)
|
self.player_widget.set_hexpand(True)
|
||||||
self.player_widget.set_halign(Gtk.Align.FILL)
|
self.player_widget.set_halign(Gtk.Align.FILL)
|
||||||
|
|
||||||
self.idle_widget = Box(
|
self.idle_widget = (
|
||||||
name="notch-idle",
|
idle_widget
|
||||||
h_expand=True,
|
if idle_widget is not None
|
||||||
|
else Box(name="notch-idle", h_expand=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
self._last_scroll_index = 0
|
self._last_scroll_index = 0
|
||||||
@@ -98,43 +88,7 @@ class Notch(Box):
|
|||||||
)
|
)
|
||||||
self._last_stack_page = 0
|
self._last_stack_page = 0
|
||||||
|
|
||||||
self.left_corner = Box(
|
super().__init__(center_widget=self.notch_stack, **kwargs)
|
||||||
name="panel-notch-corner-left",
|
|
||||||
orientation="v",
|
|
||||||
h_align="start",
|
|
||||||
children=[
|
|
||||||
Corner(
|
|
||||||
name="panel-notch-corner",
|
|
||||||
orientation="top-right",
|
|
||||||
size=20,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
self.right_corner = Box(
|
|
||||||
name="panel-notch-corner-right",
|
|
||||||
orientation="v",
|
|
||||||
h_align="end",
|
|
||||||
children=[
|
|
||||||
Corner(
|
|
||||||
name="panel-notch-corner",
|
|
||||||
orientation="top-left",
|
|
||||||
size=20,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
self.notch_box = CenterBox(
|
|
||||||
name="panel-notch",
|
|
||||||
orientation="h",
|
|
||||||
h_align="center",
|
|
||||||
v_align="center",
|
|
||||||
start_children=self.left_corner,
|
|
||||||
center_children=self.notch_stack,
|
|
||||||
end_children=self.right_corner,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.add(self.notch_box)
|
|
||||||
|
|
||||||
self._init_state()
|
self._init_state()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user