From 4f5f5ffd964c6bd81fdd1b54c562b51b3296b5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= <danielle@elementary.io> Date: Wed, 15 May 2024 12:42:46 -0700 Subject: [PATCH 1/3] Create Application.css --- data/Application.css | 88 +++++++++++++++++++++++++++ data/EditableLabel.css | 27 -------- data/EntryPopover.css | 23 ------- data/SourceRow.css | 39 ------------ data/TaskRow.css | 56 ----------------- data/gresource.xml | 5 +- src/Application.vala | 5 ++ src/Widgets/EditableLabel.vala | 12 +--- src/Widgets/EntryPopover/Generic.vala | 17 +----- src/Widgets/SourceRow.vala | 14 +---- src/Widgets/TaskRow.vala | 29 +++------ 11 files changed, 108 insertions(+), 207 deletions(-) create mode 100644 data/Application.css delete mode 100644 data/EditableLabel.css delete mode 100644 data/EntryPopover.css delete mode 100644 data/SourceRow.css delete mode 100644 data/TaskRow.css diff --git a/data/Application.css b/data/Application.css new file mode 100644 index 0000000000..dc59652ae6 --- /dev/null +++ b/data/Application.css @@ -0,0 +1,88 @@ +/* + * Copyright 2020-2023 elementary, Inc. (https://elementary.io) + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +editable-label entry { + background: transparent; + border: none; + box-shadow: none; + color: inherit; + padding: 0; +} + +entry-popover box { + border-radius: 3px; + background: @SILVER_300; +} + +entry-popover button { + color: @SILVER_900; + font-size: 0.9em; + font-weight: 600; +} + +entry-popover.error box { + background: alpha(@error_color, 0.2); +} + +entry-popover.error button { + color: @error_color; +} + +row.task { + transition: all 250ms ease-in-out; +} + +row.task:focus:not(.card) { + background-color: shade(@base_color, 0.8); +} + +row.task.card { + background-color: @base_color; + margin-bottom: 12px; + margin-top: 1px; + padding-top: 6px; +} + +row.task entry.flat { + background: transparent; + border-style: solid; + border-color: transparent; + padding: 0; +} + +row.task entry.flat:focus { + opacity: 1; +} + +row.task:not(.card) entry.add-task { + border-color: alpha(@text_color, 0.25); +} + +row.task.drag-active { + background-color: @bg_color; + border: 1px solid @borders; + border-radius: 3px; + transition: none; +} + +.source-color { + background: @colorAccent; + border: 1px solid @borders; + border-radius: 50%; + box-shadow: + inset 0 1px 0 0 alpha(@inset_dark_color, 0.7), + inset 0 0 0 1px alpha(@inset_dark_color, 0.3), + 0 1px 0 0 alpha(@bg_highlight_color, 0.3); + min-height: 14px; + min-width: 14px; +} + +.sidebar image { + color: @text_color; +} + +.drop-hover { + background-color: @selected_bg_color; +} diff --git a/data/EditableLabel.css b/data/EditableLabel.css deleted file mode 100644 index 94c2c429b3..0000000000 --- a/data/EditableLabel.css +++ /dev/null @@ -1,27 +0,0 @@ -/* -* Copyright 2019 elementary, Inc. (https://elementary.io) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -*/ - -.editable-label entry { - background: transparent; - border: none; - box-shadow: none; - color: inherit; - padding: 0; -} diff --git a/data/EntryPopover.css b/data/EntryPopover.css deleted file mode 100644 index 9341cde330..0000000000 --- a/data/EntryPopover.css +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020-2023 elementary, Inc. (https://elementary.io) - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -entry-popover box { - border-radius: 3px; - background: @SILVER_300; -} - -entry-popover button { - color: @SILVER_900; - font-size: 0.9em; - font-weight: 600; -} - -entry-popover.error box { - background: alpha (@error_color, 0.2); -} - -entry-popover.error button { - color: @error_color; -} diff --git a/data/SourceRow.css b/data/SourceRow.css deleted file mode 100644 index be810a7444..0000000000 --- a/data/SourceRow.css +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Copyright 2019 elementary, Inc. (https://elementary.io) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -*/ - -.source-color { - background: @colorAccent; - border: 1px solid @borders; - border-radius: 50%; - box-shadow: - inset 0 1px 0 0 alpha (@inset_dark_color, 0.7), - inset 0 0 0 1px alpha (@inset_dark_color, 0.3), - 0 1px 0 0 alpha (@bg_highlight_color, 0.3); - min-height: 14px; - min-width: 14px; -} - -.sidebar image { - color: @text_color; -} - -.drop-hover { - background-color: @selected_bg_color; -} diff --git a/data/TaskRow.css b/data/TaskRow.css deleted file mode 100644 index 751fb066db..0000000000 --- a/data/TaskRow.css +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright 2019 elementary, Inc. (https://elementary.io) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -*/ - -row { - transition: all 250ms ease-in-out; -} - -row:focus:not(.card) { - background-color: shade (@base_color, 0.8); -} - -row.card { - background-color: @base_color; - margin-bottom: 12px; - margin-top: 1px; - padding-top: 6px; -} - -row entry.flat { - background: transparent; - border-style: solid; - border-color: transparent; - padding: 0; -} - -row entry.flat:focus { - opacity: 1; -} - -row:not(.card) entry.add-task { - border-color: alpha (@text_color, 0.25); -} - -row.drag-active { - background-color: @bg_color; - border: 1px solid @borders; - border-radius: 3px; - transition: none; -} diff --git a/data/gresource.xml b/data/gresource.xml index 55b2f7393b..353c87343b 100644 --- a/data/gresource.xml +++ b/data/gresource.xml @@ -1,10 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <gresources> <gresource prefix="/io/elementary/tasks"> - <file compressed="true">EditableLabel.css</file> - <file compressed="true">EntryPopover.css</file> - <file compressed="true">SourceRow.css</file> - <file compressed="true">TaskRow.css</file> + <file compressed="true">Application.css</file> </gresource> <gresource prefix="/io/elementary/tasks/icons"> <file alias="location-marker.svg" compressed="true" preprocess="xml-stripblanks">LocationMarker.svg</file> diff --git a/src/Application.vala b/src/Application.vala index 25b6b6ad82..6037b1d248 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -69,6 +69,11 @@ public class Tasks.Application : Gtk.Application { gtk_settings.gtk_application_prefer_dark_theme = ((Granite.Settings) obj).prefers_color_scheme == DARK; }); + var css_provider = new Gtk.CssProvider (); + css_provider.load_from_resource ("io/elementary/tasks/Application.css"); + + Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + var quit_action = new SimpleAction ("quit", null); quit_action.activate.connect (() => { if (active_window != null) { diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index ba3538dc5f..ae24976e66 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -7,8 +7,6 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox { public signal void changed (); - private static Gtk.CssProvider label_provider; - private Gtk.Label title; private Gtk.Entry entry; private Gtk.Stack stack; @@ -34,16 +32,11 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox { } } - static construct { - label_provider = new Gtk.CssProvider (); - label_provider.load_from_resource ("io/elementary/tasks/EditableLabel.css"); + class construct { + set_css_name ("editable-label"); } construct { - unowned Gtk.StyleContext style_context = get_style_context (); - style_context.add_class ("editable-label"); - style_context.add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - valign = Gtk.Align.CENTER; events |= Gdk.EventMask.ENTER_NOTIFY_MASK; events |= Gdk.EventMask.LEAVE_NOTIFY_MASK; @@ -75,7 +68,6 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox { entry = new Gtk.Entry () { hexpand = true }; - entry.get_style_context ().add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); stack = new Gtk.Stack () { hhomogeneous = false, diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 492f97fcf8..e3e7953213 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -13,7 +13,6 @@ public abstract class Tasks.Widgets.EntryPopover.Generic<T> : Gtk.EventBox { public T value { get; set; } private Gtk.MenuButton popover_button; - private static Gtk.CssProvider style_provider; private T value_on_popover_show; protected Generic (string placeholder, string? icon_name = null) { @@ -27,11 +26,6 @@ public abstract class Tasks.Widgets.EntryPopover.Generic<T> : Gtk.EventBox { set_css_name ("entry-popover"); } - static construct { - style_provider = new Gtk.CssProvider (); - style_provider.load_from_resource ("io/elementary/tasks/EntryPopover.css"); - } - construct { events |= Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK; @@ -44,18 +38,12 @@ public abstract class Tasks.Widgets.EntryPopover.Generic<T> : Gtk.EventBox { image = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.BUTTON), always_show_image = icon_name != null }; - - unowned Gtk.StyleContext popover_button_context = popover_button.get_style_context (); - popover_button_context.add_class (Gtk.STYLE_CLASS_FLAT); - popover_button_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + popover_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); var delete_button = new Gtk.Button.from_icon_name ("process-stop-symbolic", Gtk.IconSize.BUTTON) { tooltip_text = _("Remove") }; - - unowned Gtk.StyleContext delete_button_context = delete_button.get_style_context (); - delete_button_context.add_class (Gtk.STYLE_CLASS_FLAT); - delete_button_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + delete_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); var delete_button_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT, @@ -66,7 +54,6 @@ public abstract class Tasks.Widgets.EntryPopover.Generic<T> : Gtk.EventBox { var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); button_box.add (popover_button); button_box.add (delete_button_revealer); - button_box.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); add (button_box); diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index d889d38237..60f7898f5e 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -6,8 +6,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { public E.Source source { get; construct; } - private static Gtk.CssProvider listrow_provider; - private Gtk.Grid source_color; private Gtk.Image status_image; private Gtk.Label display_name_label; @@ -18,19 +16,11 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { Object (source: source); } - static construct { - listrow_provider = new Gtk.CssProvider (); - listrow_provider.load_from_resource ("io/elementary/tasks/SourceRow.css"); - } - construct { source_color = new Gtk.Grid () { valign = Gtk.Align.CENTER }; - - unowned Gtk.StyleContext source_color_context = source_color.get_style_context (); - source_color_context.add_class ("source-color"); - source_color_context.add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + source_color.get_style_context ().add_class ("source-color"); display_name_label = new Gtk.Label (source.display_name) { halign = Gtk.Align.START, @@ -41,7 +31,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { status_image = new Gtk.Image () { pixel_size = 16 }; - status_image.get_style_context ().add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var spinner = new Gtk.Spinner () { active = true, @@ -66,7 +55,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { revealer.add (box); add (revealer); - get_style_context ().add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); build_drag_and_drop (); diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 0313e5eb4c..a4c06bc20d 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -34,9 +34,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private Gtk.Revealer task_detail_revealer; private Gtk.Revealer task_form_revealer; private Gtk.TextBuffer description_textbuffer; - private unowned Gtk.StyleContext style_context; - - private static Gtk.CssProvider taskrow_provider; private TaskRow (ECal.Component task, E.Source source) { Object (task: task, source: source); @@ -53,11 +50,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { Object (source: source, task: task, is_scheduled_view: is_scheduled_view); } - static construct { - taskrow_provider = new Gtk.CssProvider (); - taskrow_provider.load_from_resource ("io/elementary/tasks/TaskRow.css"); - } - construct { can_focus = false; created = calcomponent_created (task); @@ -87,9 +79,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { summary_entry = new Gtk.Entry (); - unowned Gtk.StyleContext summary_entry_context = summary_entry.get_style_context (); - summary_entry_context.add_class (Gtk.STYLE_CLASS_FLAT); - summary_entry_context.add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + summary_entry.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); due_datetime_popover = new Tasks.Widgets.EntryPopover.DateTime (); @@ -281,9 +271,8 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { add (event_box); margin_start = margin_end = 12; - style_context = get_style_context (); - style_context.add_class (Granite.STYLE_CLASS_ROUNDED); - style_context.add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + get_style_context ().add_class ("task"); + get_style_context ().add_class (Granite.STYLE_CLASS_ROUNDED); if (created) { check.show (); @@ -402,12 +391,12 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { task_details_reveal_request (!value); if (value) { - style_context.add_class ("collapsed"); - style_context.add_class (Granite.STYLE_CLASS_CARD); + get_style_context ().add_class ("collapsed"); + get_style_context ().add_class (Granite.STYLE_CLASS_CARD); } else { - style_context.remove_class (Granite.STYLE_CLASS_CARD); - style_context.remove_class ("collapsed"); + get_style_context ().remove_class (Granite.STYLE_CLASS_CARD); + get_style_context ().remove_class ("collapsed"); } } @@ -552,13 +541,13 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { var style_context = get_style_context (); var had_cards_class = style_context.has_class (Granite.STYLE_CLASS_CARD); - style_context.add_class ("drag-active"); + get_style_context ().add_class ("drag-active"); if (had_cards_class) { style_context.remove_class (Granite.STYLE_CLASS_CARD); } draw_to_cairo_context (cairo_context); if (had_cards_class) { - style_context.add_class (Granite.STYLE_CLASS_CARD); + get_style_context ().add_class (Granite.STYLE_CLASS_CARD); } style_context.remove_class ("drag-active"); From bcce0edd4e2463c33ae7c1f22adb3b6bbeab8595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= <danielle@elementary.io> Date: Wed, 15 May 2024 12:50:27 -0700 Subject: [PATCH 2/3] Don't cache context --- src/Application.vala | 3 +- src/MainWindow.vala | 16 +++---- src/Widgets/ListSettingsPopover.vala | 60 +++++++++------------------ src/Widgets/ScheduledTaskListBox.vala | 12 ++---- src/Widgets/SourceRow.vala | 5 +-- src/Widgets/TaskListGrid.vala | 12 ++---- src/Widgets/TaskRow.vala | 7 ++-- 7 files changed, 39 insertions(+), 76 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 6037b1d248..2a002daba1 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -172,8 +172,7 @@ public class Tasks.Application : Gtk.Application { } } - unowned Gtk.StyleContext style_context = widget.get_style_context (); - style_context.add_provider (providers[color], Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + widget.get_style_context ().add_provider (providers[color], Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } public static int main (string[] args) { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 7563d0f537..9b6219129f 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -49,15 +49,15 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { has_subtitle = false, show_close_button = true }; - - unowned Gtk.StyleContext sidebar_header_context = sidebar_header.get_style_context (); - sidebar_header_context.add_class ("default-decoration"); - sidebar_header_context.add_class (Gtk.STYLE_CLASS_FLAT); + sidebar_header.get_style_context ().add_class ("default-decoration"); + sidebar_header.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); var main_header = new Hdy.HeaderBar () { has_subtitle = false, show_close_button = true }; + main_header.get_style_context ().add_class ("default-decoration"); + main_header.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); // Create a header group that automatically assigns the right decoration controls to the // right headerbar automatically @@ -65,10 +65,6 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { header_group.add_header_bar (sidebar_header); header_group.add_header_bar (main_header); - unowned Gtk.StyleContext main_header_context = main_header.get_style_context (); - main_header_context.add_class ("default-decoration"); - main_header_context.add_class (Gtk.STYLE_CLASS_FLAT); - listbox = new Gtk.ListBox (); listbox.set_sort_func (sort_function); @@ -111,9 +107,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { var actionbar = new Gtk.ActionBar (); actionbar.add (add_tasklist_button); - - unowned Gtk.StyleContext actionbar_style_context = actionbar.get_style_context (); - actionbar_style_context.add_class (Gtk.STYLE_CLASS_FLAT); + actionbar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); sidebar.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR); diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index dc7fd4ee5f..f7e62e8943 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -20,64 +20,44 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { construct { color_button_blue = new Gtk.RadioButton (null); - - unowned Gtk.StyleContext color_button_blue_context = color_button_blue.get_style_context (); - color_button_blue_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_blue_context.add_class ("blue"); + color_button_blue.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_blue.get_style_context ().add_class ("blue"); color_button_mint = new Gtk.RadioButton.from_widget (color_button_blue); - - unowned Gtk.StyleContext color_button_mint_context = color_button_mint.get_style_context (); - color_button_mint_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_mint_context.add_class ("mint"); + color_button_mint.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_mint.get_style_context ().add_class ("mint"); color_button_green = new Gtk.RadioButton.from_widget (color_button_blue); - - unowned Gtk.StyleContext color_button_green_context = color_button_green.get_style_context (); - color_button_green_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_green_context.add_class ("green"); + color_button_green.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_green.get_style_context ().add_class ("green"); color_button_yellow = new Gtk.RadioButton.from_widget (color_button_blue); - - unowned Gtk.StyleContext color_button_yellow_context = color_button_yellow.get_style_context (); - color_button_yellow_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_yellow_context.add_class ("yellow"); + color_button_yellow.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_yellow.get_style_context ().add_class ("yellow"); color_button_orange = new Gtk.RadioButton.from_widget (color_button_blue); - - unowned Gtk.StyleContext color_button_orange_context = color_button_orange.get_style_context (); - color_button_orange_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_orange_context.add_class ("orange"); + color_button_orange.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_orange.get_style_context ().add_class ("orange"); color_button_red = new Gtk.RadioButton.from_widget (color_button_blue); - - unowned Gtk.StyleContext color_button_red_context = color_button_red.get_style_context (); - color_button_red_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_red_context.add_class ("red"); + color_button_red.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_red.get_style_context ().add_class ("red"); color_button_pink = new Gtk.RadioButton.from_widget (color_button_blue); - - unowned Gtk.StyleContext color_button_pink_context = color_button_pink.get_style_context (); - color_button_pink_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_pink_context.add_class ("pink"); + color_button_pink.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_pink.get_style_context ().add_class ("pink"); color_button_purple = new Gtk.RadioButton.from_widget (color_button_blue); - - unowned Gtk.StyleContext color_button_purple_context = color_button_purple.get_style_context (); - color_button_purple_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_purple_context.add_class ("purple"); + color_button_purple.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_purple.get_style_context ().add_class ("purple"); color_button_brown = new Gtk.RadioButton.from_widget (color_button_blue); - - unowned Gtk.StyleContext color_button_brown_context = color_button_brown.get_style_context (); - color_button_brown_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_brown_context.add_class ("brown"); + color_button_brown.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_brown.get_style_context ().add_class ("brown"); color_button_slate = new Gtk.RadioButton.from_widget (color_button_blue); - - unowned Gtk.StyleContext color_button_slate_context = color_button_slate.get_style_context (); - color_button_slate_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_slate_context.add_class ("slate"); + color_button_slate.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_slate.get_style_context ().add_class ("slate"); color_button_none = new Gtk.RadioButton.from_widget (color_button_blue); diff --git a/src/Widgets/ScheduledTaskListBox.vala b/src/Widgets/ScheduledTaskListBox.vala index 6e6dbf993a..634ed05f75 100644 --- a/src/Widgets/ScheduledTaskListBox.vala +++ b/src/Widgets/ScheduledTaskListBox.vala @@ -64,17 +64,13 @@ public class Tasks.Widgets.ScheduledTaskListBox : Gtk.Box { margin_bottom = 24, xalign = 0 }; - - unowned Gtk.StyleContext scheduled_title_context = scheduled_title.get_style_context (); - scheduled_title_context.add_class (Granite.STYLE_CLASS_H1_LABEL); - scheduled_title_context.add_class (Granite.STYLE_CLASS_ACCENT); + scheduled_title.get_style_context ().add_class (Granite.STYLE_CLASS_H1_LABEL); + scheduled_title.get_style_context ().add_class (Granite.STYLE_CLASS_ACCENT); var placeholder = new Gtk.Label (_("No Tasks")); placeholder.show (); - - unowned Gtk.StyleContext placeholder_context = placeholder.get_style_context (); - placeholder_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); - placeholder_context.add_class (Granite.STYLE_CLASS_H2_LABEL); + placeholder.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + placeholder.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); task_list = new Gtk.ListBox () { selection_mode = Gtk.SelectionMode.MULTIPLE, diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 60f7898f5e..4887447a14 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -71,9 +71,8 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { } private bool on_drag_motion (Gdk.DragContext context, int x, int y, uint time) { - var style_context = get_style_context (); - if (!style_context.has_class ("drop-hover")) { - style_context.add_class ("drop-hover"); + if (!get_style_context ().has_class ("drop-hover")) { + get_style_context ().add_class ("drop-hover"); } return true; } diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 11ee20d5b3..7ad64c84c1 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -28,10 +28,8 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { editable_title = new EditableLabel () { margin_start = 24 }; - - unowned Gtk.StyleContext title_context = editable_title.get_style_context (); - title_context.add_class (Granite.STYLE_CLASS_H1_LABEL); - title_context.add_class (Granite.STYLE_CLASS_ACCENT); + editable_title.get_style_context ().add_class (Granite.STYLE_CLASS_H1_LABEL); + editable_title.get_style_context ().add_class (Granite.STYLE_CLASS_ACCENT); var list_settings_popover = new Tasks.Widgets.ListSettingsPopover (); @@ -47,10 +45,8 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { var placeholder = new Gtk.Label (_("No Tasks")); placeholder.show (); - - unowned Gtk.StyleContext placeholder_context = placeholder.get_style_context (); - placeholder_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); - placeholder_context.add_class (Granite.STYLE_CLASS_H2_LABEL); + placeholder.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + placeholder.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); add_task_list = new Gtk.ListBox () { margin_top = 24, diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index a4c06bc20d..e57a3af11e 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -538,18 +538,17 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, alloc.width, alloc.height); var cairo_context = new Cairo.Context (surface); - var style_context = get_style_context (); - var had_cards_class = style_context.has_class (Granite.STYLE_CLASS_CARD); + var had_cards_class = get_style_context ().has_class (Granite.STYLE_CLASS_CARD); get_style_context ().add_class ("drag-active"); if (had_cards_class) { - style_context.remove_class (Granite.STYLE_CLASS_CARD); + get_style_context ().remove_class (Granite.STYLE_CLASS_CARD); } draw_to_cairo_context (cairo_context); if (had_cards_class) { get_style_context ().add_class (Granite.STYLE_CLASS_CARD); } - style_context.remove_class ("drag-active"); + get_style_context ().remove_class ("drag-active"); int drag_icon_x, drag_icon_y; translate_coordinates (this, 0, 0, out drag_icon_x, out drag_icon_y); From 3171944d5c70857bde387b945cffd3767ef061f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= <danielle@elementary.io> Date: Wed, 15 May 2024 12:50:45 -0700 Subject: [PATCH 3/3] what year is it --- data/Application.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/Application.css b/data/Application.css index dc59652ae6..73a95d959c 100644 --- a/data/Application.css +++ b/data/Application.css @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 elementary, Inc. (https://elementary.io) + * Copyright 2020-2024 elementary, Inc. (https://elementary.io) * SPDX-License-Identifier: GPL-3.0-or-later */