[gnome-clocks/bilelmoussaoui/css] CSS: simplify loading code
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/bilelmoussaoui/css] CSS: simplify loading code
- Date: Sat, 4 Apr 2020 11:41:21 +0000 (UTC)
commit 96e5f5867be80b9dbb20c25b3129bc7abcdbc2f3
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Sat Apr 4 13:40:53 2020 +0200
CSS: simplify loading code
the current code assumed we might add more 'themes' support
we only need to special case highcontrast
closes #89
src/application.vala | 8 +++++---
src/utils.vala | 11 ++---------
2 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/src/application.vala b/src/application.vala
index 24ac931..1410282 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -111,13 +111,15 @@ public class Application : Gtk.Application {
string theme_name;
settings.get ("gtk-theme-name", out theme_name);
- Utils.load_theme_css (theme_name);
+
+ if (theme_name.down () == "highcontrast") {
+ Utils.load_css ("/org/gnome/clocks/css/gnome-clocks.highcontrast.css");
+ }
}
protected override void startup () {
base.startup ();
-
- Utils.load_main_css ();
+ Utils.load_css ("/org/gnome/clocks/css/gnome-clocks.css");
set_resource_base_path ("/org/gnome/clocks/");
diff --git a/src/utils.vala b/src/utils.vala
index 74b912d..9857327 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -36,22 +36,15 @@ const double RISESET_CORRECTION_ASTRONOMICAL = 18.0;
namespace Clocks {
namespace Utils {
-private void load_css (string css, bool required) {
+private void load_css (string resource_uri) {
var provider = new Gtk.CssProvider ();
- provider.load_from_resource ("/org/gnome/clocks/css/" + css + ".css");
+ provider.load_from_resource (resource_uri);
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (),
provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
-public void load_main_css () {
- load_css ("gnome-clocks", true);
-}
-
-public void load_theme_css (string theme_name) {
- load_css ("gnome-clocks." + theme_name.down (), false);
-}
public void time_to_hms (double t, out int h, out int m, out int s, out double remainder) {
h = (int) t / 3600;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]