Mercurial > pidgin.yaz
comparison console/libgnt/gnttree.c @ 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 | ef0d515b9f97 |
comparison
equal
deleted
inserted
replaced
13930:3dbcbc5e57e1 | 13931:917a71dd02eb |
---|---|
23 | 23 |
24 gboolean collapsed; | 24 gboolean collapsed; |
25 gboolean choice; /* Is this a choice-box? | 25 gboolean choice; /* Is this a choice-box? |
26 If choice is true, then child will be NULL */ | 26 If choice is true, then child will be NULL */ |
27 gboolean isselected; | 27 gboolean isselected; |
28 GntTextFormatFlags flags; | |
28 | 29 |
29 GntTreeRow *parent; | 30 GntTreeRow *parent; |
30 GntTreeRow *child; | 31 GntTreeRow *child; |
31 GntTreeRow *next; | 32 GntTreeRow *next; |
32 GntTreeRow *prev; | 33 GntTreeRow *prev; |
178 { | 179 { |
179 char str[2048]; | 180 char str[2048]; |
180 int wr; | 181 int wr; |
181 char format[16] = ""; | 182 char format[16] = ""; |
182 | 183 |
184 GntTextFormatFlags flags = row->flags; | |
185 int attr = 0; | |
186 | |
183 deep = TRUE; | 187 deep = TRUE; |
184 | 188 |
185 if (row->parent == NULL && row->child) | 189 if (row->parent == NULL && row->child) |
186 { | 190 { |
187 if (row->collapsed) | 191 if (row->collapsed) |
206 { | 210 { |
207 while (wr < widget->priv.width - 1 - pos) | 211 while (wr < widget->priv.width - 1 - pos) |
208 str[wr++] = ' '; | 212 str[wr++] = ' '; |
209 str[wr] = 0; | 213 str[wr] = 0; |
210 } | 214 } |
211 | 215 |
216 if (flags & GNT_TEXT_FLAG_BOLD) | |
217 attr |= A_BOLD; | |
218 if (flags & GNT_TEXT_FLAG_UNDERLINE) | |
219 attr |= A_UNDERLINE; | |
220 if (flags & GNT_TEXT_FLAG_BLINK) | |
221 attr |= A_BLINK; | |
222 | |
212 if (row == tree->current) | 223 if (row == tree->current) |
213 { | 224 { |
214 if (gnt_widget_has_focus(widget)) | 225 if (gnt_widget_has_focus(widget)) |
215 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); | 226 attr |= COLOR_PAIR(GNT_COLOR_HIGHLIGHT); |
216 else | 227 else |
217 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D)); | 228 attr |= COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D); |
218 mvwprintw(widget->window, start, pos, str); | |
219 whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1)); | |
220 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); | |
221 } | 229 } |
222 else | 230 else |
223 { | 231 { |
224 mvwprintw(widget->window, start, pos, str); | 232 if (flags & GNT_TEXT_FLAG_DIM) |
225 whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1)); | 233 attr |= (A_DIM | COLOR_PAIR(GNT_COLOR_DISABLED)); |
226 } | 234 else if (flags & GNT_TEXT_FLAG_HIGHLIGHT) |
235 attr |= (A_DIM | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); | |
236 else | |
237 attr |= COLOR_PAIR(GNT_COLOR_NORMAL); | |
238 } | |
239 | |
240 wbkgdset(widget->window, '\0' | attr); | |
241 mvwprintw(widget->window, start, pos, str); | |
242 whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1)); | |
227 tree->bottom = row; | 243 tree->bottom = row; |
228 } | 244 } |
229 | 245 |
246 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); | |
230 while (start < widget->priv.height - pos) | 247 while (start < widget->priv.height - pos) |
231 { | 248 { |
232 mvwhline(widget->window, start, pos, ' ', | 249 mvwhline(widget->window, start, pos, ' ', |
233 widget->priv.width - pos * 2); | 250 widget->priv.width - pos * 2); |
234 start++; | 251 start++; |
680 g_return_val_if_fail(row->choice, FALSE); | 697 g_return_val_if_fail(row->choice, FALSE); |
681 | 698 |
682 return row->isselected; | 699 return row->isselected; |
683 } | 700 } |
684 | 701 |
702 void gnt_tree_set_row_flags(GntTree *tree, void *key, GntTextFormatFlags flags) | |
703 { | |
704 GntTreeRow *row = g_hash_table_lookup(tree->hash, key); | |
705 if (!row) | |
706 return; | |
707 | |
708 row->flags = flags; | |
709 redraw_tree(tree); | |
710 } | |
711 |