Skip to content

Commit

Permalink
Hardcode accent colors (#1683)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter committed Jun 13, 2023
1 parent c26f0a0 commit 878a918
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 80 deletions.
39 changes: 12 additions & 27 deletions src/AccentColor/AccentColorManager.vala
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
/*
* Copyright 2021 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
*
* Copyright 2021-2023 elementary, Inc. <https://elementary.io>
* SPDX-License-Identifier: GPL-3.0-or-later
* Authored by: Marius Meisenzahl <mariusmeisenzahl@gmail.com>
*/

Expand All @@ -41,16 +26,16 @@ public class Gala.AccentColorManager : Object {
private Settings interface_settings;

private NamedColor[] theme_colors = {
new NamedColor ("Blue", THEME_BLUE),
new NamedColor ("Mint", THEME_MINT),
new NamedColor ("Green", THEME_GREEN),
new NamedColor ("Yellow", THEME_YELLOW),
new NamedColor ("Orange", THEME_ORANGE),
new NamedColor ("Red", THEME_RED),
new NamedColor ("Pink", THEME_PINK),
new NamedColor ("Purple", THEME_PURPLE),
new NamedColor ("Brown", THEME_BROWN),
new NamedColor ("Gray", THEME_GRAY)
new NamedColor ("Blue", THEME_BLUE, new Drawing.Color.from_int (0x3689e6)),
new NamedColor ("Mint", THEME_MINT, new Drawing.Color.from_int (0x28bca3)),
new NamedColor ("Green", THEME_GREEN, new Drawing.Color.from_int (0x68b723)),
new NamedColor ("Yellow", THEME_YELLOW, new Drawing.Color.from_int (0xf9c440)),
new NamedColor ("Orange", THEME_ORANGE, new Drawing.Color.from_int (0xffa154)),
new NamedColor ("Red", THEME_RED, new Drawing.Color.from_int (0xed5353)),
new NamedColor ("Pink", THEME_PINK, new Drawing.Color.from_int (0xde3e80)),
new NamedColor ("Purple", THEME_PURPLE, new Drawing.Color.from_int (0xa56de2)),
new NamedColor ("Brown", THEME_BROWN, new Drawing.Color.from_int (0x8a715e)),
new NamedColor ("Gray", THEME_GRAY, new Drawing.Color.from_int (0x667885))
};

construct {
Expand Down
23 changes: 4 additions & 19 deletions src/AccentColor/NamedColor.vala
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
/*
* Copyright 2021 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
*
* Copyright 2021-2023 elementary, Inc. <https://elementary.io>
* SPDX-License-Identifier: GPL-3.0-or-later
* Authored by: Marius Meisenzahl <mariusmeisenzahl@gmail.com>
*/

Expand All @@ -24,11 +9,11 @@ public class Gala.NamedColor : Object {
public string theme { get; construct set; }
public Drawing.Color color { get; construct set; }

public NamedColor (string name, string theme) {
public NamedColor (string name, string theme, Drawing.Color color) {
Object (
name: name,
theme: theme,
color: InternalUtils.get_accent_color_by_theme_name (theme)
color: color
);
}
}
40 changes: 6 additions & 34 deletions src/InternalUtils.vala
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
//
// Copyright (C) 2012 Tom Beckmann, Rico Tzschichholz
//
// 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, see <http://www.gnu.org/licenses/>.
//
/*
* Copyright 2012 Tom Beckmann
* Copyright 2012 Rico Tzschichholz
* Copyright 2023 elementary, Inc. <https://elementary.io>
* SPDX-License-Identifier: GPL-3.0-or-later
*/

namespace Gala {
public enum InputArea {
Expand Down Expand Up @@ -323,24 +313,6 @@ namespace Gala {
);
}

public static Drawing.Color get_accent_color_by_theme_name (string theme_name) {
var label_widget_path = new Gtk.WidgetPath ();
label_widget_path.append_type (GLib.Type.from_name ("label"));
label_widget_path.iter_set_object_name (-1, "selection");

var selection_style_context = new Gtk.StyleContext ();
unowned Gtk.CssProvider theme_provider = Gtk.CssProvider.get_named (theme_name, null);
selection_style_context.add_provider (theme_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER);
selection_style_context.set_path (label_widget_path);

var rgba = (Gdk.RGBA) selection_style_context.get_property (
Gtk.STYLE_PROPERTY_BACKGROUND_COLOR,
Gtk.StateFlags.NORMAL
);

return new Drawing.Color.from_rgba (rgba);
}

/**
* Returns the workspaces geometry following the only_on_primary settings.
*/
Expand Down

0 comments on commit 878a918

Please sign in to comment.