mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge pull request #1663 from akaWolf/add_stamp_settings
Add option to configure incoming/outgoing stamps
This commit is contained in:
commit
4686a9ba2c
@ -2414,6 +2414,28 @@ static struct cmd_t command_defs[] = {
|
||||
"/color own off")
|
||||
},
|
||||
|
||||
{ "/stamp",
|
||||
parse_args, 0, 2, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_MAINFUNC(cmd_stamp)
|
||||
CMD_TAGS(
|
||||
CMD_TAG_UI)
|
||||
CMD_SYN("/stamp outgoing <string>",
|
||||
"/stamp incoming <string>",
|
||||
"/stamp unset outgoing|incoming")
|
||||
CMD_DESC("Set chat window stamp. "
|
||||
"The format of line in the chat window is: \"<timestamp> <encryption sign> <stamp> <message>\" "
|
||||
"where <stamp> is \"me:\" for incoming messages or \"username@server/resource\" for outgoing messages. "
|
||||
"This command allows to change <stamp> value.")
|
||||
CMD_ARGS({ "outgoing", "Set outgoing stamp" },
|
||||
{ "incoming", "Set incoming stamp"},
|
||||
{ "unset outgoing|incoming", "Use the defaults"})
|
||||
CMD_EXAMPLES(
|
||||
"/stamp outgoing -->",
|
||||
"/stamp incoming <--",
|
||||
"/stamp unset incoming")
|
||||
},
|
||||
|
||||
{ "/avatar",
|
||||
parse_args, 2, 2, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
|
@ -9053,6 +9053,57 @@ cmd_paste(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_stamp(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (g_strv_length(args) == 0) {
|
||||
char* def = prefs_get_string(PREF_OUTGOING_STAMP);
|
||||
if (def) {
|
||||
cons_show("The outgoing stamp is: %s", def);
|
||||
free(def);
|
||||
} else {
|
||||
cons_show("The default outgoing stamp is used.");
|
||||
}
|
||||
def = prefs_get_string(PREF_INCOMING_STAMP);
|
||||
if (def) {
|
||||
cons_show("The incoming stamp is: %s", def);
|
||||
free(def);
|
||||
} else {
|
||||
cons_show("The default incoming stamp is used.");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strv_length(args) == 1) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strv_length(args) == 2) {
|
||||
if (g_strcmp0(args[0], "outgoing") == 0) {
|
||||
prefs_set_string(PREF_OUTGOING_STAMP, args[1]);
|
||||
cons_show("Outgoing stamp set to: %s", args[1]);
|
||||
} else if (g_strcmp0(args[0], "incoming") == 0) {
|
||||
prefs_set_string(PREF_INCOMING_STAMP, args[1]);
|
||||
cons_show("Incoming stamp set to: %s", args[1]);
|
||||
} else if (g_strcmp0(args[0], "unset") == 0) {
|
||||
if (g_strcmp0(args[1], "incoming") == 0) {
|
||||
prefs_set_string(PREF_INCOMING_STAMP, NULL);
|
||||
cons_show("Incoming stamp unset");
|
||||
} else if (g_strcmp0(args[1], "outgoing") == 0) {
|
||||
prefs_set_string(PREF_OUTGOING_STAMP, NULL);
|
||||
cons_show("Outgoing stamp unset");
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_color(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
|
@ -250,5 +250,6 @@ gboolean cmd_correct_editor(ProfWin* window, const char* const command, gchar**
|
||||
gboolean cmd_silence(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_register(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_mood(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_stamp(ProfWin* window, const char* const command, gchar** args);
|
||||
|
||||
#endif
|
||||
|
@ -1817,6 +1817,8 @@ _get_group(preference_t pref)
|
||||
case PREF_TITLEBAR_MUC_TITLE_NAME:
|
||||
case PREF_SLASH_GUARD:
|
||||
case PREF_COMPOSE_EDITOR:
|
||||
case PREF_OUTGOING_STAMP:
|
||||
case PREF_INCOMING_STAMP:
|
||||
return PREF_GROUP_UI;
|
||||
case PREF_STATES:
|
||||
case PREF_OUTTYPE:
|
||||
@ -2147,6 +2149,10 @@ _get_key(preference_t pref)
|
||||
return "compose.editor";
|
||||
case PREF_SILENCE_NON_ROSTER:
|
||||
return "silence.incoming.nonroster";
|
||||
case PREF_OUTGOING_STAMP:
|
||||
return "stamp.outgoing";
|
||||
case PREF_INCOMING_STAMP:
|
||||
return "stamp.incoming";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@ -2285,6 +2291,10 @@ _get_default_string(preference_t pref)
|
||||
gchar* editor = getenv("EDITOR");
|
||||
return editor ? editor : "vim";
|
||||
}
|
||||
case PREF_OUTGOING_STAMP:
|
||||
return "me:";
|
||||
case PREF_INCOMING_STAMP:
|
||||
return NULL;
|
||||
case PREF_URL_SAVE_CMD:
|
||||
return NULL; // Default to built-in method.
|
||||
default:
|
||||
|
@ -176,6 +176,8 @@ typedef enum {
|
||||
PREF_URL_SAVE_CMD,
|
||||
PREF_COMPOSE_EDITOR,
|
||||
PREF_SILENCE_NON_ROSTER,
|
||||
PREF_OUTGOING_STAMP,
|
||||
PREF_INCOMING_STAMP,
|
||||
PREF_NOTIFY_ROOM_OFFLINE,
|
||||
} preference_t;
|
||||
|
||||
|
@ -1249,7 +1249,8 @@ win_print_outgoing(ProfWin* window, const char* show_char, const char* const id,
|
||||
if (replace_id) {
|
||||
_win_correct(window, message, id, replace_id, myjid);
|
||||
} else {
|
||||
_win_printf(window, show_char, 0, timestamp, 0, THEME_TEXT_ME, "me", myjid, id, "%s", message);
|
||||
char* outgoing_str = prefs_get_string(PREF_OUTGOING_STAMP);
|
||||
_win_printf(window, show_char, 0, timestamp, 0, THEME_TEXT_ME, outgoing_str, myjid, id, "%s", message);
|
||||
}
|
||||
|
||||
inp_nonblocking(TRUE);
|
||||
@ -1601,7 +1602,7 @@ _win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDat
|
||||
offset = 4;
|
||||
me_message = TRUE;
|
||||
} else {
|
||||
wprintw(window->layout->win, "%s: ", from);
|
||||
wprintw(window->layout->win, "%s ", from);
|
||||
wattroff(window->layout->win, colour);
|
||||
}
|
||||
}
|
||||
|
@ -199,6 +199,12 @@ roster_get_msg_display_name(const char* const barejid, const char* const resourc
|
||||
{
|
||||
assert(roster != NULL);
|
||||
|
||||
char* incoming_str = prefs_get_string(PREF_INCOMING_STAMP);
|
||||
|
||||
if (incoming_str) {
|
||||
return incoming_str;
|
||||
}
|
||||
|
||||
GString* result = g_string_new("");
|
||||
|
||||
PContact contact = roster_get_contact(barejid);
|
||||
|
Loading…
Reference in New Issue
Block a user