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) { private void on_subscribe (uint count, bool dnd, bool cc_open) {
stdout.write ( stdout.printf (
@"{ \"count\": $(count), \"dnd\": $(dnd), \"visible\": $(cc_open) }\n".data); "{ \"count\": %u, \"dnd\": %s, \"visible\": %s }\n"
.printf (count, dnd.to_string (), cc_open.to_string ()));
} }
private void print_subscribe () { private void print_subscribe () {
@@ -70,12 +71,12 @@ private void on_subscribe_waybar (uint count, bool dnd, bool cc_open) {
string tooltip = ""; string tooltip = "";
if (count > 0) { 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) { if (cc_open) {
_class = @"[$(_class), \"cc-open\"]"; _class = "[%s, \"cc-open\"]".printf (_class);
} }
print ( print (

View File

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

View File

@@ -129,13 +129,13 @@ namespace SwayNotificationCenter {
*/ */
[DBus (name = "Notify")] [DBus (name = "Notify")]
public new uint32 notify (string app_name, public new uint32 notify (string app_name,
uint32 replaces_id, uint32 replaces_id,
string app_icon, string app_icon,
string summary, string summary,
string body, string body,
string[] actions, string[] actions,
HashTable<string, Variant> hints, HashTable<string, Variant> hints,
int expire_timeout) throws DBusError, IOError { int expire_timeout) throws DBusError, IOError {
uint32 id = replaces_id; uint32 id = replaces_id;
if (replaces_id == 0 || replaces_id > noti_id) id = ++noti_id; if (replaces_id == 0 || replaces_id > noti_id) id = ++noti_id;
@@ -227,7 +227,7 @@ namespace SwayNotificationCenter {
_hints.insert ("urgency", _hints.insert ("urgency",
UrgencyLevels.CRITICAL.to_byte ()); 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; string _body = "<b>Output:</b> " + error_msg;
this.notify ("SwayNotificationCenter", this.notify ("SwayNotificationCenter",
0, 0,
@@ -274,9 +274,9 @@ namespace SwayNotificationCenter {
*/ */
[DBus (name = "GetServerInformation")] [DBus (name = "GetServerInformation")]
public void get_server_information (out string name, public void get_server_information (out string name,
out string vendor, out string vendor,
out string version, out string version,
out string spec_version) out string spec_version)
throws DBusError, IOError { throws DBusError, IOError {
name = "SwayNotificationCenter"; name = "SwayNotificationCenter";
vendor = "ErikReider"; vendor = "ErikReider";

View File

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