diff options
author | James Booth <boothj5@gmail.com> | 2015-04-12 02:16:13 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-04-12 02:16:13 +0100 |
commit | bcfbbac49a0b031a16f61204955861fd2f7c6db8 (patch) | |
tree | bc49794e02bcbbd0e07292d6f4fe7dc14744b253 /src | |
parent | 7ba7e098fead9e7a9a72090e30bc64d9a12e87ee (diff) | |
parent | 57dc5f14efec19c9532c2ec9a8742e90e4c964d2 (diff) | |
download | profani-tty-bcfbbac49a0b031a16f61204955861fd2f7c6db8.tar.gz |
Merge branch 'master' into pgp
Diffstat (limited to 'src')
-rw-r--r-- | src/command/command.c | 45 | ||||
-rw-r--r-- | src/command/commands.c | 34 | ||||
-rw-r--r-- | src/config/preferences.c | 3 | ||||
-rw-r--r-- | src/config/preferences.h | 1 | ||||
-rw-r--r-- | src/config/theme.c | 1 | ||||
-rw-r--r-- | src/ui/console.c | 5 | ||||
-rw-r--r-- | src/ui/core.c | 9 | ||||
-rw-r--r-- | src/ui/occupantswin.c | 17 | ||||
-rw-r--r-- | src/ui/ui.h | 1 | ||||
-rw-r--r-- | src/ui/window.c | 5 | ||||
-rw-r--r-- | src/ui/window.h | 1 | ||||
-rw-r--r-- | src/ui/windows.c | 8 |
12 files changed, 109 insertions, 21 deletions
diff --git a/src/command/command.c b/src/command/command.c index ab59e2a0..519550a3 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -451,16 +451,19 @@ static struct cmd_t command_defs[] = NULL } } }, { "/occupants", - cmd_occupants, parse_args, 1, 2, cons_occupants_setting, - { "/occupants show|hide|default|size [show|hide] [percent]", "Show or hide room occupants.", - { "/occupants show|hide|default|size [show|hide] [percent]", - "-------------------------------------------------------", + cmd_occupants, parse_args, 1, 3, cons_occupants_setting, + { "/occupants show|hide|default|size [jid|show|hide|percent] [jid]", "Show or hide room occupants.", + { "/occupants show|hide|default|size [jid|show|hide|percent] [jid]", + "---------------------------------------------------------------", "Show or hide room occupants, and occupants panel display settings.", "", - "show : Show the occupants panel in chat rooms.", - "hide : Hide the occupants panel in chat rooms.", - "default show|hide : Whether occupants are shown by default in new rooms, 'show' or 'hide'", - "size percent : Percentage of the screen taken by the occupants list in rooms (1-99).", + "show : Show the occupants panel in current room.", + "hide : Hide the occupants panel in current room.", + "show jid : Show jid in the occupants panel in current room.", + "hide jid : Hide jid in the occupants panel in current room.", + "default show|hide : Whether occupants are shown by default in new rooms.", + "default show|hide jid : Whether occupants jids are shown by default in new rooms.", + "size percent : Percentage of the screen taken by the occupants list in rooms (1-99).", NULL } } }, { "/form", @@ -1208,6 +1211,7 @@ static Autocomplete form_ac; static Autocomplete form_field_multi_ac; static Autocomplete occupants_ac; static Autocomplete occupants_default_ac; +static Autocomplete occupants_show_ac; static Autocomplete time_ac; static Autocomplete time_statusbar_ac; static Autocomplete resource_ac; @@ -1553,6 +1557,9 @@ cmd_init(void) autocomplete_add(occupants_default_ac, "show"); autocomplete_add(occupants_default_ac, "hide"); + occupants_show_ac = autocomplete_new(); + autocomplete_add(occupants_show_ac, "jid"); + time_ac = autocomplete_new(); autocomplete_add(time_ac, "minutes"); autocomplete_add(time_ac, "seconds"); @@ -1635,6 +1642,7 @@ cmd_uninit(void) autocomplete_free(form_field_multi_ac); autocomplete_free(occupants_ac); autocomplete_free(occupants_default_ac); + autocomplete_free(occupants_show_ac); autocomplete_free(time_ac); autocomplete_free(time_statusbar_ac); autocomplete_free(resource_ac); @@ -1803,6 +1811,7 @@ cmd_reset_autocomplete() autocomplete_reset(form_field_multi_ac); autocomplete_reset(occupants_ac); autocomplete_reset(occupants_default_ac); + autocomplete_reset(occupants_show_ac); autocomplete_reset(time_ac); autocomplete_reset(time_statusbar_ac); autocomplete_reset(resource_ac); @@ -2653,11 +2662,31 @@ _occupants_autocomplete(const char * const input) { char *found = NULL; + found = autocomplete_param_with_ac(input, "/occupants default show", occupants_show_ac, TRUE); + if (found != NULL) { + return found; + } + + found = autocomplete_param_with_ac(input, "/occupants default hide", occupants_show_ac, TRUE); + if (found != NULL) { + return found; + } + found = autocomplete_param_with_ac(input, "/occupants default", occupants_default_ac, TRUE); if (found != NULL) { return found; } + found = autocomplete_param_with_ac(input, "/occupants show", occupants_show_ac, TRUE); + if (found != NULL) { + return found; + } + + found = autocomplete_param_with_ac(input, "/occupants hide", occupants_show_ac, TRUE); + if (found != NULL) { + return found; + } + found = autocomplete_param_with_ac(input, "/occupants", occupants_ac, TRUE); if (found != NULL) { return found; diff --git a/src/command/commands.c b/src/command/commands.c index 5cd9c347..049e9893 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2866,12 +2866,22 @@ cmd_occupants(gchar **args, struct cmd_help_t help) if (g_strcmp0(args[0], "default") == 0) { if (g_strcmp0(args[1], "show") == 0) { - cons_show("Occupant list enabled."); - prefs_set_boolean(PREF_OCCUPANTS, TRUE); + if (g_strcmp0(args[2], "jid") == 0) { + cons_show("Occupant jids enabled."); + prefs_set_boolean(PREF_OCCUPANTS_JID, TRUE); + } else { + cons_show("Occupant list enabled."); + prefs_set_boolean(PREF_OCCUPANTS, TRUE); + } return TRUE; } else if (g_strcmp0(args[1], "hide") == 0) { - cons_show("Occupant list disabled."); - prefs_set_boolean(PREF_OCCUPANTS, FALSE); + if (g_strcmp0(args[2], "jid") == 0) { + cons_show("Occupant jids disabled."); + prefs_set_boolean(PREF_OCCUPANTS_JID, FALSE); + } else { + cons_show("Occupant list disabled."); + prefs_set_boolean(PREF_OCCUPANTS, FALSE); + } return TRUE; } else { cons_show("Usage: %s", help.usage); @@ -2881,16 +2891,26 @@ cmd_occupants(gchar **args, struct cmd_help_t help) win_type_t win_type = ui_current_win_type(); if (win_type != WIN_MUC) { - cons_show("Cannot show/hide occupant list when not in chat room."); + cons_show("Cannot apply setting when not in chat room."); return TRUE; } ProfMucWin *mucwin = wins_get_current_muc(); if (g_strcmp0(args[0], "show") == 0) { - ui_room_show_occupants(mucwin->roomjid); + if (g_strcmp0(args[1], "jid") == 0) { + mucwin->showjid = TRUE; + ui_room_update_occupants(mucwin->roomjid); + } else { + ui_room_show_occupants(mucwin->roomjid); + } } else if (g_strcmp0(args[0], "hide") == 0) { - ui_room_hide_occupants(mucwin->roomjid); + if (g_strcmp0(args[1], "jid") == 0) { + mucwin->showjid = FALSE; + ui_room_update_occupants(mucwin->roomjid); + } else { + ui_room_hide_occupants(mucwin->roomjid); + } } else { cons_show("Usage: %s", help.usage); } diff --git a/src/config/preferences.c b/src/config/preferences.c index fdaae11f..3ca3a721 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -499,6 +499,7 @@ _get_group(preference_t pref) case PREF_HISTORY: case PREF_MOUSE: case PREF_OCCUPANTS: + case PREF_OCCUPANTS_JID: case PREF_STATUSES: case PREF_STATUSES_CONSOLE: case PREF_STATUSES_CHAT: @@ -589,6 +590,8 @@ _get_key(preference_t pref) return "mouse"; case PREF_OCCUPANTS: return "occupants"; + case PREF_OCCUPANTS_JID: + return "occupants.jid"; case PREF_MUC_PRIVILEGES: return "privileges"; case PREF_STATUSES: diff --git a/src/config/preferences.h b/src/config/preferences.h index a9413886..4455eca1 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -65,6 +65,7 @@ typedef enum { PREF_MOUSE, PREF_OCCUPANTS, PREF_OCCUPANTS_SIZE, + PREF_OCCUPANTS_JID, PREF_ROSTER, PREF_ROSTER_SIZE, PREF_ROSTER_OFFLINE, diff --git a/src/config/theme.c b/src/config/theme.c index 5b358ba3..1ee9836b 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -439,6 +439,7 @@ _load_preferences(void) _set_string_preference("statuses.muc", PREF_STATUSES_MUC); _set_boolean_preference("occupants", PREF_OCCUPANTS); + _set_boolean_preference("occupants.jid", PREF_OCCUPANTS_JID); if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) { gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL); prefs_set_occupants_size(occupants_size); diff --git a/src/ui/console.c b/src/ui/console.c index 055b4aa6..246dc336 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -910,6 +910,11 @@ cons_occupants_setting(void) else cons_show("Occupants (/occupants) : hide"); + if (prefs_get_boolean(PREF_OCCUPANTS_JID)) + cons_show("Occupant jids (/occupants) : show"); + else + cons_show("Occupant jids (/occupants) : hide"); + int size = prefs_get_occupants_size(); cons_show("Occupants size (/occupants) : %d", size); } diff --git a/src/ui/core.c b/src/ui/core.c index acb9e550..e1df5edf 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2963,6 +2963,15 @@ ui_show_lines(ProfWin *window, const gchar** lines) } void +ui_room_update_occupants(const char * const roomjid) +{ + ProfWin *window = (ProfWin*)wins_get_muc(roomjid); + if (window && win_has_active_subwin(window)) { + occupantswin_occupants(roomjid); + } +} + +void ui_room_show_occupants(const char * const roomjid) { ProfWin *window = (ProfWin*)wins_get_muc(roomjid); diff --git a/src/ui/occupantswin.c b/src/ui/occupantswin.c index d865eeed..bba9d0b9 100644 --- a/src/ui/occupantswin.c +++ b/src/ui/occupantswin.c @@ -40,7 +40,7 @@ #include "config/preferences.h" static void -_occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant) +_occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean showjid) { const char *presence_str = string_from_resource_presence(occupant->presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); @@ -51,6 +51,13 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant) win_printline_nowrap(layout->subwin, msg->str); g_string_free(msg, TRUE); + if (showjid && occupant->jid) { + GString *msg = g_string_new(" "); + g_string_append(msg, occupant->jid); + win_printline_nowrap(layout->subwin, msg->str); + g_string_free(msg, TRUE); + } + wattroff(layout->subwin, theme_attrs(presence_colour)); } @@ -74,7 +81,7 @@ occupantswin_occupants(const char * const roomjid) while (roster_curr) { Occupant *occupant = roster_curr->data; if (occupant->role == MUC_ROLE_MODERATOR) { - _occuptantswin_occupant(layout, occupant); + _occuptantswin_occupant(layout, occupant, mucwin->showjid); } roster_curr = g_list_next(roster_curr); } @@ -86,7 +93,7 @@ occupantswin_occupants(const char * const roomjid) while (roster_curr) { Occupant *occupant = roster_curr->data; if (occupant->role == MUC_ROLE_PARTICIPANT) { - _occuptantswin_occupant(layout, occupant); + _occuptantswin_occupant(layout, occupant, mucwin->showjid); } roster_curr = g_list_next(roster_curr); } @@ -98,7 +105,7 @@ occupantswin_occupants(const char * const roomjid) while (roster_curr) { Occupant *occupant = roster_curr->data; if (occupant->role == MUC_ROLE_VISITOR) { - _occuptantswin_occupant(layout, occupant); + _occuptantswin_occupant(layout, occupant, mucwin->showjid); } roster_curr = g_list_next(roster_curr); } @@ -109,7 +116,7 @@ occupantswin_occupants(const char * const roomjid) GList *roster_curr = occupants; while (roster_curr) { Occupant *occupant = roster_curr->data; - _occuptantswin_occupant(layout, occupant); + _occuptantswin_occupant(layout, occupant, mucwin->showjid); roster_curr = g_list_next(roster_curr); } } diff --git a/src/ui/ui.h b/src/ui/ui.h index 20685e92..fc1485ff 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -174,6 +174,7 @@ void ui_room_member_nick_change(const char * const roomjid, void ui_room_nick_change(const char * const roomjid, const char * const nick); void ui_room_member_presence(const char * const roomjid, const char * const nick, const char * const show, const char * const status); +void ui_room_update_occupants(const char * const roomjid); void ui_room_show_occupants(const char * const roomjid); void ui_room_hide_occupants(const char * const roomjid); void ui_show_roster(void); diff --git a/src/ui/window.c b/src/ui/window.c index 2a1b1a7b..ab894d07 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -177,6 +177,11 @@ win_create_muc(const char * const roomjid) new_win->roomjid = strdup(roomjid); new_win->unread = 0; + if (prefs_get_boolean(PREF_OCCUPANTS_JID)) { + new_win->showjid = TRUE; + } else { + new_win->showjid = FALSE; + } new_win->memcheck = PROFMUCWIN_MEMCHECK; diff --git a/src/ui/window.h b/src/ui/window.h index f525e5fa..650df67f 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -124,6 +124,7 @@ typedef struct prof_muc_win_t { ProfWin window; char *roomjid; int unread; + gboolean showjid; unsigned long memcheck; } ProfMucWin; diff --git a/src/ui/windows.c b/src/ui/windows.c index c9496ef6..993a51c1 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -497,7 +497,13 @@ wins_resize_all(void) } wresize(layout->base.win, PAD_SIZE, cols - subwin_cols); wresize(layout->subwin, PAD_SIZE, subwin_cols); - rosterwin_roster(); + if (window->type == WIN_CONSOLE) { + rosterwin_roster(); + } else if (window->type == WIN_MUC) { + ProfMucWin *mucwin = (ProfMucWin *)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + occupantswin_occupants(mucwin->roomjid); + } } else { wresize(layout->base.win, PAD_SIZE, cols); } |