diff options
| author | James Booth <boothj5@gmail.com> | 2017-01-20 23:26:14 +0000 |
|---|---|---|
| committer | James Booth <boothj5@gmail.com> | 2017-01-20 23:26:14 +0000 |
| commit | 9cfd17821c427ae2c129842b5f626fbdb3a73a67 (patch) | |
| tree | 274d033b508a6c5affe9f3248924104893be47d7 /src/ui | |
| parent | c8874cd2e0c7a62eff66cb19acd40e36750d1b50 (diff) | |
| download | profani-tty-9cfd17821c427ae2c129842b5f626fbdb3a73a67.tar.gz | |
Allow room display properies to be set by plugins
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/mucwin.c | 49 | ||||
| -rw-r--r-- | src/ui/titlebar.c | 26 | ||||
| -rw-r--r-- | src/ui/ui.h | 4 | ||||
| -rw-r--r-- | src/ui/win_types.h | 2 | ||||
| -rw-r--r-- | src/ui/window.c | 20 | ||||
| -rw-r--r-- | src/ui/window.h | 6 |
6 files changed, 92 insertions, 15 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 676e3aed..e532871c 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -478,18 +478,23 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes ProfWin *window = (ProfWin*)mucwin; char *mynick = muc_nick(mucwin->roomjid); + char ch = '-'; + if (mucwin->message_char) { + ch = mucwin->message_char[0]; + } + if (g_strcmp0(nick, mynick) != 0) { if (g_slist_length(mentions) > 0) { - win_print_them(window, THEME_ROOMMENTION, nick); + win_print_them(window, THEME_ROOMMENTION, ch, nick); _mucwin_print_mention(window, message, mynick, mentions); } else if (triggers) { - win_print_them(window, THEME_ROOMTRIGGER, nick); + win_print_them(window, THEME_ROOMTRIGGER, ch, nick); _mucwin_print_triggers(window, message, triggers); } else { - win_println_them_message(window, nick, "%s", message); + win_println_them_message(window, ch, nick, "%s", message); } } else { - win_println_me_message(window, mynick, "%s", message); + win_println_me_message(window, ch, mynick, "%s", message); } } @@ -860,3 +865,39 @@ mucwin_get_string(ProfMucWin *mucwin) return resstr; } + +void +mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext) +{ + if (mucwin->enctext) { + free(mucwin->enctext); + } + mucwin->enctext = strdup(enctext); +} + +void +mucwin_unset_enctext(ProfMucWin *mucwin) +{ + if (mucwin->enctext) { + free(mucwin->enctext); + mucwin->enctext = NULL; + } +} + +void +mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch) +{ + if (mucwin->message_char) { + free(mucwin->message_char); + } + mucwin->message_char = strdup(ch); +} + +void +mucwin_unset_message_char(ProfMucWin *mucwin) +{ + if (mucwin->message_char) { + free(mucwin->message_char); + mucwin->message_char = NULL; + } +} diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 39624a0a..77360ec5 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -62,6 +62,7 @@ static void _title_bar_draw(void); static void _show_self_presence(void); static void _show_contact_presence(ProfChatWin *chatwin); static void _show_privacy(ProfChatWin *chatwin); +static void _show_muc_privacy(ProfMucWin *mucwin); void create_title_bar(void) @@ -202,6 +203,10 @@ _title_bar_draw(void) if (typing) { wprintw(win, " (typing...)"); } + } else if (current && current->type == WIN_MUC) { + ProfMucWin *mucwin = (ProfMucWin*) current; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + _show_muc_privacy(mucwin); } _show_self_presence(); @@ -311,6 +316,27 @@ _show_self_presence(void) } static void +_show_muc_privacy(ProfMucWin *mucwin) +{ + int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); + int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED); + + if (mucwin->enctext) { + wprintw(win, " "); + wattron(win, bracket_attrs); + wprintw(win, "["); + wattroff(win, bracket_attrs); + wattron(win, encrypted_attrs); + wprintw(win, mucwin->enctext); + wattroff(win, encrypted_attrs); + wattron(win, bracket_attrs); + wprintw(win, "]"); + + return; + } +} + +static void _show_privacy(ProfChatWin *chatwin) { int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); diff --git a/src/ui/ui.h b/src/ui/ui.h index 336e820b..608059de 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -193,6 +193,10 @@ void mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const ch void mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks); void mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error); char* mucwin_get_string(ProfMucWin *mucwin); +void mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext); +void mucwin_unset_enctext(ProfMucWin *mucwin); +void mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch); +void mucwin_unset_message_char(ProfMucWin *mucwin); // MUC private chat window void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp); diff --git a/src/ui/win_types.h b/src/ui/win_types.h index b19822d5..462e177e 100644 --- a/src/ui/win_types.h +++ b/src/ui/win_types.h @@ -168,6 +168,8 @@ typedef struct prof_muc_win_t { gboolean unread_triggers; gboolean showjid; unsigned long memcheck; + char *enctext; + char *message_char; } ProfMucWin; typedef struct prof_mucconf_win_t { diff --git a/src/ui/window.c b/src/ui/window.c index 85e2b73f..6b8ae06e 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -194,6 +194,8 @@ win_create_muc(const char *const roomjid) } else { new_win->showjid = FALSE; } + new_win->enctext = NULL; + new_win->message_char = NULL; new_win->memcheck = PROFMUCWIN_MEMCHECK; @@ -443,6 +445,8 @@ win_free(ProfWin* window) { ProfMucWin *mucwin = (ProfMucWin*)window; free(mucwin->roomjid); + free(mucwin->enctext); + free(mucwin->message_char); break; } case WIN_MUC_CONFIG: @@ -1022,13 +1026,13 @@ win_print_incoming(ProfWin *window, GDateTime *timestamp, } void -win_print_them(ProfWin *window, theme_item_t theme_item, const char *const them) +win_print_them(ProfWin *window, theme_item_t theme_item, char ch, const char *const them) { - _win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, theme_item, them, ""); + _win_printf(window, ch, 0, NULL, NO_ME | NO_EOL, theme_item, them, ""); } void -win_println_them_message(ProfWin *window, const char *const them, const char *const message, ...) +win_println_them_message(ProfWin *window, char ch, const char *const them, const char *const message, ...) { GDateTime *timestamp = g_date_time_new_now_local(); @@ -1037,9 +1041,9 @@ win_println_them_message(ProfWin *window, const char *const them, const char *co GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_append(window->layout->buffer, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL); + buffer_append(window->layout->buffer, ch, 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL); - _win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL); + _win_print(window, ch, 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); @@ -1048,7 +1052,7 @@ win_println_them_message(ProfWin *window, const char *const them, const char *co } void -win_println_me_message(ProfWin *window, const char *const me, const char *const message, ...) +win_println_me_message(ProfWin *window, char ch, const char *const me, const char *const message, ...) { GDateTime *timestamp = g_date_time_new_now_local(); @@ -1057,9 +1061,9 @@ win_println_me_message(ProfWin *window, const char *const me, const char *const GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_append(window->layout->buffer, '-', 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL); + buffer_append(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL); - _win_print(window, '-', 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL); + _win_print(window, ch, 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); diff --git a/src/ui/window.h b/src/ui/window.h index 21c9154a..31ccd7e3 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -60,9 +60,9 @@ void win_show_status_string(ProfWin *window, const char *const from, GDateTime *last_activity, const char *const pre, const char *const default_show); -void win_print_them(ProfWin *window, theme_item_t theme_item, const char *const them); -void win_println_them_message(ProfWin *window, const char *const them, const char *const message, ...); -void win_println_me_message(ProfWin *window, const char *const me, const char *const message, ...); +void win_print_them(ProfWin *window, theme_item_t theme_item, char ch, const char *const them); +void win_println_them_message(ProfWin *window, char ch, const char *const them, const char *const message, ...); +void win_println_me_message(ProfWin *window, char ch, const char *const me, const char *const message, ...); void win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...); void win_print_incoming(ProfWin *window, GDateTime *timestamp, |