Skip to content

Commit 52eda13

Browse files
authored
Add CSS for display (#881)
1 parent cfbfd6a commit 52eda13

14 files changed

Lines changed: 129 additions & 212 deletions

data/Application.css

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-or-later
3+
* SPDX-FileCopyrightText: 2018-2025 elementary, Inc. (https://elementary.io)
4+
*/
5+
6+
.daylabel {
7+
padding: 3px;
8+
border-left: solid 1px @menu_separator;
9+
}
10+
11+
.daylabel:first-child {
12+
border-left: none;
13+
}
14+
15+
.daylabel:dir(rtl) {
16+
border-right: solid 1px @menu_separator;
17+
border-left: none;
18+
}
19+
20+
.daylabel:first-child:dir(rtl) {
21+
border-right: none;
22+
}
23+
24+
.weeks {
25+
border-right: solid 1px @menu_separator;
26+
}
27+
28+
.weeks:dir(rtl) {
29+
border-left: solid 1px @menu_separator;
30+
border-right: none;
31+
}
32+
33+
.weeklabel {
34+
border-top: solid 1px @menu_separator;
35+
padding: 3px;
36+
}
37+
38+
.cell {
39+
background-color: @base_color;
40+
border-radius: 0;
41+
border-top: solid 1px @menu_separator;
42+
border-left: solid 1px @menu_separator;
43+
color: @fg_color;
44+
}
45+
46+
.cell:dir(rtl) {
47+
border-right: solid 1px @menu_separator;
48+
border-left: none;
49+
}
50+
51+
.cell.dim-label {
52+
background-color: @bg_color;
53+
}
54+
55+
.cell.firstcol {
56+
border-left: none;
57+
}
58+
59+
.cell.firstcol:dir(rtl) {
60+
border-right: none;
61+
}
62+
63+
.cell:selected #date {
64+
background-color: shade(@bg_color, 0.86);
65+
color: @fg_color;
66+
}
67+
68+
.cell > box {
69+
margin: 3px;
70+
}
71+
72+
.event {
73+
background: @selected_bg_color;
74+
border-radius: 3px;
75+
color: @selected_fg_color;
76+
padding: 6px;
77+
}
78+
79+
.cell .event {
80+
padding: 3px 6px;
81+
margin-bottom: 3px;
82+
}
83+
84+
.cell.dim-label .event {
85+
background: alpha (@base_color, 0.7);
86+
color: @text_color;
87+
}
88+
89+
.event .title {
90+
font-weight: 600;
91+
}
92+
93+
row:selected .event {
94+
background: @base_color;
95+
background-image: linear-gradient(to right, @selected_bg_color, @selected_bg_color);
96+
box-shadow:
97+
0 1px 2px alpha (#000, 0.2),
98+
0 1px 3px alpha (@selected_bg_color, 0.15);
99+
color: @selected_fg_color;
100+
}
101+
102+
#date {
103+
border-radius: 50%;
104+
min-height: 24px;
105+
min-width: 24px;
106+
}
107+
108+
#today #date {
109+
background-color: alpha (@accent_color, 0.15);
110+
color: @accent_color;
111+
font-weight: 700;
112+
}
113+
114+
#today:selected #date {
115+
background-color: @accent_color;
116+
color: #fff;
117+
}

data/io.elementary.calendar.gresource.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<gresources>
33
<gresource prefix="/io/elementary/calendar/">
4-
<file alias="AgendaEventRow.css" compressed="true">style/AgendaEventRow.css</file>
5-
<file alias="Grid.css" compressed="true">style/Grid.css</file>
6-
<file alias="Header.css" compressed="true">style/Header.css</file>
7-
<file alias="WeekLabels.css" compressed="true">style/WeekLabels.css</file>
4+
<file compressed="true">Application.css</file>
85
</gresource>
96
<gresource prefix="/io/elementary/calendar/icons">
107
<file alias="scalable/categories/event-appointment-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/event-appointment-symbolic.svg</file>

data/style/AgendaEventRow.css

Lines changed: 0 additions & 29 deletions
This file was deleted.

data/style/Grid.css

Lines changed: 0 additions & 55 deletions
This file was deleted.

data/style/Header.css

Lines changed: 0 additions & 34 deletions
This file was deleted.

data/style/WeekLabels.css

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Application.vala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ namespace Maya {
6565

6666
Hdy.init ();
6767

68+
var style_provider = new Gtk.CssProvider ();
69+
style_provider.load_from_resource ("/io/elementary/calendar/Application.css");
70+
71+
Gtk.StyleContext.add_provider_for_screen (
72+
Gdk.Screen.get_default (),
73+
style_provider,
74+
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
75+
);
76+
6877
var granite_settings = Granite.Settings.get_default ();
6978
var gtk_settings = Gtk.Settings.get_default ();
7079

src/Grid/CalendarView.vala

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ public class Maya.View.CalendarView : Gtk.Box {
4646
private Gtk.Label spacer { get; private set; }
4747
private static GLib.Settings show_weeks;
4848

49-
private static Gtk.CssProvider style_provider;
50-
5149
static construct {
52-
style_provider = new Gtk.CssProvider ();
53-
style_provider.load_from_resource ("/io/elementary/calendar/WeekLabels.css");
54-
5550
if (Application.wingpanel_settings != null) {
5651
show_weeks = Application.wingpanel_settings;
5752
} else {
@@ -343,10 +338,7 @@ public class Maya.View.CalendarView : Gtk.Box {
343338
Gtk.Grid create_big_grid () {
344339
spacer = new Gtk.Label ("");
345340
spacer.no_show_all = true;
346-
347-
unowned Gtk.StyleContext spacer_context = spacer.get_style_context ();
348-
spacer_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
349-
spacer_context.add_class ("weeks");
341+
spacer.get_style_context ().add_class ("weeks");
350342

351343
weeks = new WeekLabels ();
352344

src/Grid/EventButton.vala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
public class Maya.View.EventButton : Gtk.Revealer {
2222
public ECal.Component comp { get; construct set; }
2323

24-
private static Gtk.CssProvider css_provider;
25-
2624
private Gtk.Label label;
2725
private Gtk.StyleContext grid_style_context;
2826

@@ -35,11 +33,6 @@ public class Maya.View.EventButton : Gtk.Revealer {
3533
);
3634
}
3735

38-
static construct {
39-
css_provider = new Gtk.CssProvider ();
40-
css_provider.load_from_resource ("/io/elementary/calendar/AgendaEventRow.css");
41-
}
42-
4336
construct {
4437
transition_type = Gtk.RevealerTransitionType.CROSSFADE;
4538

@@ -54,7 +47,6 @@ public class Maya.View.EventButton : Gtk.Revealer {
5447

5548
grid_style_context = internal_grid.get_style_context ();
5649
grid_style_context.add_class ("event");
57-
grid_style_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
5850

5951
var event_box = new Gtk.EventBox ();
6052
event_box.add (internal_grid);

src/Grid/Grid.vala

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,8 @@ public class Grid : Gtk.Grid {
3838
public signal void selection_changed (DateTime new_date);
3939
private GridDay selected_gridday;
4040

41-
private static Gtk.CssProvider style_provider;
42-
4341
private GridDay today_widget = null;
4442

45-
static construct {
46-
style_provider = new Gtk.CssProvider ();
47-
style_provider.load_from_resource ("/io/elementary/calendar/Grid.css");
48-
}
49-
5043
construct {
5144
// Gtk.Grid properties
5245
insert_column (7);
@@ -174,9 +167,7 @@ public class Grid : Gtk.Grid {
174167
});
175168

176169
if (col == 0) {
177-
unowned Gtk.StyleContext day_context = day.get_style_context ();
178-
day_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
179-
day_context.add_class ("firstcol");
170+
day.get_style_context ().add_class ("firstcol");
180171
}
181172

182173
attach (day, col, row);

0 commit comments

Comments
 (0)