Mercurial > pidgin
changeset 13897:eaaf73de9188
[gaim-migrate @ 16382]
I have added a sort of a taskbar, useful in showing the active windows.
I have also readjusted the blue color a little bit, since this is the
one I am using in a few places right now. And also getting rid of some
code-duplication.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 01 Jul 2006 04:24:31 +0000 |
parents | a621329e8c85 |
children | a1b99fa5faa1 |
files | console/gntblist.c console/gntconv.c console/libgnt/gnt.h console/libgnt/gntcolors.c console/libgnt/gntmain.c console/libgnt/gntwidget.h |
diffstat | 6 files changed, 114 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/console/gntblist.c Sat Jul 01 00:56:05 2006 +0000 +++ b/console/gntblist.c Sat Jul 01 04:24:31 2006 +0000 @@ -219,6 +219,7 @@ get_display_name(node), group, NULL); } +#if 0 static void buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist) { @@ -230,6 +231,7 @@ { node_remove(gaim_get_blist(), (GaimBlistNode*)buddy); } +#endif GaimBlistUiOps *gg_blist_get_ui_ops() { @@ -259,7 +261,6 @@ static void draw_tooltip(GGBlist *ggblist) { - return; GaimBlistNode *node; int x, y, top, width; GString *str; @@ -410,7 +411,7 @@ ggblist->tree = gnt_tree_new(); GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER); - gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr) - 2); + gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr) - 3); gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree); gnt_widget_show(ggblist->window);
--- a/console/gntconv.c Sat Jul 01 00:56:05 2006 +0000 +++ b/console/gntconv.c Sat Jul 01 04:24:31 2006 +0000 @@ -101,7 +101,7 @@ ggc->conv = conv; type = gaim_conversation_get_type(conv); - title = g_strdup_printf(_("Conversation: %s"), gaim_conversation_get_name(conv)); + title = g_strdup_printf(_("%s"), gaim_conversation_get_name(conv)); ggc->window = gnt_box_new(FALSE, TRUE); gnt_box_set_title(GNT_BOX(ggc->window), title); gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); @@ -133,38 +133,52 @@ } static void -gg_write_chat(GaimConversation *conv, const char *who, const char *message, +gg_write_common(GaimConversation *conv, const char *who, const char *message, GaimMessageFlags flags, time_t mtime) { GGConv *ggconv = g_hash_table_lookup(ggconvs, conv); - char *name, *strip; + char *strip; + GntTextViewFlags fl = 0; g_return_if_fail(ggconv != NULL); - name = g_strdup_printf("%s: ", who); + if (who && *who && (flags & (GAIM_MESSAGE_SEND | GAIM_MESSAGE_RECV))) + { + char * name = g_strdup_printf("%s: ", who); + gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), + name, GNT_TEXT_FLAG_BOLD); + g_free(name); + } + else + fl = GNT_TEXT_FLAG_DIM; + + if (flags & GAIM_MESSAGE_ERROR) + fl |= GNT_TEXT_FLAG_BOLD; + if (flags & GAIM_MESSAGE_NICK) + fl |= GNT_TEXT_FLAG_UNDERLINE; + strip = gaim_markup_strip_html(message); - gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), - name, GNT_TEXT_FLAG_BOLD); - gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), - strip, (flags & GAIM_MESSAGE_NICK) ? GNT_TEXT_FLAG_UNDERLINE : 0); + strip, fl); gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv)); gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); - g_free(name); g_free(strip); + + gnt_widget_set_urgent(ggconv->tv); +} + +static void +gg_write_chat(GaimConversation *conv, const char *who, const char *message, + GaimMessageFlags flags, time_t mtime) +{ + gg_write_common(conv, who, message, flags, mtime); } static void gg_write_im(GaimConversation *conv, const char *who, const char *message, GaimMessageFlags flags, time_t mtime) { - GGConv *ggconv = g_hash_table_lookup(ggconvs, conv); - char *strip; - char *name; - - g_return_if_fail(ggconv != NULL); - if (flags & GAIM_MESSAGE_SEND) { who = gaim_connection_get_display_name(conv->account->gc); @@ -176,57 +190,22 @@ else if (flags & GAIM_MESSAGE_RECV) who = gaim_conversation_get_name(conv); - name = g_strdup_printf("%s: ", who); - - gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), - name, GNT_TEXT_FLAG_BOLD); - gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), - (strip = gaim_markup_strip_html(message)), 0); - gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv)); - gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); - - g_free(strip); - g_free(name); + gg_write_common(conv, who, message, flags, mtime); } static void gg_write_conv(GaimConversation *conv, const char *who, const char *alias, const char *message, GaimMessageFlags flags, time_t mtime) { - GGConv *ggconv = g_hash_table_lookup(ggconvs, conv); - char *strip; - GntTextViewFlags fl = 0; - - g_return_if_fail(ggconv != NULL); - - strip = gaim_markup_strip_html(message); + const char *name; + if (alias && *alias) + name = alias; + else if (who && *who) + name = who; + else + name = NULL; - if (flags & (GAIM_MESSAGE_SEND | GAIM_MESSAGE_RECV)) - { - char *name; - if (alias && *alias) - name = g_strdup_printf("%s: ", alias); - else if (who && *who) - name = g_strdup_printf("%s: ", who); - else - name = g_strdup(""); - - gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), - name, GNT_TEXT_FLAG_BOLD); - g_free(name); - } - else - fl = GNT_TEXT_FLAG_DIM; - - if (flags & GAIM_MESSAGE_ERROR) - fl |= GNT_TEXT_FLAG_BOLD; - - gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), - strip, fl); - gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv)); - gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); - - g_free(strip); + gg_write_common(conv, name, message, flags, mtime); } static void
--- a/console/libgnt/gnt.h Sat Jul 01 00:56:05 2006 +0000 +++ b/console/libgnt/gnt.h Sat Jul 01 04:24:31 2006 +0000 @@ -16,3 +16,5 @@ void gnt_screen_take_focus(GntWidget *widget); gboolean gnt_widget_has_focus(GntWidget *widget); + +void gnt_widget_set_urgent(GntWidget *widget);
--- a/console/libgnt/gntcolors.c Sat Jul 01 00:56:05 2006 +0000 +++ b/console/libgnt/gntcolors.c Sat Jul 01 04:24:31 2006 +0000 @@ -9,7 +9,7 @@ init_color(GNT_COLOR_BLACK, 0, 0, 0); init_color(GNT_COLOR_RED, 1000, 0, 0); init_color(GNT_COLOR_GREEN, 0, 1000, 0); - init_color(GNT_COLOR_BLUE, 0, 0, 1000); + init_color(GNT_COLOR_BLUE, 250, 250, 700); init_color(GNT_COLOR_WHITE, 1000, 1000, 1000); init_color(GNT_COLOR_GRAY, 699, 699, 699); init_color(GNT_COLOR_DARK_GRAY, 256, 256, 256); @@ -18,8 +18,10 @@ init_pair(GNT_COLOR_NORMAL, GNT_COLOR_BLACK, GNT_COLOR_WHITE); init_pair(GNT_COLOR_HIGHLIGHT, GNT_COLOR_WHITE, GNT_COLOR_BLUE); init_pair(GNT_COLOR_SHADOW, GNT_COLOR_BLACK, GNT_COLOR_DARK_GRAY); - init_pair(GNT_COLOR_TITLE, GNT_COLOR_WHITE, GNT_COLOR_DARK_GRAY); - init_pair(GNT_COLOR_TITLE_D, GNT_COLOR_BLACK, GNT_COLOR_GRAY); + + init_pair(GNT_COLOR_TITLE, GNT_COLOR_WHITE, GNT_COLOR_BLUE); + init_pair(GNT_COLOR_TITLE_D, GNT_COLOR_WHITE, GNT_COLOR_GRAY); + init_pair(GNT_COLOR_TEXT_NORMAL, GNT_COLOR_WHITE, GNT_COLOR_BLUE); init_pair(GNT_COLOR_HIGHLIGHT_D, GNT_COLOR_BLACK, GNT_COLOR_GRAY); init_pair(GNT_COLOR_DISABLED, GNT_COLOR_GRAY, GNT_COLOR_WHITE);
--- a/console/libgnt/gntmain.c Sat Jul 01 00:56:05 2006 +0000 +++ b/console/libgnt/gntmain.c Sat Jul 01 04:24:31 2006 +0000 @@ -23,6 +23,7 @@ static GHashTable *nodes; static void free_node(gpointer data); +static void draw_taskbar(); void gnt_screen_take_focus(GntWidget *widget) { @@ -33,6 +34,7 @@ gnt_widget_set_focus(widget, TRUE); if (w) gnt_widget_set_focus(w, FALSE); + draw_taskbar(); } void gnt_screen_remove_widget(GntWidget *widget) @@ -43,6 +45,7 @@ gnt_widget_set_focus(focus_list->data, TRUE); gnt_widget_draw(focus_list->data); } + draw_taskbar(); } static void @@ -66,6 +69,53 @@ } } +static void +draw_taskbar() +{ + static WINDOW *taskbar = NULL; + GList *iter; + int n, width; + int i; + + if (taskbar == NULL) + { + taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); + } + + werase(taskbar); + + n = g_list_length(g_list_first(focus_list)); + if (n) + width = getmaxx(stdscr) / n; + + for (i = 0, iter = g_list_first(focus_list); iter; iter = iter->next, i++) + { + GntWidget *w = iter->data; + int color; + + if (w == focus_list->data) + { + /* This is the current window in focus */ + color = GNT_COLOR_TITLE; + GNT_WIDGET_UNSET_FLAGS(w, GNT_WIDGET_URGENT); + } + else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) + { + /* This is a window with the URGENT hint set */ + color = GNT_COLOR_TITLE_D; + } + else + { + color = GNT_COLOR_NORMAL; + } + wbkgdset(taskbar, '\0' | COLOR_PAIR(color)); + mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width); + mvwprintw(taskbar, 0, width * i, "%s", GNT_BOX(w)->title); + } + + wrefresh(taskbar); +} + static gboolean io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) { @@ -135,6 +185,8 @@ gnt_widget_set_focus(w, FALSE); } } + + draw_taskbar(); refresh(); return TRUE; @@ -345,3 +397,15 @@ return FALSE; } +void gnt_widget_set_urgent(GntWidget *widget) +{ + while (widget->parent) + widget = widget->parent; + + if (focus_list && focus_list->data == widget) + return; + + GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_URGENT); + draw_taskbar(); +} +
--- a/console/libgnt/gntwidget.h Sat Jul 01 00:56:05 2006 +0000 +++ b/console/libgnt/gntwidget.h Sat Jul 01 04:24:31 2006 +0000 @@ -35,7 +35,8 @@ GNT_WIDGET_NO_BORDER = 1 << 3, GNT_WIDGET_NO_SHADOW = 1 << 4, GNT_WIDGET_HAS_FOCUS = 1 << 5, - GNT_WIDGET_DRAWING = 1 << 6 + GNT_WIDGET_DRAWING = 1 << 6, + GNT_WIDGET_URGENT = 1 << 7 } GntWidgetFlags; /* XXX: I'll have to ask grim what he's using this for in guifications. */