mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added room occupants panel
This commit is contained in:
parent
0e18b10b8e
commit
0c24b53bfa
@ -591,6 +591,7 @@ handle_room_occupant_offline(const char * const room, const char * const nick,
|
||||
ui_room_member_offline(room, nick);
|
||||
}
|
||||
prefs_free_string(muc_status_pref);
|
||||
ui_muc_roster(room);
|
||||
}
|
||||
|
||||
void
|
||||
@ -599,6 +600,7 @@ handle_room_occupent_kicked(const char * const room, const char * const nick, co
|
||||
{
|
||||
muc_roster_remove(room, nick);
|
||||
ui_room_member_kicked(room, nick, actor, reason);
|
||||
ui_muc_roster(room);
|
||||
}
|
||||
|
||||
void
|
||||
@ -607,6 +609,7 @@ handle_room_occupent_banned(const char * const room, const char * const nick, co
|
||||
{
|
||||
muc_roster_remove(room, nick);
|
||||
ui_room_member_banned(room, nick, actor, reason);
|
||||
ui_muc_roster(room);
|
||||
}
|
||||
|
||||
void
|
||||
@ -716,6 +719,8 @@ handle_muc_self_online(const char * const room, const char * const nick, gboolea
|
||||
|
||||
muc_set_role(room, role);
|
||||
muc_set_affiliation(room, affiliation);
|
||||
|
||||
ui_muc_roster(room);
|
||||
}
|
||||
|
||||
void
|
||||
@ -751,4 +756,6 @@ handle_muc_occupant_online(const char * const room, const char * const nick, con
|
||||
}
|
||||
prefs_free_string(muc_status_pref);
|
||||
}
|
||||
|
||||
ui_muc_roster(room);
|
||||
}
|
@ -2713,6 +2713,72 @@ _ui_show_lines(ProfWin *window, const gchar** lines)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_muc_roster(const char * const room)
|
||||
{
|
||||
ProfWin *window = wins_get_by_recipient(room);
|
||||
if (room) {
|
||||
GList *roster = muc_roster(room);
|
||||
if (roster) {
|
||||
werase(window->subwin);
|
||||
|
||||
wattron(window->subwin, COLOUR_ROOMINFO);
|
||||
wprintw(window->subwin, " -Moderators\n");
|
||||
wattroff(window->subwin, COLOUR_ROOMINFO);
|
||||
GList *roster_curr = roster;
|
||||
while (roster_curr) {
|
||||
Occupant *occupant = roster_curr->data;
|
||||
if (occupant->role == MUC_ROLE_MODERATOR) {
|
||||
wprintw(window->subwin, " ");
|
||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||
int presence_colour = win_presence_colour(presence_str);
|
||||
wattron(window->subwin, presence_colour);
|
||||
wprintw(window->subwin, occupant->nick);
|
||||
wattroff(window->subwin, presence_colour);
|
||||
wprintw(window->subwin, "\n");
|
||||
}
|
||||
roster_curr = g_list_next(roster_curr);
|
||||
}
|
||||
|
||||
wattron(window->subwin, COLOUR_ROOMINFO);
|
||||
wprintw(window->subwin, " -Participants\n");
|
||||
wattroff(window->subwin, COLOUR_ROOMINFO);
|
||||
roster_curr = roster;
|
||||
while (roster_curr) {
|
||||
Occupant *occupant = roster_curr->data;
|
||||
if (occupant->role == MUC_ROLE_PARTICIPANT) {
|
||||
wprintw(window->subwin, " ");
|
||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||
int presence_colour = win_presence_colour(presence_str);
|
||||
wattron(window->subwin, presence_colour);
|
||||
wprintw(window->subwin, occupant->nick);
|
||||
wattroff(window->subwin, presence_colour);
|
||||
wprintw(window->subwin, "\n");
|
||||
}
|
||||
roster_curr = g_list_next(roster_curr);
|
||||
}
|
||||
|
||||
wattron(window->subwin, COLOUR_ROOMINFO);
|
||||
wprintw(window->subwin, " -Visitors\n");
|
||||
wattroff(window->subwin, COLOUR_ROOMINFO);
|
||||
roster_curr = roster;
|
||||
while (roster_curr) {
|
||||
Occupant *occupant = roster_curr->data;
|
||||
if (occupant->role == MUC_ROLE_VISITOR) {
|
||||
wprintw(window->subwin, " ");
|
||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||
int presence_colour = win_presence_colour(presence_str);
|
||||
wattron(window->subwin, presence_colour);
|
||||
wprintw(window->subwin, occupant->nick);
|
||||
wattroff(window->subwin, presence_colour);
|
||||
wprintw(window->subwin, "\n");
|
||||
}
|
||||
roster_curr = g_list_next(roster_curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_win_handle_switch(const wint_t * const ch)
|
||||
{
|
||||
@ -2980,5 +3046,6 @@ ui_init_module(void)
|
||||
ui_handle_room_role_set = _ui_handle_room_role_set;
|
||||
ui_handle_room_role_list_error = _ui_handle_room_role_list_error;
|
||||
ui_handle_room_role_list = _ui_handle_room_role_list;
|
||||
ui_muc_roster = _ui_muc_roster;
|
||||
}
|
||||
|
||||
|
@ -235,6 +235,8 @@ void (*ui_open_xmlconsole_win)(void);
|
||||
|
||||
gboolean (*ui_win_has_unsaved_form)(int num);
|
||||
|
||||
void (*ui_muc_roster)(const char * const room);
|
||||
|
||||
// console window actions
|
||||
void (*cons_show)(const char * const msg, ...);
|
||||
void (*cons_about)(void);
|
||||
|
@ -58,8 +58,21 @@ win_create(const char * const title, int cols, win_type_t type)
|
||||
{
|
||||
ProfWin *new_win = malloc(sizeof(struct prof_win_t));
|
||||
new_win->from = strdup(title);
|
||||
new_win->win = newpad(PAD_SIZE, cols);
|
||||
wbkgd(new_win->win, COLOUR_TEXT);
|
||||
|
||||
if (type == WIN_MUC) {
|
||||
new_win->win = newpad(PAD_SIZE, (cols/4) * 3);
|
||||
wbkgd(new_win->win, COLOUR_TEXT);
|
||||
|
||||
new_win->subwin = newpad(PAD_SIZE, cols/4);
|
||||
wvline(new_win->subwin, 0, 0);
|
||||
wbkgd(new_win->subwin, COLOUR_TEXT);
|
||||
} else {
|
||||
new_win->win = newpad(PAD_SIZE, (cols));
|
||||
wbkgd(new_win->win, COLOUR_TEXT);
|
||||
|
||||
new_win->subwin = NULL;
|
||||
}
|
||||
|
||||
new_win->buffer = buffer_create();
|
||||
new_win->y_pos = 0;
|
||||
new_win->paged = 0;
|
||||
@ -89,7 +102,14 @@ win_update_virtual(ProfWin *window)
|
||||
{
|
||||
int rows, cols;
|
||||
getmaxyx(stdscr, rows, cols);
|
||||
pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1);
|
||||
|
||||
if (window->type == WIN_MUC) {
|
||||
pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, ((cols/4) * 3) -1);
|
||||
pnoutrefresh(window->subwin, 0, 0, 1, (cols/4) * 3, rows-3, cols-1);
|
||||
} else {
|
||||
pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -69,6 +69,7 @@ typedef enum {
|
||||
typedef struct prof_win_t {
|
||||
char *from;
|
||||
WINDOW *win;
|
||||
WINDOW *subwin;
|
||||
ProfBuff buffer;
|
||||
win_type_t type;
|
||||
gboolean is_otr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user