diff options
author | James Booth <boothj5@gmail.com> | 2014-04-07 20:41:06 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-04-07 20:41:06 +0100 |
commit | fc40637789136a1fecbb7ec18fa60238b77abe13 (patch) | |
tree | 8452128f00c7f14022dd557f0f9b9ad483329f64 /src/ui | |
parent | c7e214860cf97b0dfd3687b09d1a9a7ff3b891c9 (diff) | |
download | profani-tty-fc40637789136a1fecbb7ec18fa60238b77abe13.tar.gz |
Removed titlebar functions from ui.h
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/core.c | 69 | ||||
-rw-r--r-- | src/ui/titlebar.c | 77 | ||||
-rw-r--r-- | src/ui/titlebar.h | 8 | ||||
-rw-r--r-- | src/ui/ui.h | 16 |
4 files changed, 116 insertions, 54 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index 07e5bc11..bafd1987 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -352,6 +352,70 @@ _ui_group_removed(const char * const contact, const char * const 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) { ProfWin *win = wins_get_by_recipient(recipient); @@ -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; } diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index e9e2e457..bc8fc947 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -57,22 +57,28 @@ create_title_bar(void) inp_put_back(); } -static void -_title_bar_console(void) +void +title_bar_update_virtual(void) { - werase(win); - current_recipient = NULL; - typing = FALSE; - typing_elapsed = NULL; + if (current_recipient != NULL) { - free(current_title); - current_title = strdup(CONSOLE_TITLE); + if (typing_elapsed != NULL) { + gdouble seconds = g_timer_elapsed(typing_elapsed, NULL); - _title_bar_draw(); + if (seconds >= 10) { + typing = FALSE; + + g_timer_destroy(typing_elapsed); + typing_elapsed = NULL; + + _title_bar_draw(); + } + } + } } -static void -_title_bar_resize(void) +void +title_bar_resize(void) { int cols = getmaxx(stdscr); @@ -82,35 +88,29 @@ _title_bar_resize(void) _title_bar_draw(); } -static void -_title_bar_update_virtual(void) +void +title_bar_console(void) { - if (current_recipient != NULL) { - - if (typing_elapsed != NULL) { - gdouble seconds = g_timer_elapsed(typing_elapsed, NULL); - - if (seconds >= 10) { - typing = FALSE; + werase(win); + current_recipient = NULL; + typing = FALSE; + typing_elapsed = NULL; - g_timer_destroy(typing_elapsed); - typing_elapsed = NULL; + free(current_title); + current_title = strdup(CONSOLE_TITLE); - _title_bar_draw(); - } - } - } + _title_bar_draw(); } -static void -_title_bar_set_presence(contact_presence_t presence) +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) { @@ -257,15 +257,4 @@ _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; -} +} \ No newline at end of file diff --git a/src/ui/titlebar.h b/src/ui/titlebar.h index 11b015c6..3980964d 100644 --- a/src/ui/titlebar.h +++ b/src/ui/titlebar.h @@ -20,4 +20,10 @@ * */ -void create_title_bar(void); \ No newline at end of file +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); \ No newline at end of file diff --git a/src/ui/ui.h b/src/ui/ui.h index 5d737b6a..737cbc8c 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -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); |