Repository navigation
Expand file tree
/
Copy pathgtk_main.py
More file actions
2024 lines (1705 loc) · 87.1 KB
/
Copy pathgtk_main.py
File metadata and controls
2024 lines (1705 loc) · 87.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys
import math
import cairo
import os
import json
import calendar
from datetime import datetime
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Pango', '1.0')
from gi.repository import Gtk, Gdk, GLib, Pango, GdkPixbuf
try:
gi.require_version('GtkLayerShell', '0.1')
from gi.repository import GtkLayerShell
HAS_LAYER_SHELL = True
except ValueError:
HAS_LAYER_SHELL = False
from tweening import Tween, Easing, ParallelAnimationGroup
from media_monitor import MediaMonitor
from notification_monitor import NotificationMonitor
from weather_monitor import WeatherMonitor
from app_styles import get_stylesheet
from event_monitor import KeyLockMonitor
from battery_monitor import BatteryMonitor
from system_monitor import SystemMonitor
class DynamicIsland(Gtk.Window):
IDLE_W, IDLE_H = 180, 40
COMPACT_W, COMPACT_H = 160, 40
MEDIA_W, MEDIA_H = 400, 140
NOTIFY_W, NOTIFY_H = 240, 44
SYSTEM_W, SYSTEM_H = 305, 120
BATTERY_W, BATTERY_H = 320, 44
CALENDAR_W, CALENDAR_H = 400, 190
SETTINGS_W, SETTINGS_H = 220, 390
# Vertical pill for left/right sidebar: swap IDLE dims
SIDEBAR_IDLE_W, SIDEBAR_IDLE_H = 40, 180
# Square media card for left/right sidebar
SIDEBAR_MEDIA_W, SIDEBAR_MEDIA_H = 200, 200
def __init__(self):
super().__init__(type=Gtk.WindowType.TOPLEVEL)
self.config_path = os.path.expanduser("~/.config/dynamic_island_config.json")
self.app_config = {
"theme": "Frosted Black",
"time_format": "24h",
"position": "top"
}
self.load_config()
if self.app_config.get("position", "top") in ("left", "right"):
self.island_w = self.SIDEBAR_IDLE_W
self.island_h = self.SIDEBAR_IDLE_H
self.border_radius = self.SIDEBAR_IDLE_W / 2.0
else:
self.island_w = self.IDLE_W
self.island_h = self.IDLE_H
self.border_radius = self.IDLE_H / 2.0
self.current_state = "Idle"
self.current_accent = "#000000"
self.target_accent = "#000000"
self.target_light_accent = "#000000"
self.old_cover_pixbuf = None
self.cover_pixbuf = None
self.old_bg_pixbuf = None
self.bg_pixbuf = None
self.art_alpha = 1.0
self.video_cap = None
self.video_timer = None
self.current_video_pixbuf = None
try:
import cv2
self.video_cap = cv2.VideoCapture("waguri.mp4")
if not self.video_cap.isOpened():
self.video_cap = None
except Exception as e:
print("Video init error:", e)
self.bg_darkness = 0.7
self.bg_opacity = 0.0
self.current_progress = 0
self.visual_progress = 0
self.current_length = 0
self.mesh_phase = 0.0
self.wave_phase = 0.0
GLib.timeout_add(33, self.on_mesh_tick)
GLib.timeout_add_seconds(1, self.update_clock)
# Setup Layer Shell
if HAS_LAYER_SHELL and GtkLayerShell.is_supported():
GtkLayerShell.init_for_window(self)
GtkLayerShell.set_namespace(self, "dynamic-island")
GtkLayerShell.set_layer(self, GtkLayerShell.Layer.TOP)
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.TOP, True)
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.BOTTOM, False)
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.LEFT, False)
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.RIGHT, False)
GtkLayerShell.set_margin(self, GtkLayerShell.Edge.TOP, 10)
GtkLayerShell.set_margin(self, GtkLayerShell.Edge.BOTTOM, 10)
GtkLayerShell.set_margin(self, GtkLayerShell.Edge.LEFT, 10)
GtkLayerShell.set_margin(self, GtkLayerShell.Edge.RIGHT, 10)
self.set_visual(self.get_screen().get_rgba_visual())
self.set_app_paintable(True)
self.set_name("IslandWidget")
self.add_events(Gdk.EventMask.SCROLL_MASK | Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK | Gdk.EventMask.BUTTON_PRESS_MASK)
self.connect("scroll-event", self.on_scroll)
self.connect("enter-notify-event", self.on_hover_enter)
self.connect("leave-notify-event", self.on_hover_leave)
self.connect("button-press-event", self.on_button_press)
self.is_hovered = False
self.collapse_timer = None
self.last_media_title = ""
self.last_media_artist = ""
self.apply_position()
self.overlay = Gtk.Overlay()
self.add(self.overlay)
# Drawing Area for background
self.drawing_area = Gtk.DrawingArea()
self.drawing_area.set_size_request(self.IDLE_W, self.IDLE_H)
self.drawing_area.connect("draw", self.on_draw)
self.overlay.add(self.drawing_area)
self.battery_status = "Unknown"
self.battery_percent = 0
self.battery_time = ""
# Content box container
self.content_opacity = 1.0
self.content_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.content_box.set_halign(Gtk.Align.CENTER)
self.content_box.set_valign(Gtk.Align.START)
self.content_box.set_margin_top(10)
self.content_box.set_size_request(self.IDLE_W - 30, -1)
# Stack for transitions
self.stack = Gtk.Stack()
self.stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
self.stack.set_transition_duration(300)
self.stack.set_hhomogeneous(False)
self.stack.set_vhomogeneous(False)
self.content_box.pack_start(self.stack, True, True, 0)
# 1. Idle/Notify Widget
self.header_widget = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
self.header_widget.set_halign(Gtk.Align.CENTER)
self.status_label = Gtk.Label(label="")
self.status_label.set_name("TitleLabel")
self.status_label.set_ellipsize(Pango.EllipsizeMode.END)
self.status_label.set_max_width_chars(25)
self.header_widget.pack_start(self.status_label, False, False, 0)
self.stack.add_named(self.header_widget, "header")
# 2. Premium Media Widget (2 Column Layout)
self.media_widget = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
self.media_widget.set_halign(Gtk.Align.FILL)
self.media_widget.set_valign(Gtk.Align.CENTER)
# Col 1: Cover Art
self.cover_art = Gtk.DrawingArea()
self.cover_art.set_size_request(110, 110)
self.cover_art.set_valign(Gtk.Align.CENTER)
self.cover_art.connect("draw", self.on_draw_cover)
# Col 2: Grid Layout for Texts, Play Button, and Seekbar
self.media_grid = Gtk.Grid()
self.media_grid.set_column_spacing(10)
self.media_grid.set_row_spacing(2)
self.media_grid.set_valign(Gtk.Align.FILL) # Stretch to 110px to match cover
def create_crossfade_stack(name):
stack = Gtk.Stack()
stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
stack.set_transition_duration(300)
stack.set_hexpand(True)
stack.set_valign(Gtk.Align.START)
l1 = Gtk.Label(label="", xalign=0)
l1.set_name(name)
l1.set_ellipsize(Pango.EllipsizeMode.END)
l1.set_max_width_chars(1)
l2 = Gtk.Label(label="", xalign=0)
l2.set_name(name)
l2.set_ellipsize(Pango.EllipsizeMode.END)
l2.set_max_width_chars(1)
stack.add_named(l1, "1")
stack.add_named(l2, "2")
stack.set_visible_child_name("1")
return stack, l1, l2
self.title_stack, self.title_l1, self.title_l2 = create_crossfade_stack("TitleLabel")
self.artist_stack, self.artist_l1, self.artist_l2 = create_crossfade_stack("SubtitleLabel")
# Spacer to push seekbar to bottom
self.media_spacer = Gtk.Box()
self.media_spacer.set_vexpand(True)
self.media_time_label = Gtk.Label(label="0:00 / 0:00", xalign=0.0)
self.media_time_label.set_name("PerfLabel")
self.media_time_label.set_margin_left(6)
self.media_time_label.set_hexpand(True)
self.media_time_label.set_valign(Gtk.Align.END)
self.btn_play = Gtk.Button(label="▶")
self.btn_play.set_name("ControlBall")
self.btn_play.set_size_request(48, 48)
self.btn_play.set_valign(Gtk.Align.CENTER)
self.btn_play.set_halign(Gtk.Align.END)
# Seekbar and Nav
self.media_bottom = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=4)
self.btn_prev = Gtk.Button(label="⏮")
self.btn_next = Gtk.Button(label="⏭")
for btn in [self.btn_prev, self.btn_next]: btn.set_name("NavButton")
self.seekbar = Gtk.DrawingArea()
self.seekbar.set_size_request(150, 20)
self.seekbar.set_valign(Gtk.Align.CENTER)
self.seekbar.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.POINTER_MOTION_MASK)
self.seekbar.connect("draw", self.on_draw_seekbar)
self.seekbar.connect("button-press-event", self.on_seek_event)
self.seekbar.connect("motion-notify-event", self.on_seek_event)
self.media_bottom.pack_start(self.btn_prev, False, False, 0)
self.media_bottom.pack_start(self.seekbar, True, True, 0)
self.media_bottom.pack_end(self.btn_next, False, False, 0)
self.media_bottom.set_margin_top(4)
self.media_bottom.set_valign(Gtk.Align.END)
# Attach to Grid
self.media_grid.attach(self.title_stack, 0, 0, 1, 1)
self.media_grid.attach(self.artist_stack, 0, 1, 1, 1)
self.media_grid.attach(self.media_spacer, 0, 2, 1, 1) # Flexible space
self.media_grid.attach(self.media_time_label, 0, 3, 1, 1)
self.media_grid.attach(self.btn_play, 1, 0, 1, 4) # Spans 4 rows down to time label
self.media_grid.attach(self.media_bottom, 0, 4, 2, 1) # Spans 2 columns at absolute bottom
self.media_widget.pack_start(self.cover_art, False, False, 0)
self.media_widget.pack_start(self.media_grid, True, True, 0)
self.stack.add_named(self.media_widget, "media")
# 3. Compact Media Widget
self.compact_widget = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
self.compact_widget.set_halign(Gtk.Align.CENTER)
self.compact_widget.set_valign(Gtk.Align.CENTER)
self.compact_cover = Gtk.DrawingArea()
self.compact_cover.set_size_request(24, 24)
self.compact_cover.set_valign(Gtk.Align.CENTER)
self.compact_cover.connect("draw", self.on_draw_compact_cover)
vbox_compact = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
vbox_compact.set_valign(Gtk.Align.CENTER)
self.compact_title = Gtk.Label(label="")
self.compact_title.set_halign(Gtk.Align.START)
self.compact_title.set_name("TitleLabel")
self.compact_title.set_ellipsize(Pango.EllipsizeMode.END)
self.compact_title.set_max_width_chars(15)
self.compact_artist = Gtk.Label(label="")
self.compact_artist.set_halign(Gtk.Align.START)
self.compact_artist.set_name("SubtitleLabel")
self.compact_artist.set_ellipsize(Pango.EllipsizeMode.END)
self.compact_artist.set_max_width_chars(15)
vbox_compact.pack_start(self.compact_title, False, False, 0)
vbox_compact.pack_start(self.compact_artist, False, False, 0)
self.compact_widget.pack_start(self.compact_cover, False, False, 0)
self.compact_widget.pack_start(vbox_compact, False, False, 0)
self.stack.add_named(self.compact_widget, "compact")
# 4. System Details Widget
self.system_widget = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=16)
self.system_widget.set_halign(Gtk.Align.CENTER)
self.system_widget.set_valign(Gtk.Align.CENTER)
def create_sys_col(title, width=90):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=4)
box.set_size_request(width, -1)
header = Gtk.Label(label=title)
header.set_name("TitleLabel")
header.set_halign(Gtk.Align.START)
box.pack_start(header, False, False, 0)
return box
self.sys_ram_col = create_sys_col("RAM", 90)
self.sys_swap_col = create_sys_col("Swap", 90)
self.sys_cpu_col = create_sys_col("CPU", 65)
self.sys_labels = {}
def add_stat(col, key, label_text):
l = Gtk.Label(label=label_text)
l.set_name("SubtitleLabel")
l.set_halign(Gtk.Align.START)
col.pack_start(l, False, False, 0)
self.sys_labels[key] = l
add_stat(self.sys_ram_col, "ram_used", "Used: -- GB")
add_stat(self.sys_ram_col, "ram_free", "Free: -- GB")
add_stat(self.sys_ram_col, "ram_total", "Total: -- GB")
add_stat(self.sys_swap_col, "swap_used", "Used: -- GB")
add_stat(self.sys_swap_col, "swap_free", "Free: -- GB")
add_stat(self.sys_swap_col, "swap_total", "Total: -- GB")
add_stat(self.sys_cpu_col, "cpu_load", "Load: --%")
self.system_widget.pack_start(self.sys_ram_col, False, False, 0)
self.system_widget.pack_start(self.sys_swap_col, False, False, 0)
self.system_widget.pack_start(self.sys_cpu_col, False, False, 0)
self.stack.add_named(self.system_widget, "system")
# 5. Split Calendar/Weather Widget
self.calendar_widget = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
self.calendar_widget.set_halign(Gtk.Align.CENTER)
self.calendar_widget.set_valign(Gtk.Align.CENTER)
# Left side: Weather (WeatherPanel)
self.weather_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
self.weather_box.set_name("WeatherPanel")
self.weather_box.set_size_request(130, 184)
w_top = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
self.w_icon = Gtk.Label(label="☁")
self.w_icon.set_name("WeatherDesc")
self.w_desc = Gtk.Label(label="Cloudy")
self.w_desc.set_name("WeatherDesc")
w_top.pack_start(self.w_icon, False, False, 0)
w_top.pack_start(self.w_desc, False, False, 0)
w_top.set_margin_top(12)
w_top.set_margin_left(12)
self.w_temp = Gtk.Label(label="--°")
self.w_temp.set_name("WeatherTemp")
self.w_temp.set_halign(Gtk.Align.START)
self.w_temp.set_margin_left(12)
self.w_hl = Gtk.Label(label="L:--° H:--°")
self.w_hl.set_name("WeatherHL")
self.w_hl.set_halign(Gtk.Align.START)
self.w_hl.set_margin_left(12)
self.w_hl.set_margin_bottom(12)
self.weather_box.pack_start(w_top, False, False, 0)
self.weather_box.pack_start(self.w_temp, True, True, 0)
self.weather_box.pack_start(self.w_hl, False, False, 0)
# Right side: Calendar
self.cal_right = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
self.cal_right.set_size_request(252, 184)
# Top Header (Black background, white text)
cal_header = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
now = datetime.now()
month_name = calendar.month_name[now.month].upper()
pill_area = Gtk.DrawingArea()
pill_area.set_size_request(16, 14)
pill_area.set_valign(Gtk.Align.CENTER)
pill_area.set_margin_left(4)
def draw_pills(widget, cr):
colors = [(0.66, 0.33, 0.96), (0.98, 0.60, 0.13), (0.20, 0.83, 0.75)]
for i, color in enumerate(colors):
cr.set_source_rgb(*color)
x = i * 6
r = 2
cr.arc(x + r, r, r, math.pi, 2 * math.pi)
cr.arc(x + r, 14 - r, r, 0, math.pi)
cr.fill()
pill_area.connect("draw", draw_pills)
h_left = Gtk.Label(label=f"{month_name}")
h_left.set_name("CalendarHeader")
h_right = Gtk.Label(label=str(now.year))
h_right.set_name("CalendarYear")
cal_header.pack_start(pill_area, False, False, 0)
cal_header.pack_start(h_left, False, False, 0)
cal_header.pack_end(h_right, False, False, 0)
# Bottom Body (CalendarPanel)
cal_body = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=4)
cal_body.set_name("CalendarPanel")
cal_body.set_size_request(252, 148)
# Week grid
grid = Gtk.Grid()
grid.set_column_spacing(10)
grid.set_row_spacing(2)
grid.set_halign(Gtk.Align.CENTER)
grid.set_margin_top(10)
days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
for i, day in enumerate(days):
l = Gtk.Label(label=day)
l.set_name("CalendarDayName")
grid.attach(l, i, 0, 1, 1)
import datetime as dt
idx = (now.weekday() + 1) % 7
start_of_week = now - dt.timedelta(days=idx)
for i in range(7):
d = start_of_week + dt.timedelta(days=i)
l = Gtk.Label(label=str(d.day))
if d.date() == now.date():
l.set_name("ActiveDate")
else:
l.set_name("CalendarDate")
grid.attach(l, i, 1, 1, 1)
if i in (idx, idx+1):
dot = Gtk.Label(label="•")
dot.set_name("EventDot")
grid.attach(dot, i, 2, 1, 1)
cal_body.pack_start(grid, False, False, 0)
sep = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
sep.set_name("EventSep")
sep.set_margin_left(10)
sep.set_margin_right(10)
cal_body.pack_start(sep, False, False, 0)
event_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
event_box.set_margin_left(12)
event_box.set_margin_bottom(10)
self.e_time = Gtk.Label(label=f"Today, {datetime.now().strftime('%H:%M')}")
self.e_time.set_name("EventTime")
self.e_time.set_halign(Gtk.Align.START)
self.recent_apps_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
self.recent_apps_box.set_halign(Gtk.Align.START)
event_box.pack_start(self.e_time, False, False, 0)
event_box.pack_start(self.recent_apps_box, False, False, 0)
cal_body.pack_start(event_box, True, True, 0)
self.cal_right.pack_start(cal_header, False, False, 0)
self.cal_right.pack_start(cal_body, True, True, 0)
self.calendar_widget.pack_start(self.weather_box, False, False, 0)
self.calendar_widget.pack_start(self.cal_right, False, False, 0)
self.stack.add_named(self.calendar_widget, "calendar")
# 6. Battery Widget (Expanded)
self.battery_widget = Gtk.DrawingArea()
self.battery_widget.set_valign(Gtk.Align.FILL)
self.battery_widget.set_halign(Gtk.Align.FILL)
self.battery_widget.connect("draw", self.on_draw_battery)
self.stack.add_named(self.battery_widget, "battery")
# 7. Compact Battery Widget
self.compact_battery_widget = Gtk.DrawingArea()
self.compact_battery_widget.set_size_request(46, self.COMPACT_H)
self.compact_battery_widget.set_valign(Gtk.Align.FILL)
self.compact_battery_widget.connect("draw", self.on_draw_compact_battery)
self.stack.add_named(self.compact_battery_widget, "compact_battery")
# 9. Sidebar Vertical Idle (for left/right positions)
self.sidebar_idle_widget = Gtk.DrawingArea()
self.sidebar_idle_widget.set_size_request(self.SIDEBAR_IDLE_W, self.SIDEBAR_IDLE_H)
self.sidebar_idle_widget.set_valign(Gtk.Align.FILL)
self.sidebar_idle_widget.connect("draw", self.on_draw_sidebar_idle)
self.stack.add_named(self.sidebar_idle_widget, "sidebar_header")
# 10. Sidebar Media Widget (square card: cover fills all, content overlaid)
self.sidebar_cover_art = Gtk.DrawingArea()
self.sidebar_cover_art.set_size_request(self.SIDEBAR_MEDIA_W, self.SIDEBAR_MEDIA_H)
self.sidebar_cover_art.set_halign(Gtk.Align.FILL)
self.sidebar_cover_art.set_valign(Gtk.Align.FILL)
self.sidebar_cover_art.connect("draw", self.on_draw_sidebar_cover)
self.sidebar_title_label = Gtk.Label(label="")
self.sidebar_title_label.set_name("TitleLabel")
self.sidebar_title_label.set_halign(Gtk.Align.CENTER)
self.sidebar_title_label.set_ellipsize(Pango.EllipsizeMode.END)
self.sidebar_title_label.set_max_width_chars(14)
self.sidebar_artist_label = Gtk.Label(label="")
self.sidebar_artist_label.set_name("SubtitleLabel")
self.sidebar_artist_label.set_halign(Gtk.Align.CENTER)
self.sidebar_artist_label.set_ellipsize(Pango.EllipsizeMode.END)
self.sidebar_artist_label.set_max_width_chars(14)
self.sidebar_seekbar = Gtk.DrawingArea()
self.sidebar_seekbar.set_size_request(-1, 14)
self.sidebar_seekbar.set_hexpand(True)
self.sidebar_seekbar.add_events(
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.POINTER_MOTION_MASK)
self.sidebar_seekbar.connect("draw", self.on_draw_seekbar)
self.sidebar_seekbar.connect("button-press-event", self.on_seek_event)
self.sidebar_seekbar.connect("motion-notify-event", self.on_seek_event)
sidebar_controls = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
sidebar_controls.set_halign(Gtk.Align.CENTER)
self.sidebar_btn_prev = Gtk.Button(label="\u23ee")
self.sidebar_btn_prev.set_name("NavButton")
self.sidebar_btn_play = Gtk.Button(label="\u25b6")
self.sidebar_btn_play.set_name("ControlBall")
self.sidebar_btn_play.set_size_request(40, 40)
self.sidebar_btn_next = Gtk.Button(label="\u23ed")
self.sidebar_btn_next.set_name("NavButton")
sidebar_controls.pack_start(self.sidebar_btn_prev, False, False, 0)
sidebar_controls.pack_start(self.sidebar_btn_play, False, False, 0)
sidebar_controls.pack_start(self.sidebar_btn_next, False, False, 0)
# Floating bottom content panel
sidebar_content_panel = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=4)
sidebar_content_panel.set_halign(Gtk.Align.FILL)
sidebar_content_panel.set_valign(Gtk.Align.END)
sidebar_content_panel.set_margin_bottom(10)
sidebar_content_panel.set_margin_start(10)
sidebar_content_panel.set_margin_end(10)
sidebar_content_panel.pack_start(self.sidebar_title_label, False, False, 0)
sidebar_content_panel.pack_start(self.sidebar_artist_label, False, False, 0)
sidebar_content_panel.pack_start(self.sidebar_seekbar, False, False, 4)
sidebar_content_panel.pack_start(sidebar_controls, False, False, 0)
# Overlay: cover as base, content floating on top
self.sidebar_media_widget = Gtk.Overlay()
self.sidebar_media_widget.add(self.sidebar_cover_art)
self.sidebar_media_widget.add_overlay(sidebar_content_panel)
self.stack.add_named(self.sidebar_media_widget, "sidebar_media")
# 8. Settings Widget
self.settings_widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
self.settings_widget.set_halign(Gtk.Align.FILL)
self.settings_widget.set_valign(Gtk.Align.START)
self.settings_widget.set_margin_top(14)
self.settings_widget.set_margin_bottom(14)
self.settings_widget.set_margin_start(16)
self.settings_widget.set_margin_end(16)
# Header
lbl_settings = Gtk.Label(label="Settings")
lbl_settings.set_name("SettingsHeader")
lbl_settings.set_halign(Gtk.Align.START)
self.settings_widget.pack_start(lbl_settings, False, False, 0)
# ── Section: Appearance ──────────────────────
sep0 = Gtk.Separator(); sep0.set_name("SettingsSep")
self.settings_widget.pack_start(sep0, False, False, 0)
sec_lbl1 = Gtk.Label(label="APPEARANCE"); sec_lbl1.set_name("SettingsSectionLabel")
sec_lbl1.set_halign(Gtk.Align.START)
self.settings_widget.pack_start(sec_lbl1, False, False, 0)
theme_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
theme_lbl = Gtk.Label(label="Frosted Black Theme"); theme_lbl.set_name("SettingsLabel")
theme_lbl.set_halign(Gtk.Align.START)
theme_box.pack_start(theme_lbl, True, True, 0)
self.theme_switch = Gtk.Switch()
self.theme_switch.set_active(self.app_config.get("theme", "Frosted Black") == "Frosted Black")
self.theme_switch.connect("state-set", self.on_theme_toggled)
theme_box.pack_start(self.theme_switch, False, False, 0)
self.settings_widget.pack_start(theme_box, False, False, 0)
# ── Section: Clock ──────────────────────────
sep1 = Gtk.Separator(); sep1.set_name("SettingsSep")
self.settings_widget.pack_start(sep1, False, False, 0)
sec_lbl2 = Gtk.Label(label="CLOCK"); sec_lbl2.set_name("SettingsSectionLabel")
sec_lbl2.set_halign(Gtk.Align.START)
self.settings_widget.pack_start(sec_lbl2, False, False, 0)
time_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
time_lbl = Gtk.Label(label="24-Hour Format"); time_lbl.set_name("SettingsLabel")
time_lbl.set_halign(Gtk.Align.START)
time_box.pack_start(time_lbl, True, True, 0)
self.time_switch = Gtk.Switch()
self.time_switch.set_active(self.app_config.get("time_format", "24h") == "24h")
self.time_switch.connect("state-set", self.on_time_toggled)
time_box.pack_start(self.time_switch, False, False, 0)
self.settings_widget.pack_start(time_box, False, False, 0)
# ── Section: Position ───────────────────────
sep2 = Gtk.Separator(); sep2.set_name("SettingsSep")
self.settings_widget.pack_start(sep2, False, False, 0)
sec_lbl3 = Gtk.Label(label="POSITION"); sec_lbl3.set_name("SettingsSectionLabel")
sec_lbl3.set_halign(Gtk.Align.START)
self.settings_widget.pack_start(sec_lbl3, False, False, 0)
pos_lbl = Gtk.Label(label="Panel Position"); pos_lbl.set_name("SettingsLabel")
pos_lbl.set_halign(Gtk.Align.START)
self.settings_widget.pack_start(pos_lbl, False, False, 0)
self.position_combo = Gtk.ComboBoxText()
self.position_combo.set_name("SettingsCombo")
positions = ["top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right", "left", "right"]
for p in positions:
self.position_combo.append_text(p)
current_pos = self.app_config.get("position", "top")
self.position_combo.set_active(positions.index(current_pos) if current_pos in positions else 0)
self.settings_widget.pack_start(self.position_combo, False, False, 0)
# Save button
save_btn = Gtk.Button(label="Apply & Save")
save_btn.set_name("SettingsSaveBtn")
save_btn.connect("clicked", self.on_save_settings)
self.settings_widget.pack_start(save_btn, False, False, 4)
self.stack.add_named(self.settings_widget, "settings")
# 9. Mac Island Dashboard Widget
self.mac_island_widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15)
self.mac_island_widget.set_margin_top(15)
self.mac_island_widget.set_margin_bottom(15)
self.mac_island_widget.set_margin_start(20)
self.mac_island_widget.set_margin_end(20)
# 2. Main Content
content_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=30)
# --- LEFT: MEDIA ---
mac_media_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
self.mac_cover_art = Gtk.DrawingArea()
self.mac_cover_art.set_size_request(90, 90)
self.mac_cover_art.set_valign(Gtk.Align.CENTER)
self.mac_cover_art.connect("draw", self.on_draw_mac_cover)
mac_media_info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
mac_media_info.set_valign(Gtk.Align.CENTER)
self.mac_title_l1 = Gtk.Label(label="No Media", xalign=0)
self.mac_title_l1.set_name("TitleLabel")
self.mac_title_l1.set_ellipsize(Pango.EllipsizeMode.END)
self.mac_title_l1.set_max_width_chars(15)
self.mac_title_l1.set_markup("<b>No Media</b>")
self.mac_album_l1 = Gtk.Label(label="", xalign=0)
self.mac_album_l1.set_name("MacAlbumLabel")
self.mac_album_l1.set_ellipsize(Pango.EllipsizeMode.END)
self.mac_album_l1.set_max_width_chars(15)
self.mac_artist_l1 = Gtk.Label(label="", xalign=0)
self.mac_artist_l1.set_name("MacArtistLabel")
self.mac_artist_l1.set_ellipsize(Pango.EllipsizeMode.END)
self.mac_artist_l1.set_max_width_chars(15)
mac_media_controls = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
self.mac_btn_prev = Gtk.Button(label="⏮")
self.mac_btn_play = Gtk.Button(label="⏸")
self.mac_btn_next = Gtk.Button(label="⏭")
for btn in [self.mac_btn_prev, self.mac_btn_play, self.mac_btn_next]:
btn.set_name("MacNavButton")
mac_media_controls.pack_start(btn, False, False, 0)
mac_media_info.pack_start(self.mac_title_l1, False, False, 0)
mac_media_info.pack_start(self.mac_album_l1, False, False, 0)
mac_media_info.pack_start(self.mac_artist_l1, False, False, 0)
mac_media_info.pack_start(mac_media_controls, False, False, 2)
mac_media_box.pack_start(self.mac_cover_art, False, False, 0)
mac_media_box.pack_start(mac_media_info, False, False, 0)
# --- CENTER: CALENDAR ---
mac_cal_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
mac_cal_box.set_valign(Gtk.Align.CENTER)
mac_cal_top = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
self.mac_month_label = Gtk.Label(label="Aug", xalign=0)
self.mac_month_label.set_name("MacMonthLabel")
mac_cal_week = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
self.mac_cal_dates = []
for i in range(7):
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
lbl_day = Gtk.Label()
lbl_date = Gtk.Label()
lbl_day.set_name("MacCalDay")
lbl_date.set_name("MacCalDate")
vbox.pack_start(lbl_day, False, False, 0)
vbox.pack_start(lbl_date, False, False, 0)
mac_cal_week.pack_start(vbox, False, False, 0)
self.mac_cal_dates.append((lbl_day, lbl_date))
mac_cal_top.pack_start(self.mac_month_label, False, False, 0)
mac_cal_top.pack_start(mac_cal_week, False, False, 0)
mac_cal_box.pack_start(mac_cal_top, False, False, 0)
# --- RIGHT: AVATAR ---
self.mac_avatar = Gtk.DrawingArea()
self.mac_avatar.set_size_request(90, 90)
self.mac_avatar.set_valign(Gtk.Align.CENTER)
self.mac_avatar.connect("draw", self.on_draw_mac_avatar)
# Pack Content
content_box.pack_start(mac_media_box, False, False, 0)
sep1 = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
sep1.set_name("MacSep")
sep1.set_margin_start(10)
sep1.set_margin_end(10)
content_box.pack_start(sep1, False, False, 0)
content_box.pack_start(mac_cal_box, True, True, 0)
sep2 = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
sep2.set_name("MacSep")
sep2.set_margin_start(10)
sep2.set_margin_end(10)
content_box.pack_start(sep2, False, False, 0)
content_box.pack_end(self.mac_avatar, False, False, 0)
# Add to Island
self.mac_island_widget.pack_start(content_box, True, True, 0)
self.mac_island_widget.show_all()
self.stack.add_named(self.mac_island_widget, "mac_island")
# Overlay input mask & css
self.overlay.add_overlay(self.content_box)
screen = Gdk.Screen.get_default()
css = get_stylesheet() + "\nwindow { background: transparent; }\n"
provider = Gtk.CssProvider()
provider.load_from_data(css.encode())
Gtk.StyleContext.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
# Monitors
self.media_monitor = MediaMonitor(self.on_media, self.on_lyric, self.on_progress)
self.media_monitor.start()
self.btn_prev.connect("clicked", lambda w: self.media_monitor.prev_track())
self.btn_play.connect("clicked", lambda w: self.media_monitor.toggle_play_pause())
self.btn_next.connect("clicked", lambda w: self.media_monitor.next_track())
self.sidebar_btn_prev.connect("clicked", lambda w: self.media_monitor.prev_track())
self.sidebar_btn_play.connect("clicked", lambda w: self.media_monitor.toggle_play_pause())
self.sidebar_btn_next.connect("clicked", lambda w: self.media_monitor.next_track())
self.mac_btn_prev.connect("clicked", lambda w: self.media_monitor.prev_track())
self.mac_btn_play.connect("clicked", lambda w: self.media_monitor.toggle_play_pause())
self.mac_btn_next.connect("clicked", lambda w: self.media_monitor.next_track())
self.notif_monitor = NotificationMonitor(self.on_notif)
self.notif_monitor.start()
self.key_monitor = KeyLockMonitor(self.on_keylock)
self.key_monitor.start()
self.battery_monitor = BatteryMonitor(self.on_battery_changed)
self.battery_monitor.start()
self.system_monitor = SystemMonitor(self.on_system_stats_update)
self.system_monitor.start()
self.weather_monitor = WeatherMonitor(self.on_weather_update)
self.weather_monitor.start()
self.anim_group = ParallelAnimationGroup()
self.connect("destroy", self.on_destroy)
def load_config(self):
if os.path.exists(self.config_path):
try:
with open(self.config_path, "r") as f:
data = json.load(f)
self.app_config.update(data)
except Exception as e:
print("Error loading config:", e)
def save_config(self):
try:
with open(self.config_path, "w") as f:
json.dump(self.app_config, f, indent=4)
except Exception as e:
print("Error saving config:", e)
def on_button_press(self, widget, event):
if event.type == Gdk.EventType.BUTTON_PRESS:
if event.button == 3: # Right-click
if self.current_state == "Settings":
self.change_state("Idle", "")
else:
self.change_state("Settings", "")
return True
return False
def on_theme_toggled(self, switch, state):
self.app_config["theme"] = "Frosted Black" if state else "Clear Glass"
self.save_config()
self.drawing_area.queue_draw()
def on_time_toggled(self, switch, state):
self.app_config["time_format"] = "24h" if state else "12h"
self.save_config()
self.update_clock()
def on_save_settings(self, btn):
positions = ["top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right", "left", "right"]
idx = self.position_combo.get_active()
if 0 <= idx < len(positions):
self.app_config["position"] = positions[idx]
self.save_config()
self.apply_position()
self.change_state("Idle", "")
def _apply_anchors(self):
if not (HAS_LAYER_SHELL and GtkLayerShell.is_supported()):
return
for edge in [GtkLayerShell.Edge.TOP, GtkLayerShell.Edge.BOTTOM,
GtkLayerShell.Edge.LEFT, GtkLayerShell.Edge.RIGHT]:
GtkLayerShell.set_anchor(self, edge, False)
GtkLayerShell.set_margin(self, edge, 10)
pos = self.app_config.get("position", "top")
if "top" in pos:
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.TOP, True)
if "bottom" in pos:
if HAS_LAYER_SHELL and GtkLayerShell.is_supported():
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.BOTTOM, True)
if "left" in pos:
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.LEFT, True)
if "right" in pos:
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.RIGHT, True)
def apply_position(self):
self._apply_anchors()
# Align content_box — always centered within the island window
if hasattr(self, 'content_box'):
self.content_box.set_halign(Gtk.Align.CENTER)
self.content_box.set_margin_start(0)
self.content_box.set_margin_end(0)
if hasattr(self, 'drawing_area'):
self.drawing_area.queue_draw()
def update_radius(self, val):
self.border_radius = val
self.drawing_area.queue_draw()
def on_destroy(self, widget):
self.media_monitor.stop()
self.notif_monitor.stop()
self.key_monitor.stop()
self.battery_monitor.stop()
self.system_monitor.stop()
self.weather_monitor.stop()
Gtk.main_quit()
def start_collapse_timer(self):
if self.collapse_timer:
GLib.source_remove(self.collapse_timer)
self.collapse_timer = GLib.timeout_add(2000, self._do_collapse)
def _do_collapse(self):
self.collapse_timer = None
if not self.is_hovered:
self._do_idle_state()
return False
def on_hover_enter(self, widget, event):
self.is_hovered = True
if self.collapse_timer:
GLib.source_remove(self.collapse_timer)
self.collapse_timer = None
if self.current_state == "CompactMedia" or (self.current_state == "Idle" and self.last_media_title):
self.change_state("Media", f"{self.last_media_title} - {self.last_media_artist}")
return False
def on_hover_leave(self, widget, event):
self.is_hovered = False
if self.current_state not in ("Idle", "Settings"):
self.start_collapse_timer()
return False
def hex_to_rgb(self, hex_color):
hex_color = hex_color.lstrip('#')
if len(hex_color) == 6:
return tuple(int(hex_color[i:i+2], 16)/255.0 for i in (0, 2, 4))
return (0, 0, 0)
def on_draw(self, widget, cr):
alloc = widget.get_allocation()
cx = alloc.width / 2.0
w = self.island_w
h = self.island_h
r = min(getattr(self, 'border_radius', min(w, h) / 2.0), w / 2.0, h / 2.0)
x = cx - w / 2.0
y = 0
rect = cairo.RectangleInt(int(x), int(y), int(w), int(h))
region = cairo.Region(rect)
self.input_shape_combine_region(region)
cr.arc(x + r, y + r, r, math.pi, 1.5 * math.pi)
cr.arc(x + w - r, y + r, r, 1.5 * math.pi, 2 * math.pi)
cr.arc(x + w - r, y + h - r, r, 0, 0.5 * math.pi)
cr.arc(x + r, y + h - r, r, 0.5 * math.pi, math.pi)
cr.close_path()
cr.clip()
# Base background for Idle mode (dark frosted glass feel)
cr.set_source_rgba(0.0, 0.0, 0.0, 0.95)
cr.paint()
# Draw album cover background
if getattr(self, 'bg_pixbuf', None) and getattr(self, 'bg_opacity', 0.0) > 0.01:
cr.push_group()
if getattr(self, 'old_bg_pixbuf', None) and getattr(self, 'art_alpha', 1.0) < 1.0:
Gdk.cairo_set_source_pixbuf(cr, self.old_bg_pixbuf, x, y)
cr.paint()
Gdk.cairo_set_source_pixbuf(cr, self.bg_pixbuf, x, y)
cr.paint_with_alpha(self.art_alpha)
else:
Gdk.cairo_set_source_pixbuf(cr, self.bg_pixbuf, x, y)
cr.paint()
self.old_bg_pixbuf = None
# Darken the album cover to ensure text is readable
cr.set_source_rgba(0, 0, 0, getattr(self, 'bg_darkness', 0.7))
cr.paint()
cr.pop_group_to_source()
cr.paint_with_alpha(self.bg_opacity)
# Subtle frosted glass border
cr.set_source_rgba(1, 1, 1, 0.15)
cr.set_line_width(1.5)
cr.arc(x + r, y + r, r, math.pi, 1.5 * math.pi)
cr.arc(x + w - r, y + r, r, 1.5 * math.pi, 2 * math.pi)
cr.arc(x + w - r, y + h - r, r, 0, 0.5 * math.pi)
cr.arc(x + r, y + h - r, r, 0.5 * math.pi, math.pi)
cr.close_path()
cr.stroke()
def on_draw_cover(self, widget, cr):
if not self.cover_pixbuf: return False
w = widget.get_allocated_width()
h = widget.get_allocated_height()
radius = 12
cr.arc(radius, radius, radius, math.pi, 1.5 * math.pi)
cr.arc(w - radius, radius, radius, 1.5 * math.pi, 2 * math.pi)
cr.arc(w - radius, h - radius, radius, 0, 0.5 * math.pi)
cr.arc(radius, h - radius, radius, 0.5 * math.pi, math.pi)
cr.close_path()
cr.clip()
if self.old_cover_pixbuf and getattr(self, 'art_alpha', 1.0) < 1.0:
Gdk.cairo_set_source_pixbuf(cr, self.old_cover_pixbuf, 0, 0)
cr.paint()
Gdk.cairo_set_source_pixbuf(cr, self.cover_pixbuf, 0, 0)
cr.paint_with_alpha(self.art_alpha)
else:
Gdk.cairo_set_source_pixbuf(cr, self.cover_pixbuf, 0, 0)
cr.paint()
self.old_cover_pixbuf = None
return True
def on_draw_sidebar_cover(self, widget, cr):
"""Cover art fills the full square; clips to rounded capsule, adds bottom gradient."""
w = widget.get_allocated_width()
h = widget.get_allocated_height()
r = min(getattr(self, 'border_radius', 20.0), w / 2.0, h / 2.0)
# Clip to rounded rect matching the capsule shape
cr.arc(r, r, r, math.pi, 1.5 * math.pi)
cr.arc(w - r, r, r, 1.5 * math.pi, 2 * math.pi)
cr.arc(w - r, h - r, r, 0, 0.5 * math.pi)
cr.arc(r, h - r, r, 0.5 * math.pi, math.pi)
cr.close_path()
cr.clip()
if self.cover_pixbuf:
scaled = self.cover_pixbuf.scale_simple(w, h, GdkPixbuf.InterpType.BILINEAR)
if self.old_cover_pixbuf and getattr(self, 'art_alpha', 1.0) < 1.0:
old_scaled = self.old_cover_pixbuf.scale_simple(w, h, GdkPixbuf.InterpType.BILINEAR)
Gdk.cairo_set_source_pixbuf(cr, old_scaled, 0, 0)
cr.paint()
Gdk.cairo_set_source_pixbuf(cr, scaled, 0, 0)
cr.paint_with_alpha(self.art_alpha)
else:
Gdk.cairo_set_source_pixbuf(cr, scaled, 0, 0)