mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Added settings to show message text in notifications
This commit is contained in:
parent
b25b3f3180
commit
b36fbe413a
@ -477,10 +477,14 @@ static struct cmd_t command_defs[] =
|
||||
" : on|off",
|
||||
"message current : Whether messages in the current window trigger notifications.",
|
||||
" : on|off",
|
||||
"message text : Show message text in message notifications.",
|
||||
" : on|off",
|
||||
"room : Notificaitons for chat room messages.",
|
||||
" : on|off|mention",
|
||||
"room current : Whether chat room messages in the current window trigger notifications.",
|
||||
" : on|off",
|
||||
"room text : Show message test in chat room message notifications.",
|
||||
" : on|off",
|
||||
"remind : Notification reminders of unread messages.",
|
||||
" : where value is the reminder period in seconds,",
|
||||
" : use 0 to disable.",
|
||||
@ -494,8 +498,10 @@ static struct cmd_t command_defs[] =
|
||||
" : on|off",
|
||||
"",
|
||||
"Example : /notify message on (enable message notifications)",
|
||||
"Example : /notify message text on (show message text in notifications)",
|
||||
"Example : /notify room mention (enable chat room notifications only on mention)",
|
||||
"Example : /notify room current off (disable room message notifications when window visible)",
|
||||
"Example : /notify room text off (do not show message text in chat room notifications)",
|
||||
"Example : /notify remind 10 (remind every 10 seconds)",
|
||||
"Example : /notify remind 0 (switch off reminders)",
|
||||
"Example : /notify typing on (enable typing notifications)",
|
||||
@ -987,12 +993,14 @@ cmd_init(void)
|
||||
autocomplete_add(notify_message_ac, "on");
|
||||
autocomplete_add(notify_message_ac, "off");
|
||||
autocomplete_add(notify_message_ac, "current");
|
||||
autocomplete_add(notify_message_ac, "text");
|
||||
|
||||
notify_room_ac = autocomplete_new();
|
||||
autocomplete_add(notify_room_ac, "on");
|
||||
autocomplete_add(notify_room_ac, "off");
|
||||
autocomplete_add(notify_room_ac, "mention");
|
||||
autocomplete_add(notify_room_ac, "current");
|
||||
autocomplete_add(notify_room_ac, "text");
|
||||
|
||||
notify_typing_ac = autocomplete_new();
|
||||
autocomplete_add(notify_typing_ac, "on");
|
||||
@ -1821,6 +1829,16 @@ _notify_autocomplete(char *input, int *size)
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, size, "/notify room text", prefs_autocomplete_boolean_choice);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, size, "/notify message text", prefs_autocomplete_boolean_choice);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, size, "/notify room", notify_room_ac);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
|
@ -2220,6 +2220,16 @@ cmd_notify(gchar **args, struct cmd_help_t help)
|
||||
} else {
|
||||
cons_show("Usage: /notify message current on|off");
|
||||
}
|
||||
} else if (strcmp(args[1], "text") == 0) {
|
||||
if (g_strcmp0(args[2], "on") == 0) {
|
||||
cons_show("Showing text in message notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_MESSAGE_TEXT, TRUE);
|
||||
} else if (g_strcmp0(args[2], "off") == 0) {
|
||||
cons_show("Showing text in message notifications disabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_MESSAGE_TEXT, FALSE);
|
||||
} else {
|
||||
cons_show("Usage: /notify message text on|off");
|
||||
}
|
||||
} else {
|
||||
cons_show("Usage: /notify message on|off");
|
||||
}
|
||||
@ -2245,6 +2255,16 @@ cmd_notify(gchar **args, struct cmd_help_t help)
|
||||
} else {
|
||||
cons_show("Usage: /notify room current on|off");
|
||||
}
|
||||
} else if (strcmp(args[1], "text") == 0) {
|
||||
if (g_strcmp0(args[2], "on") == 0) {
|
||||
cons_show("Showing text in chat room message notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_ROOM_TEXT, TRUE);
|
||||
} else if (g_strcmp0(args[2], "off") == 0) {
|
||||
cons_show("Showing text in chat room message notifications disabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_ROOM_TEXT, FALSE);
|
||||
} else {
|
||||
cons_show("Usage: /notify room text on|off");
|
||||
}
|
||||
} else {
|
||||
cons_show("Usage: /notify room on|off|mention");
|
||||
}
|
||||
|
@ -403,8 +403,10 @@ _get_group(preference_t pref)
|
||||
case PREF_NOTIFY_TYPING_CURRENT:
|
||||
case PREF_NOTIFY_MESSAGE:
|
||||
case PREF_NOTIFY_MESSAGE_CURRENT:
|
||||
case PREF_NOTIFY_MESSAGE_TEXT:
|
||||
case PREF_NOTIFY_ROOM:
|
||||
case PREF_NOTIFY_ROOM_CURRENT:
|
||||
case PREF_NOTIFY_ROOM_TEXT:
|
||||
case PREF_NOTIFY_INVITE:
|
||||
case PREF_NOTIFY_SUB:
|
||||
return PREF_GROUP_NOTIFICATIONS;
|
||||
@ -471,10 +473,14 @@ _get_key(preference_t pref)
|
||||
return "message";
|
||||
case PREF_NOTIFY_MESSAGE_CURRENT:
|
||||
return "message.current";
|
||||
case PREF_NOTIFY_MESSAGE_TEXT:
|
||||
return "message.text";
|
||||
case PREF_NOTIFY_ROOM:
|
||||
return "room";
|
||||
case PREF_NOTIFY_ROOM_CURRENT:
|
||||
return "room.current";
|
||||
case PREF_NOTIFY_ROOM_TEXT:
|
||||
return "room.text";
|
||||
case PREF_NOTIFY_INVITE:
|
||||
return "invite";
|
||||
case PREF_NOTIFY_SUB:
|
||||
|
@ -55,8 +55,10 @@ typedef enum {
|
||||
PREF_NOTIFY_TYPING_CURRENT,
|
||||
PREF_NOTIFY_MESSAGE,
|
||||
PREF_NOTIFY_MESSAGE_CURRENT,
|
||||
PREF_NOTIFY_MESSAGE_TEXT,
|
||||
PREF_NOTIFY_ROOM,
|
||||
PREF_NOTIFY_ROOM_CURRENT,
|
||||
PREF_NOTIFY_ROOM_TEXT,
|
||||
PREF_NOTIFY_INVITE,
|
||||
PREF_NOTIFY_SUB,
|
||||
PREF_CHLOG,
|
||||
|
@ -1168,6 +1168,11 @@ _cons_notify_setting(void)
|
||||
else
|
||||
cons_show("Messages current (/notify message) : OFF");
|
||||
|
||||
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT))
|
||||
cons_show("Messages text (/notify message) : ON");
|
||||
else
|
||||
cons_show("Messages text (/notify message) : OFF");
|
||||
|
||||
char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
|
||||
cons_show ("Room messages (/notify room) : %s", room_setting);
|
||||
|
||||
@ -1176,6 +1181,11 @@ _cons_notify_setting(void)
|
||||
else
|
||||
cons_show("Room current (/notify room) : OFF");
|
||||
|
||||
if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT))
|
||||
cons_show("Room text (/notify room) : ON");
|
||||
else
|
||||
cons_show("Room text (/notify room) : OFF");
|
||||
|
||||
if (prefs_get_boolean(PREF_NOTIFY_TYPING))
|
||||
cons_show("Composing (/notify typing) : ON");
|
||||
else
|
||||
|
@ -376,7 +376,11 @@ _ui_incoming_msg(const char * const from, const char * const message,
|
||||
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
|
||||
gboolean is_current = wins_is_current(window);
|
||||
if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
|
||||
notify_message(display_from, ui_index);
|
||||
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT)) {
|
||||
notify_message(display_from, ui_index, message);
|
||||
} else {
|
||||
notify_message(display_from, ui_index, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1723,7 +1727,11 @@ _ui_room_message(const char * const room_jid, const char * const nick,
|
||||
gboolean is_current = wins_is_current(window);
|
||||
if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT)) ) {
|
||||
Jid *jidp = jid_create(room_jid);
|
||||
notify_room_message(nick, jidp->localpart, ui_index);
|
||||
if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) {
|
||||
notify_room_message(nick, jidp->localpart, ui_index, message);
|
||||
} else {
|
||||
notify_room_message(nick, jidp->localpart, ui_index, NULL);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
}
|
||||
|
@ -85,25 +85,31 @@ _notify_invite(const char * const from, const char * const room,
|
||||
}
|
||||
|
||||
static void
|
||||
_notify_message(const char * const handle, int win)
|
||||
_notify_message(const char * const handle, int win, const char * const text)
|
||||
{
|
||||
char message[strlen(handle) + 1 + 14];
|
||||
sprintf(message, "%s: message (%d).", handle, win);
|
||||
GString *message = g_string_new("");
|
||||
g_string_append_printf(message, "%s (win %d)", handle, win);
|
||||
if (text != NULL) {
|
||||
g_string_append_printf(message, "\n%s", text);
|
||||
}
|
||||
|
||||
_notify(message, 10000, "incoming message");
|
||||
_notify(message->str, 10000, "incoming message");
|
||||
|
||||
g_string_free(message, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
_notify_room_message(const char * const handle, const char * const room, int win)
|
||||
_notify_room_message(const char * const handle, const char * const room, int win, const char * const text)
|
||||
{
|
||||
GString *text = g_string_new("");
|
||||
GString *message = g_string_new("");
|
||||
g_string_append_printf(message, "%s in %s (win %d)", handle, room, win);
|
||||
if (text != NULL) {
|
||||
g_string_append_printf(message, "\n%s", text);
|
||||
}
|
||||
|
||||
g_string_append_printf(text, "Room: %s\n", room);
|
||||
g_string_append_printf(text, "%s: message (%d).", handle, win);
|
||||
_notify(message->str, 10000, "incoming message");
|
||||
|
||||
_notify(text->str, 10000, "incoming message");
|
||||
|
||||
g_string_free(text, TRUE);
|
||||
g_string_free(message, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -165,7 +171,6 @@ _notify(const char * const message, int timeout,
|
||||
const char * const category)
|
||||
{
|
||||
#ifdef HAVE_LIBNOTIFY
|
||||
|
||||
if (notify_is_initted()) {
|
||||
NotifyNotification *notification;
|
||||
notification = notify_notification_new("Profanity", message, NULL);
|
||||
|
@ -260,9 +260,9 @@ void (*notifier_init)(void);
|
||||
void (*notifier_uninit)(void);
|
||||
|
||||
void (*notify_typing)(const char * const handle);
|
||||
void (*notify_message)(const char * const handle, int win);
|
||||
void (*notify_message)(const char * const handle, int win, const char * const text);
|
||||
void (*notify_room_message)(const char * const handle, const char * const room,
|
||||
int win);
|
||||
int win, const char * const text);
|
||||
void (*notify_remind)(void);
|
||||
void (*notify_invite)(const char * const from, const char * const room,
|
||||
const char * const reason);
|
||||
|
Loading…
Reference in New Issue
Block a user