tootle-linux-client/src/API/NotificationType.vala

68 lines
2.0 KiB
Vala
Raw Normal View History

2018-04-17 14:01:55 +02:00
public enum Tootle.NotificationType {
MENTION,
REBLOG,
FAVORITE,
FOLLOW;
public string to_string() {
switch (this) {
case MENTION:
return "mention";
case REBLOG:
return "reblog";
case FAVORITE:
return "favourite";
case FOLLOW:
return "follow";
default:
assert_not_reached();
}
}
public static NotificationType from_string (string str) {
switch (str) {
case "mention":
return MENTION;
case "reblog":
return REBLOG;
case "favourite":
return FAVORITE;
case "follow":
return FOLLOW;
default:
assert_not_reached();
}
}
public string get_desc (Account? account) {
switch (this) {
case MENTION:
return _("<a href=\"%s\"><b>%s</b></a> mentioned you").printf (account.url, account.display_name);
case REBLOG:
return _("<a href=\"%s\"><b>%s</b></a> boosted your toot").printf (account.url, account.display_name);
case FAVORITE:
return _("<a href=\"%s\"><b>%s</b></a> favorited your toot").printf (account.url, account.display_name);
case FOLLOW:
return _("<a href=\"%s\"><b>%s</b></a> now follows you").printf (account.url, account.display_name);
default:
assert_not_reached();
}
}
public string get_icon () {
switch (this) {
case MENTION:
return "user-available-symbolic";
case REBLOG:
2018-04-24 16:50:38 +02:00
return "go-up-symbolic";
2018-04-17 14:01:55 +02:00
case FAVORITE:
return "help-about-symbolic";
case FOLLOW:
return "contact-new-symbolic";
default:
assert_not_reached();
}
}
}