mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 22:36:22 +00:00
Add prefs for empty tabs and tab names
This commit is contained in:
@@ -1747,6 +1747,22 @@ cons_inpblock_setting(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cons_statusbar_setting(void)
|
||||
{
|
||||
cons_winpos_setting();
|
||||
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY)) {
|
||||
cons_show("Show empty tabs (/statusbar) : ON");
|
||||
} else {
|
||||
cons_show("Show empty tabs (/statusbar) : OFF");
|
||||
}
|
||||
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME)) {
|
||||
cons_show("Show tab names (/statusbar) : ON");
|
||||
} else {
|
||||
cons_show("Show tab names (/statusbar) : OFF");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cons_winpos_setting(void)
|
||||
{
|
||||
|
||||
@@ -63,9 +63,7 @@ typedef struct _status_bar_t {
|
||||
int current_tab;
|
||||
} StatusBar;
|
||||
|
||||
#define MAX_TABS 5
|
||||
#define SHOW_EMPTY_TABS FALSE
|
||||
#define SHOW_NAME TRUE
|
||||
#define MAX_TABS 10
|
||||
|
||||
static GTimeZone *tz;
|
||||
static StatusBar *statusbar;
|
||||
@@ -229,8 +227,6 @@ status_bar_clear(void)
|
||||
statusbar->message = NULL;
|
||||
}
|
||||
|
||||
werase(statusbar_win);
|
||||
|
||||
_status_bar_draw();
|
||||
}
|
||||
|
||||
@@ -248,8 +244,11 @@ status_bar_clear_message(void)
|
||||
static int
|
||||
_tabs_width(void)
|
||||
{
|
||||
if (SHOW_NAME) {
|
||||
if (SHOW_EMPTY_TABS) {
|
||||
gboolean show_empty = prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY);
|
||||
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
|
||||
|
||||
if (show_name) {
|
||||
if (show_empty) {
|
||||
int width = 4;
|
||||
int i = 0;
|
||||
for (i = 1; i <= MAX_TABS; i++) {
|
||||
@@ -275,7 +274,7 @@ _tabs_width(void)
|
||||
return width;
|
||||
}
|
||||
} else {
|
||||
if (SHOW_EMPTY_TABS) {
|
||||
if (show_empty) {
|
||||
return MAX_TABS * 3 + 4;
|
||||
} else {
|
||||
return g_hash_table_size(statusbar->tabs) * 3 + 4;
|
||||
@@ -286,6 +285,7 @@ _tabs_width(void)
|
||||
static void
|
||||
_status_bar_draw(void)
|
||||
{
|
||||
werase(statusbar_win);
|
||||
wbkgd(statusbar_win, theme_attrs(THEME_STATUS_TEXT));
|
||||
|
||||
int pos = 1;
|
||||
@@ -337,12 +337,15 @@ _status_bar_draw(void)
|
||||
pos = cols - _tabs_width();
|
||||
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
|
||||
|
||||
gboolean show_empty = prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY);
|
||||
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
|
||||
|
||||
int i = 1;
|
||||
for (i = 1; i <= MAX_TABS; i++) {
|
||||
int display_num = i == 10 ? 0 : i;
|
||||
|
||||
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab || (tab == NULL && SHOW_EMPTY_TABS)) {
|
||||
if (tab || (tab == NULL && show_empty)) {
|
||||
wattron(statusbar_win, bracket_attrs);
|
||||
if (i == statusbar->current_tab) {
|
||||
mvwprintw(statusbar_win, 0, pos, "-");
|
||||
@@ -356,7 +359,7 @@ _status_bar_draw(void)
|
||||
int status_attrs = theme_attrs(THEME_STATUS_NEW);
|
||||
wattron(statusbar_win, status_attrs);
|
||||
mvwprintw(statusbar_win, 0, pos, "%d", display_num);
|
||||
if (SHOW_NAME) {
|
||||
if (show_name) {
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, ":");
|
||||
pos++;
|
||||
@@ -368,7 +371,7 @@ _status_bar_draw(void)
|
||||
int status_attrs = theme_attrs(THEME_STATUS_ACTIVE);
|
||||
wattron(statusbar_win, status_attrs);
|
||||
mvwprintw(statusbar_win, 0, pos, "%d", display_num);
|
||||
if (SHOW_NAME) {
|
||||
if (show_name) {
|
||||
pos++;
|
||||
mvwprintw(statusbar_win, 0, pos, ":");
|
||||
pos++;
|
||||
|
||||
@@ -318,6 +318,7 @@ void cons_autoping_setting(void);
|
||||
void cons_autoconnect_setting(void);
|
||||
void cons_room_cache_setting(void);
|
||||
void cons_inpblock_setting(void);
|
||||
void cons_statusbar_setting(void);
|
||||
void cons_winpos_setting(void);
|
||||
void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity);
|
||||
void cons_show_contact_offline(PContact contact, char *resource, char *status);
|
||||
|
||||
@@ -210,7 +210,10 @@ win_create_muc_config(const char *const roomjid, DataForm *form)
|
||||
{
|
||||
ProfMucConfWin *new_win = malloc(sizeof(ProfMucConfWin));
|
||||
new_win->window.type = WIN_MUC_CONFIG;
|
||||
new_win->window.tab_name = strdup(roomjid);
|
||||
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);
|
||||
@@ -257,7 +260,7 @@ 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(plugin_name);
|
||||
new_win->window.tab_name = strdup(tag);
|
||||
new_win->window.layout = _win_create_simple_layout();
|
||||
|
||||
new_win->tag = strdup(tag);
|
||||
|
||||
Reference in New Issue
Block a user