mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Use jid prefs in statusbar
This commit is contained in:
parent
95b639a21f
commit
4bf67fb35a
@ -388,7 +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_set_prompt(connection_get_fulljid());
|
status_bar_set_fulljid(connection_get_fulljid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -481,7 +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_prompt();
|
status_bar_clear_fulljid();
|
||||||
ui_hide_roster();
|
ui_hide_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ typedef struct _status_bar_tab_t {
|
|||||||
typedef struct _status_bar_t {
|
typedef struct _status_bar_t {
|
||||||
gchar *time;
|
gchar *time;
|
||||||
char *prompt;
|
char *prompt;
|
||||||
|
char *fulljid;
|
||||||
GHashTable *tabs;
|
GHashTable *tabs;
|
||||||
int current_tab;
|
int current_tab;
|
||||||
} StatusBar;
|
} StatusBar;
|
||||||
@ -71,7 +72,7 @@ static StatusBar *statusbar;
|
|||||||
static WINDOW *statusbar_win;
|
static WINDOW *statusbar_win;
|
||||||
|
|
||||||
static int _status_bar_draw_time(int pos);
|
static int _status_bar_draw_time(int pos);
|
||||||
static void _status_bar_draw_prompt(int pos);
|
static void _status_bar_draw_maintext(int pos);
|
||||||
static int _status_bar_draw_bracket(gboolean current, int pos, char* ch);
|
static int _status_bar_draw_bracket(gboolean current, int pos, char* ch);
|
||||||
static int _status_bar_draw_extended_tabs(int pos);
|
static int _status_bar_draw_extended_tabs(int pos);
|
||||||
static int _status_bar_draw_tab(StatusBarTab *tab, int pos, int num);
|
static int _status_bar_draw_tab(StatusBarTab *tab, int pos, int num);
|
||||||
@ -88,6 +89,7 @@ status_bar_init(void)
|
|||||||
statusbar = malloc(sizeof(StatusBar));
|
statusbar = malloc(sizeof(StatusBar));
|
||||||
statusbar->time = NULL;
|
statusbar->time = NULL;
|
||||||
statusbar->prompt = NULL;
|
statusbar->prompt = NULL;
|
||||||
|
statusbar->fulljid = NULL;
|
||||||
statusbar->tabs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)_destroy_tab);
|
statusbar->tabs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)_destroy_tab);
|
||||||
StatusBarTab *console = malloc(sizeof(StatusBarTab));
|
StatusBarTab *console = malloc(sizeof(StatusBarTab));
|
||||||
console->window_type = WIN_CONSOLE;
|
console->window_type = WIN_CONSOLE;
|
||||||
@ -115,6 +117,12 @@ status_bar_close(void)
|
|||||||
if (statusbar->prompt) {
|
if (statusbar->prompt) {
|
||||||
free(statusbar->prompt);
|
free(statusbar->prompt);
|
||||||
}
|
}
|
||||||
|
if (statusbar->fulljid) {
|
||||||
|
free(statusbar->fulljid);
|
||||||
|
}
|
||||||
|
if (statusbar->tabs) {
|
||||||
|
g_hash_table_destroy(statusbar->tabs);
|
||||||
|
}
|
||||||
free(statusbar);
|
free(statusbar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,6 +227,29 @@ status_bar_clear_prompt(void)
|
|||||||
status_bar_draw();
|
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
|
void
|
||||||
status_bar_draw(void)
|
status_bar_draw(void)
|
||||||
{
|
{
|
||||||
@ -229,7 +260,7 @@ status_bar_draw(void)
|
|||||||
|
|
||||||
pos = _status_bar_draw_time(pos);
|
pos = _status_bar_draw_time(pos);
|
||||||
|
|
||||||
_status_bar_draw_prompt(pos);
|
_status_bar_draw_maintext(pos);
|
||||||
|
|
||||||
pos = getmaxx(stdscr) - _tabs_width();
|
pos = getmaxx(stdscr) - _tabs_width();
|
||||||
gint max_tabs = prefs_get_statusbartabs();
|
gint max_tabs = prefs_get_statusbartabs();
|
||||||
@ -389,10 +420,31 @@ _status_bar_draw_time(int pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_status_bar_draw_prompt(int pos)
|
_status_bar_draw_maintext(int pos)
|
||||||
{
|
{
|
||||||
if (statusbar->prompt) {
|
if (statusbar->prompt) {
|
||||||
mvwprintw(statusbar_win, 0, pos, 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,10 @@ void status_bar_init(void);
|
|||||||
void status_bar_draw(void);
|
void status_bar_draw(void);
|
||||||
void status_bar_close(void);
|
void status_bar_close(void);
|
||||||
void status_bar_resize(void);
|
void status_bar_resize(void);
|
||||||
void status_bar_clear_prompt(void);
|
|
||||||
void status_bar_set_prompt(const char *const prompt);
|
void status_bar_set_prompt(const char *const prompt);
|
||||||
|
void status_bar_clear_prompt(void);
|
||||||
|
void status_bar_set_fulljid(const char *const fulljid);
|
||||||
|
void status_bar_clear_fulljid(void);
|
||||||
void status_bar_current(int i);
|
void status_bar_current(int i);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user