mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Add preferences for tab display
This commit is contained in:
parent
a957c545d3
commit
59382984c0
@ -201,6 +201,8 @@ static Autocomplete presence_ac;
|
||||
static Autocomplete presence_setting_ac;
|
||||
static Autocomplete winpos_ac;
|
||||
static Autocomplete statusbar_ac;
|
||||
static Autocomplete statusbar_chat_ac;
|
||||
static Autocomplete statusbar_room_ac;
|
||||
static Autocomplete statusbar_show_ac;
|
||||
|
||||
void
|
||||
@ -784,6 +786,16 @@ cmd_ac_init(void)
|
||||
autocomplete_add(statusbar_ac, "show");
|
||||
autocomplete_add(statusbar_ac, "hide");
|
||||
autocomplete_add(statusbar_ac, "maxtabs");
|
||||
autocomplete_add(statusbar_ac, "chat");
|
||||
autocomplete_add(statusbar_ac, "room");
|
||||
|
||||
statusbar_chat_ac = autocomplete_new();
|
||||
autocomplete_add(statusbar_chat_ac, "user");
|
||||
autocomplete_add(statusbar_chat_ac, "jid");
|
||||
|
||||
statusbar_room_ac = autocomplete_new();
|
||||
autocomplete_add(statusbar_room_ac, "room");
|
||||
autocomplete_add(statusbar_room_ac, "jid");
|
||||
|
||||
statusbar_show_ac = autocomplete_new();
|
||||
autocomplete_add(statusbar_show_ac, "empty");
|
||||
@ -1070,6 +1082,8 @@ cmd_ac_reset(ProfWin *window)
|
||||
autocomplete_reset(presence_setting_ac);
|
||||
autocomplete_reset(winpos_ac);
|
||||
autocomplete_reset(statusbar_ac);
|
||||
autocomplete_reset(statusbar_chat_ac);
|
||||
autocomplete_reset(statusbar_room_ac);
|
||||
autocomplete_reset(statusbar_show_ac);
|
||||
|
||||
autocomplete_reset(script_ac);
|
||||
@ -1199,6 +1213,8 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(presence_setting_ac);
|
||||
autocomplete_free(winpos_ac);
|
||||
autocomplete_free(statusbar_ac);
|
||||
autocomplete_free(statusbar_chat_ac);
|
||||
autocomplete_free(statusbar_room_ac);
|
||||
autocomplete_free(statusbar_show_ac);
|
||||
}
|
||||
|
||||
@ -3221,5 +3237,15 @@ _statusbar_autocomplete(ProfWin *window, const char *const input, gboolean previ
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/statusbar chat", statusbar_chat_ac, TRUE, previous);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/statusbar room", statusbar_room_ac, TRUE, previous);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1367,6 +1367,8 @@ static struct cmd_t command_defs[] =
|
||||
"/statusbar show empty|name",
|
||||
"/statusbar hide empty|name",
|
||||
"/statusbar maxtabs <value>",
|
||||
"/statusbar chat user|jid",
|
||||
"/statusbar room room|jid",
|
||||
"/statusbar up",
|
||||
"/statusbar down")
|
||||
CMD_DESC(
|
||||
@ -1375,11 +1377,14 @@ static struct cmd_t command_defs[] =
|
||||
{ "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be between 0 and 10" },
|
||||
{ "show|hide empty", "Show or hide empty tabs." },
|
||||
{ "show|hide name", "Show or hide names in tabs." },
|
||||
{ "chat user|jid", "Show only the users name, or the full jid if no nick is present for chat tabs." },
|
||||
{ "room room|jid", "Show only the rooms name, or the full jid for room tabs." },
|
||||
{ "up", "Move the status bar up the screen." },
|
||||
{ "down", "Move the status bar down the screen." })
|
||||
CMD_EXAMPLES(
|
||||
"/statusbar maxtabs 5",
|
||||
"/statusbar show empty",
|
||||
"/statusbar chat jid",
|
||||
"/statusbar hide name")
|
||||
},
|
||||
|
||||
|
@ -2095,7 +2095,7 @@ cmd_who(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
if (window->type != WIN_CONSOLE && window->type != WIN_MUC) {
|
||||
status_bar_new(1, "console");
|
||||
status_bar_new(1, WIN_CONSOLE, "console");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -5848,6 +5848,7 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args)
|
||||
} else {
|
||||
cons_show("Status bar tabs set to %d.", intval);
|
||||
}
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
} else {
|
||||
cons_show(err_msg);
|
||||
@ -5857,6 +5858,40 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "chat") == 0) {
|
||||
if (g_strcmp0(args[1], "jid") == 0) {
|
||||
prefs_set_string(PREF_STATUSBAR_CHAT, "jid");
|
||||
cons_show("Using jid for chat tabs.");
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
if (g_strcmp0(args[1], "user") == 0) {
|
||||
prefs_set_string(PREF_STATUSBAR_CHAT, "user");
|
||||
cons_show("Using user for chat tabs.");
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "room") == 0) {
|
||||
if (g_strcmp0(args[1], "jid") == 0) {
|
||||
prefs_set_string(PREF_STATUSBAR_ROOM, "jid");
|
||||
cons_show("Using jid for room tabs.");
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
if (g_strcmp0(args[1], "room") == 0) {
|
||||
prefs_set_string(PREF_STATUSBAR_ROOM, "room");
|
||||
cons_show("Using room name for room tabs.");
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "up") == 0) {
|
||||
gboolean result = prefs_statusbar_pos_up();
|
||||
if (result) {
|
||||
|
@ -1589,6 +1589,8 @@ _get_group(preference_t pref)
|
||||
case PREF_CONSOLE_CHAT:
|
||||
case PREF_STATUSBAR_SHOW_EMPTY:
|
||||
case PREF_STATUSBAR_SHOW_NAME:
|
||||
case PREF_STATUSBAR_CHAT:
|
||||
case PREF_STATUSBAR_ROOM:
|
||||
return PREF_GROUP_UI;
|
||||
case PREF_STATES:
|
||||
case PREF_OUTTYPE:
|
||||
@ -1848,6 +1850,10 @@ _get_key(preference_t pref)
|
||||
return "statusbar.show.empty";
|
||||
case PREF_STATUSBAR_SHOW_NAME:
|
||||
return "statusbar.show.name";
|
||||
case PREF_STATUSBAR_CHAT:
|
||||
return "statusbar.chat";
|
||||
case PREF_STATUSBAR_ROOM:
|
||||
return "statusbar.room";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@ -1960,6 +1966,10 @@ _get_default_string(preference_t pref)
|
||||
case PREF_CONSOLE_PRIVATE:
|
||||
case PREF_CONSOLE_CHAT:
|
||||
return "all";
|
||||
case PREF_STATUSBAR_CHAT:
|
||||
return "user";
|
||||
case PREF_STATUSBAR_ROOM:
|
||||
return "room";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -146,6 +146,8 @@ typedef enum {
|
||||
PREF_ROOM_LIST_CACHE,
|
||||
PREF_STATUSBAR_SHOW_EMPTY,
|
||||
PREF_STATUSBAR_SHOW_NAME,
|
||||
PREF_STATUSBAR_CHAT,
|
||||
PREF_STATUSBAR_ROOM,
|
||||
} preference_t;
|
||||
|
||||
typedef struct prof_alias_t {
|
||||
|
@ -282,7 +282,7 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha
|
||||
// currently in groupchat window
|
||||
if (wins_is_current(window)) {
|
||||
is_current = TRUE;
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_MUC, mucwin->roomjid);
|
||||
|
||||
if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_BEEP))) {
|
||||
beep();
|
||||
@ -290,7 +290,7 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha
|
||||
|
||||
// not currently on groupchat window
|
||||
} else {
|
||||
status_bar_new(num, window->tab_name);
|
||||
status_bar_new(num, WIN_MUC, mucwin->roomjid);
|
||||
|
||||
if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_FLASH))) {
|
||||
flash();
|
||||
|
@ -333,7 +333,7 @@ api_win_create(
|
||||
// set status bar active
|
||||
ProfPluginWin *pluginwin = wins_get_plugin(tag);
|
||||
int num = wins_get_num((ProfWin*)pluginwin);
|
||||
status_bar_active(num, pluginwin->plugin_name);
|
||||
status_bar_active(num, WIN_PLUGIN, pluginwin->tag);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -105,7 +105,7 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted)
|
||||
title_bar_switch();
|
||||
} else {
|
||||
int num = wins_get_num(window);
|
||||
status_bar_new(num, window->tab_name);
|
||||
status_bar_new(num, WIN_CHAT, chatwin->barejid);
|
||||
|
||||
int ui_index = num;
|
||||
if (ui_index == 10) {
|
||||
@ -249,11 +249,11 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
|
||||
if (wins_is_current(window)) {
|
||||
win_print_incoming(window, timestamp, display_name, plugin_message, enc_mode);
|
||||
title_bar_set_typing(FALSE);
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_CHAT, chatwin->barejid);
|
||||
|
||||
// not currently viewing chat window with sender
|
||||
} else {
|
||||
status_bar_new(num, window->tab_name);
|
||||
status_bar_new(num, WIN_CHAT, chatwin->barejid);
|
||||
cons_show_incoming_message(display_name, num, chatwin->unread);
|
||||
|
||||
if (prefs_get_boolean(PREF_FLASH)) {
|
||||
@ -328,7 +328,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_en
|
||||
|
||||
win_print_outgoing(window, enc_char, "%s", message);
|
||||
int num = wins_get_num(window);
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_CHAT, chatwin->barejid);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1761,8 +1761,16 @@ cons_statusbar_setting(void)
|
||||
} else {
|
||||
cons_show("Show tab names (/statusbar) : OFF");
|
||||
}
|
||||
|
||||
cons_show("Max tabs (/statusbar) : %d", prefs_get_statusbartabs());
|
||||
|
||||
char *pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT);
|
||||
cons_show("Chat tab display (/statusbar) : %s", pref_chat);
|
||||
prefs_free_string(pref_chat);
|
||||
|
||||
char *pref_room = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
cons_show("Room tab display (/statusbar) : %s", pref_room);
|
||||
prefs_free_string(pref_room);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2179,7 +2187,7 @@ cons_alert(void)
|
||||
{
|
||||
ProfWin *current = wins_get_current();
|
||||
if (current->type != WIN_CONSOLE) {
|
||||
status_bar_new(1, "console");
|
||||
status_bar_new(1, WIN_CONSOLE, "console");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ ui_init(void)
|
||||
refresh();
|
||||
create_title_bar();
|
||||
status_bar_init();
|
||||
status_bar_active(1, "console");
|
||||
status_bar_active(1, WIN_CONSOLE, "console");
|
||||
create_input_window();
|
||||
wins_init();
|
||||
notifier_initialise();
|
||||
@ -287,7 +287,7 @@ ui_contact_typing(const char *const barejid, const char *const resource)
|
||||
title_bar_set_typing(TRUE);
|
||||
|
||||
int num = wins_get_num(window);
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_CHAT, chatwin->barejid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,7 +673,10 @@ ui_focus_win(ProfWin *window)
|
||||
title_bar_switch();
|
||||
}
|
||||
status_bar_current(i);
|
||||
status_bar_active(i, window->tab_name);
|
||||
|
||||
char *identifier = win_get_tab_identifier(window);
|
||||
status_bar_active(i, window->type, identifier);
|
||||
free(identifier);
|
||||
}
|
||||
|
||||
void
|
||||
@ -690,7 +693,7 @@ ui_close_win(int index)
|
||||
wins_close_by_num(index);
|
||||
title_bar_console();
|
||||
status_bar_current(1);
|
||||
status_bar_active(1, "console");
|
||||
status_bar_active(1, WIN_CONSOLE, "console");
|
||||
}
|
||||
|
||||
void
|
||||
@ -744,12 +747,13 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag
|
||||
int num = 0;
|
||||
window = wins_new_chat(barejid);
|
||||
if (window) {
|
||||
chatwin = (ProfChatWin*)window;
|
||||
num = wins_get_num(window);
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_CHAT, chatwin->barejid);
|
||||
} else {
|
||||
num = 0;
|
||||
window = wins_get_console();
|
||||
status_bar_active(1, window->tab_name);
|
||||
status_bar_active(1, WIN_CONSOLE, "console");
|
||||
}
|
||||
}
|
||||
|
||||
@ -760,10 +764,10 @@ void
|
||||
ui_room_join(const char *const roomjid, gboolean focus)
|
||||
{
|
||||
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||
ProfWin *window = (ProfWin*)mucwin;
|
||||
if (!window) {
|
||||
window = wins_new_muc(roomjid);
|
||||
if (mucwin == NULL) {
|
||||
mucwin = (ProfMucWin*)wins_new_muc(roomjid);
|
||||
}
|
||||
ProfWin *window = (ProfWin*)mucwin;
|
||||
|
||||
char *nick = muc_nick(roomjid);
|
||||
win_print(window, THEME_ROOMINFO, '!', "-> You have joined the room as %s", nick);
|
||||
@ -783,7 +787,7 @@ ui_room_join(const char *const roomjid, gboolean focus)
|
||||
ui_focus_win(window);
|
||||
} else {
|
||||
int num = wins_get_num(window);
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_MUC, mucwin->roomjid);
|
||||
ProfWin *console = wins_get_console();
|
||||
char *nick = muc_nick(roomjid);
|
||||
win_println(console, THEME_TYPING, '!', "-> Autojoined %s as %s (%d).", roomjid, nick, num);
|
||||
|
@ -519,11 +519,11 @@ mucwin_requires_config(ProfMucWin *mucwin)
|
||||
|
||||
// currently in groupchat window
|
||||
if (wins_is_current(window)) {
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_MUC, mucwin->roomjid);
|
||||
|
||||
// not currently on groupchat window
|
||||
} else {
|
||||
status_bar_new(num, window->tab_name);
|
||||
status_bar_new(num, WIN_MUC, mucwin->roomjid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -553,11 +553,11 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub
|
||||
|
||||
// currently in groupchat window
|
||||
if (wins_is_current(window)) {
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_MUC, mucwin->roomjid);
|
||||
|
||||
// not currently on groupchat window
|
||||
} else {
|
||||
status_bar_new(num, window->tab_name);
|
||||
status_bar_new(num, WIN_MUC, mucwin->roomjid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,11 +583,11 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message)
|
||||
|
||||
// currently in groupchat window
|
||||
if (wins_is_current(window)) {
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_MUC, mucwin->roomjid);
|
||||
|
||||
// not currently on groupchat window
|
||||
} else {
|
||||
status_bar_new(num, window->tab_name);
|
||||
status_bar_new(num, WIN_MUC, mucwin->roomjid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,11 +62,11 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
|
||||
if (wins_is_current(window)) {
|
||||
win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN);
|
||||
title_bar_set_typing(FALSE);
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, WIN_PRIVATE, privatewin->fulljid);
|
||||
|
||||
// not currently viewing chat window with sender
|
||||
} else {
|
||||
status_bar_new(num, window->tab_name);
|
||||
status_bar_new(num, WIN_PRIVATE, privatewin->fulljid);
|
||||
cons_show_incoming_private_message(jidp->resourcepart, jidp->barejid, num, privatewin->unread);
|
||||
win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN);
|
||||
|
||||
|
@ -50,9 +50,12 @@
|
||||
#include "ui/statusbar.h"
|
||||
#include "ui/inputwin.h"
|
||||
#include "ui/screen.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "xmpp/contact.h"
|
||||
|
||||
typedef struct _status_bar_tab_t {
|
||||
char *display_name;
|
||||
win_type_t window_type;
|
||||
char *identifier;
|
||||
gboolean highlight;
|
||||
} StatusBarTab;
|
||||
|
||||
@ -70,6 +73,7 @@ static WINDOW *statusbar_win;
|
||||
static void _status_bar_draw(void);
|
||||
static void _destroy_tab(StatusBarTab *tab);
|
||||
static int _tabs_width(void);
|
||||
static char* _display_name(StatusBarTab *tab);
|
||||
|
||||
void
|
||||
status_bar_init(void)
|
||||
@ -81,7 +85,8 @@ status_bar_init(void)
|
||||
statusbar->message = NULL;
|
||||
statusbar->tabs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)_destroy_tab);
|
||||
StatusBarTab *console = malloc(sizeof(StatusBarTab));
|
||||
console->display_name = strdup("console");
|
||||
console->window_type = WIN_CONSOLE;
|
||||
console->identifier = strdup("console");
|
||||
g_hash_table_insert(statusbar->tabs, GINT_TO_POINTER(1), console);
|
||||
statusbar->current_tab = 1;
|
||||
|
||||
@ -159,7 +164,7 @@ status_bar_inactive(const int win)
|
||||
}
|
||||
|
||||
void
|
||||
status_bar_active(const int win, char *name)
|
||||
status_bar_active(const int win, win_type_t wintype, char *identifier)
|
||||
{
|
||||
int true_win = win;
|
||||
if (true_win == 0) {
|
||||
@ -167,15 +172,16 @@ status_bar_active(const int win, char *name)
|
||||
}
|
||||
|
||||
StatusBarTab *tab = malloc(sizeof(StatusBarTab));
|
||||
tab->display_name = strdup(name);
|
||||
tab->identifier = strdup(identifier);
|
||||
tab->highlight = FALSE;
|
||||
tab->window_type = wintype;
|
||||
g_hash_table_replace(statusbar->tabs, GINT_TO_POINTER(true_win), tab);
|
||||
|
||||
_status_bar_draw();
|
||||
}
|
||||
|
||||
void
|
||||
status_bar_new(const int win, char* name)
|
||||
status_bar_new(const int win, win_type_t wintype, char* identifier)
|
||||
{
|
||||
int true_win = win;
|
||||
if (true_win == 0) {
|
||||
@ -183,8 +189,9 @@ status_bar_new(const int win, char* name)
|
||||
}
|
||||
|
||||
StatusBarTab *tab = malloc(sizeof(StatusBarTab));
|
||||
tab->display_name = strdup(name);
|
||||
tab->identifier = strdup(identifier);
|
||||
tab->highlight = TRUE;
|
||||
tab->window_type = wintype;
|
||||
g_hash_table_replace(statusbar->tabs, GINT_TO_POINTER(true_win), tab);
|
||||
|
||||
_status_bar_draw();
|
||||
@ -304,6 +311,7 @@ _status_bar_draw(void)
|
||||
wattroff(statusbar_win, bracket_attrs);
|
||||
pos++;
|
||||
if (tab) {
|
||||
char *display_name = _display_name(tab);
|
||||
if (tab->highlight) {
|
||||
int status_attrs = theme_attrs(THEME_STATUS_NEW);
|
||||
wattron(statusbar_win, status_attrs);
|
||||
@ -312,8 +320,8 @@ _status_bar_draw(void)
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, ":");
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, tab->display_name);
|
||||
pos += strlen(tab->display_name) -1 ;
|
||||
mvwprintw(statusbar_win, 0, pos, display_name);
|
||||
pos += strlen(display_name) -1 ;
|
||||
}
|
||||
wattroff(statusbar_win, status_attrs);
|
||||
} else {
|
||||
@ -324,11 +332,12 @@ _status_bar_draw(void)
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, ":");
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, tab->display_name);
|
||||
pos += strlen(tab->display_name) - 1;
|
||||
mvwprintw(statusbar_win, 0, pos, display_name);
|
||||
pos += strlen(display_name) - 1;
|
||||
}
|
||||
wattroff(statusbar_win, status_attrs);
|
||||
}
|
||||
free(display_name);
|
||||
} else {
|
||||
mvwprintw(statusbar_win, 0, pos, " ");
|
||||
}
|
||||
@ -363,8 +372,8 @@ static void
|
||||
_destroy_tab(StatusBarTab *tab)
|
||||
{
|
||||
if (tab) {
|
||||
if (tab->display_name) {
|
||||
free(tab->display_name);
|
||||
if (tab->identifier) {
|
||||
free(tab->identifier);
|
||||
}
|
||||
free(tab);
|
||||
}
|
||||
@ -384,8 +393,10 @@ _tabs_width(void)
|
||||
for (i = 1; i <= max_tabs; i++) {
|
||||
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
width += strlen(tab->display_name);
|
||||
char *display_name = _display_name(tab);
|
||||
width += strlen(display_name);
|
||||
width += 4;
|
||||
free(display_name);
|
||||
} else {
|
||||
width += 3;
|
||||
}
|
||||
@ -397,8 +408,10 @@ _tabs_width(void)
|
||||
for (i = 1; i <= max_tabs; i++) {
|
||||
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
width += strlen(tab->display_name);
|
||||
char *display_name = _display_name(tab);
|
||||
width += strlen(display_name);
|
||||
width += 4;
|
||||
free(display_name);
|
||||
}
|
||||
}
|
||||
return width;
|
||||
@ -411,3 +424,75 @@ _tabs_width(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char*
|
||||
_display_name(StatusBarTab *tab)
|
||||
{
|
||||
if (tab->window_type == WIN_CONSOLE) {
|
||||
return strdup("console");
|
||||
}
|
||||
if (tab->window_type == WIN_XML) {
|
||||
return strdup("xmlconsole");
|
||||
}
|
||||
if (tab->window_type == WIN_PLUGIN) {
|
||||
return strdup(tab->identifier);
|
||||
}
|
||||
if (tab->window_type == WIN_CHAT) {
|
||||
PContact contact = roster_get_contact(tab->identifier);
|
||||
if (contact && p_contact_name(contact)) {
|
||||
return strdup(p_contact_name(contact));
|
||||
}
|
||||
char *pref = prefs_get_string(PREF_STATUSBAR_CHAT);
|
||||
if (g_strcmp0("user", pref) == 0) {
|
||||
Jid *jidp = jid_create(tab->identifier);
|
||||
char *user = strdup(jidp->localpart);
|
||||
jid_destroy(jidp);
|
||||
return user;
|
||||
} else {
|
||||
return strdup(tab->identifier);
|
||||
}
|
||||
}
|
||||
if (tab->window_type == WIN_MUC) {
|
||||
char *pref = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
Jid *jidp = jid_create(tab->identifier);
|
||||
char *room = strdup(jidp->localpart);
|
||||
jid_destroy(jidp);
|
||||
return room;
|
||||
} else {
|
||||
return strdup(tab->identifier);
|
||||
}
|
||||
}
|
||||
if (tab->window_type == WIN_MUC_CONFIG) {
|
||||
char *pref = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
GString *display_str = g_string_new("");
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
Jid *jidp = jid_create(tab->identifier);
|
||||
g_string_append(display_str, jidp->localpart);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
g_string_append(display_str, tab->identifier);
|
||||
}
|
||||
g_string_append(display_str, " conf");
|
||||
char *result = strdup(display_str->str);
|
||||
g_string_free(display_str, TRUE);
|
||||
return result;
|
||||
}
|
||||
if (tab->window_type == WIN_PRIVATE) {
|
||||
char *pref = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
GString *display_str = g_string_new("");
|
||||
Jid *jidp = jid_create(tab->identifier);
|
||||
g_string_append(display_str, jidp->localpart);
|
||||
g_string_append(display_str, "/");
|
||||
g_string_append(display_str, jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
char *result = strdup(display_str->str);
|
||||
g_string_free(display_str, TRUE);
|
||||
return result;
|
||||
} else {
|
||||
return strdup(tab->identifier);
|
||||
}
|
||||
}
|
||||
return strdup("window");
|
||||
}
|
||||
|
@ -332,8 +332,8 @@ void title_bar_set_presence(contact_presence_t presence);
|
||||
|
||||
// status bar
|
||||
void status_bar_inactive(const int win);
|
||||
void status_bar_active(const int win, char *name);
|
||||
void status_bar_new(const int win, char *name);
|
||||
void status_bar_active(const int win, win_type_t wintype, char *identifier);
|
||||
void status_bar_new(const int win, win_type_t wintype, char *identifier);
|
||||
void status_bar_set_all_inactive(void);
|
||||
|
||||
// roster window
|
||||
@ -376,6 +376,7 @@ void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *o
|
||||
void win_show_contact(ProfWin *window, PContact contact);
|
||||
void win_show_info(ProfWin *window, PContact contact);
|
||||
void win_clear(ProfWin *window);
|
||||
char* win_get_tab_identifier(ProfWin *window);
|
||||
char* win_to_string(ProfWin *window);
|
||||
|
||||
// desktop notifications
|
||||
|
@ -136,7 +136,6 @@ typedef enum {
|
||||
|
||||
typedef struct prof_win_t {
|
||||
win_type_t type;
|
||||
char *tab_name;
|
||||
ProfLayout *layout;
|
||||
} ProfWin;
|
||||
|
||||
|
@ -125,7 +125,6 @@ win_create_console(void)
|
||||
{
|
||||
ProfConsoleWin *new_win = malloc(sizeof(ProfConsoleWin));
|
||||
new_win->window.type = WIN_CONSOLE;
|
||||
new_win->window.tab_name = strdup("console");
|
||||
new_win->window.layout = _win_create_split_layout();
|
||||
|
||||
return &new_win->window;
|
||||
@ -136,7 +135,6 @@ win_create_chat(const char *const barejid)
|
||||
{
|
||||
ProfChatWin *new_win = malloc(sizeof(ProfChatWin));
|
||||
new_win->window.type = WIN_CHAT;
|
||||
new_win->window.tab_name = strdup(barejid);
|
||||
new_win->window.layout = _win_create_simple_layout();
|
||||
|
||||
new_win->barejid = strdup(barejid);
|
||||
@ -164,8 +162,7 @@ win_create_muc(const char *const roomjid)
|
||||
int cols = getmaxx(stdscr);
|
||||
|
||||
new_win->window.type = WIN_MUC;
|
||||
new_win->window.tab_name = strdup(roomjid);
|
||||
|
||||
new_win->window.layout = _win_create_simple_layout();
|
||||
ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit));
|
||||
layout->base.type = LAYOUT_SPLIT;
|
||||
|
||||
@ -210,12 +207,7 @@ win_create_muc_config(const char *const roomjid, DataForm *form)
|
||||
{
|
||||
ProfMucConfWin *new_win = malloc(sizeof(ProfMucConfWin));
|
||||
new_win->window.type = WIN_MUC_CONFIG;
|
||||
GString *tab_str = g_string_new(roomjid);
|
||||
g_string_append(tab_str, " config");
|
||||
new_win->window.tab_name = strdup(tab_str->str);
|
||||
g_string_free(tab_str, TRUE);
|
||||
new_win->window.layout = _win_create_simple_layout();
|
||||
|
||||
new_win->roomjid = strdup(roomjid);
|
||||
new_win->form = form;
|
||||
|
||||
@ -229,9 +221,7 @@ win_create_private(const char *const fulljid)
|
||||
{
|
||||
ProfPrivateWin *new_win = malloc(sizeof(ProfPrivateWin));
|
||||
new_win->window.type = WIN_PRIVATE;
|
||||
new_win->window.tab_name = strdup(fulljid);
|
||||
new_win->window.layout = _win_create_simple_layout();
|
||||
|
||||
new_win->fulljid = strdup(fulljid);
|
||||
new_win->unread = 0;
|
||||
new_win->occupant_offline = FALSE;
|
||||
@ -247,7 +237,6 @@ win_create_xmlconsole(void)
|
||||
{
|
||||
ProfXMLWin *new_win = malloc(sizeof(ProfXMLWin));
|
||||
new_win->window.type = WIN_XML;
|
||||
new_win->window.tab_name = strdup("xmlconsole");
|
||||
new_win->window.layout = _win_create_simple_layout();
|
||||
|
||||
new_win->memcheck = PROFXMLWIN_MEMCHECK;
|
||||
@ -260,7 +249,6 @@ win_create_plugin(const char *const plugin_name, const char *const tag)
|
||||
{
|
||||
ProfPluginWin *new_win = malloc(sizeof(ProfPluginWin));
|
||||
new_win->window.type = WIN_PLUGIN;
|
||||
new_win->window.tab_name = strdup(tag);
|
||||
new_win->window.layout = _win_create_simple_layout();
|
||||
|
||||
new_win->tag = strdup(tag);
|
||||
@ -330,6 +318,50 @@ win_get_title(ProfWin *window)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char*
|
||||
win_get_tab_identifier(ProfWin *window)
|
||||
{
|
||||
assert(window != NULL);
|
||||
|
||||
switch (window->type) {
|
||||
case WIN_CONSOLE:
|
||||
{
|
||||
return strdup("console");
|
||||
}
|
||||
case WIN_CHAT:
|
||||
{
|
||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||
return strdup(chatwin->barejid);
|
||||
}
|
||||
case WIN_MUC:
|
||||
{
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
return strdup(mucwin->roomjid);
|
||||
}
|
||||
case WIN_MUC_CONFIG:
|
||||
{
|
||||
ProfMucConfWin *mucconfwin = (ProfMucConfWin*)window;
|
||||
return strdup(mucconfwin->roomjid);
|
||||
}
|
||||
case WIN_PRIVATE:
|
||||
{
|
||||
ProfPrivateWin *privwin = (ProfPrivateWin*)window;
|
||||
return strdup(privwin->fulljid);
|
||||
}
|
||||
case WIN_PLUGIN:
|
||||
{
|
||||
ProfPluginWin *pluginwin = (ProfPluginWin*)window;
|
||||
return strdup(pluginwin->tag);
|
||||
}
|
||||
case WIN_XML:
|
||||
{
|
||||
return strdup("xmlconsole");
|
||||
}
|
||||
default:
|
||||
return strdup("UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
win_to_string(ProfWin *window)
|
||||
{
|
||||
@ -426,7 +458,6 @@ win_show_subwin(ProfWin *window)
|
||||
void
|
||||
win_free(ProfWin* window)
|
||||
{
|
||||
free(window->tab_name);
|
||||
if (window->layout->type == LAYOUT_SPLIT) {
|
||||
ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
|
||||
if (layout->subwin) {
|
||||
|
@ -856,15 +856,17 @@ wins_swap(int source_win, int target_win)
|
||||
ProfWin *target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win));
|
||||
|
||||
// target window empty
|
||||
if (!target) {
|
||||
if (target == NULL) {
|
||||
g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
|
||||
status_bar_inactive(source_win);
|
||||
char *identifier = win_get_tab_identifier(source);
|
||||
if (win_unread(source) > 0) {
|
||||
status_bar_new(target_win, source->tab_name);
|
||||
status_bar_new(target_win, source->type, identifier);
|
||||
} else {
|
||||
status_bar_active(target_win, source->tab_name);
|
||||
status_bar_active(target_win, source->type, identifier);
|
||||
}
|
||||
free(identifier);
|
||||
if (wins_get_current_num() == source_win) {
|
||||
wins_set_current_by_num(target_win);
|
||||
ui_focus_win(console);
|
||||
@ -877,16 +879,20 @@ wins_swap(int source_win, int target_win)
|
||||
g_hash_table_steal(windows, GINT_TO_POINTER(target_win));
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(source_win), target);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
|
||||
char *source_identifier = win_get_tab_identifier(source);
|
||||
char *target_identifier = win_get_tab_identifier(target);
|
||||
if (win_unread(source) > 0) {
|
||||
status_bar_new(target_win, source->tab_name);
|
||||
status_bar_new(target_win, source->type, source_identifier);
|
||||
} else {
|
||||
status_bar_active(target_win, source->tab_name);
|
||||
status_bar_active(target_win, source->type, source_identifier);
|
||||
}
|
||||
if (win_unread(target) > 0) {
|
||||
status_bar_new(source_win, target->tab_name);
|
||||
status_bar_new(source_win, target->type, target_identifier);
|
||||
} else {
|
||||
status_bar_active(source_win, target->tab_name);
|
||||
status_bar_active(source_win, target->type, target_identifier);
|
||||
}
|
||||
free(source_identifier);
|
||||
free(target_identifier);
|
||||
if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
|
||||
ui_focus_win(console);
|
||||
}
|
||||
@ -998,22 +1004,24 @@ wins_tidy(void)
|
||||
GList *curr = keys;
|
||||
while (curr) {
|
||||
ProfWin *window = g_hash_table_lookup(windows, curr->data);
|
||||
char *identifier = win_get_tab_identifier(window);
|
||||
g_hash_table_steal(windows, curr->data);
|
||||
if (num == 10) {
|
||||
g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window);
|
||||
if (win_unread(window) > 0) {
|
||||
status_bar_new(0, window->tab_name);
|
||||
status_bar_new(0, window->type, identifier);
|
||||
} else {
|
||||
status_bar_active(0, window->tab_name);
|
||||
status_bar_active(0, window->type, identifier);
|
||||
}
|
||||
} else {
|
||||
g_hash_table_insert(new_windows, GINT_TO_POINTER(num), window);
|
||||
if (win_unread(window) > 0) {
|
||||
status_bar_new(num, window->tab_name);
|
||||
status_bar_new(num, window->type, identifier);
|
||||
} else {
|
||||
status_bar_active(num, window->tab_name);
|
||||
status_bar_active(num, window->type, identifier);
|
||||
}
|
||||
}
|
||||
free(identifier);
|
||||
num++;
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
@ -467,8 +467,8 @@ void title_bar_set_presence(contact_presence_t presence) {}
|
||||
|
||||
// status bar
|
||||
void status_bar_inactive(const int win) {}
|
||||
void status_bar_active(const int win, char *name) {}
|
||||
void status_bar_new(const int win, char *name) {}
|
||||
void status_bar_active(const int win, win_type_t type, char *identifier) {}
|
||||
void status_bar_new(const int win, win_type_t type, char *identifier) {}
|
||||
void status_bar_set_all_inactive(void) {}
|
||||
|
||||
// roster window
|
||||
@ -507,6 +507,11 @@ ProfWin* win_create_plugin(const char *const plugin_name, const char * const tag
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* win_get_tab_identifier(ProfWin *window)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void win_update_virtual(ProfWin *window) {}
|
||||
void win_free(ProfWin *window) {}
|
||||
gboolean win_notify_remind(ProfWin *window)
|
||||
|
Loading…
Reference in New Issue
Block a user