Unverified Commit f765d2d4 authored by Erik Reider's avatar Erik Reider Committed by GitHub

Add cssPriority to config (#176)

* Added cssPriority to config * Fixed linting issues
parent 69375cc7
...@@ -27,6 +27,13 @@ config file to be able to detect config errors ...@@ -27,6 +27,13 @@ config file to be able to detect config errors
values: background, bottom, top, overlay ++ values: background, bottom, top, overlay ++
description: Layer of control center window relative to normal windows. background is below all windows, overlay is above all windows. description: Layer of control center window relative to normal windows. background is below all windows, overlay is above all windows.
*cssPriority* ++
type: string ++
default: application ++
values: application, user ++
description: Which GTK priority to use when loading the default and user ++
CSS files. Pick "user" to override *XDG_CONFIG_HOME/gtk-3.0/gtk.css*
*control-center-margin-top* ++ *control-center-margin-top* ++
type: integer ++ type: integer ++
default: 0 ++ default: 0 ++
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"positionX": "right", "positionX": "right",
"positionY": "top", "positionY": "top",
"layer": "top", "layer": "top",
"cssPriority": "application",
"control-center-margin-top": 0, "control-center-margin-top": 0,
"control-center-margin-bottom": 0, "control-center-margin-bottom": 0,
"control-center-margin-right": 0, "control-center-margin-right": 0,
......
...@@ -61,6 +61,20 @@ namespace SwayNotificationCenter { ...@@ -61,6 +61,20 @@ namespace SwayNotificationCenter {
} }
} }
public enum CssPriority {
APPLICATION, USER;
public int get_priority () {
switch (this) {
case APPLICATION:
default:
return Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION;
case USER:
return Gtk.STYLE_PROVIDER_PRIORITY_USER;
}
}
}
public class Category : Object { public class Category : Object {
public string ? sound { get; set; default = null; } public string ? sound { get; set; default = null; }
public string ? icon { get; set; default = null; } public string ? icon { get; set; default = null; }
...@@ -308,6 +322,11 @@ namespace SwayNotificationCenter { ...@@ -308,6 +322,11 @@ namespace SwayNotificationCenter {
get; set; default = Layer.TOP; get; set; default = Layer.TOP;
} }
/** The CSS loading priority */
public CssPriority cssPriority { // vala-lint=naming-convention
get; set; default = CssPriority.APPLICATION;
}
/** The timeout for notifications with NORMAL priority */ /** The timeout for notifications with NORMAL priority */
private const int TIMEOUT_DEFAULT = 10; private const int TIMEOUT_DEFAULT = 10;
private int _timeout = TIMEOUT_DEFAULT; private int _timeout = TIMEOUT_DEFAULT;
......
...@@ -20,6 +20,12 @@ ...@@ -20,6 +20,12 @@
"default": "top", "default": "top",
"enum": ["background", "bottom", "top", "overlay"] "enum": ["background", "bottom", "top", "overlay"]
}, },
"cssPriority": {
"type": "string",
"description": "Which GTK priority to use when loading the default and user CSS files. Pick \"user\" to override XDG_CONFIG_HOME/gtk-3.0/gtk.css",
"default": "application",
"enum": ["application", "user"]
},
"positionY": { "positionY": {
"type": "string", "type": "string",
"description": "Vertical position of control center and notification window", "description": "Vertical position of control center and notification window",
......
...@@ -70,6 +70,8 @@ namespace SwayNotificationCenter { ...@@ -70,6 +70,8 @@ namespace SwayNotificationCenter {
* with default GTK style properties * with default GTK style properties
*/ */
public static bool load_css (string ? style_path) { public static bool load_css (string ? style_path) {
int css_priority = ConfigModel.instance.cssPriority.get_priority ();
try { try {
// Load packaged CSS as backup // Load packaged CSS as backup
string system_css = get_style_path (null, true); string system_css = get_style_path (null, true);
...@@ -77,18 +79,23 @@ namespace SwayNotificationCenter { ...@@ -77,18 +79,23 @@ namespace SwayNotificationCenter {
Gtk.StyleContext.add_provider_for_screen ( Gtk.StyleContext.add_provider_for_screen (
Gdk.Screen.get_default (), Gdk.Screen.get_default (),
system_css_provider, system_css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); css_priority);
} catch (Error e) {
print ("Load packaged CSS Error: %s\n", e.message);
return false;
}
try {
// Load user CSS // Load user CSS
string user_css = get_style_path (style_path); string user_css = get_style_path (style_path);
user_css_provider.load_from_path (user_css); user_css_provider.load_from_path (user_css);
Gtk.StyleContext.add_provider_for_screen ( Gtk.StyleContext.add_provider_for_screen (
Gdk.Screen.get_default (), Gdk.Screen.get_default (),
user_css_provider, user_css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); css_priority);
return true; return true;
} catch (Error e) { } catch (Error e) {
print ("Load CSS Error: %s\n", e.message); print ("Load user CSS Error: %s\n", e.message);
return false; return false;
} }
} }
......
...@@ -37,8 +37,8 @@ namespace SwayNotificationCenter { ...@@ -37,8 +37,8 @@ namespace SwayNotificationCenter {
} }
} }
Functions.load_css (style_path);
ConfigModel.init (config_path); ConfigModel.init (config_path);
Functions.load_css (style_path);
swaync_daemon = new SwayncDaemon (); swaync_daemon = new SwayncDaemon ();
Bus.own_name (BusType.SESSION, "org.erikreider.swaync.cc", Bus.own_name (BusType.SESSION, "org.erikreider.swaync.cc",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment