mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Merge branch 'master' into pgp
This commit is contained in:
commit
bcfbbac49a
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -65,6 +65,7 @@ typedef enum {
|
||||
PREF_MOUSE,
|
||||
PREF_OCCUPANTS,
|
||||
PREF_OCCUPANTS_SIZE,
|
||||
PREF_OCCUPANTS_JID,
|
||||
PREF_ROSTER,
|
||||
PREF_ROSTER_SIZE,
|
||||
PREF_ROSTER_OFFLINE,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -2962,6 +2962,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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -124,6 +124,7 @@ typedef struct prof_muc_win_t {
|
||||
ProfWin window;
|
||||
char *roomjid;
|
||||
int unread;
|
||||
gboolean showjid;
|
||||
unsigned long memcheck;
|
||||
} ProfMucWin;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -252,6 +252,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) {}
|
||||
|
@ -71,3 +71,4 @@ roster.by=
|
||||
roster.size=
|
||||
occupants=
|
||||
occupants.size=
|
||||
occupants.jid=
|
||||
|
@ -72,5 +72,4 @@ roster.by=presence
|
||||
roster.size=25
|
||||
occupants=true
|
||||
occupants.size=15
|
||||
|
||||
|
||||
occupants.jid=true
|
||||
|
@ -12,6 +12,7 @@ statuses.chat=all
|
||||
statuses.muc=all
|
||||
occupants=true
|
||||
occupants.size=15
|
||||
occupants.jid=true
|
||||
roster=true
|
||||
roster.offline=true
|
||||
roster.resource=true
|
||||
|
Loading…
Reference in New Issue
Block a user