Removed all string templates

This commit is contained in:
Erik Reider
2022-05-06 13:28:57 +02:00
parent 902ede9c15
commit c38a189060
4 changed files with 36 additions and 35 deletions

View File

@@ -51,8 +51,9 @@ private void print_help (string[] args) {
}
private void on_subscribe (uint count, bool dnd, bool cc_open) {
stdout.write (
@"{ \"count\": $(count), \"dnd\": $(dnd), \"visible\": $(cc_open) }\n".data);
stdout.printf (
"{ \"count\": %u, \"dnd\": %s, \"visible\": %s }\n"
.printf (count, dnd.to_string (), cc_open.to_string ()));
}
private void print_subscribe () {
@@ -70,12 +71,12 @@ private void on_subscribe_waybar (uint count, bool dnd, bool cc_open) {
string tooltip = "";
if (count > 0) {
tooltip = @"$(count) Notification" + (count > 1 ? "s" : "");
tooltip = "%u Notification%s".printf (count, count > 1 ? "s" : "");
}
string _class = @"\"$(state)\"";
string _class = "\"%s\"".printf (state);
if (cc_open) {
_class = @"[$(_class), \"cc-open\"]";
_class = "[%s, \"cc-open\"]".printf (_class);
}
print (

View File

@@ -48,8 +48,8 @@ namespace SwayNotificationCenter {
public string to_string () {
string[] fields = {};
if (sound != null) fields += @"sound: $sound";
if (icon != null) fields += @"icon: $icon";
if (sound != null) fields += "sound: %s".printf (sound);
if (icon != null) fields += "icon: %s".printf (icon);
return string.joinv (", ", fields);
}
}
@@ -106,11 +106,11 @@ namespace SwayNotificationCenter {
public string to_string () {
string[] fields = {};
if (app_name != null) fields += @"app-name: $app_name";
if (summary != null) fields += @"summary: $summary";
if (body != null) fields += @"body: $body";
if (urgency != null) fields += @"urgency: $urgency";
if (category != null) fields += @"category: $category";
if (app_name != null) fields += "app-name: %s".printf (app_name);
if (summary != null) fields += "summary: %s".printf (summary);
if (body != null) fields += "body: %s".printf (body);
if (urgency != null) fields += "urgency: %s".printf (urgency);
if (category != null) fields += "category: %s".printf (category);
return string.joinv (", ", fields);
}
@@ -175,15 +175,15 @@ namespace SwayNotificationCenter {
try {
string[] spawn_env = Environ.get ();
// Export env variables
spawn_env += @"SWAYNC_APP_NAME=" + param.app_name;
spawn_env += @"SWAYNC_SUMMARY=" + param.summary;
spawn_env += @"SWAYNC_BODY=" + param.body;
spawn_env += @"SWAYNC_URGENCY=" + param.urgency.to_string ();
spawn_env += @"SWAYNC_CATEGORY=" + param.category;
spawn_env += @"SWAYNC_ID=" + param.applied_id.to_string ();
spawn_env += @"SWAYNC_REPLACES_ID=" + param.replaces_id.to_string ();
spawn_env += @"SWAYNC_TIME=" + param.time.to_string ();
spawn_env += @"SWAYNC_DESKTOP_ENTRY=" + param.desktop_entry ?? "";
spawn_env += "SWAYNC_APP_NAME=%s".printf (param.app_name);
spawn_env += "SWAYNC_SUMMARY=%s".printf (param.summary);
spawn_env += "SWAYNC_BODY=%s".printf (param.body);
spawn_env += "SWAYNC_URGENCY=%s".printf (param.urgency.to_string ());
spawn_env += "SWAYNC_CATEGORY=%s".printf (param.category);
spawn_env += "SWAYNC_ID=%s".printf (param.applied_id.to_string ());
spawn_env += "SWAYNC_REPLACES_ID=%s".printf (param.replaces_id.to_string ());
spawn_env += "SWAYNC_TIME=%s".printf (param.time.to_string ());
spawn_env += "SWAYNC_DESKTOP_ENTRY=%s".printf (param.desktop_entry ?? "");
Pid child_pid;
Process.spawn_async (

View File

@@ -227,7 +227,7 @@ namespace SwayNotificationCenter {
_hints.insert ("urgency",
UrgencyLevels.CRITICAL.to_byte ());
string _summary = @"Failed to run script: $key";
string _summary = "Failed to run script: %s".printf (key);
string _body = "<b>Output:</b> " + error_msg;
this.notify ("SwayNotificationCenter",
0,

View File

@@ -59,7 +59,7 @@ namespace SwayNotificationCenter {
public string to_string () {
if (identifier == null || name == null) return "None";
return @"Name: $name, Id: $identifier";
return "Name: %s, Id: %s".printf (name, identifier);
}
}
@@ -250,7 +250,7 @@ namespace SwayNotificationCenter {
if (!key.contains ("image") && !key.contains ("icon")) {
data = v.print (true);
}
_hints += @"\n\t$key: " + data;
_hints += "\n\t%s: %s".printf (key, data);
}
params.set ("hints", string.joinv ("", _hints));
params.set ("expire_timeout", expire_timeout.to_string ());
@@ -273,7 +273,7 @@ namespace SwayNotificationCenter {
string[] result = {};
foreach (var k in params.get_keys ()) {
string ? v = params[k];
result += @"$k:\t\t" + v;
result += "%s:\t\t %s".printf (k, v);
}
return "\n" + string.joinv ("\n", result);
}