Skip to content

Commit b2cd175

Browse files
authored
Fix easy style class deprecations (#327)
1 parent 5291e0b commit b2cd175

8 files changed

Lines changed: 25 additions & 37 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You'll need the following dependencies:
1313
* libecal1.2-dev
1414
* libedataserver1.2-dev
1515
* libical-dev
16-
* libgranite-7-dev >= 7.6.0
16+
* libgranite-7-dev >= 7.7.0
1717
* libwingpanel-9-dev
1818
* meson (>= 0.57.0)
1919
* valac >= 0.40.3

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ shared_module(
6464
dependencies: [
6565
dependency('glib-2.0'),
6666
dependency('gobject-2.0'),
67-
dependency('granite-7', version: '>=7.6.0'),
67+
dependency('granite-7', version: '>=7.7.0'),
6868
dependency('gtk4'),
6969
libecal_dep,
7070
dependency('libedataserver-1.2'),

src/Indicator.vala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ public class DateTime.Indicator : Wingpanel.Indicator {
7171
max_width_chars = 20,
7272
justify = Gtk.Justification.CENTER
7373
};
74-
75-
var placeholder_style_context = placeholder_label.get_style_context ();
76-
placeholder_style_context.add_class (Granite.STYLE_CLASS_DIM_LABEL);
77-
placeholder_style_context.add_class (Granite.STYLE_CLASS_H3_LABEL);
74+
placeholder_label.add_css_class (Granite.CssClass.DIM);
75+
placeholder_label.add_css_class (Granite.STYLE_CLASS_H3_LABEL);
7876

7977
component_listbox = new Gtk.ListBox () {
8078
selection_mode = Gtk.SelectionMode.NONE

src/Widgets/ComponentRow.vala

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ public class DateTime.ComponentRow : Gtk.ListBoxRow {
9090
component_image = new Gtk.Image.from_icon_name (icon_name) {
9191
valign = Gtk.Align.START
9292
};
93-
94-
unowned var component_image_context = component_image.get_style_context ();
95-
component_image_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
93+
component_image.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
9694

9795
name_label = new Gtk.Label (component.get_summary ()) {
9896
hexpand = true,
@@ -103,16 +101,14 @@ public class DateTime.ComponentRow : Gtk.ListBoxRow {
103101
wrap_mode = Pango.WrapMode.WORD_CHAR,
104102
xalign = 0
105103
};
106-
107-
var name_label_context = name_label.get_style_context ();
108-
name_label_context.add_class ("title");
109-
name_label_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
104+
name_label.add_css_class ("title");
105+
name_label.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
110106

111107
time_label = new Gtk.Label (null) {
112108
use_markup = true,
113109
xalign = 0,
114110
};
115-
time_label.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL);
111+
time_label.add_css_class (Granite.CssClass.DIM);
116112

117113
grid = new Gtk.Grid () {
118114
column_spacing = 6,
@@ -127,9 +123,8 @@ public class DateTime.ComponentRow : Gtk.ListBoxRow {
127123
grid.attach (time_label, 1, 1);
128124
}
129125

130-
unowned var grid_context = grid.get_style_context ();
131-
grid_context.add_class ("event");
132-
grid_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
126+
grid.add_css_class ("event");
127+
grid.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
133128

134129
child = grid;
135130

src/Widgets/calendar/CalendarView.vala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,21 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid {
4646
var provider = new Gtk.CssProvider ();
4747
provider.load_from_resource ("/io/elementary/desktop/wingpanel/datetime/ControlHeader.css");
4848

49-
unowned var label_style_context = label.get_style_context ();
50-
label_style_context.add_class (Granite.STYLE_CLASS_ACCENT);
51-
label_style_context.add_class ("header-label");
52-
label_style_context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
49+
label.add_css_class (Granite.CssClass.ACCENT);
50+
label.add_css_class ("header-label");
51+
52+
label.get_style_context ().add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
5353

5454
var left_button = new Gtk.Button.from_icon_name ("pan-start-symbolic");
5555
var center_button = new Gtk.Button.from_icon_name ("office-calendar-symbolic") {
5656
tooltip_text = _("Go to today's date")
5757
};
5858
var right_button = new Gtk.Button.from_icon_name ("pan-end-symbolic");
5959

60-
var box_buttons = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
60+
var box_buttons = new Granite.Box (HORIZONTAL, LINKED) {
6161
margin_end = 6,
62-
valign = Gtk.Align.CENTER
62+
valign = CENTER
6363
};
64-
box_buttons.get_style_context ().add_class (Granite.STYLE_CLASS_LINKED);
6564
box_buttons.append (left_button);
6665
box_buttons.append (center_button);
6766
box_buttons.append (right_button);

src/Widgets/calendar/Grid.vala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace DateTime.Widgets {
5151
header_labels = new Gtk.Label[7];
5252
for (int c = 0; c < 7; c++) {
5353
header_labels[c] = new Gtk.Label (null);
54-
header_labels[c].get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL);
54+
header_labels[c].add_css_class (Granite.STYLE_CLASS_H4_LABEL);
5555

5656
attach (header_labels[c], c + 2, 0);
5757
}
@@ -248,7 +248,7 @@ namespace DateTime.Widgets {
248248
margin_bottom = 6,
249249
width_chars = 2
250250
};
251-
week_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL);
251+
week_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL);
252252

253253
week_labels[c] = new Gtk.Revealer () {
254254
transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT,
@@ -280,11 +280,11 @@ namespace DateTime.Widgets {
280280
private void update_today_style (GridDay day, GLib.DateTime date, GLib.DateTime today) {
281281
if (date.get_day_of_year () == today.get_day_of_year () && date.get_year () == today.get_year ()) {
282282
day.name = "today";
283-
day.get_style_context ().add_class (Granite.STYLE_CLASS_ACCENT);
283+
day.add_css_class (Granite.CssClass.ACCENT);
284284
day.receives_default = true;
285285
} else if (day.name == "today") {
286286
day.name = "";
287-
day.get_style_context ().remove_class (Granite.STYLE_CLASS_ACCENT);
287+
day.remove_css_class (Granite.CssClass.ACCENT);
288288
day.receives_default = false;
289289
}
290290
}

src/Widgets/calendar/GridDay.vala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ public class DateTime.Widgets.GridDay : Granite.Bin {
4848
construct {
4949
label = new Gtk.Label (null);
5050

51-
unowned var label_style_context = label.get_style_context ();
52-
label_style_context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
53-
label_style_context.add_class ("circular");
51+
label.get_style_context ().add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
52+
label.add_css_class (Granite.CssClass.CIRCULAR);
5453

5554
event_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
5655
halign = Gtk.Align.CENTER,
@@ -101,10 +100,8 @@ public class DateTime.Widgets.GridDay : Granite.Bin {
101100
gicon = new ThemedIcon ("pager-checked-symbolic"),
102101
pixel_size = 6
103102
};
104-
105-
unowned var style_context = event_dot.get_style_context ();
106-
style_context.add_class (Granite.STYLE_CLASS_ACCENT);
107-
style_context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
103+
event_dot.add_css_class (Granite.CssClass.ACCENT);
104+
event_dot.get_style_context ().add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
108105

109106
unowned E.SourceSelectable? source_selectable = null;
110107
if (source.has_extension (E.SOURCE_EXTENSION_TASK_LIST)) {

src/Widgets/calendar/Util.vala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ namespace Util {
120120
providers[color] = style_provider;
121121
}
122122

123-
unowned Gtk.StyleContext style_context = widget.get_style_context ();
124-
style_context.add_provider (providers[color], Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
123+
widget.get_style_context ().add_provider (providers[color], Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
125124
}
126125

127126
/*

0 commit comments

Comments
 (0)