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

95 lines
3.4 KiB
Vala
Raw Normal View History

2019-03-11 15:14:37 +01:00
public enum Tootle.API.NotificationType {
2018-04-17 14:01:55 +02:00
MENTION,
REBLOG,
REBLOG_REMOTE_USER, // Internal
2018-04-17 14:01:55 +02:00
FAVORITE,
2018-05-09 17:32:53 +02:00
FOLLOW,
FOLLOW_REQUEST, // Internal
WATCHLIST; // Internal
2018-04-17 14:01:55 +02:00
2020-05-29 14:19:35 +02:00
public string to_string () {
2018-04-17 14:01:55 +02:00
switch (this) {
case MENTION:
return "mention";
case REBLOG:
return "reblog";
case REBLOG_REMOTE_USER:
return "reblog_remote";
2018-04-17 14:01:55 +02:00
case FAVORITE:
return "favourite";
case FOLLOW:
return "follow";
2018-05-09 17:32:53 +02:00
case FOLLOW_REQUEST:
return "follow_request";
2018-07-14 10:37:41 +02:00
case WATCHLIST:
return "watchlist";
2018-04-17 14:01:55 +02:00
default:
2020-05-29 14:19:35 +02:00
warning (@"Unknown notification type: $this");
return "";
2018-04-17 14:01:55 +02:00
}
}
2020-05-29 14:19:35 +02:00
public static NotificationType from_string (string str) throws Oopsie {
2018-04-17 14:01:55 +02:00
switch (str) {
case "mention":
return MENTION;
case "reblog":
return REBLOG;
case "reblog_remote":
return REBLOG_REMOTE_USER;
2018-04-17 14:01:55 +02:00
case "favourite":
return FAVORITE;
case "follow":
return FOLLOW;
2018-05-09 17:32:53 +02:00
case "follow_request":
return FOLLOW_REQUEST;
2018-07-14 10:37:41 +02:00
case "watchlist":
return WATCHLIST;
2018-04-17 14:01:55 +02:00
default:
2020-05-29 14:19:35 +02:00
throw new Oopsie.INSTANCE (@"Unknown notification type: $str");
2018-04-17 14:01:55 +02:00
}
}
2018-04-17 14:01:55 +02:00
public string get_desc (Account? account) {
switch (this) {
case MENTION:
return _("<span underline=\"none\"><a href=\"%s\">%s</a> mentioned you</span>").printf (account.url, account.display_name);
2018-04-17 14:01:55 +02:00
case REBLOG:
return _("<span underline=\"none\"><a href=\"%s\">%s</a> boosted your status</span>").printf (account.url, account.display_name);
case REBLOG_REMOTE_USER:
return _("<span underline=\"none\"><a href=\"%s\">%s</a> boosted</span>").printf (account.url, account.display_name);
2018-04-17 14:01:55 +02:00
case FAVORITE:
return _("<span underline=\"none\"><a href=\"%s\">%s</a> favorited your status</span>").printf (account.url, account.display_name);
2018-04-17 14:01:55 +02:00
case FOLLOW:
return _("<span underline=\"none\"><a href=\"%s\">%s</a> now follows you</span>").printf (account.url, account.display_name);
2018-05-09 17:32:53 +02:00
case FOLLOW_REQUEST:
return _("<span underline=\"none\"><a href=\"%s\">%s</a> wants to follow you</span>").printf (account.url, account.display_name);
2018-07-14 10:37:41 +02:00
case WATCHLIST:
return _("<span underline=\"none\"><a href=\"%s\">%s</a> posted a status</span>").printf (account.url, account.display_name);
2018-04-17 14:01:55 +02:00
default:
2020-05-29 14:19:35 +02:00
warning (@"Unknown notification type: $this");
return "";
2018-04-17 14:01:55 +02:00
}
}
2018-04-17 14:01:55 +02:00
public string get_icon () {
switch (this) {
case MENTION:
2018-07-14 10:37:41 +02:00
case WATCHLIST:
2018-04-17 14:01:55 +02:00
return "user-available-symbolic";
case REBLOG:
2020-05-29 14:19:35 +02:00
case REBLOG_REMOTE_USER:
2018-06-03 18:44:36 +02:00
return "media-playlist-repeat-symbolic";
2018-04-17 14:01:55 +02:00
case FAVORITE:
2019-03-09 11:32:26 +01:00
return "emblem-favorite-symbolic";
2018-04-17 14:01:55 +02:00
case FOLLOW:
2018-05-09 17:32:53 +02:00
case FOLLOW_REQUEST:
2018-04-17 14:01:55 +02:00
return "contact-new-symbolic";
default:
2020-05-29 14:19:35 +02:00
warning (@"Unknown notification type: $this");
return "";
2018-04-17 14:01:55 +02:00
}
}
2018-04-17 14:01:55 +02:00
}