Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Application.css #379

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions data/Application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright 2020-2024 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;
}
27 changes: 0 additions & 27 deletions data/EditableLabel.css

This file was deleted.

23 changes: 0 additions & 23 deletions data/EntryPopover.css

This file was deleted.

39 changes: 0 additions & 39 deletions data/SourceRow.css

This file was deleted.

56 changes: 0 additions & 56 deletions data/TaskRow.css

This file was deleted.

5 changes: 1 addition & 4 deletions data/gresource.xml
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
8 changes: 6 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -167,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) {
Expand Down
16 changes: 5 additions & 11 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,22 @@ 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
var header_group = new Hdy.HeaderGroup ();
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);

Expand Down Expand Up @@ -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);
Expand Down
12 changes: 2 additions & 10 deletions src/Widgets/EditableLabel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 2 additions & 15 deletions src/Widgets/EntryPopover/Generic.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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,
Expand All @@ -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);

Expand Down
Loading