Mercurial > pidgin.yaz
changeset 13931:917a71dd02eb
[gaim-migrate @ 16458]
Add text-attributes for rows in a GntTree. Use this feature to dim
idle buddies in the buddylist.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 08 Jul 2006 07:13:29 +0000 |
parents | 3dbcbc5e57e1 |
children | e18155a11d1c |
files | console/gntblist.c console/gntconv.c console/libgnt/gntbox.c console/libgnt/gnttextview.c console/libgnt/gnttextview.h console/libgnt/gnttree.c console/libgnt/gnttree.h console/libgnt/test/multiwin.c |
diffstat | 8 files changed, 69 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/console/gntblist.c Sat Jul 08 02:11:11 2006 +0000 +++ b/console/gntblist.c Sat Jul 08 07:13:29 2006 +0000 @@ -203,6 +203,10 @@ node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, get_display_name(node), group, NULL); + if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) + gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM); + else + gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0); } #if 0 @@ -358,7 +362,6 @@ draw_tooltip(ggblist); } - static gboolean key_pressed(GntWidget *widget, const char *text, GGBlist *ggblist) { @@ -377,11 +380,28 @@ } static void -buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *now, GGBlist *ggblist) +update_buddy_display(GaimBuddy *buddy, GGBlist *ggblist) { gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, get_display_name((GaimBlistNode*)buddy)); if (ggblist->tnode == (GaimBlistNode*)buddy) draw_tooltip(ggblist); + + if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) + gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM); + else + gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0); +} + +static void +buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *now, GGBlist *ggblist) +{ + update_buddy_display(buddy, ggblist); +} + +static void +buddy_idle_changed(GaimBuddy *buddy, int old, int new, GGBlist *ggblist) +{ + update_buddy_display(buddy, ggblist); } void gg_blist_init() @@ -405,6 +425,8 @@ gaim_signal_connect(gaim_blist_get_handle(), "buddy-status-changed", gg_blist_get_handle(), GAIM_CALLBACK(buddy_status_changed), ggblist); + gaim_signal_connect(gaim_blist_get_handle(), "buddy-idle-changed", gg_blist_get_handle(), + GAIM_CALLBACK(buddy_idle_changed), ggblist); #if 0 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gg_blist_get_handle(),
--- a/console/gntconv.c Sat Jul 08 02:11:11 2006 +0000 +++ b/console/gntconv.c Sat Jul 08 07:13:29 2006 +0000 @@ -146,7 +146,7 @@ { GGConv *ggconv = g_hash_table_lookup(ggconvs, conv); char *strip; - GntTextViewFlags fl = 0; + GntTextFormatFlags fl = 0; g_return_if_fail(ggconv != NULL);
--- a/console/libgnt/gntbox.c Sat Jul 08 02:11:11 2006 +0000 +++ b/console/libgnt/gntbox.c Sat Jul 08 07:13:29 2006 +0000 @@ -284,7 +284,6 @@ GList *iter; GntBox *box = GNT_BOX(widget); int wchange, hchange; - int wc = 0, hc = 0; wchange = widget->priv.width - width; hchange = widget->priv.height - height;
--- a/console/libgnt/gnttextview.c Sat Jul 08 02:11:11 2006 +0000 +++ b/console/libgnt/gnttextview.c Sat Jul 08 07:13:29 2006 +0000 @@ -7,7 +7,7 @@ typedef struct { - GntTextViewFlags flags; + GntTextFormatFlags flags; char *text; } GntTextSegment; @@ -162,7 +162,7 @@ return widget; } -void gnt_text_view_append_text_with_flags(GntTextView *view, const char *text, GntTextViewFlags flags) +void gnt_text_view_append_text_with_flags(GntTextView *view, const char *text, GntTextFormatFlags flags) { GntWidget *widget = GNT_WIDGET(view); int fl = 0;
--- a/console/libgnt/gnttextview.h Sat Jul 08 02:11:11 2006 +0000 +++ b/console/libgnt/gnttextview.h Sat Jul 08 07:13:29 2006 +0000 @@ -35,7 +35,7 @@ GNT_TEXT_FLAG_BLINK = 1 << 2, GNT_TEXT_FLAG_DIM = 1 << 3, GNT_TEXT_FLAG_HIGHLIGHT = 1 << 4, -} GntTextViewFlags; +} GntTextFormatFlags; struct _GnTextViewClass { @@ -58,7 +58,7 @@ /* scroll > 0 means scroll up, < 0 means scroll down, == 0 means scroll to the end */ void gnt_text_view_scroll(GntTextView *view, int scroll); -void gnt_text_view_append_text_with_flags(GntTextView *view, const char *text, GntTextViewFlags flags); +void gnt_text_view_append_text_with_flags(GntTextView *view, const char *text, GntTextFormatFlags flags); /* Move the cursor to the beginning of the next line and resets text-attributes. * It first completes the current line with the current text-attributes. */
--- a/console/libgnt/gnttree.c Sat Jul 08 02:11:11 2006 +0000 +++ b/console/libgnt/gnttree.c Sat Jul 08 07:13:29 2006 +0000 @@ -25,6 +25,7 @@ gboolean choice; /* Is this a choice-box? If choice is true, then child will be NULL */ gboolean isselected; + GntTextFormatFlags flags; GntTreeRow *parent; GntTreeRow *child; @@ -180,6 +181,9 @@ int wr; char format[16] = ""; + GntTextFormatFlags flags = row->flags; + int attr = 0; + deep = TRUE; if (row->parent == NULL && row->child) @@ -208,25 +212,38 @@ str[wr++] = ' '; str[wr] = 0; } - + + if (flags & GNT_TEXT_FLAG_BOLD) + attr |= A_BOLD; + if (flags & GNT_TEXT_FLAG_UNDERLINE) + attr |= A_UNDERLINE; + if (flags & GNT_TEXT_FLAG_BLINK) + attr |= A_BLINK; + if (row == tree->current) { if (gnt_widget_has_focus(widget)) - wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); + attr |= COLOR_PAIR(GNT_COLOR_HIGHLIGHT); else - wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D)); - mvwprintw(widget->window, start, pos, str); - whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1)); - wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); + attr |= COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D); } else { - mvwprintw(widget->window, start, pos, str); - whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1)); + if (flags & GNT_TEXT_FLAG_DIM) + attr |= (A_DIM | COLOR_PAIR(GNT_COLOR_DISABLED)); + else if (flags & GNT_TEXT_FLAG_HIGHLIGHT) + attr |= (A_DIM | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); + else + attr |= COLOR_PAIR(GNT_COLOR_NORMAL); } + + wbkgdset(widget->window, '\0' | attr); + mvwprintw(widget->window, start, pos, str); + whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1)); tree->bottom = row; } + wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); while (start < widget->priv.height - pos) { mvwhline(widget->window, start, pos, ' ', @@ -682,3 +699,13 @@ return row->isselected; } +void gnt_tree_set_row_flags(GntTree *tree, void *key, GntTextFormatFlags flags) +{ + GntTreeRow *row = g_hash_table_lookup(tree->hash, key); + if (!row) + return; + + row->flags = flags; + redraw_tree(tree); +} +
--- a/console/libgnt/gnttree.h Sat Jul 08 02:11:11 2006 +0000 +++ b/console/libgnt/gnttree.h Sat Jul 08 07:13:29 2006 +0000 @@ -5,6 +5,7 @@ #include "gnt.h" #include "gntcolors.h" #include "gntkeys.h" +#include "gnttextview.h" #define GNT_TYPE_TREE (gnt_tree_get_gtype()) #define GNT_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_TREE, GntTree)) @@ -79,6 +80,8 @@ gboolean gnt_tree_get_choice(GntTree *tree, void *key); +void gnt_tree_set_row_flags(GntTree *tree, void *key, GntTextFormatFlags flags); + G_END_DECLS #endif /* GNT_TREE_H */
--- a/console/libgnt/test/multiwin.c Sat Jul 08 02:11:11 2006 +0000 +++ b/console/libgnt/test/multiwin.c Sat Jul 08 07:13:29 2006 +0000 @@ -58,6 +58,8 @@ gnt_tree_add_row_after(GNT_TREE(tree), "6", "6", "4", NULL); + gnt_tree_set_row_flags(GNT_TREE(tree), "e", GNT_TEXT_FLAG_DIM); + g_timeout_add(5000, show, box2); gnt_main();