1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Merge branch 'wider-tabs'

This commit is contained in:
James Booth 2018-03-10 23:41:38 +00:00
commit 73b8d07a80
24 changed files with 943 additions and 519 deletions

View File

@ -99,6 +99,7 @@ static char* _blocked_autocomplete(ProfWin *window, const char *const input, gbo
static char* _tray_autocomplete(ProfWin *window, const char *const input, gboolean previous); static char* _tray_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _presence_autocomplete(ProfWin *window, const char *const input, gboolean previous); static char* _presence_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous); static char* _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _statusbar_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _script_autocomplete_func(const char *const prefix, gboolean previous); static char* _script_autocomplete_func(const char *const prefix, gboolean previous);
@ -199,6 +200,11 @@ static Autocomplete tray_ac;
static Autocomplete presence_ac; static Autocomplete presence_ac;
static Autocomplete presence_setting_ac; static Autocomplete presence_setting_ac;
static Autocomplete winpos_ac; static Autocomplete winpos_ac;
static Autocomplete statusbar_ac;
static Autocomplete statusbar_self_ac;
static Autocomplete statusbar_chat_ac;
static Autocomplete statusbar_room_ac;
static Autocomplete statusbar_show_ac;
void void
cmd_ac_init(void) cmd_ac_init(void)
@ -386,8 +392,6 @@ cmd_ac_init(void)
wins_ac = autocomplete_new(); wins_ac = autocomplete_new();
autocomplete_add(wins_ac, "unread"); autocomplete_add(wins_ac, "unread");
autocomplete_add(wins_ac, "prune"); autocomplete_add(wins_ac, "prune");
autocomplete_add(wins_ac, "tidy");
autocomplete_add(wins_ac, "autotidy");
autocomplete_add(wins_ac, "swap"); autocomplete_add(wins_ac, "swap");
roster_ac = autocomplete_new(); roster_ac = autocomplete_new();
@ -774,6 +778,34 @@ cmd_ac_init(void)
winpos_ac = autocomplete_new(); winpos_ac = autocomplete_new();
autocomplete_add(winpos_ac, "up"); autocomplete_add(winpos_ac, "up");
autocomplete_add(winpos_ac, "down"); autocomplete_add(winpos_ac, "down");
statusbar_ac = autocomplete_new();
autocomplete_add(statusbar_ac, "up");
autocomplete_add(statusbar_ac, "down");
autocomplete_add(statusbar_ac, "show");
autocomplete_add(statusbar_ac, "hide");
autocomplete_add(statusbar_ac, "maxtabs");
autocomplete_add(statusbar_ac, "self");
autocomplete_add(statusbar_ac, "chat");
autocomplete_add(statusbar_ac, "room");
statusbar_self_ac = autocomplete_new();
autocomplete_add(statusbar_self_ac, "user");
autocomplete_add(statusbar_self_ac, "barejid");
autocomplete_add(statusbar_self_ac, "fulljid");
autocomplete_add(statusbar_self_ac, "off");
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, "name");
autocomplete_add(statusbar_show_ac, "number");
} }
void void
@ -1055,6 +1087,11 @@ cmd_ac_reset(ProfWin *window)
autocomplete_reset(presence_ac); autocomplete_reset(presence_ac);
autocomplete_reset(presence_setting_ac); autocomplete_reset(presence_setting_ac);
autocomplete_reset(winpos_ac); autocomplete_reset(winpos_ac);
autocomplete_reset(statusbar_ac);
autocomplete_reset(statusbar_self_ac);
autocomplete_reset(statusbar_chat_ac);
autocomplete_reset(statusbar_room_ac);
autocomplete_reset(statusbar_show_ac);
autocomplete_reset(script_ac); autocomplete_reset(script_ac);
if (script_show_ac) { if (script_show_ac) {
@ -1182,6 +1219,11 @@ cmd_ac_uninit(void)
autocomplete_free(presence_ac); autocomplete_free(presence_ac);
autocomplete_free(presence_setting_ac); autocomplete_free(presence_setting_ac);
autocomplete_free(winpos_ac); autocomplete_free(winpos_ac);
autocomplete_free(statusbar_ac);
autocomplete_free(statusbar_self_ac);
autocomplete_free(statusbar_chat_ac);
autocomplete_free(statusbar_room_ac);
autocomplete_free(statusbar_show_ac);
} }
char* char*
@ -1301,7 +1343,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
// autocomplete boolean settings // autocomplete boolean settings
gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", "/chlog", "/grlog", gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", "/chlog", "/grlog",
"/history", "/vercheck", "/privileges", "/wrap", "/winstidy", "/carbons", "/encwarn", "/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/encwarn",
"/lastactivity" }; "/lastactivity" };
for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
@ -1369,8 +1411,8 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
} }
} }
gchar *cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/titlebar", "/mainwin", "/statusbar", "/inputwin" }; gchar *cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/titlebar", "/mainwin", "/inputwin" };
Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, winpos_ac, winpos_ac, winpos_ac, winpos_ac }; Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, winpos_ac, winpos_ac, winpos_ac };
for (i = 0; i < ARRAY_SIZE(cmds); i++) { for (i = 0; i < ARRAY_SIZE(cmds); i++) {
result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE, previous); result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE, previous);
@ -1421,6 +1463,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
g_hash_table_insert(ac_funcs, "/tray", _tray_autocomplete); g_hash_table_insert(ac_funcs, "/tray", _tray_autocomplete);
g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete); g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete);
g_hash_table_insert(ac_funcs, "/rooms", _rooms_autocomplete); g_hash_table_insert(ac_funcs, "/rooms", _rooms_autocomplete);
g_hash_table_insert(ac_funcs, "/statusbar", _statusbar_autocomplete);
int len = strlen(input); int len = strlen(input);
char parsed[len+1]; char parsed[len+1];
@ -2632,11 +2675,6 @@ _wins_autocomplete(ProfWin *window, const char *const input, gboolean previous)
{ {
char *result = NULL; char *result = NULL;
result = autocomplete_param_with_func(input, "/wins autotidy", prefs_autocomplete_boolean_choice, previous);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/wins", wins_ac, TRUE, previous); result = autocomplete_param_with_ac(input, "/wins", wins_ac, TRUE, previous);
if (result) { if (result) {
return result; return result;
@ -3181,3 +3219,41 @@ _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous)
return NULL; return NULL;
} }
static char*
_statusbar_autocomplete(ProfWin *window, const char *const input, gboolean previous)
{
char *found = NULL;
found = autocomplete_param_with_ac(input, "/statusbar", statusbar_ac, TRUE, previous);
if (found) {
return found;
}
found = autocomplete_param_with_ac(input, "/statusbar show", statusbar_show_ac, TRUE, previous);
if (found) {
return found;
}
found = autocomplete_param_with_ac(input, "/statusbar hide", statusbar_show_ac, TRUE, previous);
if (found) {
return found;
}
found = autocomplete_param_with_ac(input, "/statusbar self", statusbar_self_ac, TRUE, previous);
if (found) {
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;
}

View File

@ -962,18 +962,14 @@ static struct cmd_t command_defs[] =
parse_args, 0, 3, NULL, parse_args, 0, 3, NULL,
CMD_SUBFUNCS( CMD_SUBFUNCS(
{ "unread", cmd_wins_unread }, { "unread", cmd_wins_unread },
{ "tidy", cmd_wins_tidy },
{ "prune", cmd_wins_prune }, { "prune", cmd_wins_prune },
{ "swap", cmd_wins_swap }, { "swap", cmd_wins_swap })
{ "autotidy", cmd_wins_autotidy })
CMD_MAINFUNC(cmd_wins) CMD_MAINFUNC(cmd_wins)
CMD_TAGS( CMD_TAGS(
CMD_TAG_UI) CMD_TAG_UI)
CMD_SYN( CMD_SYN(
"/wins", "/wins",
"/wins unread", "/wins unread",
"/wins tidy",
"/wins autotidy on|off",
"/wins prune", "/wins prune",
"/wins swap <source> <target>") "/wins swap <source> <target>")
CMD_DESC( CMD_DESC(
@ -981,9 +977,7 @@ static struct cmd_t command_defs[] =
"Passing no argument will list all currently active windows and information about their usage.") "Passing no argument will list all currently active windows and information about their usage.")
CMD_ARGS( CMD_ARGS(
{ "unread", "List windows with unread messages." }, { "unread", "List windows with unread messages." },
{ "tidy", "Move windows so there are no gaps." }, { "prune", "Close all windows with no unread messages." },
{ "autotidy on|off", "Automatically remove gaps when closing windows." },
{ "prune", "Close all windows with no unread messages, and then tidy so there are no gaps." },
{ "swap <source> <target>", "Swap windows, target may be an empty position." }) { "swap <source> <target>", "Swap windows, target may be an empty position." })
CMD_NOEXAMPLES CMD_NOEXAMPLES
}, },
@ -1358,20 +1352,37 @@ static struct cmd_t command_defs[] =
}, },
{ "/statusbar", { "/statusbar",
parse_args, 1, 1, &cons_winpos_setting, parse_args, 1, 2, &cons_statusbar_setting,
CMD_NOSUBFUNCS CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_statusbar) CMD_MAINFUNC(cmd_statusbar)
CMD_TAGS( CMD_TAGS(
CMD_TAG_UI) CMD_TAG_UI)
CMD_SYN( CMD_SYN(
"/statusbar show name|number",
"/statusbar hide name|number",
"/statusbar maxtabs <value>",
"/statusbar self user|barejid|fulljid|off",
"/statusbar chat user|jid",
"/statusbar room room|jid",
"/statusbar up", "/statusbar up",
"/statusbar down") "/statusbar down")
CMD_DESC( CMD_DESC(
"Move the status bar.") "Manage statusbar display preferences.")
CMD_ARGS( CMD_ARGS(
{ "up", "Move the status bar up the screen." }, { "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be between 0 and 10" },
{ "down", "Move the status bar down the screen." }) { "show|hide name", "Show or hide names in tabs." },
CMD_NOEXAMPLES { "show|hide number", "Show or hide numbers in tabs." },
{ "self user|barejid|fulljid", "Show account user name, barejid, fulljid as status bar title." },
{ "self off", "Disable showing self as status bar title." },
{ "chat user|jid", "Show users name, or the fulljid if no nick is present for chat tabs." },
{ "room room|jid", "Show room name, or the fulljid 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 self user",
"/statusbar chat jid",
"/statusbar hide name")
}, },
{ "/inputwin", { "/inputwin",

View File

@ -1252,17 +1252,6 @@ cmd_wins_unread(ProfWin *window, const char *const command, gchar **args)
return TRUE; return TRUE;
} }
gboolean
cmd_wins_tidy(ProfWin *window, const char *const command, gchar **args)
{
if (wins_tidy()) {
cons_show("Windows tidied.");
} else {
cons_show("No tidy needed.");
}
return TRUE;
}
gboolean gboolean
cmd_wins_prune(ProfWin *window, const char *const command, gchar **args) cmd_wins_prune(ProfWin *window, const char *const command, gchar **args)
{ {
@ -1280,38 +1269,34 @@ cmd_wins_swap(ProfWin *window, const char *const command, gchar **args)
int source_win = atoi(args[1]); int source_win = atoi(args[1]);
int target_win = atoi(args[2]); int target_win = atoi(args[2]);
if ((source_win == 1) || (target_win == 1)) { if ((source_win == 1) || (target_win == 1)) {
cons_show("Cannot move console window."); cons_show("Cannot move console window.");
} else if (source_win == 10 || target_win == 10) { return TRUE;
}
if (source_win == 10 || target_win == 10) {
cons_show("Window 10 does not exist"); cons_show("Window 10 does not exist");
} else if (source_win != target_win) { return TRUE;
gboolean swapped = wins_swap(source_win, target_win); }
if (swapped) {
cons_show("Swapped windows %d <-> %d", source_win, target_win); if (source_win == target_win) {
} else {
cons_show("Window %d does not exist", source_win);
}
} else {
cons_show("Same source and target window supplied."); cons_show("Same source and target window supplied.");
return TRUE;
} }
return TRUE; if (wins_get_by_num(source_win) == NULL) {
} cons_show("Window %d does not exist", source_win);
return TRUE;
gboolean
cmd_wins_autotidy(ProfWin *window, const char *const command, gchar **args)
{
if (g_strcmp0(args[1], "on") == 0) {
cons_show("Window autotidy enabled");
prefs_set_boolean(PREF_WINS_AUTO_TIDY, TRUE);
wins_tidy();
} else if (g_strcmp0(args[1], "off") == 0) {
cons_show("Window autotidy disabled");
prefs_set_boolean(PREF_WINS_AUTO_TIDY, FALSE);
} else {
cons_bad_cmd_usage(command);
} }
if (wins_get_by_num(target_win) == NULL) {
cons_show("Window %d does not exist", target_win);
return TRUE;
}
wins_swap(source_win, target_win);
cons_show("Swapped windows %d <-> %d", source_win, target_win);
return TRUE; return TRUE;
} }
@ -1407,11 +1392,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args)
// close the window // close the window
ui_close_win(index); ui_close_win(index);
cons_show("Closed window %d", index); cons_show("Closed window %d", index);
wins_tidy();
// Tidy up the window list.
if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) {
wins_tidy();
}
rosterwin_roster(); rosterwin_roster();
return TRUE; return TRUE;
@ -1442,11 +1423,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args)
// close the window // close the window
ui_close_win(index); ui_close_win(index);
cons_show("Closed window %s", args[0]); cons_show("Closed window %s", args[0]);
wins_tidy();
// Tidy up the window list.
if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) {
wins_tidy();
}
rosterwin_roster(); rosterwin_roster();
return TRUE; return TRUE;
@ -2095,7 +2072,7 @@ cmd_who(ProfWin *window, const char *const command, gchar **args)
} }
if (window->type != WIN_CONSOLE && window->type != WIN_MUC) { if (window->type != WIN_CONSOLE && window->type != WIN_MUC) {
status_bar_new(1); status_bar_new(1, WIN_CONSOLE, "console");
} }
return TRUE; return TRUE;
@ -3942,6 +3919,7 @@ cmd_form(ProfWin *window, const char *const command, gchar **args)
} }
ui_focus_win(new_current); ui_focus_win(new_current);
wins_close_by_num(num); wins_close_by_num(num);
wins_tidy();
} }
return TRUE; return TRUE;
@ -5792,6 +5770,145 @@ cmd_mainwin(ProfWin *window, const char *const command, gchar **args)
gboolean gboolean
cmd_statusbar(ProfWin *window, const char *const command, gchar **args) cmd_statusbar(ProfWin *window, const char *const command, gchar **args)
{ {
if (g_strcmp0(args[0], "show") == 0) {
if (g_strcmp0(args[1], "name") == 0) {
prefs_set_boolean(PREF_STATUSBAR_SHOW_NAME, TRUE);
cons_show("Enabled showing tab names.");
ui_resize();
return TRUE;
}
if (g_strcmp0(args[1], "number") == 0) {
prefs_set_boolean(PREF_STATUSBAR_SHOW_NUMBER, TRUE);
cons_show("Enabled showing tab numbers.");
ui_resize();
return TRUE;
}
cons_bad_cmd_usage(command);
return TRUE;
}
if (g_strcmp0(args[0], "hide") == 0) {
if (g_strcmp0(args[1], "name") == 0) {
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER) == FALSE) {
cons_show("Cannot disable both names and numbers in statusbar.");
cons_show("Use '/statusbar maxtabs 0' to hide tabs.");
return TRUE;
}
prefs_set_boolean(PREF_STATUSBAR_SHOW_NAME, FALSE);
cons_show("Disabled showing tab names.");
ui_resize();
return TRUE;
}
if (g_strcmp0(args[1], "number") == 0) {
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME) == FALSE) {
cons_show("Cannot disable both names and numbers in statusbar.");
cons_show("Use '/statusbar maxtabs 0' to hide tabs.");
return TRUE;
}
prefs_set_boolean(PREF_STATUSBAR_SHOW_NUMBER, FALSE);
cons_show("Disabled showing tab numbers.");
ui_resize();
return TRUE;
}
cons_bad_cmd_usage(command);
return TRUE;
}
if (g_strcmp0(args[0], "maxtabs") == 0) {
if (args[1] == NULL) {
cons_bad_cmd_usage(command);
return TRUE;
}
char *value = args[1];
int intval = 0;
char *err_msg = NULL;
gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg);
if (res) {
if (intval < 0 || intval > 10) {
cons_bad_cmd_usage(command);
return TRUE;
}
prefs_set_statusbartabs(intval);
if (intval == 0) {
cons_show("Status bar tabs disabled.");
} else {
cons_show("Status bar tabs set to %d.", intval);
}
ui_resize();
return TRUE;
} else {
cons_show(err_msg);
cons_bad_cmd_usage(command);
free(err_msg);
return TRUE;
}
}
if (g_strcmp0(args[0], "self") == 0) {
if (g_strcmp0(args[1], "barejid") == 0) {
prefs_set_string(PREF_STATUSBAR_SELF, "barejid");
cons_show("Using barejid for statusbar title.");
ui_resize();
return TRUE;
}
if (g_strcmp0(args[1], "fulljid") == 0) {
prefs_set_string(PREF_STATUSBAR_SELF, "fulljid");
cons_show("Using fulljid for statusbar title.");
ui_resize();
return TRUE;
}
if (g_strcmp0(args[1], "user") == 0) {
prefs_set_string(PREF_STATUSBAR_SELF, "user");
cons_show("Using user for statusbar title.");
ui_resize();
return TRUE;
}
if (g_strcmp0(args[1], "off") == 0) {
prefs_set_string(PREF_STATUSBAR_SELF, "off");
cons_show("Disabling statusbar title.");
ui_resize();
return TRUE;
}
cons_bad_cmd_usage(command);
return TRUE;
}
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) { if (g_strcmp0(args[0], "up") == 0) {
gboolean result = prefs_statusbar_pos_up(); gboolean result = prefs_statusbar_pos_up();
if (result) { if (result) {

View File

@ -205,10 +205,8 @@ gboolean cmd_otr_answer(ProfWin *window, const char *const command, gchar **args
gboolean cmd_wins(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_wins_unread(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_unread(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_wins_tidy(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_wins_prune(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_prune(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_wins_swap(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_swap(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_wins_autotidy(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args); gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args);

View File

@ -663,6 +663,23 @@ prefs_get_tray_timer(void)
} }
} }
gint
prefs_get_statusbartabs(void)
{
if (!g_key_file_has_key(prefs, PREF_GROUP_UI, "statusbar.tabs", NULL)) {
return 10;
} else {
return g_key_file_get_integer(prefs, PREF_GROUP_UI, "statusbar.tabs", NULL);
}
}
void
prefs_set_statusbartabs(gint value)
{
g_key_file_set_integer(prefs, PREF_GROUP_UI, "statusbar.tabs", value);
_save_prefs();
}
gchar** gchar**
prefs_get_plugins(void) prefs_get_plugins(void)
{ {
@ -1530,7 +1547,6 @@ _get_group(preference_t pref)
case PREF_MUC_PRIVILEGES: case PREF_MUC_PRIVILEGES:
case PREF_PRESENCE: case PREF_PRESENCE:
case PREF_WRAP: case PREF_WRAP:
case PREF_WINS_AUTO_TIDY:
case PREF_TIME_CONSOLE: case PREF_TIME_CONSOLE:
case PREF_TIME_CHAT: case PREF_TIME_CHAT:
case PREF_TIME_MUC: case PREF_TIME_MUC:
@ -1570,6 +1586,11 @@ _get_group(preference_t pref)
case PREF_CONSOLE_MUC: case PREF_CONSOLE_MUC:
case PREF_CONSOLE_PRIVATE: case PREF_CONSOLE_PRIVATE:
case PREF_CONSOLE_CHAT: case PREF_CONSOLE_CHAT:
case PREF_STATUSBAR_SHOW_NAME:
case PREF_STATUSBAR_SHOW_NUMBER:
case PREF_STATUSBAR_SELF:
case PREF_STATUSBAR_CHAT:
case PREF_STATUSBAR_ROOM:
return PREF_GROUP_UI; return PREF_GROUP_UI;
case PREF_STATES: case PREF_STATES:
case PREF_OUTTYPE: case PREF_OUTTYPE:
@ -1733,8 +1754,6 @@ _get_key(preference_t pref)
return "presence"; return "presence";
case PREF_WRAP: case PREF_WRAP:
return "wrap"; return "wrap";
case PREF_WINS_AUTO_TIDY:
return "wins.autotidy";
case PREF_TIME_CONSOLE: case PREF_TIME_CONSOLE:
return "time.console"; return "time.console";
case PREF_TIME_CHAT: case PREF_TIME_CHAT:
@ -1825,6 +1844,16 @@ _get_key(preference_t pref)
return "sourcepath"; return "sourcepath";
case PREF_ROOM_LIST_CACHE: case PREF_ROOM_LIST_CACHE:
return "rooms.cache"; return "rooms.cache";
case PREF_STATUSBAR_SHOW_NAME:
return "statusbar.show.name";
case PREF_STATUSBAR_SHOW_NUMBER:
return "statusbar.show.number";
case PREF_STATUSBAR_SELF:
return "statusbar.self";
case PREF_STATUSBAR_CHAT:
return "statusbar.chat";
case PREF_STATUSBAR_ROOM:
return "statusbar.room";
default: default:
return NULL; return NULL;
} }
@ -1854,7 +1883,6 @@ _get_default_boolean(preference_t pref)
case PREF_MUC_PRIVILEGES: case PREF_MUC_PRIVILEGES:
case PREF_PRESENCE: case PREF_PRESENCE:
case PREF_WRAP: case PREF_WRAP:
case PREF_WINS_AUTO_TIDY:
case PREF_INPBLOCK_DYNAMIC: case PREF_INPBLOCK_DYNAMIC:
case PREF_RESOURCE_TITLE: case PREF_RESOURCE_TITLE:
case PREF_RESOURCE_MESSAGE: case PREF_RESOURCE_MESSAGE:
@ -1874,6 +1902,7 @@ _get_default_boolean(preference_t pref)
case PREF_TRAY_READ: case PREF_TRAY_READ:
case PREF_BOOKMARK_INVITE: case PREF_BOOKMARK_INVITE:
case PREF_ROOM_LIST_CACHE: case PREF_ROOM_LIST_CACHE:
case PREF_STATUSBAR_SHOW_NUMBER:
return TRUE; return TRUE;
default: default:
return FALSE; return FALSE;
@ -1937,6 +1966,12 @@ _get_default_string(preference_t pref)
case PREF_CONSOLE_PRIVATE: case PREF_CONSOLE_PRIVATE:
case PREF_CONSOLE_CHAT: case PREF_CONSOLE_CHAT:
return "all"; return "all";
case PREF_STATUSBAR_SELF:
return "fulljid";
case PREF_STATUSBAR_CHAT:
return "user";
case PREF_STATUSBAR_ROOM:
return "room";
default: default:
return NULL; return NULL;
} }

View File

@ -89,7 +89,6 @@ typedef enum {
PREF_MUC_PRIVILEGES, PREF_MUC_PRIVILEGES,
PREF_PRESENCE, PREF_PRESENCE,
PREF_WRAP, PREF_WRAP,
PREF_WINS_AUTO_TIDY,
PREF_TIME_CONSOLE, PREF_TIME_CONSOLE,
PREF_TIME_CHAT, PREF_TIME_CHAT,
PREF_TIME_MUC, PREF_TIME_MUC,
@ -144,6 +143,11 @@ typedef enum {
PREF_BOOKMARK_INVITE, PREF_BOOKMARK_INVITE,
PREF_PLUGINS_SOURCEPATH, PREF_PLUGINS_SOURCEPATH,
PREF_ROOM_LIST_CACHE, PREF_ROOM_LIST_CACHE,
PREF_STATUSBAR_SHOW_NAME,
PREF_STATUSBAR_SHOW_NUMBER,
PREF_STATUSBAR_SELF,
PREF_STATUSBAR_CHAT,
PREF_STATUSBAR_ROOM,
} preference_t; } preference_t;
typedef struct prof_alias_t { typedef struct prof_alias_t {
@ -188,6 +192,9 @@ gint prefs_get_autoping_timeout(void);
gint prefs_get_inpblock(void); gint prefs_get_inpblock(void);
void prefs_set_inpblock(gint value); void prefs_set_inpblock(gint value);
void prefs_set_statusbartabs(gint value);
gint prefs_get_statusbartabs(void);
void prefs_set_occupants_size(gint value); void prefs_set_occupants_size(gint value);
gint prefs_get_occupants_size(void); gint prefs_get_occupants_size(void);
void prefs_set_roster_size(gint value); void prefs_set_roster_size(gint value);

View File

@ -384,7 +384,6 @@ _load_preferences(void)
_set_boolean_preference("flash", PREF_FLASH); _set_boolean_preference("flash", PREF_FLASH);
_set_boolean_preference("splash", PREF_SPLASH); _set_boolean_preference("splash", PREF_SPLASH);
_set_boolean_preference("wrap", PREF_WRAP); _set_boolean_preference("wrap", PREF_WRAP);
_set_boolean_preference("wins.autotidy", PREF_WINS_AUTO_TIDY);
_set_boolean_preference("resource.title", PREF_RESOURCE_TITLE); _set_boolean_preference("resource.title", PREF_RESOURCE_TITLE);
_set_boolean_preference("resource.message", PREF_RESOURCE_MESSAGE); _set_boolean_preference("resource.message", PREF_RESOURCE_MESSAGE);
_set_boolean_preference("occupants", PREF_OCCUPANTS); _set_boolean_preference("occupants", PREF_OCCUPANTS);
@ -408,6 +407,8 @@ _load_preferences(void)
_set_boolean_preference("intype", PREF_INTYPE); _set_boolean_preference("intype", PREF_INTYPE);
_set_boolean_preference("enc.warn", PREF_ENC_WARN); _set_boolean_preference("enc.warn", PREF_ENC_WARN);
_set_boolean_preference("tls.show", PREF_TLS_SHOW); _set_boolean_preference("tls.show", PREF_TLS_SHOW);
_set_boolean_preference("statusbar.show.name", PREF_STATUSBAR_SHOW_NAME);
_set_boolean_preference("statusbar.show.nuumber", PREF_STATUSBAR_SHOW_NUMBER);
_set_string_preference("time.console", PREF_TIME_CONSOLE); _set_string_preference("time.console", PREF_TIME_CONSOLE);
_set_string_preference("time.chat", PREF_TIME_CHAT); _set_string_preference("time.chat", PREF_TIME_CHAT);
@ -432,6 +433,14 @@ _load_preferences(void)
_set_string_preference("roster.rooms.by", PREF_ROSTER_ROOMS_BY); _set_string_preference("roster.rooms.by", PREF_ROSTER_ROOMS_BY);
_set_string_preference("roster.private", PREF_ROSTER_PRIVATE); _set_string_preference("roster.private", PREF_ROSTER_PRIVATE);
_set_string_preference("roster.count", PREF_ROSTER_COUNT); _set_string_preference("roster.count", PREF_ROSTER_COUNT);
_set_string_preference("statusbar.self", PREF_STATUSBAR_SELF);
_set_string_preference("statusbar.chat", PREF_STATUSBAR_CHAT);
_set_string_preference("statusbar.room", PREF_STATUSBAR_ROOM);
if (g_key_file_has_key(theme, "ui", "statusbar.tabs", NULL)) {
gint tabs_size = g_key_file_get_integer(theme, "ui", "statusbar.tabs", NULL);
prefs_set_statusbartabs(tabs_size);
}
if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) { if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) {
gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL); gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL);

View File

@ -282,7 +282,7 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha
// currently in groupchat window // currently in groupchat window
if (wins_is_current(window)) { if (wins_is_current(window)) {
is_current = TRUE; is_current = TRUE;
status_bar_active(num); status_bar_active(num, WIN_MUC, mucwin->roomjid);
if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_BEEP))) { if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_BEEP))) {
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 // not currently on groupchat window
} else { } else {
status_bar_new(num); status_bar_new(num, WIN_MUC, mucwin->roomjid);
if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_FLASH))) { if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_FLASH))) {
flash(); flash();

View File

@ -333,7 +333,7 @@ api_win_create(
// set status bar active // set status bar active
ProfPluginWin *pluginwin = wins_get_plugin(tag); ProfPluginWin *pluginwin = wins_get_plugin(tag);
int num = wins_get_num((ProfWin*)pluginwin); int num = wins_get_num((ProfWin*)pluginwin);
status_bar_active(num); status_bar_active(num, WIN_PLUGIN, pluginwin->tag);
} }
int int

View File

@ -105,7 +105,7 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted)
title_bar_switch(); title_bar_switch();
} else { } else {
int num = wins_get_num(window); int num = wins_get_num(window);
status_bar_new(num); status_bar_new(num, WIN_CHAT, chatwin->barejid);
int ui_index = num; int ui_index = num;
if (ui_index == 10) { if (ui_index == 10) {
@ -249,11 +249,11 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
if (wins_is_current(window)) { if (wins_is_current(window)) {
win_print_incoming(window, timestamp, display_name, plugin_message, enc_mode); win_print_incoming(window, timestamp, display_name, plugin_message, enc_mode);
title_bar_set_typing(FALSE); title_bar_set_typing(FALSE);
status_bar_active(num); status_bar_active(num, WIN_CHAT, chatwin->barejid);
// not currently viewing chat window with sender // not currently viewing chat window with sender
} else { } else {
status_bar_new(num); status_bar_new(num, WIN_CHAT, chatwin->barejid);
cons_show_incoming_message(display_name, num, chatwin->unread); cons_show_incoming_message(display_name, num, chatwin->unread);
if (prefs_get_boolean(PREF_FLASH)) { if (prefs_get_boolean(PREF_FLASH)) {
@ -324,9 +324,11 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_en
enc_char = prefs_get_pgp_char(); enc_char = prefs_get_pgp_char();
} }
win_print_outgoing((ProfWin*)chatwin, enc_char, "%s", message); ProfWin *window = (ProfWin*)chatwin;
int num = wins_get_num((ProfWin*)chatwin);
status_bar_active(num); win_print_outgoing(window, enc_char, "%s", message);
int num = wins_get_num(window);
status_bar_active(num, WIN_CHAT, chatwin->barejid);
} }
void void

View File

@ -1123,15 +1123,6 @@ cons_wrap_setting(void)
cons_show("Word wrap (/wrap) : OFF"); cons_show("Word wrap (/wrap) : OFF");
} }
void
cons_winstidy_setting(void)
{
if (prefs_get_boolean(PREF_WINS_AUTO_TIDY))
cons_show("Window Auto Tidy (/wins) : ON");
else
cons_show("Window Auto Tidy (/wins) : OFF");
}
void void
cons_encwarn_setting(void) cons_encwarn_setting(void)
{ {
@ -1531,7 +1522,6 @@ cons_show_ui_prefs(void)
cons_splash_setting(); cons_splash_setting();
cons_winpos_setting(); cons_winpos_setting();
cons_wrap_setting(); cons_wrap_setting();
cons_winstidy_setting();
cons_time_setting(); cons_time_setting();
cons_resource_setting(); cons_resource_setting();
cons_vercheck_setting(); cons_vercheck_setting();
@ -1544,6 +1534,7 @@ cons_show_ui_prefs(void)
cons_presence_setting(); cons_presence_setting();
cons_inpblock_setting(); cons_inpblock_setting();
cons_tlsshow_setting(); cons_tlsshow_setting();
cons_statusbar_setting();
cons_alert(); cons_alert();
} }
@ -1747,6 +1738,39 @@ cons_inpblock_setting(void)
} }
} }
void
cons_statusbar_setting(void)
{
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME)) {
cons_show("Show tab names (/statusbar) : ON");
} else {
cons_show("Show tab names (/statusbar) : OFF");
}
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER)) {
cons_show("Show tab numbers (/statusbar) : ON");
} else {
cons_show("Show tab numbers (/statusbar) : OFF");
}
cons_show("Max tabs (/statusbar) : %d", prefs_get_statusbartabs());
char *pref_self = prefs_get_string(PREF_STATUSBAR_SELF);
if (g_strcmp0(pref_self, "off") == 0) {
cons_show("Self statusbar display (/statusbar) : OFF");
} else {
cons_show("Self statusbar display (/statusbar) : %s", pref_self);
}
prefs_free_string(pref_self);
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 void
cons_winpos_setting(void) cons_winpos_setting(void)
{ {
@ -2161,7 +2185,7 @@ cons_alert(void)
{ {
ProfWin *current = wins_get_current(); ProfWin *current = wins_get_current();
if (current->type != WIN_CONSOLE) { if (current->type != WIN_CONSOLE) {
status_bar_new(1); status_bar_new(1, WIN_CONSOLE, "console");
} }
} }

View File

@ -102,8 +102,8 @@ ui_init(void)
ui_load_colours(); ui_load_colours();
refresh(); refresh();
create_title_bar(); create_title_bar();
create_status_bar(); status_bar_init();
status_bar_active(1); status_bar_active(1, WIN_CONSOLE, "console");
create_input_window(); create_input_window();
wins_init(); wins_init();
notifier_initialise(); notifier_initialise();
@ -137,7 +137,7 @@ ui_update(void)
_ui_draw_term_title(); _ui_draw_term_title();
} }
title_bar_update_virtual(); title_bar_update_virtual();
status_bar_update_virtual(); status_bar_draw();
inp_put_back(); inp_put_back();
doupdate(); doupdate();
@ -183,6 +183,7 @@ ui_close(void)
notifier_uninit(); notifier_uninit();
wins_destroy(); wins_destroy();
inp_close(); inp_close();
status_bar_close();
endwin(); endwin();
} }
@ -286,7 +287,7 @@ ui_contact_typing(const char *const barejid, const char *const resource)
title_bar_set_typing(TRUE); title_bar_set_typing(TRUE);
int num = wins_get_num(window); int num = wins_get_num(window);
status_bar_active(num); status_bar_active(num, WIN_CHAT, chatwin->barejid);
} }
} }
@ -387,8 +388,7 @@ ui_handle_login_account_success(ProfAccount *account, gboolean secured)
title_bar_set_connected(TRUE); title_bar_set_connected(TRUE);
title_bar_set_tls(secured); title_bar_set_tls(secured);
status_bar_print_message(connection_get_fulljid()); status_bar_set_fulljid(connection_get_fulljid());
status_bar_update_virtual();
} }
void void
@ -481,8 +481,7 @@ ui_disconnected(void)
title_bar_set_connected(FALSE); title_bar_set_connected(FALSE);
title_bar_set_tls(FALSE); title_bar_set_tls(FALSE);
title_bar_set_presence(CONTACT_OFFLINE); title_bar_set_presence(CONTACT_OFFLINE);
status_bar_clear_message(); status_bar_clear_fulljid();
status_bar_update_virtual();
ui_hide_roster(); ui_hide_roster();
} }
@ -672,7 +671,10 @@ ui_focus_win(ProfWin *window)
title_bar_switch(); title_bar_switch();
} }
status_bar_current(i); status_bar_current(i);
status_bar_active(i);
char *identifier = win_get_tab_identifier(window);
status_bar_active(i, window->type, identifier);
free(identifier);
} }
void void
@ -689,7 +691,7 @@ ui_close_win(int index)
wins_close_by_num(index); wins_close_by_num(index);
title_bar_console(); title_bar_console();
status_bar_current(1); status_bar_current(1);
status_bar_active(1); status_bar_active(1, WIN_CONSOLE, "console");
} }
void void
@ -737,17 +739,19 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag
if (barejid == NULL || message == NULL) if (barejid == NULL || message == NULL)
return; return;
ProfWin *window = (ProfWin*)wins_get_chat(barejid); ProfChatWin *chatwin = wins_get_chat(barejid);
ProfWin *window = (ProfWin*)chatwin;
if (window == NULL) { if (window == NULL) {
int num = 0; int num = 0;
window = wins_new_chat(barejid); window = wins_new_chat(barejid);
if (window) { if (window) {
chatwin = (ProfChatWin*)window;
num = wins_get_num(window); num = wins_get_num(window);
status_bar_active(num); status_bar_active(num, WIN_CHAT, chatwin->barejid);
} else { } else {
num = 0; num = 0;
window = wins_get_console(); window = wins_get_console();
status_bar_active(1); status_bar_active(1, WIN_CONSOLE, "console");
} }
} }
@ -757,10 +761,11 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag
void void
ui_room_join(const char *const roomjid, gboolean focus) ui_room_join(const char *const roomjid, gboolean focus)
{ {
ProfWin *window = (ProfWin*)wins_get_muc(roomjid); ProfMucWin *mucwin = wins_get_muc(roomjid);
if (!window) { if (mucwin == NULL) {
window = wins_new_muc(roomjid); mucwin = (ProfMucWin*)wins_new_muc(roomjid);
} }
ProfWin *window = (ProfWin*)mucwin;
char *nick = muc_nick(roomjid); char *nick = muc_nick(roomjid);
win_print(window, THEME_ROOMINFO, '!', "-> You have joined the room as %s", nick); win_print(window, THEME_ROOMINFO, '!', "-> You have joined the room as %s", nick);
@ -780,7 +785,7 @@ ui_room_join(const char *const roomjid, gboolean focus)
ui_focus_win(window); ui_focus_win(window);
} else { } else {
int num = wins_get_num(window); int num = wins_get_num(window);
status_bar_active(num); status_bar_active(num, WIN_MUC, mucwin->roomjid);
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
char *nick = muc_nick(roomjid); char *nick = muc_nick(roomjid);
win_println(console, THEME_TYPING, '!', "-> Autojoined %s as %s (%d).", roomjid, nick, num); win_println(console, THEME_TYPING, '!', "-> Autojoined %s as %s (%d).", roomjid, nick, num);
@ -968,15 +973,14 @@ ui_win_unread(int index)
char* char*
ui_ask_password(void) ui_ask_password(void)
{ {
status_bar_get_password(); status_bar_set_prompt("Enter password:");
status_bar_update_virtual();
return inp_get_password(); return inp_get_password();
} }
char* char*
ui_get_line(void) ui_get_line(void)
{ {
status_bar_update_virtual(); status_bar_draw();
return inp_get_line(); return inp_get_line();
} }
@ -999,8 +1003,7 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail)
ui_update(); ui_update();
status_bar_get_password(); status_bar_set_prompt("Enter password:");
status_bar_update_virtual();
return inp_get_password(); return inp_get_password();
} }

View File

@ -251,7 +251,7 @@ inp_get_line(void)
line = inp_readline(); line = inp_readline();
ui_update(); ui_update();
} }
status_bar_clear(); status_bar_clear_prompt();
return line; return line;
} }
@ -269,7 +269,7 @@ inp_get_password(void)
ui_update(); ui_update();
} }
get_password = FALSE; get_password = FALSE;
status_bar_clear(); status_bar_clear_prompt();
return password; return password;
} }

View File

@ -519,11 +519,11 @@ mucwin_requires_config(ProfMucWin *mucwin)
// currently in groupchat window // currently in groupchat window
if (wins_is_current(window)) { if (wins_is_current(window)) {
status_bar_active(num); status_bar_active(num, WIN_MUC, mucwin->roomjid);
// not currently on groupchat window // not currently on groupchat window
} else { } else {
status_bar_new(num); status_bar_new(num, WIN_MUC, mucwin->roomjid);
} }
} }
@ -533,8 +533,6 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
int num = wins_get_num(window);
if (subject) { if (subject) {
if (nick) { if (nick) {
win_print(window, THEME_ROOMINFO, '!', "*%s has set the room subject: ", nick); win_print(window, THEME_ROOMINFO, '!', "*%s has set the room subject: ", nick);
@ -550,15 +548,6 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub
win_println(window, THEME_ROOMINFO, '!', "Room subject cleared"); win_println(window, THEME_ROOMINFO, '!', "Room subject cleared");
} }
} }
// currently in groupchat window
if (wins_is_current(window)) {
status_bar_active(num);
// not currently on groupchat window
} else {
status_bar_active(num);
}
} }
void void
@ -583,11 +572,11 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message)
// currently in groupchat window // currently in groupchat window
if (wins_is_current(window)) { if (wins_is_current(window)) {
status_bar_active(num); status_bar_active(num, WIN_MUC, mucwin->roomjid);
// not currently on groupchat window // not currently on groupchat window
} else { } else {
status_bar_new(num); status_bar_new(num, WIN_MUC, mucwin->roomjid);
} }
} }

View File

@ -62,11 +62,11 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
if (wins_is_current(window)) { if (wins_is_current(window)) {
win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN); win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN);
title_bar_set_typing(FALSE); title_bar_set_typing(FALSE);
status_bar_active(num); status_bar_active(num, WIN_PRIVATE, privatewin->fulljid);
// not currently viewing chat window with sender // not currently viewing chat window with sender
} else { } else {
status_bar_new(num); status_bar_new(num, WIN_PRIVATE, privatewin->fulljid);
cons_show_incoming_private_message(jidp->resourcepart, jidp->barejid, num, privatewin->unread); cons_show_incoming_private_message(jidp->resourcepart, jidp->barejid, num, privatewin->unread);
win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN); win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN);

View File

@ -50,151 +50,111 @@
#include "ui/statusbar.h" #include "ui/statusbar.h"
#include "ui/inputwin.h" #include "ui/inputwin.h"
#include "ui/screen.h" #include "ui/screen.h"
#include "xmpp/roster_list.h"
#include "xmpp/contact.h"
#define TIME_CHECK 60000000 typedef struct _status_bar_tab_t {
win_type_t window_type;
char *identifier;
gboolean highlight;
} StatusBarTab;
typedef struct _status_bar_t {
gchar *time;
char *prompt;
char *fulljid;
GHashTable *tabs;
int current_tab;
} StatusBar;
static WINDOW *status_bar;
static char *message = NULL;
// 1 2 3 4 5 6 7 8 9 0 >
static char _active[34] = "[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]";
static char *bracket = "- -";
static int is_active[12];
static GHashTable *remaining_active;
static int is_new[12];
static GHashTable *remaining_new;
static GTimeZone *tz; static GTimeZone *tz;
static GDateTime *last_time; static StatusBar *statusbar;
static int current; static WINDOW *statusbar_win;
static void _update_win_statuses(void); static int _status_bar_draw_time(int pos);
static void _mark_new(int num); static void _status_bar_draw_maintext(int pos);
static void _mark_active(int num); static int _status_bar_draw_bracket(gboolean current, int pos, char* ch);
static void _mark_inactive(int num); static int _status_bar_draw_extended_tabs(int pos);
static void _status_bar_draw(void); static int _status_bar_draw_tab(StatusBarTab *tab, int pos, int num);
static void _destroy_tab(StatusBarTab *tab);
static int _tabs_width(void);
static char* _display_name(StatusBarTab *tab);
static gboolean _extended_new(void);
void void
create_status_bar(void) status_bar_init(void)
{ {
int i;
int cols = getmaxx(stdscr);
is_active[1] = TRUE;
is_new[1] = FALSE;
for (i = 2; i < 12; i++) {
is_active[i] = FALSE;
is_new[i] = FALSE;
}
remaining_active = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
remaining_new = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
current = 1;
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
int row = screen_statusbar_row();
status_bar = newwin(1, cols, row, 0);
wbkgd(status_bar, theme_attrs(THEME_STATUS_TEXT));
wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, bracket_attrs);
tz = g_time_zone_new_local(); tz = g_time_zone_new_local();
if (last_time) { statusbar = malloc(sizeof(StatusBar));
g_date_time_unref(last_time); statusbar->time = NULL;
} statusbar->prompt = NULL;
last_time = g_date_time_new_now(tz); statusbar->fulljid = NULL;
statusbar->tabs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)_destroy_tab);
StatusBarTab *console = malloc(sizeof(StatusBarTab));
console->window_type = WIN_CONSOLE;
console->identifier = strdup("console");
g_hash_table_insert(statusbar->tabs, GINT_TO_POINTER(1), console);
statusbar->current_tab = 1;
_status_bar_draw(); int row = screen_statusbar_row();
int cols = getmaxx(stdscr);
statusbar_win = newwin(1, cols, row, 0);
status_bar_draw();
} }
void void
status_bar_update_virtual(void) status_bar_close(void)
{ {
_status_bar_draw(); if (tz) {
g_time_zone_unref(tz);
}
if (statusbar) {
if (statusbar->time) {
g_free(statusbar->time);
}
if (statusbar->prompt) {
free(statusbar->prompt);
}
if (statusbar->fulljid) {
free(statusbar->fulljid);
}
if (statusbar->tabs) {
g_hash_table_destroy(statusbar->tabs);
}
free(statusbar);
}
} }
void void
status_bar_resize(void) status_bar_resize(void)
{ {
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
werase(statusbar_win);
werase(status_bar);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
int row = screen_statusbar_row(); int row = screen_statusbar_row();
mvwin(status_bar, row, 0); mvwin(statusbar_win, row, 0);
wresize(status_bar, 1, cols); wresize(statusbar_win, 1, cols);
wbkgd(status_bar, theme_attrs(THEME_STATUS_TEXT));
wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, bracket_attrs);
if (message) { status_bar_draw();
char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR);
gchar *date_fmt = NULL;
if (g_strcmp0(time_pref, "off") == 0) {
date_fmt = g_strdup("");
} else {
date_fmt = g_date_time_format(last_time, time_pref);
}
assert(date_fmt != NULL);
size_t len = strlen(date_fmt);
g_free(date_fmt);
if (g_strcmp0(time_pref, "off") != 0) {
/* 01234567890123456
* [HH:MM] message */
mvwprintw(status_bar, 0, 5 + len, message);
} else {
mvwprintw(status_bar, 0, 1, message);
}
prefs_free_string(time_pref);
}
if (last_time) {
g_date_time_unref(last_time);
}
last_time = g_date_time_new_now_local();
_status_bar_draw();
} }
void void
status_bar_set_all_inactive(void) status_bar_set_all_inactive(void)
{ {
int i = 0; g_hash_table_remove_all(statusbar->tabs);
for (i = 0; i < 12; i++) {
is_active[i] = FALSE;
is_new[i] = FALSE;
_mark_inactive(i);
}
g_hash_table_remove_all(remaining_active);
g_hash_table_remove_all(remaining_new);
_status_bar_draw();
} }
void void
status_bar_current(int i) status_bar_current(int i)
{ {
if (i == 0) { if (i == 0) {
current = 10; statusbar->current_tab = 10;
} else if (i > 10) {
current = 11;
} else { } else {
current = i; statusbar->current_tab = i;
} }
int cols = getmaxx(stdscr);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, bracket_attrs);
_status_bar_draw(); status_bar_draw();
} }
void void
@ -205,281 +165,417 @@ status_bar_inactive(const int win)
true_win = 10; true_win = 10;
} }
// extra windows g_hash_table_remove(statusbar->tabs, GINT_TO_POINTER(true_win));
if (true_win > 10) {
g_hash_table_remove(remaining_active, GINT_TO_POINTER(true_win));
g_hash_table_remove(remaining_new, GINT_TO_POINTER(true_win));
// still have new windows status_bar_draw();
if (g_hash_table_size(remaining_new) != 0) {
is_active[11] = TRUE;
is_new[11] = TRUE;
_mark_new(11);
// still have active windows
} else if (g_hash_table_size(remaining_active) != 0) {
is_active[11] = TRUE;
is_new[11] = FALSE;
_mark_active(11);
// no active or new windows
} else {
is_active[11] = FALSE;
is_new[11] = FALSE;
_mark_inactive(11);
}
// visible window indicators
} else {
is_active[true_win] = FALSE;
is_new[true_win] = FALSE;
_mark_inactive(true_win);
}
_status_bar_draw();
} }
void void
status_bar_active(const int win) status_bar_active(const int win, win_type_t wintype, char *identifier)
{ {
int true_win = win; int true_win = win;
if (true_win == 0) { if (true_win == 0) {
true_win = 10; true_win = 10;
} }
// extra windows StatusBarTab *tab = malloc(sizeof(StatusBarTab));
if (true_win > 10) { tab->identifier = strdup(identifier);
g_hash_table_add(remaining_active, GINT_TO_POINTER(true_win)); tab->highlight = FALSE;
g_hash_table_remove(remaining_new, GINT_TO_POINTER(true_win)); tab->window_type = wintype;
g_hash_table_replace(statusbar->tabs, GINT_TO_POINTER(true_win), tab);
// still have new windows status_bar_draw();
if (g_hash_table_size(remaining_new) != 0) {
is_active[11] = TRUE;
is_new[11] = TRUE;
_mark_new(11);
// only active windows
} else {
is_active[11] = TRUE;
is_new[11] = FALSE;
_mark_active(11);
}
// visible window indicators
} else {
is_active[true_win] = TRUE;
is_new[true_win] = FALSE;
_mark_active(true_win);
}
_status_bar_draw();
} }
void void
status_bar_new(const int win) status_bar_new(const int win, win_type_t wintype, char* identifier)
{ {
int true_win = win; int true_win = win;
if (true_win == 0) { if (true_win == 0) {
true_win = 10; true_win = 10;
} }
if (true_win > 10) { StatusBarTab *tab = malloc(sizeof(StatusBarTab));
g_hash_table_add(remaining_active, GINT_TO_POINTER(true_win)); tab->identifier = strdup(identifier);
g_hash_table_add(remaining_new, GINT_TO_POINTER(true_win)); tab->highlight = TRUE;
tab->window_type = wintype;
g_hash_table_replace(statusbar->tabs, GINT_TO_POINTER(true_win), tab);
is_active[11] = TRUE; status_bar_draw();
is_new[11] = TRUE; }
_mark_new(11);
void
status_bar_set_prompt(const char *const prompt)
{
if (statusbar->prompt) {
free(statusbar->prompt);
statusbar->prompt = NULL;
}
statusbar->prompt = strdup(prompt);
status_bar_draw();
}
void
status_bar_clear_prompt(void)
{
if (statusbar->prompt) {
free(statusbar->prompt);
statusbar->prompt = NULL;
}
status_bar_draw();
}
void
status_bar_set_fulljid(const char *const fulljid)
{
if (statusbar->fulljid) {
free(statusbar->fulljid);
statusbar->fulljid = NULL;
}
statusbar->fulljid = strdup(fulljid);
status_bar_draw();
}
void
status_bar_clear_fulljid(void)
{
if (statusbar->fulljid) {
free(statusbar->fulljid);
statusbar->fulljid = NULL;
}
status_bar_draw();
}
void
status_bar_draw(void)
{
werase(statusbar_win);
wbkgd(statusbar_win, theme_attrs(THEME_STATUS_TEXT));
int pos = 1;
pos = _status_bar_draw_time(pos);
_status_bar_draw_maintext(pos);
pos = getmaxx(stdscr) - _tabs_width();
if (pos < 0) {
pos = 0;
}
gint max_tabs = prefs_get_statusbartabs();
int i = 1;
for (i = 1; i <= max_tabs; i++) {
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
if (tab) {
pos = _status_bar_draw_tab(tab, pos, i);
}
}
pos = _status_bar_draw_extended_tabs(pos);
wnoutrefresh(statusbar_win);
inp_put_back();
}
static gboolean
_extended_new(void)
{
gint max_tabs = prefs_get_statusbartabs();
int tabs_count = g_hash_table_size(statusbar->tabs);
if (tabs_count <= max_tabs) {
return FALSE;
}
int i = 0;
for (i = max_tabs + 1; i <= tabs_count; i++) {
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
if (tab && tab->highlight) {
return TRUE;
}
}
return FALSE;
}
static int
_status_bar_draw_extended_tabs(int pos)
{
gint max_tabs = prefs_get_statusbartabs();
if (max_tabs == 0) {
return pos;
}
if (g_hash_table_size(statusbar->tabs) > max_tabs) {
gboolean is_current = statusbar->current_tab > max_tabs;
pos = _status_bar_draw_bracket(is_current, pos, "[");
int status_attrs = theme_attrs(THEME_STATUS_ACTIVE);
if (_extended_new()) {
status_attrs = theme_attrs(THEME_STATUS_NEW);
}
wattron(statusbar_win, status_attrs);
mvwprintw(statusbar_win, 0, pos, ">");
wattroff(statusbar_win, status_attrs);
pos++;
pos = _status_bar_draw_bracket(is_current, pos, "]");
}
return pos;
}
static int
_status_bar_draw_tab(StatusBarTab *tab, int pos, int num)
{
int display_num = num == 10 ? 0 : num;
gboolean is_current = num == statusbar->current_tab;
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
pos = _status_bar_draw_bracket(is_current, pos, "[");
int status_attrs = 0;
if (tab->highlight) {
status_attrs = theme_attrs(THEME_STATUS_NEW);
} else { } else {
is_active[true_win] = TRUE; status_attrs = theme_attrs(THEME_STATUS_ACTIVE);
is_new[true_win] = TRUE;
_mark_new(true_win);
} }
wattron(statusbar_win, status_attrs);
if (show_number) {
mvwprintw(statusbar_win, 0, pos, "%d", display_num);
pos++;
}
if (show_number && show_name) {
mvwprintw(statusbar_win, 0, pos, ":");
pos++;
}
if (show_name) {
char *display_name = _display_name(tab);
mvwprintw(statusbar_win, 0, pos, display_name);
pos += strlen(display_name);
free(display_name);
}
wattroff(statusbar_win, status_attrs);
_status_bar_draw(); pos = _status_bar_draw_bracket(is_current, pos, "]");
return pos;
} }
void static int
status_bar_get_password(void) _status_bar_draw_bracket(gboolean current, int pos, char* ch)
{ {
status_bar_print_message("Enter password:"); int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
wattron(statusbar_win, bracket_attrs);
if (current) {
mvwprintw(statusbar_win, 0, pos, "-");
} else {
mvwprintw(statusbar_win, 0, pos, ch);
}
wattroff(statusbar_win, bracket_attrs);
pos++;
_status_bar_draw(); return pos;
} }
void static int
status_bar_print_message(const char *const msg) _status_bar_draw_time(int pos)
{ {
werase(status_bar);
if (message) {
free(message);
}
message = strdup(msg);
char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR); char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR);
gchar *date_fmt = NULL;
if (g_strcmp0(time_pref, "off") == 0) { if (g_strcmp0(time_pref, "off") == 0) {
date_fmt = g_strdup(""); prefs_free_string(time_pref);
} else { return pos;
date_fmt = g_date_time_format(last_time, time_pref);
} }
assert(date_fmt != NULL); if (statusbar->time) {
size_t len = strlen(date_fmt); g_free(statusbar->time);
g_free(date_fmt); statusbar->time = NULL;
if (g_strcmp0(time_pref, "off") != 0) {
mvwprintw(status_bar, 0, 5 + len, message);
} else {
mvwprintw(status_bar, 0, 1, message);
}
prefs_free_string(time_pref);
int cols = getmaxx(stdscr);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, bracket_attrs);
_status_bar_draw();
}
void
status_bar_clear(void)
{
if (message) {
free(message);
message = NULL;
} }
werase(status_bar); GDateTime *datetime = g_date_time_new_now(tz);
statusbar->time = g_date_time_format(datetime, time_pref);
int cols = getmaxx(stdscr); assert(statusbar->time != NULL);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); g_date_time_unref(datetime);
wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, bracket_attrs);
_status_bar_draw();
}
void
status_bar_clear_message(void)
{
if (message) {
free(message);
message = NULL;
}
werase(status_bar);
int cols = getmaxx(stdscr);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, bracket_attrs);
_status_bar_draw();
}
static void
_update_win_statuses(void)
{
int i;
for(i = 1; i < 12; i++) {
if (is_new[i]) {
_mark_new(i);
}
else if (is_active[i]) {
_mark_active(i);
}
else {
_mark_inactive(i);
}
}
}
static void
_mark_new(int num)
{
int active_pos = 1 + ((num-1) * 3);
int cols = getmaxx(stdscr);
int status_attrs = theme_attrs(THEME_STATUS_NEW);
wattron(status_bar, status_attrs);
wattron(status_bar, A_BLINK);
if (num == 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "0");
} else if (num > 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, ">");
} else {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "%d", num);
}
wattroff(status_bar, status_attrs);
wattroff(status_bar, A_BLINK);
}
static void
_mark_active(int num)
{
int active_pos = 1 + ((num-1) * 3);
int cols = getmaxx(stdscr);
int status_attrs = theme_attrs(THEME_STATUS_ACTIVE);
wattron(status_bar, status_attrs);
if (num == 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "0");
} else if (num > 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, ">");
} else {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "%d", num);
}
wattroff(status_bar, status_attrs);
}
static void
_mark_inactive(int num)
{
int active_pos = 1 + ((num-1) * 3);
int cols = getmaxx(stdscr);
mvwaddch(status_bar, 0, cols - 34 + active_pos, ' ');
}
static void
_status_bar_draw(void)
{
if (last_time) {
g_date_time_unref(last_time);
}
last_time = g_date_time_new_now(tz);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
int time_attrs = theme_attrs(THEME_STATUS_TIME); int time_attrs = theme_attrs(THEME_STATUS_TIME);
char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR); size_t len = strlen(statusbar->time);
if (g_strcmp0(time_pref, "off") != 0) { wattron(statusbar_win, bracket_attrs);
gchar *date_fmt = g_date_time_format(last_time, time_pref); mvwaddch(statusbar_win, 0, pos, '[');
assert(date_fmt != NULL); pos++;
size_t len = strlen(date_fmt); wattroff(statusbar_win, bracket_attrs);
wattron(status_bar, bracket_attrs); wattron(statusbar_win, time_attrs);
mvwaddch(status_bar, 0, 1, '['); mvwprintw(statusbar_win, 0, pos, statusbar->time);
wattroff(status_bar, bracket_attrs); pos += len;
wattron(status_bar, time_attrs); wattroff(statusbar_win, time_attrs);
mvwprintw(status_bar, 0, 2, date_fmt); wattron(statusbar_win, bracket_attrs);
wattroff(status_bar, time_attrs); mvwaddch(statusbar_win, 0, pos, ']');
wattron(status_bar, bracket_attrs); wattroff(statusbar_win, bracket_attrs);
mvwaddch(status_bar, 0, 2 + len, ']'); pos += 2;
wattroff(status_bar, bracket_attrs);
g_free(date_fmt);
}
prefs_free_string(time_pref); prefs_free_string(time_pref);
_update_win_statuses(); return pos;
wnoutrefresh(status_bar); }
inp_put_back();
static void
_status_bar_draw_maintext(int pos)
{
if (statusbar->prompt) {
mvwprintw(statusbar_win, 0, pos, statusbar->prompt);
return;
}
if (statusbar->fulljid) {
char *pref = prefs_get_string(PREF_STATUSBAR_SELF);
if (g_strcmp0(pref, "off") == 0) {
return;
}
if (g_strcmp0(pref, "user") == 0) {
Jid *jidp = jid_create(statusbar->fulljid);
mvwprintw(statusbar_win, 0, pos, jidp->localpart);
jid_destroy(jidp);
return;
}
if (g_strcmp0(pref, "barejid") == 0) {
Jid *jidp = jid_create(statusbar->fulljid);
mvwprintw(statusbar_win, 0, pos, jidp->barejid);
jid_destroy(jidp);
return;
}
mvwprintw(statusbar_win, 0, pos, statusbar->fulljid);
}
}
static void
_destroy_tab(StatusBarTab *tab)
{
if (tab) {
if (tab->identifier) {
free(tab->identifier);
}
free(tab);
}
}
static int
_tabs_width(void)
{
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
gint max_tabs = prefs_get_statusbartabs();
if (show_name && show_number) {
int width = g_hash_table_size(statusbar->tabs) > max_tabs ? 4 : 1;
int i = 0;
for (i = 1; i <= max_tabs; i++) {
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
if (tab) {
char *display_name = _display_name(tab);
width += strlen(display_name);
width += 4;
free(display_name);
}
}
return width;
}
if (show_name && !show_number) {
int width = g_hash_table_size(statusbar->tabs) > max_tabs ? 4 : 1;
int i = 0;
for (i = 1; i <= max_tabs; i++) {
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
if (tab) {
char *display_name = _display_name(tab);
width += strlen(display_name);
width += 2;
free(display_name);
}
}
return width;
}
if (g_hash_table_size(statusbar->tabs) > max_tabs) {
return max_tabs * 3 + (g_hash_table_size(statusbar->tabs) > max_tabs ? 4 : 1);
}
return g_hash_table_size(statusbar->tabs) * 3 + (g_hash_table_size(statusbar->tabs) > max_tabs ? 4 : 1);
}
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");
} }

View File

@ -35,13 +35,14 @@
#ifndef UI_STATUSBAR_H #ifndef UI_STATUSBAR_H
#define UI_STATUSBAR_H #define UI_STATUSBAR_H
void create_status_bar(void); void status_bar_init(void);
void status_bar_update_virtual(void); void status_bar_draw(void);
void status_bar_close(void);
void status_bar_resize(void); void status_bar_resize(void);
void status_bar_clear(void); void status_bar_set_prompt(const char *const prompt);
void status_bar_clear_message(void); void status_bar_clear_prompt(void);
void status_bar_get_password(void); void status_bar_set_fulljid(const char *const fulljid);
void status_bar_print_message(const char *const msg); void status_bar_clear_fulljid(void);
void status_bar_current(int i); void status_bar_current(int i);
#endif #endif

View File

@ -297,7 +297,6 @@ void cons_occupants_setting(void);
void cons_roster_setting(void); void cons_roster_setting(void);
void cons_presence_setting(void); void cons_presence_setting(void);
void cons_wrap_setting(void); void cons_wrap_setting(void);
void cons_winstidy_setting(void);
void cons_time_setting(void); void cons_time_setting(void);
void cons_wintitle_setting(void); void cons_wintitle_setting(void);
void cons_notify_setting(void); void cons_notify_setting(void);
@ -318,6 +317,7 @@ void cons_autoping_setting(void);
void cons_autoconnect_setting(void); void cons_autoconnect_setting(void);
void cons_room_cache_setting(void); void cons_room_cache_setting(void);
void cons_inpblock_setting(void); void cons_inpblock_setting(void);
void cons_statusbar_setting(void);
void cons_winpos_setting(void); void cons_winpos_setting(void);
void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity);
void cons_show_contact_offline(PContact contact, char *resource, char *status); void cons_show_contact_offline(PContact contact, char *resource, char *status);
@ -331,8 +331,8 @@ void title_bar_set_presence(contact_presence_t presence);
// status bar // status bar
void status_bar_inactive(const int win); void status_bar_inactive(const int win);
void status_bar_active(const int win); void status_bar_active(const int win, win_type_t wintype, char *identifier);
void status_bar_new(const int win); void status_bar_new(const int win, win_type_t wintype, char *identifier);
void status_bar_set_all_inactive(void); void status_bar_set_all_inactive(void);
// roster window // roster window
@ -375,6 +375,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_contact(ProfWin *window, PContact contact);
void win_show_info(ProfWin *window, PContact contact); void win_show_info(ProfWin *window, PContact contact);
void win_clear(ProfWin *window); void win_clear(ProfWin *window);
char* win_get_tab_identifier(ProfWin *window);
char* win_to_string(ProfWin *window); char* win_to_string(ProfWin *window);
// desktop notifications // desktop notifications

View File

@ -194,7 +194,7 @@ typedef struct prof_xml_win_t {
} ProfXMLWin; } ProfXMLWin;
typedef struct prof_plugin_win_t { typedef struct prof_plugin_win_t {
ProfWin super; ProfWin window;
char *tag; char *tag;
char *plugin_name; char *plugin_name;
unsigned long memcheck; unsigned long memcheck;

View File

@ -162,7 +162,7 @@ win_create_muc(const char *const roomjid)
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
new_win->window.type = WIN_MUC; new_win->window.type = WIN_MUC;
new_win->window.layout = _win_create_simple_layout();
ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit)); ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit));
layout->base.type = LAYOUT_SPLIT; layout->base.type = LAYOUT_SPLIT;
@ -208,7 +208,6 @@ win_create_muc_config(const char *const roomjid, DataForm *form)
ProfMucConfWin *new_win = malloc(sizeof(ProfMucConfWin)); ProfMucConfWin *new_win = malloc(sizeof(ProfMucConfWin));
new_win->window.type = WIN_MUC_CONFIG; new_win->window.type = WIN_MUC_CONFIG;
new_win->window.layout = _win_create_simple_layout(); new_win->window.layout = _win_create_simple_layout();
new_win->roomjid = strdup(roomjid); new_win->roomjid = strdup(roomjid);
new_win->form = form; new_win->form = form;
@ -223,7 +222,6 @@ win_create_private(const char *const fulljid)
ProfPrivateWin *new_win = malloc(sizeof(ProfPrivateWin)); ProfPrivateWin *new_win = malloc(sizeof(ProfPrivateWin));
new_win->window.type = WIN_PRIVATE; new_win->window.type = WIN_PRIVATE;
new_win->window.layout = _win_create_simple_layout(); new_win->window.layout = _win_create_simple_layout();
new_win->fulljid = strdup(fulljid); new_win->fulljid = strdup(fulljid);
new_win->unread = 0; new_win->unread = 0;
new_win->occupant_offline = FALSE; new_win->occupant_offline = FALSE;
@ -250,15 +248,15 @@ ProfWin*
win_create_plugin(const char *const plugin_name, const char *const tag) win_create_plugin(const char *const plugin_name, const char *const tag)
{ {
ProfPluginWin *new_win = malloc(sizeof(ProfPluginWin)); ProfPluginWin *new_win = malloc(sizeof(ProfPluginWin));
new_win->super.type = WIN_PLUGIN; new_win->window.type = WIN_PLUGIN;
new_win->super.layout = _win_create_simple_layout(); new_win->window.layout = _win_create_simple_layout();
new_win->tag = strdup(tag); new_win->tag = strdup(tag);
new_win->plugin_name = strdup(plugin_name); new_win->plugin_name = strdup(plugin_name);
new_win->memcheck = PROFPLUGINWIN_MEMCHECK; new_win->memcheck = PROFPLUGINWIN_MEMCHECK;
return &new_win->super; return &new_win->window;
} }
char* char*
@ -320,6 +318,50 @@ win_get_title(ProfWin *window)
return NULL; 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* char*
win_to_string(ProfWin *window) win_to_string(ProfWin *window)
{ {

View File

@ -45,7 +45,6 @@
#include "config/theme.h" #include "config/theme.h"
#include "plugins/plugins.h" #include "plugins/plugins.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "ui/statusbar.h"
#include "ui/window_list.h" #include "ui/window_list.h"
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
#include "xmpp/roster_list.h" #include "xmpp/roster_list.h"
@ -239,9 +238,7 @@ wins_close_plugin(char *tag)
int index = wins_get_num(toclose); int index = wins_get_num(toclose);
ui_close_win(index); ui_close_win(index);
if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) { wins_tidy();
wins_tidy();
}
} }
GList* GList*
@ -847,7 +844,7 @@ wins_lost_connection(void)
g_list_free(values); g_list_free(values);
} }
gboolean void
wins_swap(int source_win, int target_win) wins_swap(int source_win, int target_win)
{ {
ProfWin *source = g_hash_table_lookup(windows, GINT_TO_POINTER(source_win)); ProfWin *source = g_hash_table_lookup(windows, GINT_TO_POINTER(source_win));
@ -857,20 +854,21 @@ wins_swap(int source_win, int target_win)
ProfWin *target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win)); ProfWin *target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win));
// target window empty // target window empty
if (!target) { if (target == NULL) {
g_hash_table_steal(windows, GINT_TO_POINTER(source_win)); g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source); g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
status_bar_inactive(source_win); status_bar_inactive(source_win);
char *identifier = win_get_tab_identifier(source);
if (win_unread(source) > 0) { if (win_unread(source) > 0) {
status_bar_new(target_win); status_bar_new(target_win, source->type, identifier);
} else { } else {
status_bar_active(target_win); status_bar_active(target_win, source->type, identifier);
} }
free(identifier);
if (wins_get_current_num() == source_win) { if (wins_get_current_num() == source_win) {
wins_set_current_by_num(target_win); wins_set_current_by_num(target_win);
ui_focus_win(console); ui_focus_win(console);
} }
return TRUE;
// target window occupied // target window occupied
} else { } else {
@ -878,23 +876,24 @@ wins_swap(int source_win, int target_win)
g_hash_table_steal(windows, GINT_TO_POINTER(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(source_win), target);
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source); 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) { if (win_unread(source) > 0) {
status_bar_new(target_win); status_bar_new(target_win, source->type, source_identifier);
} else { } else {
status_bar_active(target_win); status_bar_active(target_win, source->type, source_identifier);
} }
if (win_unread(target) > 0) { if (win_unread(target) > 0) {
status_bar_new(source_win); status_bar_new(source_win, target->type, target_identifier);
} else { } else {
status_bar_active(source_win); 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)) { if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
ui_focus_win(console); ui_focus_win(console);
} }
return TRUE;
} }
} else {
return FALSE;
} }
} }
@ -999,22 +998,24 @@ wins_tidy(void)
GList *curr = keys; GList *curr = keys;
while (curr) { while (curr) {
ProfWin *window = g_hash_table_lookup(windows, curr->data); ProfWin *window = g_hash_table_lookup(windows, curr->data);
char *identifier = win_get_tab_identifier(window);
g_hash_table_steal(windows, curr->data); g_hash_table_steal(windows, curr->data);
if (num == 10) { if (num == 10) {
g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window); g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window);
if (win_unread(window) > 0) { if (win_unread(window) > 0) {
status_bar_new(0); status_bar_new(0, window->type, identifier);
} else { } else {
status_bar_active(0); status_bar_active(0, window->type, identifier);
} }
} else { } else {
g_hash_table_insert(new_windows, GINT_TO_POINTER(num), window); g_hash_table_insert(new_windows, GINT_TO_POINTER(num), window);
if (win_unread(window) > 0) { if (win_unread(window) > 0) {
status_bar_new(num); status_bar_new(num, window->type, identifier);
} else { } else {
status_bar_active(num); status_bar_active(num, window->type, identifier);
} }
} }
free(identifier);
num++; num++;
curr = g_list_next(curr); curr = g_list_next(curr);
} }

View File

@ -87,7 +87,7 @@ gboolean wins_tidy(void);
GSList* wins_create_summary(gboolean unread); GSList* wins_create_summary(gboolean unread);
void wins_destroy(void); void wins_destroy(void);
GList* wins_get_nums(void); GList* wins_get_nums(void);
gboolean wins_swap(int source_win, int target_win); void wins_swap(int source_win, int target_win);
void wins_hide_subwin(ProfWin *window); void wins_hide_subwin(ProfWin *window);
void wins_show_subwin(ProfWin *window); void wins_show_subwin(ProfWin *window);

View File

@ -448,6 +448,7 @@ void cons_autoconnect_setting(void) {}
void cons_rooms_cache_setting(void) {} void cons_rooms_cache_setting(void) {}
void cons_inpblock_setting(void) {} void cons_inpblock_setting(void) {}
void cons_winpos_setting(void) {} void cons_winpos_setting(void) {}
void cons_statusbar_setting(void) {}
void cons_tray_setting(void) {} void cons_tray_setting(void) {}
void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity)
@ -466,8 +467,8 @@ void title_bar_set_presence(contact_presence_t presence) {}
// status bar // status bar
void status_bar_inactive(const int win) {} void status_bar_inactive(const int win) {}
void status_bar_active(const int win) {} void status_bar_active(const int win, win_type_t type, char *identifier) {}
void status_bar_new(const int win) {} void status_bar_new(const int win, win_type_t type, char *identifier) {}
void status_bar_set_all_inactive(void) {} void status_bar_set_all_inactive(void) {}
// roster window // roster window
@ -506,6 +507,11 @@ ProfWin* win_create_plugin(const char *const plugin_name, const char * const tag
return NULL; return NULL;
} }
char* win_get_tab_identifier(ProfWin *window)
{
return NULL;
}
void win_update_virtual(ProfWin *window) {} void win_update_virtual(ProfWin *window) {}
void win_free(ProfWin *window) {} void win_free(ProfWin *window) {}
gboolean win_notify_remind(ProfWin *window) gboolean win_notify_remind(ProfWin *window)

View File

@ -142,4 +142,10 @@ titlebar.position=1
mainwin.position=2 mainwin.position=2
statusbar.position=3 statusbar.position=3
inputwin.position=4 inputwin.position=4
statusbar.self=user
statusbar.chat=user
statusbar.room=room
statusbar.tabs=8
statusbar.show.name=true
statusbar.show.number=true