Added image_visibility parameter to config
This commit is contained in:
@@ -89,6 +89,7 @@ To reload the config, you'll need to run `swaync-client --reload-config`
|
|||||||
- `timeout`: Any positive number. The notification timeout for notifications with normal priority
|
- `timeout`: Any positive number. The notification timeout for notifications with normal priority
|
||||||
- `timeout-low`: Any positive number. The notification timeout for notifications with low priority
|
- `timeout-low`: Any positive number. The notification timeout for notifications with low priority
|
||||||
- `keyboard-shortcuts`: Boolean. If control center should use keyboard shortcuts
|
- `keyboard-shortcuts`: Boolean. If control center should use keyboard shortcuts
|
||||||
|
- `image-visibility`: `always`, `when-available` or `never`. Notification image visiblilty
|
||||||
|
|
||||||
The main CSS style file is located in `/etc/xdg/swaync/style.css`. Copy it over to your `.config/swaync/` folder to customize without needing root access.
|
The main CSS style file is located in `/etc/xdg/swaync/style.css`. Copy it over to your `.config/swaync/` folder to customize without needing root access.
|
||||||
|
|
||||||
|
@@ -9,4 +9,6 @@
|
|||||||
"timeout-low": 5,
|
"timeout-low": 5,
|
||||||
// If control center should use keyboard shortcuts
|
// If control center should use keyboard shortcuts
|
||||||
"keyboard_shortcuts": true,
|
"keyboard_shortcuts": true,
|
||||||
|
// Sets the notification image visiblilty
|
||||||
|
"image-visibility": "always"
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,15 @@ namespace SwayNotificatonCenter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ImageVisibility {
|
||||||
|
ALWAYS, WHEN_AVAILABLE, NEVER;
|
||||||
|
|
||||||
|
public string parse () {
|
||||||
|
EnumClass enumc = (EnumClass) typeof (ImageVisibility).class_ref ();
|
||||||
|
return enumc.get_value_by_name (this.to_string ()).value_nick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ConfigModel : Object, Json.Serializable {
|
public class ConfigModel : Object, Json.Serializable {
|
||||||
|
|
||||||
private static ConfigModel _instance;
|
private static ConfigModel _instance;
|
||||||
@@ -80,7 +89,8 @@ namespace SwayNotificatonCenter {
|
|||||||
public int timeout {
|
public int timeout {
|
||||||
get {
|
get {
|
||||||
return _timeout;
|
return _timeout;
|
||||||
} set {
|
}
|
||||||
|
set {
|
||||||
_timeout = value < 1 ? _timeout_def : value;
|
_timeout = value < 1 ? _timeout_def : value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,7 +101,8 @@ namespace SwayNotificatonCenter {
|
|||||||
public int timeout_low {
|
public int timeout_low {
|
||||||
get {
|
get {
|
||||||
return _timeout_low;
|
return _timeout_low;
|
||||||
} set {
|
}
|
||||||
|
set {
|
||||||
_timeout_low = value < 1 ? _timeout_low_def : value;
|
_timeout_low = value < 1 ? _timeout_low_def : value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,6 +113,13 @@ namespace SwayNotificatonCenter {
|
|||||||
*/
|
*/
|
||||||
public bool keyboard_shortcuts { get; set; default = true; }
|
public bool keyboard_shortcuts { get; set; default = true; }
|
||||||
|
|
||||||
|
/** Specifies if the notifcation image should be shown or not */
|
||||||
|
public ImageVisibility image_visibility {
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
default = ImageVisibility.ALWAYS;
|
||||||
|
}
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,6 +136,10 @@ namespace SwayNotificatonCenter {
|
|||||||
case "positionY":
|
case "positionY":
|
||||||
node.set_string (((PositionY) value.get_enum ()).parse ());
|
node.set_string (((PositionY) value.get_enum ()).parse ());
|
||||||
break;
|
break;
|
||||||
|
case "image-visibility":
|
||||||
|
var val = ((ImageVisibility) value.get_enum ()).parse ();
|
||||||
|
node.set_string (val);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
node.set_value (value);
|
node.set_value (value);
|
||||||
break;
|
break;
|
||||||
|
@@ -246,6 +246,12 @@ namespace SwayNotificatonCenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void set_icon () {
|
private void set_icon () {
|
||||||
|
var image_visibility = ConfigModel.instance.image_visibility;
|
||||||
|
if (image_visibility == ImageVisibility.NEVER) {
|
||||||
|
img.set_visible (false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
img.set_pixel_size (48);
|
img.set_pixel_size (48);
|
||||||
|
|
||||||
var img_path_exists = File.new_for_path (
|
var img_path_exists = File.new_for_path (
|
||||||
@@ -266,25 +272,29 @@ namespace SwayNotificatonCenter {
|
|||||||
} else {
|
} else {
|
||||||
// Get the app icon
|
// Get the app icon
|
||||||
GLib.Icon ? icon = null;
|
GLib.Icon ? icon = null;
|
||||||
foreach (var app in AppInfo.get_all ()) {
|
if (param.desktop_entry != null) {
|
||||||
var entry = app.get_id ();
|
foreach (var app in AppInfo.get_all ()) {
|
||||||
var ref_entry = param.desktop_entry;
|
var entry = app.get_id ();
|
||||||
var entry_same = true;
|
var ref_entry = param.desktop_entry;
|
||||||
if (entry != null && ref_entry != null) {
|
var entry_same = true;
|
||||||
entry_same = (entry == ref_entry);
|
if (entry != null && ref_entry != null) {
|
||||||
}
|
entry_same = (entry == ref_entry);
|
||||||
|
}
|
||||||
|
|
||||||
if (entry_same
|
if (entry_same &&
|
||||||
&& app.get_name ().down () == param.app_name.down ()) {
|
app.get_name ().down () == param.app_name.down ()) {
|
||||||
icon = app.get_icon ();
|
icon = app.get_icon ();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
img.set_from_gicon (icon, Gtk.IconSize.DIALOG);
|
img.set_from_gicon (icon, Gtk.IconSize.DIALOG);
|
||||||
} else {
|
} else if (image_visibility == ImageVisibility.ALWAYS) {
|
||||||
// Default icon
|
// Default icon
|
||||||
img.set_from_icon_name ("image-missing", Gtk.IconSize.DIALOG);
|
img.set_from_icon_name ("image-missing", Gtk.IconSize.DIALOG);
|
||||||
|
} else {
|
||||||
|
img.set_visible (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user