1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Removed titlebar functions from ui.h

This commit is contained in:
James Booth 2014-04-07 20:41:06 +01:00
parent c7e214860c
commit fc40637789
8 changed files with 126 additions and 101 deletions

View File

@ -2790,18 +2790,8 @@ _update_presence(const resource_presence_t resource_presence,
cons_show("You are not currently connected.");
} else {
presence_update(resource_presence, msg, 0);
contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
title_bar_set_presence(contact_presence);
gint priority = accounts_get_priority_for_presence_type(jabber_get_account_name(), resource_presence);
if (msg != NULL) {
cons_show("Status set to %s (priority %d), \"%s\".", show, priority, msg);
} else {
cons_show("Status set to %s (priority %d).", show, priority);
}
ui_update_presence(resource_presence, msg, show);
}
}
// helper function for boolean preference commands

View File

@ -57,7 +57,6 @@ _init_modules(void)
inputwin_init_module();
notifier_init_module();
statusbar_init_module();
titlebar_init_module();
accounts_init_module();
#ifdef HAVE_LIBOTR

View File

@ -224,28 +224,11 @@ _handle_idle_time()
// handle away mode
if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "away") == 0) {
presence_update(RESOURCE_AWAY, prefs_get_string(PREF_AUTOAWAY_MESSAGE), 0);
if (prefs_get_string(PREF_AUTOAWAY_MESSAGE) != NULL) {
int pri =
accounts_get_priority_for_presence_type(jabber_get_account_name(),
RESOURCE_AWAY);
cons_show("Idle for %d minutes, status set to away (priority %d), \"%s\".",
prefs_get_autoaway_time(), pri, prefs_get_string(PREF_AUTOAWAY_MESSAGE));
title_bar_set_presence(CONTACT_AWAY);
ui_current_page_off();
} else {
int pri =
accounts_get_priority_for_presence_type(jabber_get_account_name(),
RESOURCE_AWAY);
cons_show("Idle for %d minutes, status set to away (priority %d).",
prefs_get_autoaway_time(), pri);
title_bar_set_presence(CONTACT_AWAY);
ui_current_page_off();
}
ui_auto_away();
// handle idle mode
} else if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "idle") == 0) {
presence_update(RESOURCE_ONLINE,
prefs_get_string(PREF_AUTOAWAY_MESSAGE), idle_ms / 1000);
presence_update(RESOURCE_ONLINE, prefs_get_string(PREF_AUTOAWAY_MESSAGE), idle_ms / 1000);
}
}
}
@ -258,15 +241,10 @@ _handle_idle_time()
if (prefs_get_boolean(PREF_AUTOAWAY_CHECK)) {
if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "away") == 0) {
presence_update(RESOURCE_ONLINE, NULL, 0);
int pri =
accounts_get_priority_for_presence_type(jabber_get_account_name(),
RESOURCE_ONLINE);
cons_show("No longer idle, status set to online (priority %d).", pri);
title_bar_set_presence(CONTACT_ONLINE);
ui_current_page_off();
ui_end_auto_away();
} else if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "idle") == 0) {
presence_update(RESOURCE_ONLINE, NULL, 0);
title_bar_set_presence(CONTACT_ONLINE);
ui_titlebar_presence(CONTACT_ONLINE);
}
}
}

View File

@ -87,18 +87,14 @@ void
handle_login_account_success(char *account_name)
{
ProfAccount *account = accounts_get_account(account_name);
#ifdef HAVE_LIBOTR
otr_on_connect(account);
#endif
resource_presence_t resource_presence = accounts_get_login_presence(account->name);
contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
cons_show_login_success(account);
title_bar_set_presence(contact_presence);
log_info("%s logged in successfully", account->jid);
ui_current_page_off();
status_bar_print_message(account->jid);
status_bar_update_virtual();
ui_handle_login_account_success(account);
log_info("%s logged in successfully", account->jid);
account_free(account);
}

View File

@ -351,6 +351,70 @@ _ui_group_removed(const char * const contact, const char * const group)
cons_show("%s removed from group %s", contact, group);
}
static void
_ui_auto_away(void)
{
if (prefs_get_string(PREF_AUTOAWAY_MESSAGE) != NULL) {
int pri =
accounts_get_priority_for_presence_type(jabber_get_account_name(),
RESOURCE_AWAY);
cons_show("Idle for %d minutes, status set to away (priority %d), \"%s\".",
prefs_get_autoaway_time(), pri, prefs_get_string(PREF_AUTOAWAY_MESSAGE));
title_bar_set_presence(CONTACT_AWAY);
ui_current_page_off();
} else {
int pri =
accounts_get_priority_for_presence_type(jabber_get_account_name(),
RESOURCE_AWAY);
cons_show("Idle for %d minutes, status set to away (priority %d).",
prefs_get_autoaway_time(), pri);
title_bar_set_presence(CONTACT_AWAY);
ui_current_page_off();
}
}
static void
_ui_end_auto_away(void)
{
int pri =
accounts_get_priority_for_presence_type(jabber_get_account_name(), RESOURCE_ONLINE);
cons_show("No longer idle, status set to online (priority %d).", pri);
title_bar_set_presence(CONTACT_ONLINE);
ui_current_page_off();
}
static void
_ui_titlebar_presence(contact_presence_t presence)
{
title_bar_set_presence(presence);
}
static void
_ui_handle_login_account_success(ProfAccount *account)
{
resource_presence_t resource_presence = accounts_get_login_presence(account->name);
contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
cons_show_login_success(account);
title_bar_set_presence(contact_presence);
ui_current_page_off();
status_bar_print_message(account->jid);
status_bar_update_virtual();
}
static void
_ui_update_presence(const resource_presence_t resource_presence,
const char * const message, const char * const show)
{
contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
title_bar_set_presence(contact_presence);
gint priority = accounts_get_priority_for_presence_type(jabber_get_account_name(), resource_presence);
if (message != NULL) {
cons_show("Status set to %s (priority %d), \"%s\".", show, priority, message);
} else {
cons_show("Status set to %s (priority %d).", show, priority);
}
}
static void
_ui_handle_recipient_not_found(const char * const recipient, const char * const err_msg)
{
@ -1775,4 +1839,9 @@ ui_init_module(void)
ui_handle_error = _ui_handle_error;
ui_current_update_virtual = _ui_current_update_virtual;
ui_clear_win_title = _ui_clear_win_title;
ui_auto_away = _ui_auto_away;
ui_end_auto_away = _ui_end_auto_away;
ui_titlebar_presence = _ui_titlebar_presence;
ui_handle_login_account_success = _ui_handle_login_account_success;
ui_update_presence =_ui_update_presence;
}

View File

@ -57,33 +57,8 @@ create_title_bar(void)
inp_put_back();
}
static void
_title_bar_console(void)
{
werase(win);
current_recipient = NULL;
typing = FALSE;
typing_elapsed = NULL;
free(current_title);
current_title = strdup(CONSOLE_TITLE);
_title_bar_draw();
}
static void
_title_bar_resize(void)
{
int cols = getmaxx(stdscr);
wresize(win, 1, cols);
wbkgd(win, COLOUR_TITLE_TEXT);
_title_bar_draw();
}
static void
_title_bar_update_virtual(void)
void
title_bar_update_virtual(void)
{
if (current_recipient != NULL) {
@ -102,15 +77,40 @@ _title_bar_update_virtual(void)
}
}
static void
_title_bar_set_presence(contact_presence_t presence)
void
title_bar_resize(void)
{
int cols = getmaxx(stdscr);
wresize(win, 1, cols);
wbkgd(win, COLOUR_TITLE_TEXT);
_title_bar_draw();
}
void
title_bar_console(void)
{
werase(win);
current_recipient = NULL;
typing = FALSE;
typing_elapsed = NULL;
free(current_title);
current_title = strdup(CONSOLE_TITLE);
_title_bar_draw();
}
void
title_bar_set_presence(contact_presence_t presence)
{
current_presence = presence;
_title_bar_draw();
}
static void
_title_bar_set_recipient(const char * const recipient)
void
title_bar_set_recipient(const char * const recipient)
{
if (typing_elapsed != NULL) {
g_timer_destroy(typing_elapsed);
@ -127,8 +127,8 @@ _title_bar_set_recipient(const char * const recipient)
_title_bar_draw();
}
static void
_title_bar_set_typing(gboolean is_typing)
void
title_bar_set_typing(gboolean is_typing)
{
if (is_typing) {
if (typing_elapsed != NULL) {
@ -258,14 +258,3 @@ _title_bar_draw(void)
wnoutrefresh(win);
inp_put_back();
}
void
titlebar_init_module(void)
{
title_bar_console = _title_bar_console;
title_bar_resize = _title_bar_resize;
title_bar_update_virtual = _title_bar_update_virtual;
title_bar_set_presence = _title_bar_set_presence;
title_bar_set_recipient = _title_bar_set_recipient;
title_bar_set_typing = _title_bar_set_typing;
}

View File

@ -21,3 +21,9 @@
*/
void create_title_bar(void);
void title_bar_update_virtual(void);
void title_bar_resize(void);
void title_bar_console(void);
void title_bar_set_presence(contact_presence_t presence);
void title_bar_set_recipient(const char * const from);
void title_bar_set_typing(gboolean is_typing);

View File

@ -46,7 +46,6 @@ void console_init_module(void);
void inputwin_init_module(void);
void notifier_init_module(void);
void statusbar_init_module(void);
void titlebar_init_module(void);
// ui startup and control
void (*ui_init)(void);
@ -148,18 +147,17 @@ gboolean (*ui_duck_exists)(void);
void (*ui_tidy_wins)(void);
void (*ui_prune_wins)(void);
void (*ui_auto_away)(void);
void (*ui_end_auto_away)(void);
void (*ui_titlebar_presence)(contact_presence_t presence);
void (*ui_handle_login_account_success)(ProfAccount *account);
void (*ui_update_presence)(const resource_presence_t resource_presence,
const char * const message, const char * const show);
// create windows
void (*create_status_bar)(void);
void (*create_input_window)(void);
// title bar actions
void (*title_bar_update_virtual)(void);
void (*title_bar_resize)(void);
void (*title_bar_console)(void);
void (*title_bar_set_presence)(contact_presence_t presence);
void (*title_bar_set_recipient)(const char * const from);
void (*title_bar_set_typing)(gboolean is_typing);
// console window actions
void (*cons_show)(const char * const msg, ...);
void (*cons_about)(void);