diff options
-rw-r--r-- | src/ui/console.c | 154 | ||||
-rw-r--r-- | src/ui/core.c | 56 | ||||
-rw-r--r-- | src/ui/window.c | 97 | ||||
-rw-r--r-- | src/ui/window.h | 13 | ||||
-rw-r--r-- | src/ui/windows.c | 2 |
5 files changed, 154 insertions, 168 deletions
diff --git a/src/ui/console.c b/src/ui/console.c index 348a3ec0..9fecf4e3 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -51,7 +51,7 @@ void cons_show_time(void) { ProfWin *console = wins_get_console(); - console->print_time(console, '-'); + win_print_time(console, '-'); wins_refresh_console(); } @@ -72,7 +72,7 @@ cons_debug(const char * const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "%s\n", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); @@ -93,7 +93,7 @@ cons_show(const char * const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "%s\n", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); @@ -108,7 +108,7 @@ cons_show_error(const char * const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - console->print_time(console, '-'); + win_print_time(console, '-'); wattron(console->win, COLOUR_ERROR); wprintw(console->win, "%s\n", fmt_msg->str); wattroff(console->win, COLOUR_ERROR); @@ -131,7 +131,7 @@ cons_show_typing(const char * const barejid) display_usr = barejid; } - console->print_line(console, '-', COLOUR_TYPING, "!! %s is typing a message...", display_usr); + win_print_line(console, '-', COLOUR_TYPING, "!! %s is typing a message...", display_usr); wins_refresh_console(); cons_alert(); @@ -146,7 +146,7 @@ cons_show_incoming_message(const char * const short_from, const int win_index) if (ui_index == 10) { ui_index = 0; } - console->print_time(console, '-'); + win_print_time(console, '-'); wattron(console->win, COLOUR_INCOMING); wprintw(console->win, "<< incoming from %s (%d)\n", short_from, ui_index); wattroff(console->win, COLOUR_INCOMING); @@ -165,7 +165,7 @@ cons_about(void) if (prefs_get_boolean(PREF_SPLASH)) { _cons_splash_logo(); } else { - console->print_time(console, '-'); + win_print_time(console, '-'); if (strcmp(PACKAGE_STATUS, "development") == 0) { @@ -179,22 +179,22 @@ cons_about(void) } } - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "Copyright (C) 2012, 2013 James Booth <%s>.\n", PACKAGE_BUGREPORT); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "\n"); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "This is free software; you are free to change and redistribute it.\n"); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "There is NO WARRANTY, to the extent permitted by law.\n"); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "\n"); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "Type '/help' to show complete help.\n"); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "\n"); if (prefs_get_boolean(PREF_VERCHECK)) { @@ -218,12 +218,12 @@ cons_check_version(gboolean not_available_msg) if (relase_valid) { if (release_is_new(latest_release)) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "A new version of Profanity is available: %s", latest_release); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "Check <http://www.profanity.im> for details.\n"); free(latest_release); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "\n"); } else { if (not_available_msg) { @@ -242,15 +242,15 @@ void cons_show_login_success(ProfAccount *account) { ProfWin *console = wins_get_console(); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "%s logged in successfully, ", account->jid); resource_presence_t presence = accounts_get_login_presence(account->name); const char *presence_str = string_from_resource_presence(presence); - console->presence_colour_on(console, presence_str); + win_presence_colour_on(console, presence_str); wprintw(console->win, "%s", presence_str); - console->presence_colour_off(console, presence_str); + win_presence_colour_off(console, presence_str); wprintw(console->win, " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); wprintw(console->win, ".\n"); @@ -268,7 +268,7 @@ cons_show_wins(void) GSList *curr = window_strings; while (curr != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, curr->data); wprintw(console->win, "\n"); curr = g_slist_next(curr); @@ -310,19 +310,19 @@ cons_show_info(PContact pcontact) GDateTime *last_activity = p_contact_last_activity(pcontact); WINDOW *win = console->win; - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, "\n"); - console->print_time(console, '-'); - console->presence_colour_on(console, presence); + win_print_time(console, '-'); + win_presence_colour_on(console, presence); wprintw(win, "%s", barejid); if (name != NULL) { wprintw(win, " (%s)", name); } - console->presence_colour_off(console, presence); + win_presence_colour_off(console, presence); wprintw(win, ":\n"); if (sub != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, "Subscription: %s\n", sub); } @@ -330,7 +330,7 @@ cons_show_info(PContact pcontact) GDateTime *now = g_date_time_new_now_local(); GTimeSpan span = g_date_time_difference(now, last_activity); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, "Last activity: "); int hours = span / G_TIME_SPAN_HOUR; @@ -352,7 +352,7 @@ cons_show_info(PContact pcontact) } if (resources != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, "Resources:\n"); // sort in order of availabiltiy @@ -367,21 +367,21 @@ cons_show_info(PContact pcontact) while (ordered_resources != NULL) { Resource *resource = ordered_resources->data; const char *resource_presence = string_from_resource_presence(resource->presence); - console->print_time(console, '-'); - console->presence_colour_on(console, resource_presence); + win_print_time(console, '-'); + win_presence_colour_on(console, resource_presence); wprintw(win, " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status != NULL) { wprintw(win, ", \"%s\"", resource->status); } wprintw(win, "\n"); - console->presence_colour_off(console, resource_presence); + win_presence_colour_off(console, resource_presence); if (resource->caps_str != NULL) { Capabilities *caps = caps_get(resource->caps_str); if (caps != NULL) { // show identity if ((caps->category != NULL) || (caps->type != NULL) || (caps->name != NULL)) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, " Identity: "); if (caps->name != NULL) { wprintw(win, "%s", caps->name); @@ -401,7 +401,7 @@ cons_show_info(PContact pcontact) wprintw(win, "\n"); } if (caps->software != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, " Software: %s", caps->software); } if (caps->software_version != NULL) { @@ -411,7 +411,7 @@ cons_show_info(PContact pcontact) wprintw(win, "\n"); } if (caps->os != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, " OS: %s", caps->os); } if (caps->os_version != NULL) { @@ -437,10 +437,10 @@ cons_show_caps(const char * const contact, Resource *resource) WINDOW *win = console->win; cons_show(""); const char *resource_presence = string_from_resource_presence(resource->presence); - console->print_time(console, '-'); - console->presence_colour_on(console, resource_presence); + win_print_time(console, '-'); + win_presence_colour_on(console, resource_presence); wprintw(console->win, "%s", contact); - console->presence_colour_off(console, resource_presence); + win_presence_colour_off(console, resource_presence); wprintw(win, ":\n"); if (resource->caps_str != NULL) { @@ -448,7 +448,7 @@ cons_show_caps(const char * const contact, Resource *resource) if (caps != NULL) { // show identity if ((caps->category != NULL) || (caps->type != NULL) || (caps->name != NULL)) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, "Identity: "); if (caps->name != NULL) { wprintw(win, "%s", caps->name); @@ -468,7 +468,7 @@ cons_show_caps(const char * const contact, Resource *resource) wprintw(win, "\n"); } if (caps->software != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, "Software: %s", caps->software); } if (caps->software_version != NULL) { @@ -478,7 +478,7 @@ cons_show_caps(const char * const contact, Resource *resource) wprintw(win, "\n"); } if (caps->os != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, "OS: %s", caps->os); } if (caps->os_version != NULL) { @@ -489,11 +489,11 @@ cons_show_caps(const char * const contact, Resource *resource) } if (caps->features != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, "Features:\n"); GSList *feature = caps->features; while (feature != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, " %s\n", feature->data); feature = g_slist_next(feature); } @@ -512,10 +512,10 @@ cons_show_software_version(const char * const jid, const char * const presence, ProfWin *console = wins_get_console(); if ((name != NULL) || (version != NULL) || (os != NULL)) { cons_show(""); - console->print_time(console, '-'); - console->presence_colour_on(console, presence); + win_print_time(console, '-'); + win_presence_colour_on(console, presence); wprintw(console->win, "%s", jid); - console->presence_colour_off(console, presence); + win_presence_colour_off(console, presence); wprintw(console->win, ":\n"); } if (name != NULL) { @@ -582,7 +582,7 @@ cons_show_room_list(GSList *rooms, const char * const conference_node) cons_show("Chat rooms at %s:", conference_node); while (rooms != NULL) { DiscoItem *room = rooms->data; - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, " %s", room->jid); if (room->name != NULL) { wprintw(console->win, ", (%s)", room->name); @@ -612,7 +612,7 @@ cons_show_bookmarks(const GList *list) ProfWin *console = wins_get_console(); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, " %s", item->jid); if (item->nick != NULL) { wprintw(console->win, "/%s", item->nick); @@ -680,7 +680,7 @@ cons_show_disco_items(GSList *items, const char * const jid) cons_show("Service discovery items for %s:", jid); while (items != NULL) { DiscoItem *item = items->data; - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, " %s", item->jid); if (item->name != NULL) { wprintw(console->win, ", (%s)", item->name); @@ -703,7 +703,7 @@ cons_show_status(const char * const barejid) PContact pcontact = roster_get_contact(barejid); if (pcontact != NULL) { - console->show_contact(console, pcontact); + win_show_contact(console, pcontact); } else { cons_show("No such contact \"%s\" in roster.", barejid); } @@ -760,10 +760,10 @@ cons_show_account_list(gchar **accounts) if ((jabber_get_connection_status() == JABBER_CONNECTED) && (g_strcmp0(jabber_get_account_name(), accounts[i]) == 0)) { resource_presence_t presence = accounts_get_last_presence(accounts[i]); - console->print_time(console, '-'); - console->presence_colour_on(console, string_from_resource_presence(presence)); + win_print_time(console, '-'); + win_presence_colour_on(console, string_from_resource_presence(presence)); wprintw(console->win, "%s\n", accounts[i]); - console->presence_colour_off(console, string_from_resource_presence(presence)); + win_presence_colour_off(console, string_from_resource_presence(presence)); } else { cons_show(accounts[i]); } @@ -819,7 +819,7 @@ cons_show_account(ProfAccount *account) WINDOW *win = console->win; if (resources != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, "Resources:\n"); // sort in order of availabiltiy @@ -834,21 +834,21 @@ cons_show_account(ProfAccount *account) while (ordered_resources != NULL) { Resource *resource = ordered_resources->data; const char *resource_presence = string_from_resource_presence(resource->presence); - console->print_time(console, '-'); - console->presence_colour_on(console, resource_presence); + win_print_time(console, '-'); + win_presence_colour_on(console, resource_presence); wprintw(win, " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status != NULL) { wprintw(win, ", \"%s\"", resource->status); } wprintw(win, "\n"); - console->presence_colour_off(console, resource_presence); + win_presence_colour_off(console, resource_presence); if (resource->caps_str != NULL) { Capabilities *caps = caps_get(resource->caps_str); if (caps != NULL) { // show identity if ((caps->category != NULL) || (caps->type != NULL) || (caps->name != NULL)) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, " Identity: "); if (caps->name != NULL) { wprintw(win, "%s", caps->name); @@ -868,7 +868,7 @@ cons_show_account(ProfAccount *account) wprintw(win, "\n"); } if (caps->software != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, " Software: %s", caps->software); } if (caps->software_version != NULL) { @@ -878,7 +878,7 @@ cons_show_account(ProfAccount *account) wprintw(win, "\n"); } if (caps->os != NULL) { - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(win, " OS: %s", caps->os); } if (caps->os_version != NULL) { @@ -1341,7 +1341,7 @@ cons_show_contacts(GSList *list) PContact contact = curr->data; if ((strcmp(p_contact_subscription(contact), "to") == 0) || (strcmp(p_contact_subscription(contact), "both") == 0)) { - console->show_contact(console, contact); + win_show_contact(console, contact); } curr = g_slist_next(curr); } @@ -1362,47 +1362,47 @@ static void _cons_splash_logo(void) { ProfWin *console = wins_get_console(); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "Welcome to\n"); - console->print_time(console, '-'); + win_print_time(console, '-'); wattron(console->win, COLOUR_SPLASH); wprintw(console->win, " ___ _ \n"); wattroff(console->win, COLOUR_SPLASH); - console->print_time(console, '-'); + win_print_time(console, '-'); wattron(console->win, COLOUR_SPLASH); wprintw(console->win, " / __) (_)_ \n"); wattroff(console->win, COLOUR_SPLASH); - console->print_time(console, '-'); + win_print_time(console, '-'); wattron(console->win, COLOUR_SPLASH); wprintw(console->win, " ____ ____ ___ | |__ ____ ____ _| |_ _ _ \n"); wattroff(console->win, COLOUR_SPLASH); - console->print_time(console, '-'); + win_print_time(console, '-'); wattron(console->win, COLOUR_SPLASH); wprintw(console->win, "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |\n"); wattroff(console->win, COLOUR_SPLASH); - console->print_time(console, '-'); + win_print_time(console, '-'); wattron(console->win, COLOUR_SPLASH); wprintw(console->win, "| | | | | | |_| | | ( ( | | | | | | |_| |_| |\n"); wattroff(console->win, COLOUR_SPLASH); - console->print_time(console, '-'); + win_print_time(console, '-'); wattron(console->win, COLOUR_SPLASH); wprintw(console->win, "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |\n"); wattroff(console->win, COLOUR_SPLASH); - console->print_time(console, '-'); + win_print_time(console, '-'); wattron(console->win, COLOUR_SPLASH); wprintw(console->win, "|_| (____/ \n"); wattroff(console->win, COLOUR_SPLASH); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, "\n"); - console->print_time(console, '-'); + win_print_time(console, '-'); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION wprintw(console->win, "Version %sdev.%s.%s\n", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); @@ -1431,20 +1431,20 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } const char *presence = p_contact_presence(contact); - console->print_time(console, '-'); + win_print_time(console, '-'); if (p_contact_subscribed(contact)) { - console->presence_colour_on(console, presence); + win_presence_colour_on(console, presence); wprintw(console->win, "%s\n", title->str); - console->presence_colour_off(console, presence); + win_presence_colour_off(console, presence); } else { - console->presence_colour_on(console, "offline"); + win_presence_colour_on(console, "offline"); wprintw(console->win, "%s\n", title->str); - console->presence_colour_off(console, "offline"); + win_presence_colour_off(console, "offline"); } g_string_free(title, TRUE); - console->print_time(console, '-'); + win_print_time(console, '-'); wprintw(console->win, " Subscription : "); GString *sub = g_string_new(""); sub = g_string_append(sub, p_contact_subscription(contact)); diff --git a/src/ui/core.c b/src/ui/core.c index 807625d8..d5418cef 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -301,7 +301,7 @@ ui_incoming_msg(const char * const from, const char * const message, if ((tv_stamp != NULL) && (win_created)) { PContact pcontact = roster_get_contact(from); if (pcontact != NULL) { - window->show_contact(window, pcontact); + win_show_contact(window, pcontact); } } @@ -783,17 +783,17 @@ ui_current_print_line(const char * const msg, ...) ProfWin *current = wins_get_current(); va_list arg; va_start(arg, msg); - current->print_line(current, '-', 0, msg, arg); + win_print_line(current, '-', 0, msg, arg); va_end(arg); - current->refresh_win(current); + win_refresh(current); } void ui_current_error_line(const char * const msg) { ProfWin *current = wins_get_current(); - current->print_line(current, '-', COLOUR_ERROR, msg); - current->refresh_win(current); + win_print_line(current, '-', COLOUR_ERROR, msg); + win_refresh(current); } void @@ -822,7 +822,7 @@ ui_print_error_from_recipient(const char * const from, const char *err_msg) ProfWin *window = wins_get_by_recipient(from); if (window != NULL) { - window->print_time(window, '-'); + win_print_time(window, '-'); _win_show_error_msg(window->win, err_msg); if (wins_is_current(window)) { wins_refresh_current(); @@ -856,7 +856,7 @@ ui_print_system_msg_from_recipient(const char * const from, const char *message) } } - window->print_time(window, '-'); + win_print_time(window, '-'); wprintw(window->win, "*%s %s\n", bare_jid, message); // this is the current window @@ -881,7 +881,7 @@ ui_recipient_gone(const char * const barejid) ProfWin *window = wins_get_by_recipient(barejid); if (window != NULL) { - window->print_time(window, '!'); + win_print_time(window, '!'); wattron(window->win, COLOUR_GONE); wprintw(window->win, "<- %s ", display_usr); wprintw(window->win, "has left the conversation."); @@ -938,7 +938,7 @@ ui_create_duck_win(void) ProfWin *window = wins_new("DuckDuckGo search", WIN_DUCK); int num = wins_get_num(window); ui_switch_win(num); - window->print_time(window, '-'); + win_print_time(window, '-'); wprintw(window->win, "Type ':help' to find out more.\n"); } @@ -957,9 +957,9 @@ ui_duck(const char * const query) { ProfWin *window = wins_get_by_recipient("DuckDuckGo search"); if (window != NULL) { - window->print_time(window, '-'); + win_print_time(window, '-'); wprintw(window->win, "\n"); - window->print_time(window, '-'); + win_print_time(window, '-'); wattron(window->win, COLOUR_ME); wprintw(window->win, "Query : "); wattroff(window->win, COLOUR_ME); @@ -974,7 +974,7 @@ ui_duck_result(const char * const result) ProfWin *window = wins_get_by_recipient("DuckDuckGo search"); if (window != NULL) { - window->print_time(window, '-'); + win_print_time(window, '-'); wattron(window->win, COLOUR_THEM); wprintw(window->win, "Result : "); wattroff(window->win, COLOUR_THEM); @@ -985,7 +985,7 @@ ui_duck_result(const char * const result) gunichar unichar = g_utf8_get_char(ptr); if (unichar == '\n') { wprintw(window->win, "\n"); - window->print_time(window, '-'); + win_print_time(window, '-'); } else { gchar *string = g_ucs4_to_utf8(&unichar, 1, NULL, NULL, NULL); if (string != NULL) { @@ -1039,7 +1039,7 @@ ui_outgoing_msg(const char * const from, const char * const to, num = wins_get_num(window); } - window->print_time(window, '-'); + win_print_time(window, '-'); if (strncmp(message, "/me ", 4) == 0) { wattron(window->win, COLOUR_ME); wprintw(window->win, "*%s ", from); @@ -1073,7 +1073,7 @@ ui_room_roster(const char * const room, GList *roster, const char * const presen { ProfWin *window = wins_get_by_recipient(room); - window->print_time(window, '!'); + win_print_time(window, '!'); if ((roster == NULL) || (g_list_length(roster) == 0)) { wattron(window->win, COLOUR_ROOMINFO); if (presence == NULL) { @@ -1103,9 +1103,9 @@ ui_room_roster(const char * const room, GList *roster, const char * const presen const char const *nick = p_contact_barejid(member); const char const *show = p_contact_presence(member); - window->presence_colour_on(window, show); + win_presence_colour_on(window, show); wprintw(window->win, "%s", nick); - window->presence_colour_off(window, show); + win_presence_colour_off(window, show); if (roster->next != NULL) { wprintw(window->win, ", "); @@ -1128,7 +1128,7 @@ ui_room_member_offline(const char * const room, const char * const nick) { ProfWin *window = wins_get_by_recipient(room); - window->print_time(window, '!'); + win_print_time(window, '!'); wattron(window->win, COLOUR_OFFLINE); wprintw(window->win, "<- %s has left the room.\n", nick); wattroff(window->win, COLOUR_OFFLINE); @@ -1144,7 +1144,7 @@ ui_room_member_online(const char * const room, const char * const nick, { ProfWin *window = wins_get_by_recipient(room); - window->print_time(window, '!'); + win_print_time(window, '!'); wattron(window->win, COLOUR_ONLINE); wprintw(window->win, "-> %s has joined the room.\n", nick); wattroff(window->win, COLOUR_ONLINE); @@ -1175,7 +1175,7 @@ ui_room_member_nick_change(const char * const room, { ProfWin *window = wins_get_by_recipient(room); - window->print_time(window, '!'); + win_print_time(window, '!'); wattron(window->win, COLOUR_THEM); wprintw(window->win, "** %s is now known as %s\n", old_nick, nick); wattroff(window->win, COLOUR_THEM); @@ -1190,7 +1190,7 @@ ui_room_nick_change(const char * const room, const char * const nick) { ProfWin *window = wins_get_by_recipient(room); - window->print_time(window, '!'); + win_print_time(window, '!'); wattron(window->win, COLOUR_ME); wprintw(window->win, "** You are now known as %s\n", nick); wattroff(window->win, COLOUR_ME); @@ -1233,7 +1233,7 @@ ui_room_message(const char * const room_jid, const char * const nick, ProfWin *window = wins_get_by_recipient(room_jid); int num = wins_get_num(window); - window->print_time(window, '-'); + win_print_time(window, '-'); if (strcmp(nick, muc_get_room_nick(room_jid)) != 0) { if (strncmp(message, "/me ", 4) == 0) { wattron(window->win, COLOUR_THEM); @@ -1304,7 +1304,7 @@ ui_room_subject(const char * const room_jid, const char * const subject) ProfWin *window = wins_get_by_recipient(room_jid); int num = wins_get_num(window); - window->print_time(window, '!'); + win_print_time(window, '!'); wattron(window->win, COLOUR_ROOMINFO); wprintw(window->win, "Room subject: "); wattroff(window->win, COLOUR_ROOMINFO); @@ -1327,7 +1327,7 @@ ui_room_broadcast(const char * const room_jid, const char * const message) ProfWin *window = wins_get_by_recipient(room_jid); int num = wins_get_num(window); - window->print_time(window, '!'); + win_print_time(window, '!'); wattron(window->win, COLOUR_ROOMINFO); wprintw(window->win, "Room message: "); wattroff(window->win, COLOUR_ROOMINFO); @@ -1352,7 +1352,7 @@ ui_status(void) ProfWin *current = wins_get_current(); if (pcontact != NULL) { - current->show_contact(current, pcontact); + win_show_contact(current, pcontact); } else { ui_current_print_line("Error getting contact info."); } @@ -1366,7 +1366,7 @@ ui_status_private(void) ProfWin *current = wins_get_current(); if (pcontact != NULL) { - current->show_contact(current, pcontact); + win_show_contact(current, pcontact); } else { ui_current_print_line("Error getting contact info."); } @@ -1381,7 +1381,7 @@ ui_status_room(const char * const contact) ProfWin *current = wins_get_current(); if (pcontact != NULL) { - current->show_contact(current, pcontact); + win_show_contact(current, pcontact); } else { ui_current_print_line("No such participant \"%s\" in room.", contact); } @@ -1493,7 +1493,7 @@ _show_status_string(ProfWin *window, const char * const from, if (!prefs_get_boolean(PREF_STATUSES)) return; - window->print_time(window, '-'); + win_print_time(window, '-'); if (show != NULL) { if (strcmp(show, "away") == 0) { diff --git a/src/ui/window.c b/src/ui/window.c index fa881df0..d21297a3 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -38,10 +38,6 @@ static gboolean _default_handle_error_message(ProfWin *self, const char * const from, const char * const err_msg); -static void _win_print_time(ProfWin *self, char show_char); -static void _win_presence_colour_on(ProfWin *self, const char * const presence); -static void _win_presence_colour_off(ProfWin *self, const char * const presence); -static void _win_show_contact(ProfWin *self, PContact contact); static void _print_incoming_message(ProfWin *self, GTimeVal *tv_stamp, const char * const from, const char * const message); @@ -58,13 +54,6 @@ win_create(const char * const title, int cols, win_type_t type) new_win->history_shown = 0; new_win->type = type; - new_win->print_time = _win_print_time; - new_win->print_line = win_print_line; - new_win->refresh_win = win_refresh; - new_win->presence_colour_on = _win_presence_colour_on; - new_win->presence_colour_off = _win_presence_colour_off; - new_win->show_contact = _win_show_contact; - switch (new_win->type) { case WIN_CONSOLE: @@ -107,80 +96,80 @@ win_free(ProfWin* window) window = NULL; } -static void -_win_print_time(ProfWin* self, char show_char) +void +win_print_time(ProfWin* window, char show_char) { GDateTime *time = g_date_time_new_now_local(); gchar *date_fmt = g_date_time_format(time, "%H:%M:%S"); - wattron(self->win, COLOUR_TIME); - wprintw(self->win, "%s %c ", date_fmt, show_char); - wattroff(self->win, COLOUR_TIME); + wattron(window->win, COLOUR_TIME); + wprintw(window->win, "%s %c ", date_fmt, show_char); + wattroff(window->win, COLOUR_TIME); g_date_time_unref(time); g_free(date_fmt); } void -win_print_line(ProfWin *self, const char show_char, int attrs, +win_print_line(ProfWin *window, const char show_char, int attrs, const char * const msg, ...) { va_list arg; va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - _win_print_time(self, show_char); - wattron(self->win, attrs); - wprintw(self->win, "%s\n", fmt_msg->str); - wattroff(self->win, attrs); + win_print_time(window, show_char); + wattron(window->win, attrs); + wprintw(window->win, "%s\n", fmt_msg->str); + wattroff(window->win, attrs); g_string_free(fmt_msg, TRUE); va_end(arg); } void -win_refresh(ProfWin *self) +win_refresh(ProfWin *window) { int rows, cols; getmaxyx(stdscr, rows, cols); - prefresh(self->win, self->y_pos, 0, 1, 0, rows-3, cols-1); + prefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1); } -static void -_win_presence_colour_on(ProfWin *self, const char * const presence) +void +win_presence_colour_on(ProfWin *window, const char * const presence) { if (g_strcmp0(presence, "online") == 0) { - wattron(self->win, COLOUR_ONLINE); + wattron(window->win, COLOUR_ONLINE); } else if (g_strcmp0(presence, "away") == 0) { - wattron(self->win, COLOUR_AWAY); + wattron(window->win, COLOUR_AWAY); } else if (g_strcmp0(presence, "chat") == 0) { - wattron(self->win, COLOUR_CHAT); + wattron(window->win, COLOUR_CHAT); } else if (g_strcmp0(presence, "dnd") == 0) { - wattron(self->win, COLOUR_DND); + wattron(window->win, COLOUR_DND); } else if (g_strcmp0(presence, "xa") == 0) { - wattron(self->win, COLOUR_XA); + wattron(window->win, COLOUR_XA); } else { - wattron(self->win, COLOUR_OFFLINE); + wattron(window->win, COLOUR_OFFLINE); } } -static void -_win_presence_colour_off(ProfWin *self, const char * const presence) +void +win_presence_colour_off(ProfWin *window, const char * const presence) { if (g_strcmp0(presence, "online") == 0) { - wattroff(self->win, COLOUR_ONLINE); + wattroff(window->win, COLOUR_ONLINE); } else if (g_strcmp0(presence, "away") == 0) { - wattroff(self->win, COLOUR_AWAY); + wattroff(window->win, COLOUR_AWAY); } else if (g_strcmp0(presence, "chat") == 0) { - wattroff(self->win, COLOUR_CHAT); + wattroff(window->win, COLOUR_CHAT); } else if (g_strcmp0(presence, "dnd") == 0) { - wattroff(self->win, COLOUR_DND); + wattroff(window->win, COLOUR_DND); } else if (g_strcmp0(presence, "xa") == 0) { - wattroff(self->win, COLOUR_XA); + wattroff(window->win, COLOUR_XA); } else { - wattroff(self->win, COLOUR_OFFLINE); + wattroff(window->win, COLOUR_OFFLINE); } } -static void -_win_show_contact(ProfWin *self, PContact contact) +void +win_show_contact(ProfWin *window, PContact contact) { const char *barejid = p_contact_barejid(contact); const char *name = p_contact_name(contact); @@ -188,43 +177,43 @@ _win_show_contact(ProfWin *self, PContact contact) const char *status = p_contact_status(contact); GDateTime *last_activity = p_contact_last_activity(contact); - _win_print_time(self, '-'); - _win_presence_colour_on(self, presence); + win_print_time(window, '-'); + win_presence_colour_on(window, presence); if (name != NULL) { - wprintw(self->win, "%s", name); + wprintw(window->win, "%s", name); } else { - wprintw(self->win, "%s", barejid); + wprintw(window->win, "%s", barejid); } - wprintw(self->win, " is %s", presence); + wprintw(window->win, " is %s", presence); if (last_activity != NULL) { GDateTime *now = g_date_time_new_now_local(); GTimeSpan span = g_date_time_difference(now, last_activity); - wprintw(self->win, ", idle "); + wprintw(window->win, ", idle "); int hours = span / G_TIME_SPAN_HOUR; span = span - hours * G_TIME_SPAN_HOUR; if (hours > 0) { - wprintw(self->win, "%dh", hours); + wprintw(window->win, "%dh", hours); } int minutes = span / G_TIME_SPAN_MINUTE; span = span - minutes * G_TIME_SPAN_MINUTE; - wprintw(self->win, "%dm", minutes); + wprintw(window->win, "%dm", minutes); int seconds = span / G_TIME_SPAN_SECOND; - wprintw(self->win, "%ds", seconds); + wprintw(window->win, "%ds", seconds); } if (status != NULL) { - wprintw(self->win, ", \"%s\"", p_contact_status(contact)); + wprintw(window->win, ", \"%s\"", p_contact_status(contact)); } - wprintw(self->win, "\n"); - _win_presence_colour_off(self, presence); + wprintw(window->win, "\n"); + win_presence_colour_off(window, presence); } static gboolean @@ -239,7 +228,7 @@ _print_incoming_message(ProfWin *self, GTimeVal *tv_stamp, const char * const from, const char * const message) { if (tv_stamp == NULL) { - self->print_time(self, '-'); + win_print_time(self, '-'); } else { GDateTime *time = g_date_time_new_from_timeval_utc(tv_stamp); gchar *date_fmt = g_date_time_format(time, "%H:%M:%S"); diff --git a/src/ui/window.h b/src/ui/window.h index ccf68dab..bfd9b267 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -52,13 +52,6 @@ typedef struct prof_win_t { int paged; int unread; int history_shown; - void (*print_time)(struct prof_win_t *self, char show_char); - void (*print_line)(struct prof_win_t *self, const char show_char, - int attrs, const char * const msg, ...); - void (*refresh_win)(struct prof_win_t *self); - void (*presence_colour_on)(struct prof_win_t *self, const char * const presence); - void (*presence_colour_off)(struct prof_win_t *self, const char * const presence); - void (*show_contact)(struct prof_win_t *self, PContact contact); gboolean (*handle_error_message)(struct prof_win_t *self, const char * const from, const char * const err_msg); void (*print_incoming_message)(struct prof_win_t *self, GTimeVal *tv_stamp, @@ -69,6 +62,10 @@ ProfWin* win_create(const char * const title, int cols, win_type_t type); void win_free(ProfWin *window); void win_print_line(ProfWin *self, const char show_char, int attrs, const char * const msg, ...); -void win_refresh(ProfWin *self); +void win_refresh(ProfWin *window); +void win_print_time(ProfWin *window, char show_char); +void win_presence_colour_on(ProfWin *window, const char * const presence); +void win_presence_colour_off(ProfWin *window, const char * const presence); +void win_show_contact(ProfWin *window, PContact contact); #endif diff --git a/src/ui/windows.c b/src/ui/windows.c index 0d9d7048..87b61ab1 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -350,7 +350,7 @@ wins_lost_connection(void) while (curr != NULL) { ProfWin *window = curr->data; if (window->type != WIN_CONSOLE) { - window->print_time(window, '-'); + win_print_time(window, '-'); wattron(window->win, COLOUR_ERROR); wprintw(window->win, "%s\n", "Lost connection."); wattroff(window->win, COLOUR_ERROR); |