add calendar widget and fixes some error
This commit is contained in:
10 files changed
+132
-12
No files matched your search
@@ -34,6 +34,11 @@
|
||||
"command": ":p",
|
||||
"description": "Shutdown and go sleepy time",
|
||||
"handler": "show_powermenu"
|
||||
},
|
||||
{
|
||||
"command": ":cl",
|
||||
"description": "Show the calendar",
|
||||
"handler": "show_calendar"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
import os
|
||||
|
||||
import setproctitle
|
||||
from fabric import Application
|
||||
from fabric.utils import get_relative_path, monitor_file
|
||||
from loguru import logger
|
||||
|
||||
from fabric import Application
|
||||
from fabric.utils import get_relative_path, monitor_file
|
||||
from modules.bar.bar import Bar
|
||||
from modules.launcher.launcher import Launcher
|
||||
from modules.notifications import NotificationPopup
|
||||
from modules.notification_popup import NotificationPopup
|
||||
from modules.osd import OSDContainer
|
||||
from services import ScreenRecorder
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from fabric import Application
|
||||
from fabric.utils import (
|
||||
get_desktop_applications,
|
||||
get_relative_path,
|
||||
idle_add,
|
||||
invoke_repeater,
|
||||
remove_handler,
|
||||
@@ -13,8 +11,10 @@ from fabric.widgets.label import Label
|
||||
from fabric.widgets.revealer import Revealer
|
||||
from fabric.widgets.scrolledwindow import ScrolledWindow
|
||||
from fabric.widgets.wayland import WaylandWindow as Window
|
||||
|
||||
from modules.launcher.widgets import (
|
||||
BluetoothMenu,
|
||||
Calendar,
|
||||
ClipboardManager,
|
||||
EmojiManager,
|
||||
PowerMenu,
|
||||
@@ -63,6 +63,7 @@ class Launcher(Window):
|
||||
self.power_menu = PowerMenu(self)
|
||||
self.bluetooth_menu = BluetoothMenu(self)
|
||||
self.network_menu = WifiMenu(self)
|
||||
self.calendar_menu = Calendar(self)
|
||||
|
||||
def setup_ui(self):
|
||||
self.default_button = Button(
|
||||
@@ -272,9 +273,8 @@ class Launcher(Window):
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# launcher = Launcher()
|
||||
# app = Application("launcher", launcher)
|
||||
# app.set_stylesheet_from_file(get_relative_path("./styles/main.css"))
|
||||
# app.run()
|
||||
def show_calendar(self, *_):
|
||||
self.calendar_menu.show_calendar_menu(self.viewport)
|
||||
dynamic_buttons = self.calendar_menu.get_calendar_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
@@ -1,5 +1,6 @@
|
||||
from .app import *
|
||||
from .bluetooth import *
|
||||
from .calendar import *
|
||||
from .clipboard import *
|
||||
from .emoji import *
|
||||
from .power_menu import *
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from snippets import GtkCalendar, MaterialIcon
|
||||
|
||||
|
||||
class Calendar:
|
||||
def __init__(self, launcher):
|
||||
self.launcher = launcher
|
||||
self.today_button = Button(
|
||||
child=MaterialIcon("event_available"),
|
||||
v_align="center",
|
||||
)
|
||||
|
||||
def show_calendar_menu(self, viewport):
|
||||
viewport.children = []
|
||||
|
||||
calendar_container = Box(
|
||||
name="calendar",
|
||||
children=GtkCalendar(h_expand=True),
|
||||
)
|
||||
|
||||
viewport.add(calendar_container)
|
||||
|
||||
def get_calendar_buttons(self):
|
||||
return self.today_button
|
||||
@@ -74,7 +74,7 @@ class PowerMenu:
|
||||
orientation="h",
|
||||
spacing=10,
|
||||
children=[
|
||||
MaterialIcon(option["icon"], size="28px"),
|
||||
MaterialIcon(option["icon"], size=28),
|
||||
Label(label=option["label"], h_align="start"),
|
||||
],
|
||||
),
|
||||
|
||||
File renamed without changes.
@@ -1,4 +1,5 @@
|
||||
from .animator import *
|
||||
from .calendar import *
|
||||
from .custom_image import *
|
||||
from .functions import *
|
||||
from .icon import *
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
from collections.abc import Iterable
|
||||
from typing import Literal
|
||||
|
||||
import gi
|
||||
from fabric.widgets.widget import Widget
|
||||
from gi.repository import Gtk
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
|
||||
|
||||
class GtkCalendar(Gtk.Calendar, Widget):
|
||||
"""A switch widget."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: str | None = None,
|
||||
h_align: (
|
||||
Literal["fill", "start", "end", "center", "baseline"] | Gtk.Align | None
|
||||
) = None,
|
||||
v_align: (
|
||||
Literal["fill", "start", "end", "center", "baseline"] | Gtk.Align | None
|
||||
) = None,
|
||||
h_expand: bool = False,
|
||||
v_expand: bool = False,
|
||||
tooltip_text: str | None = None,
|
||||
tooltip_markup: str | None = None,
|
||||
visible: bool = True,
|
||||
all_visible: bool = False,
|
||||
style: str | None = None,
|
||||
style_classes: Iterable[str] | str | None = None,
|
||||
**kwargs,
|
||||
):
|
||||
Gtk.Calendar.__init__(self) # type: ignore
|
||||
Widget.__init__(
|
||||
self,
|
||||
name,
|
||||
visible,
|
||||
all_visible,
|
||||
style,
|
||||
style_classes,
|
||||
tooltip_text,
|
||||
tooltip_markup,
|
||||
h_align,
|
||||
v_align,
|
||||
h_expand,
|
||||
v_expand,
|
||||
**kwargs,
|
||||
)
|
||||
@@ -144,3 +144,43 @@
|
||||
background-color: @surfaceVariant;
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
#calendar calendar {
|
||||
all: unset;
|
||||
font-size: 18px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#calendar calendar.button {
|
||||
all: unset;
|
||||
transition: 200ms;
|
||||
border-radius: 10px;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#calendar calendar:selected {
|
||||
box-shadow:
|
||||
inset 0 -7px 0 0 @primary,
|
||||
inset 0 0 0 1px @surfaceVariant;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
#calendar calendar.header {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#calendar calendar.highlight {
|
||||
background-color: transparent;
|
||||
color: @onSurface;
|
||||
}
|
||||
|
||||
#calendar calendar:hover {
|
||||
color: @errorContainer;
|
||||
}
|
||||
|
||||
#calendar calendar:indeterminate {
|
||||
color: mix(@onSurfaceVariant, transparent, 0.3);
|
||||
}
|
||||
Reference in new issue
Block a user