1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Merge branch 'master' into plugins

Conflicts:
	Makefile.am
	src/server_events.c
This commit is contained in:
James Booth 2014-04-07 21:58:15 +01:00
commit 48922fb7a9
16 changed files with 353 additions and 225 deletions

View File

@ -14,6 +14,7 @@ core_sources = \
src/server_events.c src/server_events.h \
src/ui/ui.h src/ui/window.c src/ui/window.h src/ui/core.c \
src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
src/ui/console.c src/ui/notifier.c \
src/ui/windows.c src/ui/windows.h \
src/command/command.h src/command/command.c src/command/history.c \
@ -59,6 +60,8 @@ tests_sources = \
tests/xmpp/mock_xmpp.h tests/xmpp/mock_xmpp.c \
tests/otr/mock_otr.h tests/otr/mock_otr.c \
tests/ui/mock_ui.h tests/ui/mock_ui.c \
src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
tests/config/mock_accounts.h tests/config/mock_accounts.c \
tests/helpers.c tests/helpers.h \
tests/log/mock_log.c \

View File

@ -1185,7 +1185,7 @@ cmd_autocomplete(char *input, int *size)
found = autocomplete_complete(commands_ac, inp_cpy);
if (found != NULL) {
char *auto_msg = strdup(found);
inp_replace_input(input, auto_msg, size);
ui_replace_input(input, auto_msg, size);
free(auto_msg);
free(found);
}
@ -1443,7 +1443,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, boolean_choices[i],
prefs_autocomplete_boolean_choice);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1460,7 +1460,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_ac(input, size, nick_choices[i],
nick_ac);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1474,7 +1474,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, contact_choices[i],
roster_find_contact);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1485,7 +1485,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, resource_choices[i],
roster_find_resource);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1494,7 +1494,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, "/invite", roster_find_contact);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1504,7 +1504,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, invite_choices[i],
muc_find_invite);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1516,7 +1516,7 @@ _cmd_complete_parameters(char *input, int *size)
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
result = autocomplete_param_with_ac(input, size, cmds[i], completers[i]);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1532,7 +1532,7 @@ _cmd_complete_parameters(char *input, int *size)
for (i = 0; i < ARRAY_SIZE(acs); i++) {
result = acs[i](input, size);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}

View File

@ -648,11 +648,7 @@ cmd_help(gchar **args, struct cmd_help_t help)
gboolean
cmd_about(gchar **args, struct cmd_help_t help)
{
cons_show("");
cons_about();
if (ui_current_win_type() != WIN_CONSOLE) {
status_bar_new(1);
}
ui_about();
return TRUE;
}
@ -953,7 +949,7 @@ cmd_who(gchar **args, struct cmd_help_t help)
}
if (win_type != WIN_CONSOLE && win_type != WIN_MUC) {
status_bar_new(1);
ui_statusbar_new(1);
}
return TRUE;
@ -2814,18 +2810,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

@ -54,10 +54,7 @@ _init_modules(void)
ui_init_module();
console_init_module();
inputwin_init_module();
notifier_init_module();
statusbar_init_module();
titlebar_init_module();
accounts_init_module();
#ifdef PROF_HAVE_LIBOTR

View File

@ -63,7 +63,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
{
_init(disable_tls, log_level);
log_info("Starting main event loop");
inp_non_block();
ui_input_nonblocking();
GTimer *timer = g_timer_new();
gboolean cmd_result = TRUE;
jabber_conn_status_t conn_status = jabber_get_connection_status();
@ -108,10 +108,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
ui_update_screen();
jabber_process_events();
ch = inp_get_char(inp, &size);
if (ch != ERR) {
ui_reset_idle_time();
}
ch = ui_get_char(inp, &size);
}
inp[size++] = '\0';
@ -206,7 +203,7 @@ prof_process_input(char *inp)
result = cmd_execute_default(inp);
}
inp_win_reset();
ui_input_clear();
roster_reset_search_attempts();
ui_current_page_off();
@ -228,28 +225,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);
}
}
}
@ -262,15 +242,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

@ -93,15 +93,10 @@ handle_login_account_success(char *account_name)
#ifdef PROF_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

@ -37,6 +37,7 @@
#include "ui/window.h"
#include "ui/windows.h"
#include "ui/ui.h"
#include "ui/statusbar.h"
#include "xmpp/xmpp.h"
#include "xmpp/bookmark.h"

View File

@ -50,6 +50,9 @@
#include "muc.h"
#include "otr/otr.h"
#include "ui/ui.h"
#include "ui/titlebar.h"
#include "ui/statusbar.h"
#include "ui/inputwin.h"
#include "ui/window.h"
#include "ui/windows.h"
#include "xmpp/xmpp.h"
@ -111,6 +114,16 @@ _ui_update_screen(void)
doupdate();
}
static void
_ui_about(void)
{
cons_show("");
cons_about();
if (ui_current_win_type() != WIN_CONSOLE) {
status_bar_new(1);
}
}
static unsigned long
_ui_get_idle_time(void)
{
@ -144,6 +157,34 @@ _ui_close(void)
endwin();
}
static wint_t
_ui_get_char(char *input, int *size)
{
wint_t ch = inp_get_char(input, size);
if (ch != ERR) {
ui_reset_idle_time();
}
return ch;
}
static void
_ui_input_clear(void)
{
inp_win_reset();
}
static void
_ui_replace_input(char *input, const char * const new_input, int *size)
{
inp_replace_input(input, new_input, size);
}
static void
_ui_input_nonblocking(void)
{
inp_non_block();
}
static void
_ui_resize(const int ch, const char * const input, const int size)
{
@ -353,6 +394,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)
{
@ -1518,6 +1623,12 @@ _ui_clear_win_title(void)
printf("%c]0;%c", '\033', '\007');
}
static void
_ui_statusbar_new(const int win)
{
status_bar_new(win);
}
static void
_ui_draw_term_title(void)
{
@ -1779,4 +1890,15 @@ 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;
ui_about = _ui_about;
ui_statusbar_new = _ui_statusbar_new;
ui_get_char = _ui_get_char;
ui_input_clear = _ui_input_clear;
ui_input_nonblocking = _ui_input_nonblocking;
ui_replace_input = _ui_replace_input;
}

View File

@ -42,6 +42,8 @@
#include "profanity.h"
#include "roster_list.h"
#include "ui/ui.h"
#include "ui/statusbar.h"
#include "ui/inputwin.h"
#include "ui/windows.h"
#include "xmpp/xmpp.h"
@ -58,8 +60,8 @@ static int _printable(const wint_t ch);
static void _clear_input(void);
static void _go_to_end(int display_size);
static void
_create_input_window(void)
void
create_input_window(void)
{
#ifdef NCURSES_REENTRANT
set_escdelay(25);
@ -74,8 +76,8 @@ _create_input_window(void)
_inp_win_update_virtual();
}
static void
_inp_win_resize(const char * const input, const int size)
void
inp_win_resize(const char * const input, const int size)
{
int inp_x;
getmaxyx(stdscr, rows, cols);
@ -92,20 +94,20 @@ _inp_win_resize(const char * const input, const int size)
_inp_win_update_virtual();
}
static void
_inp_non_block(void)
void
inp_non_block(void)
{
wtimeout(inp_win, 20);
}
static void
_inp_block(void)
void
inp_block(void)
{
wtimeout(inp_win, -1);
}
static wint_t
_inp_get_char(char *input, int *size)
wint_t
inp_get_char(char *input, int *size)
{
int inp_x = 0;
int i;
@ -207,8 +209,8 @@ _inp_get_char(char *input, int *size)
return ch;
}
static void
_inp_get_password(char *passwd)
void
inp_get_password(char *passwd)
{
_clear_input();
_inp_win_update_virtual();
@ -220,14 +222,14 @@ _inp_get_password(char *passwd)
status_bar_clear();
}
static void
_inp_put_back(void)
void
inp_put_back(void)
{
_inp_win_update_virtual();
}
static void
_inp_replace_input(char *input, const char * const new_input, int *size)
void
inp_replace_input(char *input, const char * const new_input, int *size)
{
int display_size;
strncpy(input, new_input, INP_WIN_MAX);
@ -239,8 +241,8 @@ _inp_replace_input(char *input, const char * const new_input, int *size)
_go_to_end(display_size);
}
static void
_inp_win_reset(void)
void
inp_win_reset(void)
{
_clear_input();
pad_start = 0;
@ -708,17 +710,3 @@ _printable(const wint_t ch)
gunichar unichar = g_utf8_get_char(bytes);
return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
}
void
inputwin_init_module(void)
{
create_input_window = _create_input_window;
inp_win_resize = _inp_win_resize;
inp_non_block = _inp_non_block;
inp_block = _inp_block;
inp_get_char = _inp_get_char;
inp_get_password = _inp_get_password;
inp_put_back = _inp_put_back;
inp_replace_input = _inp_replace_input;
inp_win_reset = _inp_win_reset;
}

36
src/ui/inputwin.h Normal file
View File

@ -0,0 +1,36 @@
/*
* inputwin.c
*
* Copyright (C) 2012 - 2014 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Profanity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef UI_INPUTWIN_H
#define UI_INPUTWIN_H
void create_input_window(void);
wint_t inp_get_char(char *input, int *size);
void inp_win_reset(void);
void inp_win_resize(const char * input, const int size);
void inp_put_back(void);
void inp_non_block(void);
void inp_block(void);
void inp_get_password(char *passwd);
void inp_replace_input(char *input, const char * const new_input, int *size);
#endif

View File

@ -34,6 +34,8 @@
#include "config/theme.h"
#include "ui/ui.h"
#include "ui/statusbar.h"
#include "ui/inputwin.h"
#define TIME_CHECK 60000000
@ -55,8 +57,8 @@ static void _mark_active(int num);
static void _mark_inactive(int num);
static void _status_bar_draw(void);
static void
_create_status_bar(void)
void
create_status_bar(void)
{
int rows, cols, i;
getmaxyx(stdscr, rows, cols);
@ -86,8 +88,8 @@ _create_status_bar(void)
_status_bar_draw();
}
static void
_status_bar_update_virtual(void)
void
status_bar_update_virtual(void)
{
GDateTime *now_time = g_date_time_new_now_local();
GTimeSpan elapsed = g_date_time_difference(now_time, last_time);
@ -99,8 +101,8 @@ _status_bar_update_virtual(void)
g_date_time_unref(now_time);
}
static void
_status_bar_resize(void)
void
status_bar_resize(void)
{
int rows, cols;
getmaxyx(stdscr, rows, cols);
@ -125,8 +127,8 @@ _status_bar_resize(void)
_status_bar_draw();
}
static void
_status_bar_set_all_inactive(void)
void
status_bar_set_all_inactive(void)
{
int i = 0;
for (i = 0; i < 12; i++) {
@ -141,8 +143,8 @@ _status_bar_set_all_inactive(void)
_status_bar_draw();
}
static void
_status_bar_current(int i)
void
status_bar_current(int i)
{
if (i == 0) {
current = 10;
@ -160,8 +162,8 @@ _status_bar_current(int i)
_status_bar_draw();
}
static void
_status_bar_inactive(const int win)
void
status_bar_inactive(const int win)
{
int true_win = win;
if (true_win == 0) {
@ -202,8 +204,8 @@ _status_bar_inactive(const int win)
_status_bar_draw();
}
static void
_status_bar_active(const int win)
void
status_bar_active(const int win)
{
int true_win = win;
if (true_win == 0) {
@ -238,8 +240,8 @@ _status_bar_active(const int win)
_status_bar_draw();
}
static void
_status_bar_new(const int win)
void
status_bar_new(const int win)
{
int true_win = win;
if (true_win == 0) {
@ -263,16 +265,16 @@ _status_bar_new(const int win)
_status_bar_draw();
}
static void
_status_bar_get_password(void)
void
status_bar_get_password(void)
{
status_bar_print_message("Enter password:");
_status_bar_draw();
}
static void
_status_bar_print_message(const char * const msg)
void
status_bar_print_message(const char * const msg)
{
werase(status_bar);
@ -292,8 +294,8 @@ _status_bar_print_message(const char * const msg)
_status_bar_draw();
}
static void
_status_bar_clear(void)
void
status_bar_clear(void)
{
if (message != NULL) {
free(message);
@ -320,8 +322,8 @@ _status_bar_clear(void)
_status_bar_draw();
}
static void
_status_bar_clear_message(void)
void
status_bar_clear_message(void)
{
if (message != NULL) {
free(message);
@ -422,20 +424,3 @@ _status_bar_draw(void)
wnoutrefresh(status_bar);
inp_put_back();
}
void
statusbar_init_module(void)
{
create_status_bar = _create_status_bar;
status_bar_update_virtual = _status_bar_update_virtual;
status_bar_resize = _status_bar_resize;
status_bar_set_all_inactive = _status_bar_set_all_inactive;
status_bar_current = _status_bar_current;
status_bar_inactive = _status_bar_inactive;
status_bar_active = _status_bar_active;
status_bar_new = _status_bar_new;
status_bar_get_password = _status_bar_get_password;
status_bar_print_message = _status_bar_print_message;
status_bar_clear = _status_bar_clear;
status_bar_clear_message = _status_bar_clear_message;
}

39
src/ui/statusbar.h Normal file
View File

@ -0,0 +1,39 @@
/*
* statusbar.h
*
* Copyright (C) 2012 - 2014 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Profanity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef UI_STATUSBAR_H
#define UI_STATUSBAR_H
void create_status_bar(void);
void status_bar_update_virtual(void);
void status_bar_resize(void);
void status_bar_clear(void);
void status_bar_clear_message(void);
void status_bar_get_password(void);
void status_bar_print_message(const char * const msg);
void status_bar_inactive(const int win);
void status_bar_active(const int win);
void status_bar_new(const int win);
void status_bar_set_all_inactive(void);
void status_bar_current(int i);
#endif

View File

@ -27,6 +27,8 @@
#include "config/theme.h"
#include "config/preferences.h"
#include "ui/ui.h"
#include "ui/titlebar.h"
#include "ui/inputwin.h"
#include "ui/windows.h"
#include "ui/window.h"
#include "roster_list.h"
@ -43,8 +45,8 @@ static GTimer *typing_elapsed;
static void _title_bar_draw(void);
static void
_create_title_bar(void)
void
create_title_bar(void)
{
int cols = getmaxx(stdscr);
@ -56,33 +58,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) {
@ -101,15 +78,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);
@ -126,8 +128,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 +259,3 @@ _title_bar_draw(void)
wnoutrefresh(win);
inp_put_back();
}
void
titlebar_init_module(void)
{
create_title_bar = _create_title_bar;
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;
}

34
src/ui/titlebar.h Normal file
View File

@ -0,0 +1,34 @@
/*
* titlebar.h
*
* Copyright (C) 2012 - 2014 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Profanity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef UI_TITLEBAR_H
#define UI_TITLEBAR_H
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);
#endif

View File

@ -45,8 +45,6 @@ void ui_init_module(void);
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 +146,19 @@ gboolean (*ui_duck_exists)(void);
void (*ui_tidy_wins)(void);
void (*ui_prune_wins)(void);
// create windows
void (*create_title_bar)(void);
void (*create_status_bar)(void);
void (*create_input_window)(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);
void (*ui_about)(void);
void (*ui_statusbar_new)(const int win);
// 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);
wint_t (*ui_get_char)(char *input, int *size);
void (*ui_input_clear)(void);
void (*ui_input_nonblocking)(void);
void (*ui_replace_input)(char *input, const char * const new_input, int *size);
// console window actions
void (*cons_show)(const char * const msg, ...);
@ -233,29 +232,6 @@ void (*cons_autoconnect_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);
// status bar actions
void (*status_bar_update_virtual)(void);
void (*status_bar_resize)(void);
void (*status_bar_clear)(void);
void (*status_bar_clear_message)(void);
void (*status_bar_get_password)(void);
void (*status_bar_print_message)(const char * const msg);
void (*status_bar_inactive)(const int win);
void (*status_bar_active)(const int win);
void (*status_bar_new)(const int win);
void (*status_bar_set_all_inactive)(void);
void (*status_bar_current)(int i);
// input window actions
wint_t (*inp_get_char)(char *input, int *size);
void (*inp_win_reset)(void);
void (*inp_win_resize)(const char * input, const int size);
void (*inp_put_back)(void);
void (*inp_non_block)(void);
void (*inp_block)(void);
void (*inp_get_password)(char *passwd);
void (*inp_replace_input)(char *input, const char * const new_input, int *size);
// desktop notifier actions
void (*notifier_init)(void);
void (*notifier_uninit)(void);

View File

@ -36,6 +36,7 @@
#include "roster_list.h"
#include "config/theme.h"
#include "ui/ui.h"
#include "ui/statusbar.h"
#include "ui/window.h"
#include "ui/windows.h"