Mercurial > pidgin.yaz
annotate console/libgnt/gnttree.c @ 14693:ae0136b0a3ae
[gaim-migrate @ 17445]
Patch #1569730 from Richard Nelson (wabz):
"This patch adds a "Clear" button, timestamp and pause
options, and stops it scrolling down if it's scrolled up."
and
"Also gives the debug window a name, so window managers
can more easily have their way with it."
These changes make the debug window a whole lot more usable.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 08 Oct 2006 03:56:06 +0000 |
parents | f1f1dcb26d89 |
children | b15c2eaeb67f |
rev | line source |
---|---|
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gnttree.h" |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13934
diff
changeset
|
2 #include "gntmarshal.h" |
14616
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
3 #include "gntutils.h" |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
5 #include <string.h> |
14215 | 6 #include <ctype.h> |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
7 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 enum |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 { |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
10 SIG_SELECTION_CHANGED, |
13865
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
11 SIG_SCROLLED, |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
12 SIG_TOGGLED, |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
13 SIGS, |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 }; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 |
13858
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
16 #define TAB_SIZE 3 |
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
17 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 /* XXX: Make this one into a GObject? |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 * ... Probably not */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 struct _GnTreeRow |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 void *key; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 void *data; /* XXX: unused */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
25 gboolean collapsed; |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
26 gboolean choice; /* Is this a choice-box? |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
27 If choice is true, then child will be NULL */ |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
28 gboolean isselected; |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
29 GntTextFormatFlags flags; |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
30 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 GntTreeRow *parent; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 GntTreeRow *child; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 GntTreeRow *next; |
13857
d341b5ac1a78
[gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13856
diff
changeset
|
34 GntTreeRow *prev; |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
35 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
36 GList *columns; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
37 }; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
38 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
39 struct _GnTreeCol |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
40 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
41 char *text; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
42 int span; /* How many columns does it span? */ |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 }; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 static GntWidgetClass *parent_class = NULL; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 static guint signals[SIGS] = { 0 }; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
48 static GntTreeRow * |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
49 _get_next(GntTreeRow *row, gboolean godeep) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
50 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
51 if (row == NULL) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
52 return NULL; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
53 if (godeep && row->child) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
54 return row->child; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
55 if (row->next) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
56 return row->next; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
57 return _get_next(row->parent, FALSE); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
58 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
59 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
60 static GntTreeRow * |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
61 get_next(GntTreeRow *row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
62 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
63 if (row == NULL) |
13888
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
64 return NULL; |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
65 return _get_next(row, !row->collapsed); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
66 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
67 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
68 /* Returns the n-th next row. If it doesn't exist, returns NULL */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
69 static GntTreeRow * |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
70 get_next_n(GntTreeRow *row, int n) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
71 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
72 while (row && n--) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
73 row = get_next(row); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
74 return row; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
75 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
76 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
77 /* Returns the n-th next row. If it doesn't exist, then the last non-NULL node */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
78 static GntTreeRow * |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
79 get_next_n_opt(GntTreeRow *row, int n, int *pos) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
80 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
81 GntTreeRow *next = row; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
82 int r = 0; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
83 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
84 if (row == NULL) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
85 return NULL; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
86 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
87 while (row && n--) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
88 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
89 row = get_next(row); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
90 if (row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
91 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
92 next = row; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
93 r++; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
94 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
95 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
96 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
97 if (pos) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
98 *pos = r; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
99 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
100 return next; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
101 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
102 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
103 static GntTreeRow * |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
104 get_last_child(GntTreeRow *row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
105 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
106 if (row == NULL) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
107 return NULL; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
108 if (!row->collapsed && row->child) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
109 row = row->child; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
110 else |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
111 return row; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
112 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
113 while(row->next) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
114 row = row->next; |
14384
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
115 if (!row->collapsed && row->child) |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
116 row = get_last_child(row->child); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
117 return row; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
118 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
119 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
120 static GntTreeRow * |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
121 get_prev(GntTreeRow *row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
122 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
123 if (row == NULL) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
124 return NULL; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
125 if (row->prev) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
126 return get_last_child(row->prev); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
127 return row->parent; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
128 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
129 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
130 static GntTreeRow * |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
131 get_prev_n(GntTreeRow *row, int n) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
132 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
133 while (row && n--) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
134 row = get_prev(row); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
135 return row; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
136 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
137 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
138 /* Distance of row from the root */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
139 /* XXX: This is uber-inefficient */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
140 static int |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
141 get_root_distance(GntTreeRow *row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
142 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
143 if (row == NULL) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
144 return -1; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
145 return get_root_distance(get_prev(row)) + 1; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
146 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
147 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
148 /* Returns the distance between a and b. |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
149 * If a is 'above' b, then the distance is positive */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
150 static int |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
151 get_distance(GntTreeRow *a, GntTreeRow *b) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
152 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
153 /* First get the distance from a to the root. |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
154 * Then the distance from b to the root. |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
155 * Subtract. |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
156 * It's not that good, but it works. */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
157 int ha = get_root_distance(a); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
158 int hb = get_root_distance(b); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
159 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
160 return (hb - ha); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
161 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
162 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
163 static int |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
164 find_depth(GntTreeRow *row) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
165 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
166 int dep = -1; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
167 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
168 while (row) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
169 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
170 dep++; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
171 row = row->parent; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
172 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
173 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
174 return dep; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
175 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
176 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
177 static char * |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
178 update_row_text(GntTree *tree, GntTreeRow *row) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
179 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
180 GString *string = g_string_new(NULL); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
181 GList *iter; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
182 int i; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
183 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
184 for (i = 0, iter = row->columns; i < tree->ncol && iter; i++, iter = iter->next) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
185 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
186 GntTreeCol *col = iter->data; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
187 char *text; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
188 int len = g_utf8_strlen(col->text, -1); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
189 int fl = 0; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
190 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
191 if (i == 0) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
192 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
193 if (row->choice) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
194 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
195 g_string_append_printf(string, "[%c] ", |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
196 row->isselected ? 'X' : ' '); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
197 fl = 4; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
198 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
199 else if (row->parent == NULL && row->child) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
200 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
201 if (row->collapsed) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
202 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
203 string = g_string_append(string, "+ "); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
204 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
205 else |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
206 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
207 string = g_string_append(string, "- "); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
208 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
209 fl = 2; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
210 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
211 else |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
212 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
213 fl = TAB_SIZE * find_depth(row); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
214 g_string_append_printf(string, "%*s", fl, ""); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
215 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
216 len += fl; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
217 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
218 else |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
219 g_string_append_c(string, '|'); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
220 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
221 if (len > tree->columns[i].width) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
222 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
223 len = tree->columns[i].width; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
224 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
225 |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
226 text = g_utf8_offset_to_pointer(col->text, len - fl); |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
227 string = g_string_append_len(string, col->text, text - col->text); |
14107
c0ee28af3ca2
[gaim-migrate @ 16741]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
228 if (len < tree->columns[i].width && iter->next) |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
229 g_string_append_printf(string, "%*s", tree->columns[i].width - len, ""); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
230 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
231 return g_string_free(string, FALSE); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
232 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
233 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
234 static void |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
235 tree_mark_columns(GntTree *tree, int pos, int y, chtype type) |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
236 { |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
237 GntWidget *widget = GNT_WIDGET(tree); |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
238 int i; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
239 int x = pos; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
240 |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
241 for (i = 0; i < tree->ncol - 1; i++) |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
242 { |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
243 x += tree->columns[i].width; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
244 mvwaddch(widget->window, y, x + i, type); |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
245 } |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
246 } |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
247 |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
248 static void |
13853
bbf0470cb348
[gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13851
diff
changeset
|
249 redraw_tree(GntTree *tree) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
250 { |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
251 int start, i; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 GntWidget *widget = GNT_WIDGET(tree); |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
253 GntTreeRow *row; |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
254 int pos, up, down; |
14131
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
255 int rows, scrcol; |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
256 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
257 if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED)) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
258 return; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
259 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
260 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
261 pos = 0; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
262 else |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
263 pos = 1; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
264 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
265 if (tree->top == NULL) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
266 tree->top = tree->root; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
267 if (tree->current == NULL) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
268 tree->current = tree->root; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
269 |
13854
a4c30c1d9de8
[gaim-migrate @ 16313]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13853
diff
changeset
|
270 wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL)); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
272 start = 0; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
273 if (tree->show_title) |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
274 { |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
275 int i; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
276 int x = pos; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
277 |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
278 mvwhline(widget->window, pos + 1, pos, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14123
diff
changeset
|
279 widget->priv.width - pos - 1); |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
280 |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
281 for (i = 0; i < tree->ncol; i++) |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
282 { |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
283 mvwprintw(widget->window, pos, x + i, tree->columns[i].title); |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
284 x += tree->columns[i].width; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
285 } |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
286 if (pos) |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
287 { |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
288 tree_mark_columns(tree, pos, 0, ACS_TTEE | COLOR_PAIR(GNT_COLOR_NORMAL)); |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
289 tree_mark_columns(tree, pos, widget->priv.height - pos, |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
290 ACS_BTEE | COLOR_PAIR(GNT_COLOR_NORMAL)); |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
291 } |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
292 tree_mark_columns(tree, pos, pos + 1, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
293 (tree->show_separator ? ACS_PLUS : ACS_HLINE) | COLOR_PAIR(GNT_COLOR_NORMAL)); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
294 tree_mark_columns(tree, pos, pos, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
295 (tree->show_separator ? ACS_VLINE : ' ') | COLOR_PAIR(GNT_COLOR_NORMAL)); |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
296 start = 2; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
297 } |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
298 |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
299 rows = widget->priv.height - pos * 2 - start - 1; |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
300 tree->bottom = get_next_n_opt(tree->top, rows, &down); |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
301 if (down < rows) |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
302 { |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
303 tree->top = get_prev_n(tree->bottom, rows); |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
304 if (tree->top == NULL) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
305 tree->top = tree->root; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
306 } |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
307 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
308 up = get_distance(tree->top, tree->current); |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
309 if (up < 0) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
310 tree->top = tree->current; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
311 else if (up >= widget->priv.height - pos) |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
312 tree->top = get_prev_n(tree->current, rows); |
14107
c0ee28af3ca2
[gaim-migrate @ 16741]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
313 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
314 row = tree->top; |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
315 for (i = start + pos; row && i < widget->priv.height - pos; |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
316 i++, row = get_next(row)) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
317 { |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
318 char *str; |
13853
bbf0470cb348
[gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13851
diff
changeset
|
319 int wr; |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
320 |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
321 GntTextFormatFlags flags = row->flags; |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
322 int attr = 0; |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
323 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
324 str = update_row_text(tree, row); |
13936
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
325 |
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
326 if ((wr = g_utf8_strlen(str, -1)) >= widget->priv.width - 1 - pos) |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
327 { |
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
328 /* XXX: ellipsize */ |
13936
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
329 char *s = g_utf8_offset_to_pointer(str, widget->priv.width - 1 - pos); |
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
330 *s = '\0'; |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
331 } |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
332 |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
333 if (flags & GNT_TEXT_FLAG_BOLD) |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
334 attr |= A_BOLD; |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
335 if (flags & GNT_TEXT_FLAG_UNDERLINE) |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
336 attr |= A_UNDERLINE; |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
337 if (flags & GNT_TEXT_FLAG_BLINK) |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
338 attr |= A_BLINK; |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
339 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
340 if (row == tree->current) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
341 { |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
342 if (gnt_widget_has_focus(widget)) |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
343 attr |= COLOR_PAIR(GNT_COLOR_HIGHLIGHT); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
344 else |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
345 attr |= COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
346 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
347 else |
13927
9309d27d780c
[gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
348 { |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
349 if (flags & GNT_TEXT_FLAG_DIM) |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
350 attr |= (A_DIM | COLOR_PAIR(GNT_COLOR_DISABLED)); |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
351 else if (flags & GNT_TEXT_FLAG_HIGHLIGHT) |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
352 attr |= (A_DIM | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
353 else |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
354 attr |= COLOR_PAIR(GNT_COLOR_NORMAL); |
13927
9309d27d780c
[gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
355 } |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
356 |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
357 wbkgdset(widget->window, '\0' | attr); |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
358 mvwprintw(widget->window, i, pos, str); |
14107
c0ee28af3ca2
[gaim-migrate @ 16741]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
359 whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1) - 1); |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
360 tree->bottom = row; |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
361 g_free(str); |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
362 tree_mark_columns(tree, pos, i, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
363 (tree->show_separator ? ACS_VLINE : ' ') | attr); |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
364 } |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
365 |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
366 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
367 while (i < widget->priv.height - pos) |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
368 { |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
369 mvwhline(widget->window, i, pos, ' ', |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
370 widget->priv.width - pos * 2 - 1); |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
371 tree_mark_columns(tree, pos, i, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
372 (tree->show_separator ? ACS_VLINE : ' ')); |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
373 i++; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
374 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
375 |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
376 scrcol = widget->priv.width - pos - 1; |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
377 rows--; |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
378 if (rows > 0) |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
379 { |
14131
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
380 int total; |
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
381 int showing, position; |
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
382 |
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
383 get_next_n_opt(tree->root, g_list_length(tree->list), &total); |
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
384 showing = rows * rows / MAX(total, 1) + 1; |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
385 showing = MIN(rows, showing); |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
386 |
14131
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
387 total -= rows; |
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
388 up = get_distance(tree->root, tree->top); |
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
389 down = total - up; |
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
390 |
db2311999862
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
391 position = (rows - showing) * up / MAX(1, up + down); |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
392 position = MAX((tree->top != tree->root), position); |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
393 |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
394 if (showing + position > rows) |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
395 position = rows - showing; |
14107
c0ee28af3ca2
[gaim-migrate @ 16741]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
396 |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
397 if (showing + position == rows && row) |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
398 position = MAX(0, rows - 1 - showing); |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
399 else if (showing + position < rows && !row) |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
400 position = rows - showing; |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
401 |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
402 position += pos + start + 1; |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
403 |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
404 mvwvline(widget->window, pos + start + 1, scrcol, |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
405 ' ' | COLOR_PAIR(GNT_COLOR_NORMAL), rows); |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
406 mvwvline(widget->window, position, scrcol, |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
407 ACS_CKBOARD | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D), showing); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
408 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
409 |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
410 mvwaddch(widget->window, start + pos, scrcol, |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
411 ((tree->top != tree->root) ? ACS_UARROW : ' ') | |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
412 COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D)); |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
413 |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
414 mvwaddch(widget->window, widget->priv.height - pos - 1, scrcol, |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
415 (row ? ACS_DARROW : ' ') | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D)); |
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
416 |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13865
diff
changeset
|
417 gnt_widget_queue_update(widget); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
418 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
419 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
420 static void |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
421 gnt_tree_draw(GntWidget *widget) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
422 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
423 GntTree *tree = GNT_TREE(widget); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
424 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
425 redraw_tree(tree); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
426 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14384
diff
changeset
|
427 GNTDEBUG; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
428 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
429 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
430 static void |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
431 gnt_tree_size_request(GntWidget *widget) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
432 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
433 if (widget->priv.height == 0) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
434 widget->priv.height = 10; /* XXX: Why?! */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
435 if (widget->priv.width == 0) |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
436 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
437 GntTree *tree = GNT_TREE(widget); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
438 int i, width = 0; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
439 for (i = 0; i < tree->ncol; i++) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
440 width += tree->columns[i].width; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
441 widget->priv.width = width + i; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
442 } |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
443 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
444 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
445 static void |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
446 gnt_tree_map(GntWidget *widget) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
447 { |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
448 GntTree *tree = GNT_TREE(widget); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
449 if (widget->priv.width == 0 || widget->priv.height == 0) |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
450 { |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
451 gnt_widget_size_request(widget); |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
452 } |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
453 tree->top = tree->root; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
454 tree->current = tree->root; |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14384
diff
changeset
|
455 GNTDEBUG; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
456 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
457 |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
458 static void |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
459 tree_selection_changed(GntTree *tree, GntTreeRow *old, GntTreeRow *current) |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
460 { |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
461 g_signal_emit(tree, signals[SIG_SELECTION_CHANGED], 0, old->key, current->key); |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
462 } |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
463 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
464 static GntTreeRow * |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
465 get_nth_row(GntTree *tree, int n) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
466 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
467 gpointer key = g_list_nth_data(tree->list, n); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
468 return g_hash_table_lookup(tree->hash, key); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
469 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
470 |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
471 static void |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
472 action_down(GntTree *tree) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
473 { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
474 int dist; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
475 GntTreeRow *row = get_next(tree->current); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
476 if (row == NULL) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
477 return; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
478 tree->current = row; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
479 if ((dist = get_distance(tree->current, tree->bottom)) < 0) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
480 gnt_tree_scroll(tree, -dist); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
481 else |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
482 redraw_tree(tree); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
483 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
484 |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
485 static void |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
486 action_up(GntTree *tree) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
487 { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
488 int dist; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
489 GntTreeRow *row = get_prev(tree->current); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
490 if (!row) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
491 return; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
492 tree->current = row; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
493 if ((dist = get_distance(tree->current, tree->top)) > 0) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
494 gnt_tree_scroll(tree, -dist); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
495 else |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
496 redraw_tree(tree); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
497 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
498 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
499 static gboolean |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
500 gnt_tree_key_pressed(GntWidget *widget, const char *text) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
501 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
502 GntTree *tree = GNT_TREE(widget); |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
503 GntTreeRow *old = tree->current; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
504 GntTreeRow *row; |
14215 | 505 int dist; |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
506 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
507 if (text[0] == 27) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
508 { |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
509 if (strcmp(text+1, GNT_KEY_DOWN) == 0) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
510 { |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
511 action_down(tree); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
512 } |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
513 else if (strcmp(text+1, GNT_KEY_UP) == 0) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
514 { |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
515 action_up(tree); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
516 } |
14216
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
517 else if (strcmp(text+1, GNT_KEY_PGDOWN) == 0) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
518 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
519 row = get_next(tree->bottom); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
520 if (row) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
521 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
522 int dist = get_distance(tree->top, tree->current); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
523 tree->top = tree->bottom; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
524 tree->current = get_next_n_opt(tree->top, dist, NULL); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
525 redraw_tree(tree); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
526 } |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
527 else if (tree->current != tree->bottom) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
528 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
529 tree->current = tree->bottom; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
530 redraw_tree(tree); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
531 } |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
532 } |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
533 else if (strcmp(text+1, GNT_KEY_PGUP) == 0) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
534 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
535 if (tree->top != tree->root) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
536 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
537 int dist = get_distance(tree->top, tree->current); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
538 row = get_prev_n(tree->top, widget->priv.height - 1 - |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
539 tree->show_title * 2 - 2 * (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER) == 0)); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
540 if (row == NULL) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
541 row = tree->root; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
542 tree->top = row; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
543 tree->current = get_next_n_opt(tree->top, dist, NULL); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
544 redraw_tree(tree); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
545 } |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
546 else if (tree->current != tree->top) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
547 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
548 tree->current = tree->top; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
549 redraw_tree(tree); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
550 } |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14215
diff
changeset
|
551 } |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
552 } |
14215 | 553 else if (iscntrl(text[0])) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
554 { |
14215 | 555 if (strcmp(text, GNT_KEY_CTRL_N) == 0 && (row = get_next(tree->current)) != NULL) |
556 { | |
557 tree->current = row; | |
558 if ((dist = get_distance(tree->current, tree->bottom)) < 0) | |
559 gnt_tree_scroll(tree, -dist); | |
560 else | |
561 redraw_tree(tree); | |
562 } | |
563 else if (strcmp(text, GNT_KEY_CTRL_P) == 0 && (row = get_prev(tree->current)) != NULL) | |
564 { | |
565 tree->current = row; | |
566 | |
567 if ((dist = get_distance(tree->current, tree->top)) > 0) | |
568 gnt_tree_scroll(tree, -dist); | |
569 else | |
570 redraw_tree(tree); | |
571 } | |
572 else if (text[0] == '\r') | |
573 { | |
574 gnt_widget_activate(widget); | |
575 } | |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
576 } |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
577 else if (text[0] == ' ' && text[1] == 0) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
578 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
579 /* Space pressed */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
580 GntTreeRow *row = tree->current; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
581 if (row && row->child) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
582 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
583 row->collapsed = !row->collapsed; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
584 redraw_tree(tree); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
585 } |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
586 else if (row && row->choice) |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
587 { |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
588 row->isselected = !row->isselected; |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
589 g_signal_emit(tree, signals[SIG_TOGGLED], 0, row->key); |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
590 redraw_tree(tree); |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
591 } |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
592 } |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
593 |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
594 if (old != tree->current) |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
595 { |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
596 tree_selection_changed(tree, old, tree->current); |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
597 return TRUE; |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
598 } |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
599 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
600 return FALSE; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
601 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
602 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
603 static void |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
604 gnt_tree_destroy(GntWidget *widget) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
605 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
606 GntTree *tree = GNT_TREE(widget); |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
607 int i; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
608 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
609 g_hash_table_destroy(tree->hash); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
610 g_list_free(tree->list); |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
611 |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
612 for (i = 0; i < tree->ncol; i++) |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
613 { |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
614 g_free(tree->columns[i].title); |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
615 } |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
616 g_free(tree->columns); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
617 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
618 |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
619 static gboolean |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
620 gnt_tree_clicked(GntWidget *widget, GntMouseEvent event, int x, int y) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
621 { |
14379
a7e29c0b51f4
[gaim-migrate @ 17085]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
622 GntTree *tree = GNT_TREE(widget); |
a7e29c0b51f4
[gaim-migrate @ 17085]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
623 GntTreeRow *old = tree->current; |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
624 if (event == GNT_MOUSE_SCROLL_UP) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
625 action_up(GNT_TREE(widget)); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
626 } else if (event == GNT_MOUSE_SCROLL_DOWN) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
627 action_down(GNT_TREE(widget)); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
628 } else if (event == GNT_LEFT_MOUSE_DOWN) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
629 GntTreeRow *row; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
630 GntTree *tree = GNT_TREE(widget); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
631 int pos = 1; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
632 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
633 pos = 0; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
634 if (tree->show_title) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
635 pos += 2; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
636 pos = y - widget->priv.y - pos; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
637 row = get_next_n(tree->top, pos); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
638 if (row && tree->current != row) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
639 GntTreeRow *old = tree->current; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
640 tree->current = row; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
641 redraw_tree(tree); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
642 tree_selection_changed(tree, old, tree->current); |
14351
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
643 } else if (row && row == tree->current) { |
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
644 if (row->choice) { |
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
645 row->isselected = !row->isselected; |
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
646 g_signal_emit(tree, signals[SIG_TOGGLED], 0, row->key); |
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
647 redraw_tree(tree); |
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
648 } else { |
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
649 gnt_widget_activate(widget); |
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
650 } |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
651 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
652 } else { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
653 return FALSE; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
654 } |
14379
a7e29c0b51f4
[gaim-migrate @ 17085]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
655 if (old != tree->current) { |
a7e29c0b51f4
[gaim-migrate @ 17085]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
656 tree_selection_changed(tree, old, tree->current); |
a7e29c0b51f4
[gaim-migrate @ 17085]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
657 } |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
658 return TRUE; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
659 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
660 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
661 static void |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
662 gnt_tree_class_init(GntTreeClass *klass) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
663 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
664 parent_class = GNT_WIDGET_CLASS(klass); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
665 parent_class->destroy = gnt_tree_destroy; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
666 parent_class->draw = gnt_tree_draw; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
667 parent_class->map = gnt_tree_map; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
668 parent_class->size_request = gnt_tree_size_request; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
669 parent_class->key_pressed = gnt_tree_key_pressed; |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14336
diff
changeset
|
670 parent_class->clicked = gnt_tree_clicked; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
671 |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
672 signals[SIG_SELECTION_CHANGED] = |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
673 g_signal_new("selection-changed", |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
674 G_TYPE_FROM_CLASS(klass), |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
675 G_SIGNAL_RUN_LAST, |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
676 G_STRUCT_OFFSET(GntTreeClass, selection_changed), |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
677 NULL, NULL, |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
678 gnt_closure_marshal_VOID__POINTER_POINTER, |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
679 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); |
13865
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
680 signals[SIG_SCROLLED] = |
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
681 g_signal_new("scrolled", |
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
682 G_TYPE_FROM_CLASS(klass), |
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
683 G_SIGNAL_RUN_LAST, |
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
684 0, |
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
685 NULL, NULL, |
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
686 g_cclosure_marshal_VOID__INT, |
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
687 G_TYPE_NONE, 1, G_TYPE_INT); |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
688 signals[SIG_TOGGLED] = |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
689 g_signal_new("toggled", |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
690 G_TYPE_FROM_CLASS(klass), |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
691 G_SIGNAL_RUN_LAST, |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
692 0, |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
693 NULL, NULL, |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
694 g_cclosure_marshal_VOID__POINTER, |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
695 G_TYPE_NONE, 1, G_TYPE_POINTER); |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
696 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14384
diff
changeset
|
697 GNTDEBUG; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
698 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
699 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
700 static void |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
701 gnt_tree_init(GTypeInstance *instance, gpointer class) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
702 { |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13937
diff
changeset
|
703 GntWidget *widget = GNT_WIDGET(instance); |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
704 GntTree *tree = GNT_TREE(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
705 tree->show_separator = TRUE; |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13937
diff
changeset
|
706 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X | GNT_WIDGET_GROW_Y); |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13937
diff
changeset
|
707 widget->priv.minw = 4; |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
708 widget->priv.minh = 4; |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14384
diff
changeset
|
709 GNTDEBUG; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
710 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
711 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
712 /****************************************************************************** |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
713 * GntTree API |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
714 *****************************************************************************/ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
715 GType |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
716 gnt_tree_get_gtype(void) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
717 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
718 static GType type = 0; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
719 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
720 if(type == 0) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
721 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
722 static const GTypeInfo info = { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
723 sizeof(GntTreeClass), |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
724 NULL, /* base_init */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
725 NULL, /* base_finalize */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
726 (GClassInitFunc)gnt_tree_class_init, |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
727 NULL, /* class_finalize */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
728 NULL, /* class_data */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
729 sizeof(GntTree), |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
730 0, /* n_preallocs */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
731 gnt_tree_init, /* instance_init */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
732 }; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
733 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
734 type = g_type_register_static(GNT_TYPE_WIDGET, |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
735 "GntTree", |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
736 &info, 0); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
737 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
738 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
739 return type; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
740 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
741 |
13858
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
742 static void |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
743 free_tree_col(gpointer data) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
744 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
745 GntTreeCol *col = data; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
746 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
747 g_free(col->text); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
748 g_free(col); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
749 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
750 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
751 static void |
13858
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
752 free_tree_row(gpointer data) |
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
753 { |
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
754 GntTreeRow *row = data; |
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
755 |
13861
55fb5cd9bac9
[gaim-migrate @ 16322]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
756 if (!row) |
55fb5cd9bac9
[gaim-migrate @ 16322]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
757 return; |
55fb5cd9bac9
[gaim-migrate @ 16322]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
758 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
759 g_list_foreach(row->columns, (GFunc)free_tree_col, NULL); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
760 g_list_free(row->columns); |
13858
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
761 g_free(row); |
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
762 } |
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
763 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
764 GntWidget *gnt_tree_new() |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
765 { |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
766 return gnt_tree_new_with_columns(1); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
767 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
768 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
769 void gnt_tree_set_visible_rows(GntTree *tree, int rows) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
770 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
771 GntWidget *widget = GNT_WIDGET(tree); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
772 widget->priv.height = rows; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
773 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
774 widget->priv.height += 2; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
775 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
776 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
777 int gnt_tree_get_visible_rows(GntTree *tree) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
778 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
779 GntWidget *widget = GNT_WIDGET(tree); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
780 int ret = widget->priv.height; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
781 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) |
13888
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
782 ret -= 2; |
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
783 return ret; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
784 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
785 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
786 void gnt_tree_scroll(GntTree *tree, int count) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
787 { |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
788 GntTreeRow *row; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
789 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
790 if (count < 0) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
791 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
792 if (get_root_distance(tree->top) == 0) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
793 return; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
794 row = get_prev_n(tree->top, -count); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
795 if (row == NULL) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
796 row = tree->root; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
797 tree->top = row; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
798 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
799 else |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
800 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
801 get_next_n_opt(tree->bottom, count, &count); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
802 tree->top = get_next_n(tree->top, count); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
803 } |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
804 |
13853
bbf0470cb348
[gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13851
diff
changeset
|
805 redraw_tree(tree); |
13865
d78ab363e02d
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13864
diff
changeset
|
806 g_signal_emit(tree, signals[SIG_SCROLLED], 0, count); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
807 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
808 |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
809 static gpointer |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
810 find_position(GntTree *tree, gpointer key, gpointer parent) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
811 { |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
812 GntTreeRow *row; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
813 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
814 if (tree->compare == NULL) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
815 return NULL; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
816 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
817 if (parent == NULL) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
818 row = tree->root; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
819 else |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
820 row = g_hash_table_lookup(tree->hash, parent); |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
821 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
822 if (!row) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
823 return NULL; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
824 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
825 if (parent) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
826 row = row->child; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
827 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
828 while (row) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
829 { |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
830 if (tree->compare(key, row->key) < 0) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
831 return (row->prev ? row->prev->key : NULL); |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
832 if (row->next) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
833 row = row->next; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
834 else |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
835 return row->key; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
836 } |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
837 return NULL; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
838 } |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
839 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
840 GntTreeRow *gnt_tree_add_row_after(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro) |
13858
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
841 { |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
842 GntTreeRow *pr = NULL; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
843 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
844 g_hash_table_replace(tree->hash, key, row); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
845 |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
846 if (bigbro == NULL && tree->compare) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
847 { |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
848 bigbro = find_position(tree, key, parent); |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
849 } |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
850 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
851 if (tree->root == NULL) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
852 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
853 tree->root = row; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
854 tree->list = g_list_prepend(tree->list, key); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
855 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
856 else |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
857 { |
13927
9309d27d780c
[gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
858 int position = 0; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
859 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
860 if (bigbro) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
861 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
862 pr = g_hash_table_lookup(tree->hash, bigbro); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
863 if (pr) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
864 { |
13857
d341b5ac1a78
[gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13856
diff
changeset
|
865 if (pr->next) pr->next->prev = row; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
866 row->next = pr->next; |
13857
d341b5ac1a78
[gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13856
diff
changeset
|
867 row->prev = pr; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
868 pr->next = row; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
869 row->parent = pr->parent; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
870 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
871 position = g_list_index(tree->list, bigbro); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
872 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
873 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
874 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
875 if (pr == NULL && parent) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
876 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
877 pr = g_hash_table_lookup(tree->hash, parent); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
878 if (pr) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
879 { |
13857
d341b5ac1a78
[gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13856
diff
changeset
|
880 if (pr->child) pr->child->prev = row; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
881 row->next = pr->child; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
882 pr->child = row; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
883 row->parent = pr; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
884 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
885 position = g_list_index(tree->list, parent); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
886 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
887 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
888 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
889 if (pr == NULL) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
890 { |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
891 GntTreeRow *r = tree->root; |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
892 row->next = r; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
893 if (r) r->prev = row; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
894 tree->root = row; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
895 tree->list = g_list_prepend(tree->list, key); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
896 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
897 else |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
898 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
899 tree->list = g_list_insert(tree->list, key, position + 1); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
900 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
901 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
902 |
13858
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
903 row->key = key; |
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
904 row->data = NULL; |
aa1c97f5e6eb
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13857
diff
changeset
|
905 |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
906 redraw_tree(tree); |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
907 |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
908 return row; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
909 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
910 |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
911 GntTreeRow *gnt_tree_add_row_last(GntTree *tree, void *key, GntTreeRow *row, void *parent) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
912 { |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
913 GntTreeRow *pr = NULL, *br = NULL; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
914 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
915 if (parent) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
916 pr = g_hash_table_lookup(tree->hash, parent); |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
917 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
918 if (pr) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
919 br = pr->child; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
920 else |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
921 br = tree->root; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
922 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
923 if (br) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
924 { |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
925 while (br->next) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
926 br = br->next; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
927 } |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
928 |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
929 return gnt_tree_add_row_after(tree, key, row, parent, br ? br->key : NULL); |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
930 } |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
931 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
932 gpointer gnt_tree_get_selection_data(GntTree *tree) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
933 { |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
934 if (tree->current) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
935 return tree->current->key; /* XXX: perhaps we should just get rid of 'data' */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
936 return NULL; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
937 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
938 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
939 char *gnt_tree_get_selection_text(GntTree *tree) |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13934
diff
changeset
|
940 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13934
diff
changeset
|
941 if (tree->current) |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
942 return update_row_text(tree, tree->current); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13934
diff
changeset
|
943 return NULL; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13934
diff
changeset
|
944 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13934
diff
changeset
|
945 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
946 GList *gnt_tree_get_selection_text_list(GntTree *tree) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
947 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
948 GList *list = NULL, *iter; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
949 int i; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
950 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
951 if (!tree->current) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
952 return NULL; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
953 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
954 for (i = 0, iter = tree->current->columns; i < tree->ncol && iter; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
955 i++, iter = iter->next) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
956 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
957 GntTreeCol *col = iter->data; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
958 list = g_list_append(list, g_strdup(col->text)); |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
959 } |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
960 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
961 return list; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
962 } |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
963 |
13857
d341b5ac1a78
[gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13856
diff
changeset
|
964 /* XXX: Should this also remove all the children of the row being removed? */ |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
965 void gnt_tree_remove(GntTree *tree, gpointer key) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
966 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
967 GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
968 if (row) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
969 { |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
970 gboolean redraw = FALSE; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
971 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
972 if (get_distance(tree->top, row) >= 0 && get_distance(row, tree->bottom) >= 0) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
973 redraw = TRUE; |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
974 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
975 /* Update root/top/current/bottom if necessary */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
976 if (tree->root == row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
977 tree->root = get_next(row); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
978 if (tree->top == row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
979 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
980 if (tree->top != tree->root) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
981 tree->top = get_prev(row); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
982 else |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
983 tree->top = get_next(row); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
984 if (tree->current == row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
985 tree->current = tree->top; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
986 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
987 else if (tree->current == row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
988 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
989 if (tree->current != tree->root) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
990 tree->current = get_prev(row); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
991 else |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
992 tree->current = get_next(row); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
993 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
994 else if (tree->bottom == row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
995 { |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
996 tree->bottom = get_prev(row); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
997 } |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
998 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
999 /* Fix the links */ |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1000 if (row->next) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1001 row->next->prev = row->prev; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1002 if (row->parent && row->parent->child == row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1003 row->parent->child = row->next; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1004 if (row->prev) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1005 row->prev->next = row->next; |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1006 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1007 g_hash_table_remove(tree->hash, key); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1008 tree->list = g_list_remove(tree->list, key); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1009 |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1010 if (redraw) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1011 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1012 redraw_tree(tree); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1013 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1014 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1015 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1016 |
14208
7d708210e317
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14131
diff
changeset
|
1017 static gboolean |
7d708210e317
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14131
diff
changeset
|
1018 return_true(gpointer key, gpointer data, gpointer null) |
7d708210e317
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14131
diff
changeset
|
1019 { |
7d708210e317
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14131
diff
changeset
|
1020 return TRUE; |
7d708210e317
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14131
diff
changeset
|
1021 } |
7d708210e317
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14131
diff
changeset
|
1022 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
1023 void gnt_tree_remove_all(GntTree *tree) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
1024 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
1025 tree->root = NULL; |
14208
7d708210e317
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14131
diff
changeset
|
1026 g_hash_table_foreach_remove(tree->hash, (GHRFunc)return_true, NULL); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
1027 g_list_free(tree->list); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
1028 tree->list = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
1029 tree->current = tree->top = tree->bottom = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
1030 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
1031 |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
1032 int gnt_tree_get_selection_visible_line(GntTree *tree) |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
1033 { |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1034 return get_distance(tree->top, tree->current) + |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
1035 !!(GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER)); |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
1036 } |
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13858
diff
changeset
|
1037 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1038 void gnt_tree_change_text(GntTree *tree, gpointer key, int colno, const char *text) |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1039 { |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1040 GntTreeRow *row; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1041 GntTreeCol *col; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1042 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1043 g_return_if_fail(colno < tree->ncol); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1044 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1045 row = g_hash_table_lookup(tree->hash, key); |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1046 if (row) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1047 { |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1048 col = g_list_nth_data(row->columns, colno); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1049 g_free(col->text); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1050 col->text = g_strdup(text); |
13864
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1051 |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1052 if (get_distance(tree->top, row) >= 0 && get_distance(row, tree->bottom) > 0) |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1053 redraw_tree(tree); |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1054 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1055 } |
c7d84d4c5afa
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13861
diff
changeset
|
1056 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1057 GntTreeRow *gnt_tree_add_choice(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro) |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1058 { |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1059 GntTreeRow *r; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1060 r = g_hash_table_lookup(tree->hash, key); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1061 g_return_val_if_fail(!r || !r->choice, NULL); |
14336
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1062 |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1063 if (bigbro == NULL) { |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1064 r = g_hash_table_lookup(tree->hash, parent); |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1065 if (!r) |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1066 r = tree->root; |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1067 else |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1068 r = r->child; |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1069 if (r) { |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1070 while (r->next) |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1071 r = r->next; |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1072 bigbro = r->key; |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1073 } |
f3ef96e8428f
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14216
diff
changeset
|
1074 } |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1075 row = gnt_tree_add_row_after(tree, key, row, parent, bigbro); |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1076 row->choice = TRUE; |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1077 |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1078 return row; |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1079 } |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1080 |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1081 void gnt_tree_set_choice(GntTree *tree, void *key, gboolean set) |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1082 { |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1083 GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1084 |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1085 if (!row) |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1086 return; |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1087 g_return_if_fail(row->choice); |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1088 |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1089 row->isselected = set; |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1090 redraw_tree(tree); |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1091 } |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1092 |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1093 gboolean gnt_tree_get_choice(GntTree *tree, void *key) |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1094 { |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1095 GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1096 |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1097 if (!row) |
13927
9309d27d780c
[gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
1098 return FALSE; |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1099 g_return_val_if_fail(row->choice, FALSE); |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1100 |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1101 return row->isselected; |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1102 } |
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
1103 |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
1104 void gnt_tree_set_row_flags(GntTree *tree, void *key, GntTextFormatFlags flags) |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
1105 { |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
1106 GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
13934
ef0d515b9f97
[gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13931
diff
changeset
|
1107 if (!row || row->flags == flags) |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
1108 return; |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
1109 |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
1110 row->flags = flags; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13934
diff
changeset
|
1111 redraw_tree(tree); /* XXX: It shouldn't be necessary to redraw the whole darned tree */ |
13931
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
1112 } |
917a71dd02eb
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
1113 |
13952
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1114 void gnt_tree_set_selected(GntTree *tree , void *key) |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1115 { |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1116 int dist; |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1117 GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1118 if (!row) |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1119 return; |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1120 |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1121 if (tree->top == NULL) |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1122 tree->top = row; |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1123 if (tree->bottom == NULL) |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1124 tree->bottom = row; |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1125 |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1126 tree->current = row; |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1127 if ((dist = get_distance(tree->current, tree->bottom)) < 0) |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1128 gnt_tree_scroll(tree, -dist); |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1129 else if ((dist = get_distance(tree->current, tree->top)) > 0) |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1130 gnt_tree_scroll(tree, -dist); |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1131 else |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1132 redraw_tree(tree); |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1133 } |
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
1134 |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1135 void _gnt_tree_init_internals(GntTree *tree, int col) |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1136 { |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1137 tree->ncol = col; |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1138 tree->hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_tree_row); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1139 tree->columns = g_new0(struct _GntTreeColInfo, col); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1140 while (col--) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1141 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1142 tree->columns[col].width = 15; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1143 } |
14616
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1144 tree->list = NULL; |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1145 tree->show_title = FALSE; |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1146 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1147 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1148 GntWidget *gnt_tree_new_with_columns(int col) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1149 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1150 GntWidget *widget = g_object_new(GNT_TYPE_TREE, NULL); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1151 GntTree *tree = GNT_TREE(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1152 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1153 _gnt_tree_init_internals(tree, col); |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1154 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1155 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1156 gnt_widget_set_take_focus(widget, TRUE); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1157 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1158 return widget; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1159 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1160 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1161 GntTreeRow *gnt_tree_create_row_from_list(GntTree *tree, GList *list) |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1162 { |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1163 GList *iter; |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1164 int i; |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1165 GntTreeRow *row = g_new0(GntTreeRow, 1); |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1166 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1167 for (i = 0, iter = list; i < tree->ncol && iter; iter = iter->next, i++) |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1168 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1169 GntTreeCol *col = g_new0(GntTreeCol, 1); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1170 col->span = 1; |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1171 col->text = g_strdup(iter->data); |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1172 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1173 row->columns = g_list_append(row->columns, col); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1174 } |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1175 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1176 return row; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1177 } |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1178 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1179 GntTreeRow *gnt_tree_create_row(GntTree *tree, ...) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1180 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1181 int i; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1182 va_list args; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1183 GList *list = NULL; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1184 GntTreeRow *row; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1185 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1186 va_start(args, tree); |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1187 for (i = 0; i < tree->ncol; i++) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1188 { |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
1189 list = g_list_append(list, va_arg(args, char *)); |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1190 } |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1191 va_end(args); |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1192 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1193 row = gnt_tree_create_row_from_list(tree, list); |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1194 g_list_free(list); |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13971
diff
changeset
|
1195 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1196 return row; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1197 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1198 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1199 void gnt_tree_set_col_width(GntTree *tree, int col, int width) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1200 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1201 g_return_if_fail(col < tree->ncol); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1202 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1203 tree->columns[col].width = width; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1204 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
1205 |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1206 void gnt_tree_set_column_titles(GntTree *tree, ...) |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1207 { |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1208 int i; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1209 va_list args; |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1210 |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1211 va_start(args, tree); |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1212 for (i = 0; i < tree->ncol; i++) |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1213 { |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1214 const char *title = va_arg(args, const char *); |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1215 tree->columns[i].title = g_strdup(title); |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1216 } |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1217 va_end(args); |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1218 } |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1219 |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1220 void gnt_tree_set_show_title(GntTree *tree, gboolean set) |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1221 { |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1222 tree->show_title = set; |
14123
f8ab496671fa
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14107
diff
changeset
|
1223 GNT_WIDGET(tree)->priv.minh = (set ? 6 : 4); |
13971
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1224 } |
df8183b7fa2c
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
1225 |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
1226 void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func) |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
1227 { |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
1228 tree->compare = func; |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
1229 } |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
1230 |
14384
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
1231 void gnt_tree_set_expanded(GntTree *tree, void *key, gboolean expanded) |
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
1232 { |
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
1233 GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
1234 if (row) { |
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
1235 row->collapsed = !expanded; |
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
1236 if (GNT_WIDGET(tree)->window) |
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
1237 gnt_widget_draw(GNT_WIDGET(tree)); |
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
1238 } |
4a901f5d1312
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14379
diff
changeset
|
1239 } |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1240 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1241 void gnt_tree_set_show_separator(GntTree *tree, gboolean set) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1242 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1243 tree->show_separator = set; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1244 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
1245 |
14616
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1246 void gnt_tree_adjust_columns(GntTree *tree) |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1247 { |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1248 GntTreeRow *row = tree->root; |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1249 int *widths, i, twidth, height; |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1250 |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1251 widths = g_new0(int, tree->ncol); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1252 while (row) { |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1253 GList *iter; |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1254 for (i = 0, iter = row->columns; iter; iter = iter->next, i++) { |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1255 GntTreeCol *col = iter->data; |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1256 int w = gnt_util_onscreen_width(col->text, NULL); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1257 if (widths[i] < w) |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1258 widths[i] = w; |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1259 } |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1260 row = row->next; |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1261 } |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1262 |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1263 twidth = 1 + 2 * (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER)); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1264 for (i = 0; i < tree->ncol; i++) { |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1265 gnt_tree_set_col_width(tree, i, widths[i]); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1266 twidth += widths[i] + (tree->show_separator ? 1 : 0) + 1; |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1267 fprintf(stderr, "column width for col %d: %d\n", i, widths[i]); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1268 } |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1269 g_free(widths); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1270 |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1271 fprintf(stderr, "tree width: %d\n", twidth); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1272 gnt_widget_get_size(GNT_WIDGET(tree), NULL, &height); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1273 gnt_widget_set_size(GNT_WIDGET(tree), twidth, height); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1274 } |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
1275 |