Tue, 22 Apr 2014 13:18:02 +0530
Merged default branch
|
35456
821aa4bcb6fa
Fix a bunch of gtk-doc warnings in finch
Ankit Vani <a@nevitus.org>
parents:
35059
diff
changeset
|
1 | /* |
|
17586
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
2 | * GNT - The GLib Ncurses Toolkit |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
3 | * |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
4 | * GNT is the legal property of its developers, whose names are too numerous |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
6 | * source distribution. |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
7 | * |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
8 | * This library is free software; you can redistribute it and/or modify |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
11 | * (at your option) any later version. |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
12 | * |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
16 | * GNU General Public License for more details. |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
17 | * |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19551
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
17586
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
21 | */ |
|
5beb8d987e84
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
16646
diff
changeset
|
22 | |
|
28937
5f87e66597d9
Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28822
diff
changeset
|
23 | #include "gntinternal.h" |
|
14898
107b971b39f2
[gaim-migrate @ 17605]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14886
diff
changeset
|
24 | #include "gntmarshal.h" |
|
107b971b39f2
[gaim-migrate @ 17605]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14886
diff
changeset
|
25 | #include "gntstyle.h" |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
26 | #include "gnttree.h" |
|
14678
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
27 | #include "gntutils.h" |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
28 | |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
29 | #include <string.h> |
| 14277 | 30 | #include <ctype.h> |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
31 | |
|
26651
d9f1eeefb89c
Save the world.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26650
diff
changeset
|
32 | #define SEARCH_TIMEOUT_S 4 /* 4 secs */ |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
33 | #define SEARCHING(tree) (tree->priv->search && tree->priv->search->len > 0) |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
34 | |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
35 | #define COLUMN_INVISIBLE(tree, index) (tree->columns[index].flags & GNT_TREE_COLUMN_INVISIBLE) |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
36 | #define BINARY_DATA(tree, index) (tree->columns[index].flags & GNT_TREE_COLUMN_BINARY_DATA) |
|
18632
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
37 | #define RIGHT_ALIGNED(tree, index) (tree->columns[index].flags & GNT_TREE_COLUMN_RIGHT_ALIGNED) |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
38 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
39 | enum |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
40 | { |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
41 | PROP_0, |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
42 | PROP_COLUMNS, |
|
22311
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
43 | PROP_EXPANDER, |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
44 | }; |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
45 | |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
46 | enum |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
47 | { |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
48 | SIG_SELECTION_CHANGED, |
|
13927
c2f57a00bc1f
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13926
diff
changeset
|
49 | SIG_SCROLLED, |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
50 | SIG_TOGGLED, |
|
16165
24ec117bc52c
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
16032
diff
changeset
|
51 | SIG_COLLAPSED, |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
52 | SIGS, |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
53 | }; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
54 | |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
55 | struct _GntTreePriv |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
56 | { |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
57 | GString *search; |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
58 | int search_timeout; |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
59 | int search_column; |
|
18829
35138e0fbf77
Patch from Javeed Shaikh to make the search function non-braindamaged.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18827
diff
changeset
|
60 | gboolean (*search_func)(GntTree *tree, gpointer key, const char *search, const char *current); |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
61 | |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
62 | GCompareFunc compare; |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
63 | int lastvisible; |
|
22311
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
64 | int expander_level; |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
65 | }; |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
66 | |
|
13920
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
67 | #define TAB_SIZE 3 |
|
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
68 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
69 | /* XXX: Make this one into a GObject? |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
70 | * ... Probably not */ |
|
15991
1efb6bd8ba3f
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15886
diff
changeset
|
71 | struct _GntTreeRow |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
72 | { |
|
35596
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
73 | int box_count; |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
74 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
75 | void *key; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
76 | void *data; /* XXX: unused */ |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
77 | |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
78 | gboolean collapsed; |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
79 | gboolean choice; /* Is this a choice-box? |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
80 | If choice is true, then child will be NULL */ |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
81 | gboolean isselected; |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
82 | GntTextFormatFlags flags; |
|
21804
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
83 | int color; |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
84 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
85 | GntTreeRow *parent; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
86 | GntTreeRow *child; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
87 | GntTreeRow *next; |
|
13919
94caf5dc02b4
[gaim-migrate @ 16316]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13918
diff
changeset
|
88 | GntTreeRow *prev; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
89 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
90 | GList *columns; |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
91 | GntTree *tree; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
92 | }; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
93 | |
|
15991
1efb6bd8ba3f
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15886
diff
changeset
|
94 | struct _GntTreeCol |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
95 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
96 | char *text; |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
97 | gboolean isbinary; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
98 | int span; /* How many columns does it span? */ |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
99 | }; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
100 | |
|
16264
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16185
diff
changeset
|
101 | static void tree_selection_changed(GntTree *, GntTreeRow *, GntTreeRow *); |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
102 | static void _gnt_tree_init_internals(GntTree *tree, int col); |
|
16264
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16185
diff
changeset
|
103 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
104 | static GntWidgetClass *parent_class = NULL; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
105 | static guint signals[SIGS] = { 0 }; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
106 | |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
107 | static void |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
108 | readjust_columns(GntTree *tree) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
109 | { |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
110 | int i, col, total; |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
111 | int width; |
|
18559
d39d742f54bd
Parentheses helps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18558
diff
changeset
|
112 | #define WIDTH(i) (tree->columns[i].width_ratio ? tree->columns[i].width_ratio : tree->columns[i].width) |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
113 | gnt_widget_get_size(GNT_WIDGET(tree), &width, NULL); |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
114 | if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER)) |
|
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
115 | width -= 2; |
|
23485
8733da333c8f
Fix an off-by-one bug in calculating column widths in trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23221
diff
changeset
|
116 | width -= 1; /* Exclude the scrollbar from the calculation */ |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
117 | for (i = 0, total = 0; i < tree->ncol ; i++) { |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
118 | if (tree->columns[i].flags & GNT_TREE_COLUMN_INVISIBLE) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
119 | continue; |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
120 | if (tree->columns[i].flags & GNT_TREE_COLUMN_FIXED_SIZE) |
|
23485
8733da333c8f
Fix an off-by-one bug in calculating column widths in trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23221
diff
changeset
|
121 | width -= WIDTH(i) + (tree->priv->lastvisible != i); |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
122 | else |
|
23485
8733da333c8f
Fix an off-by-one bug in calculating column widths in trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23221
diff
changeset
|
123 | total += WIDTH(i) + (tree->priv->lastvisible != i); |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
124 | } |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
125 | |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
126 | if (total == 0) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
127 | return; |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
128 | |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
129 | for (i = 0; i < tree->ncol; i++) { |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
130 | if (tree->columns[i].flags & GNT_TREE_COLUMN_INVISIBLE) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
131 | continue; |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
132 | if (tree->columns[i].flags & GNT_TREE_COLUMN_FIXED_SIZE) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
133 | col = WIDTH(i); |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
134 | else |
|
18559
d39d742f54bd
Parentheses helps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18558
diff
changeset
|
135 | col = (WIDTH(i) * width) / total; |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
136 | gnt_tree_set_col_width(GNT_TREE(tree), i, col); |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
137 | } |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
138 | } |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
139 | |
| 14774 | 140 | /* Move the item at position old to position new */ |
| 141 | static GList * | |
| 142 | g_list_reposition_child(GList *list, int old, int new) | |
| 143 | { | |
| 144 | gpointer item = g_list_nth_data(list, old); | |
| 145 | list = g_list_remove(list, item); | |
| 146 | if (old < new) | |
| 147 | new--; /* because the positions would have shifted after removing the item */ | |
| 148 | list = g_list_insert(list, item, new); | |
| 149 | return list; | |
| 150 | } | |
| 151 | ||
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
152 | static GntTreeRow * |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
153 | _get_next(GntTreeRow *row, gboolean godeep) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
154 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
155 | if (row == NULL) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
156 | return NULL; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
157 | if (godeep && row->child) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
158 | return row->child; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
159 | if (row->next) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
160 | return row->next; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
161 | return _get_next(row->parent, FALSE); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
162 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
163 | |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
164 | static gboolean |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
165 | row_matches_search(GntTreeRow *row) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
166 | { |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
167 | GntTree *t = row->tree; |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
168 | if (t->priv->search && t->priv->search->len > 0) { |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
169 | GntTreeCol *col = (col = g_list_nth_data(row->columns, t->priv->search_column)) ? col : row->columns->data; |
|
18827
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
170 | char *one, *two, *z; |
|
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
171 | if (t->priv->search_func) |
|
18829
35138e0fbf77
Patch from Javeed Shaikh to make the search function non-braindamaged.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18827
diff
changeset
|
172 | return t->priv->search_func(t, row->key, t->priv->search->str, col->text); |
|
18827
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
173 | one = g_utf8_casefold(col->text, -1); |
|
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
174 | two = g_utf8_casefold(t->priv->search->str, -1); |
|
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
175 | z = strstr(one, two); |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
176 | g_free(one); |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
177 | g_free(two); |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
178 | if (z == NULL) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
179 | return FALSE; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
180 | } |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
181 | return TRUE; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
182 | } |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
183 | |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
184 | static GntTreeRow * |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
185 | get_next(GntTreeRow *row) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
186 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
187 | if (row == NULL) |
|
13950
bd8d39b3a9e2
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13944
diff
changeset
|
188 | return NULL; |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
189 | while ((row = _get_next(row, !row->collapsed)) != NULL) { |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
190 | if (row_matches_search(row)) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
191 | break; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
192 | } |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
193 | return row; |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
194 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
195 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
196 | /* Returns the n-th next row. If it doesn't exist, returns NULL */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
197 | static GntTreeRow * |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
198 | get_next_n(GntTreeRow *row, int n) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
199 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
200 | while (row && n--) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
201 | row = get_next(row); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
202 | return row; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
203 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
204 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
205 | /* Returns the n-th next row. If it doesn't exist, then the last non-NULL node */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
206 | static GntTreeRow * |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
207 | get_next_n_opt(GntTreeRow *row, int n, int *pos) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
208 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
209 | GntTreeRow *next = row; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
210 | int r = 0; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
211 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
212 | if (row == NULL) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
213 | return NULL; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
214 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
215 | while (row && n--) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
216 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
217 | row = get_next(row); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
218 | if (row) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
219 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
220 | next = row; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
221 | r++; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
222 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
223 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
224 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
225 | if (pos) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
226 | *pos = r; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
227 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
228 | return next; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
229 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
230 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
231 | static GntTreeRow * |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
232 | get_last_child(GntTreeRow *row) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
233 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
234 | if (row == NULL) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
235 | return NULL; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
236 | if (!row->collapsed && row->child) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
237 | row = row->child; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
238 | else |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
239 | return row; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
240 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
241 | while(row->next) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
242 | row = row->next; |
|
16646
fd3c9b8de3e2
Fix an odd selection issue when moving up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16362
diff
changeset
|
243 | return get_last_child(row); |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
244 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
245 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
246 | static GntTreeRow * |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
247 | get_prev(GntTreeRow *row) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
248 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
249 | if (row == NULL) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
250 | return NULL; |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
251 | while (row) { |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
252 | if (row->prev) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
253 | row = get_last_child(row->prev); |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
254 | else |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
255 | row = row->parent; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
256 | if (!row || row_matches_search(row)) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
257 | break; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
258 | } |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
259 | return row; |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
260 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
261 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
262 | static GntTreeRow * |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
263 | get_prev_n(GntTreeRow *row, int n) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
264 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
265 | while (row && n--) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
266 | row = get_prev(row); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
267 | return row; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
268 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
269 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
270 | /* Distance of row from the root */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
271 | /* XXX: This is uber-inefficient */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
272 | static int |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
273 | get_root_distance(GntTreeRow *row) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
274 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
275 | if (row == NULL) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
276 | return -1; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
277 | return get_root_distance(get_prev(row)) + 1; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
278 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
279 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30499
diff
changeset
|
280 | /* Returns the distance between a and b. |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
281 | * If a is 'above' b, then the distance is positive */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
282 | static int |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
283 | get_distance(GntTreeRow *a, GntTreeRow *b) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
284 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
285 | /* First get the distance from a to the root. |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
286 | * Then the distance from b to the root. |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
287 | * Subtract. |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
288 | * It's not that good, but it works. */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
289 | int ha = get_root_distance(a); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
290 | int hb = get_root_distance(b); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
291 | |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
292 | return (hb - ha); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
293 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
294 | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
295 | static int |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
296 | find_depth(GntTreeRow *row) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
297 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
298 | int dep = -1; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
299 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
300 | while (row) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
301 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
302 | dep++; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
303 | row = row->parent; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
304 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
305 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
306 | return dep; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
307 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
308 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
309 | static char * |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
310 | update_row_text(GntTree *tree, GntTreeRow *row) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
311 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
312 | GString *string = g_string_new(NULL); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
313 | GList *iter; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
314 | int i; |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
315 | gboolean notfirst = FALSE; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
316 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
317 | for (i = 0, iter = row->columns; i < tree->ncol && iter; i++, iter = iter->next) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
318 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
319 | GntTreeCol *col = iter->data; |
|
14886
9f76d3a61aa7
[gaim-migrate @ 17591]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14885
diff
changeset
|
320 | const char *text; |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
321 | int len; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
322 | int fl = 0; |
| 14908 | 323 | gboolean cut = FALSE; |
|
16031
7ca3d73eab52
Fine tune column hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16030
diff
changeset
|
324 | int width; |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
325 | const char *display; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
326 | |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
327 | if (COLUMN_INVISIBLE(tree, i)) |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
328 | continue; |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
329 | |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
330 | if (BINARY_DATA(tree, i)) |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
331 | display = ""; |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
332 | else |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
333 | display = col->text; |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
334 | |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
335 | len = gnt_util_onscreen_width(display, NULL); |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
336 | |
|
18632
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
337 | width = tree->columns[i].width; |
|
16031
7ca3d73eab52
Fine tune column hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16030
diff
changeset
|
338 | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
339 | if (i == 0) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
340 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
341 | if (row->choice) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
342 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
343 | g_string_append_printf(string, "[%c] ", |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
344 | row->isselected ? 'X' : ' '); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
345 | fl = 4; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
346 | } |
|
22311
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
347 | else if (find_depth(row) < tree->priv->expander_level && row->child) |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
348 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
349 | if (row->collapsed) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
350 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
351 | string = g_string_append(string, "+ "); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
352 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
353 | else |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
354 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
355 | string = g_string_append(string, "- "); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
356 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
357 | fl = 2; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
358 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
359 | else |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
360 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
361 | fl = TAB_SIZE * find_depth(row); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
362 | g_string_append_printf(string, "%*s", fl, ""); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
363 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
364 | len += fl; |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
365 | } else if (notfirst && tree->show_separator) |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
366 | g_string_append_c(string, '|'); |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
367 | else |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
368 | g_string_append_c(string, ' '); |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
369 | |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
370 | notfirst = TRUE; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
371 | |
|
18255
f29124ab560e
I think this fixes the ellipsization in the trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18190
diff
changeset
|
372 | if (len > width) { |
|
21263
0919212f5a8c
Do not ellipsize in a column of size 1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21262
diff
changeset
|
373 | len = MAX(1, width - 1); |
| 14908 | 374 | cut = TRUE; |
| 375 | } | |
|
18632
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
376 | |
|
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
377 | if (RIGHT_ALIGNED(tree, i) && len < tree->columns[i].width) { |
|
21262
b1635191fe14
Patch from Josh Davis to correct ellipsization for right-aligned columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21261
diff
changeset
|
378 | g_string_append_printf(string, "%*s", width - len - cut, ""); |
|
18632
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
379 | } |
|
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
380 | |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
381 | text = gnt_util_onscreen_width_to_pointer(display, len - fl, NULL); |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
382 | string = g_string_append_len(string, display, text - display); |
|
21263
0919212f5a8c
Do not ellipsize in a column of size 1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21262
diff
changeset
|
383 | if (cut && width > 1) { /* ellipsis */ |
| 14908 | 384 | if (gnt_ascii_only()) |
| 385 | g_string_append_c(string, '~'); | |
| 386 | else | |
| 387 | string = g_string_append(string, "\342\200\246"); | |
| 388 | len++; | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
389 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
390 | |
|
18632
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
391 | if (!RIGHT_ALIGNED(tree, i) && len < tree->columns[i].width && iter->next) |
|
16031
7ca3d73eab52
Fine tune column hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16030
diff
changeset
|
392 | g_string_append_printf(string, "%*s", width - len, ""); |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
393 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
394 | return g_string_free(string, FALSE); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
395 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
396 | |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
397 | #define NEXT_X x += tree->columns[i].width + (i > 0 ? 1 : 0) |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
398 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
399 | static void |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
400 | tree_mark_columns(GntTree *tree, int pos, int y, chtype type) |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
401 | { |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
402 | GntWidget *widget = GNT_WIDGET(tree); |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
403 | int i; |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
404 | int x = pos; |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
405 | gboolean notfirst = FALSE; |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
406 | |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
407 | for (i = 0; i < tree->ncol - 1; i++) |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
408 | { |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
409 | if (!COLUMN_INVISIBLE(tree, i)) { |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
410 | notfirst = TRUE; |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
411 | NEXT_X; |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
412 | } |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
413 | if (!COLUMN_INVISIBLE(tree, i+1) && notfirst) |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
414 | mvwaddch(widget->window, y, x, type); |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
415 | } |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
416 | } |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
417 | |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
418 | static void |
|
13915
15a38b312abe
[gaim-migrate @ 16312]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13913
diff
changeset
|
419 | redraw_tree(GntTree *tree) |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
420 | { |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
421 | int start, i; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
422 | GntWidget *widget = GNT_WIDGET(tree); |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
423 | GntTreeRow *row; |
|
18793
30a5e011f4b3
Fix compile warnings that only shows up with -O3. This may have caused
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18787
diff
changeset
|
424 | int pos, up, down = 0; |
|
14193
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
425 | int rows, scrcol; |
|
26650
cfa29f8cf9b7
Update hardware cursor correctly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25351
diff
changeset
|
426 | int current = 0; |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
427 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
428 | if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED)) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
429 | return; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
430 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
431 | if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
432 | pos = 0; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
433 | else |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
434 | pos = 1; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
435 | |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
436 | if (tree->top == NULL) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
437 | tree->top = tree->root; |
|
26734
509686762673
- Don't bother changing/signalling the selected row from NULL to NULL
Richard Nelson <wabz@pidgin.im>
parents:
26651
diff
changeset
|
438 | if (tree->current == NULL && tree->root != NULL) { |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
439 | tree->current = tree->root; |
|
16264
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16185
diff
changeset
|
440 | tree_selection_changed(tree, NULL, tree->current); |
|
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16185
diff
changeset
|
441 | } |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
442 | |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
443 | wbkgd(widget->window, gnt_color_pair(GNT_COLOR_NORMAL)); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
444 | |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
445 | start = 0; |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
446 | if (tree->show_title) |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
447 | { |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
448 | int i; |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
449 | int x = pos; |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
450 | |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
451 | mvwhline(widget->window, pos + 1, pos, ACS_HLINE | gnt_color_pair(GNT_COLOR_NORMAL), |
|
14188
cff503f91616
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14185
diff
changeset
|
452 | widget->priv.width - pos - 1); |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
453 | mvwhline(widget->window, pos, pos, ' ' | gnt_color_pair(GNT_COLOR_NORMAL), |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
454 | widget->priv.width - pos - 1); |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
455 | |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
456 | for (i = 0; i < tree->ncol; i++) |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
457 | { |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
458 | if (COLUMN_INVISIBLE(tree, i)) { |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
459 | continue; |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
460 | } |
|
19190
d0b7bf1b250a
Make sure long titles remain within their own cell.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19184
diff
changeset
|
461 | mvwaddnstr(widget->window, pos, x + (x != pos), tree->columns[i].title, tree->columns[i].width); |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
462 | NEXT_X; |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
463 | } |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
464 | if (pos) |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
465 | { |
|
21254
ab6e08037b7c
Draw the 'header' correctly when not showing borders.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21244
diff
changeset
|
466 | tree_mark_columns(tree, pos, 0, |
|
ab6e08037b7c
Draw the 'header' correctly when not showing borders.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21244
diff
changeset
|
467 | (tree->show_separator ? ACS_TTEE : ACS_HLINE) | gnt_color_pair(GNT_COLOR_NORMAL)); |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
468 | tree_mark_columns(tree, pos, widget->priv.height - pos, |
|
21254
ab6e08037b7c
Draw the 'header' correctly when not showing borders.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21244
diff
changeset
|
469 | (tree->show_separator ? ACS_BTEE : ACS_HLINE) | gnt_color_pair(GNT_COLOR_NORMAL)); |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
470 | } |
|
14675
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
471 | tree_mark_columns(tree, pos, pos + 1, |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
472 | (tree->show_separator ? ACS_PLUS : ACS_HLINE) | gnt_color_pair(GNT_COLOR_NORMAL)); |
|
14675
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
473 | tree_mark_columns(tree, pos, pos, |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
474 | (tree->show_separator ? ACS_VLINE : ' ') | gnt_color_pair(GNT_COLOR_NORMAL)); |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
475 | start = 2; |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
476 | } |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
477 | |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
478 | rows = widget->priv.height - pos * 2 - start - 1; |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
479 | tree->bottom = get_next_n_opt(tree->top, rows, &down); |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
480 | if (down < rows) |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
481 | { |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
482 | tree->top = get_prev_n(tree->bottom, rows); |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
483 | if (tree->top == NULL) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
484 | tree->top = tree->root; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
485 | } |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
486 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
487 | up = get_distance(tree->top, tree->current); |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
488 | if (up < 0) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
489 | tree->top = tree->current; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
490 | else if (up >= widget->priv.height - pos) |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
491 | tree->top = get_prev_n(tree->current, rows); |
|
14169
90d1d4697e23
[gaim-migrate @ 16741]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
492 | |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
493 | if (tree->top && !row_matches_search(tree->top)) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
494 | tree->top = get_next(tree->top); |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
495 | row = tree->top; |
|
14886
9f76d3a61aa7
[gaim-migrate @ 17591]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14885
diff
changeset
|
496 | scrcol = widget->priv.width - 1 - 2 * pos; /* exclude the borders and the scrollbar */ |
|
26734
509686762673
- Don't bother changing/signalling the selected row from NULL to NULL
Richard Nelson <wabz@pidgin.im>
parents:
26651
diff
changeset
|
497 | |
|
509686762673
- Don't bother changing/signalling the selected row from NULL to NULL
Richard Nelson <wabz@pidgin.im>
parents:
26651
diff
changeset
|
498 | if (tree->current && !row_matches_search(tree->current)) { |
|
509686762673
- Don't bother changing/signalling the selected row from NULL to NULL
Richard Nelson <wabz@pidgin.im>
parents:
26651
diff
changeset
|
499 | GntTreeRow *old = tree->current; |
|
509686762673
- Don't bother changing/signalling the selected row from NULL to NULL
Richard Nelson <wabz@pidgin.im>
parents:
26651
diff
changeset
|
500 | tree->current = tree->top; |
|
509686762673
- Don't bother changing/signalling the selected row from NULL to NULL
Richard Nelson <wabz@pidgin.im>
parents:
26651
diff
changeset
|
501 | tree_selection_changed(tree, old, tree->current); |
|
509686762673
- Don't bother changing/signalling the selected row from NULL to NULL
Richard Nelson <wabz@pidgin.im>
parents:
26651
diff
changeset
|
502 | } |
|
509686762673
- Don't bother changing/signalling the selected row from NULL to NULL
Richard Nelson <wabz@pidgin.im>
parents:
26651
diff
changeset
|
503 | |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
504 | for (i = start + pos; row && i < widget->priv.height - pos; |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
505 | i++, row = get_next(row)) |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
506 | { |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
507 | char *str; |
|
13915
15a38b312abe
[gaim-migrate @ 16312]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13913
diff
changeset
|
508 | int wr; |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
509 | |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
510 | GntTextFormatFlags flags = row->flags; |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
511 | int attr = 0; |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
512 | |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
513 | if (!row_matches_search(row)) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
514 | continue; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
515 | str = update_row_text(tree, row); |
|
13998
680eb6d0ed40
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13997
diff
changeset
|
516 | |
|
14886
9f76d3a61aa7
[gaim-migrate @ 17591]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14885
diff
changeset
|
517 | if ((wr = gnt_util_onscreen_width(str, NULL)) > scrcol) |
|
13913
14dc0af2b33f
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13852
diff
changeset
|
518 | { |
|
14886
9f76d3a61aa7
[gaim-migrate @ 17591]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14885
diff
changeset
|
519 | char *s = (char*)gnt_util_onscreen_width_to_pointer(str, scrcol, &wr); |
|
13998
680eb6d0ed40
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13997
diff
changeset
|
520 | *s = '\0'; |
|
13913
14dc0af2b33f
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13852
diff
changeset
|
521 | } |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
522 | |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
523 | if (flags & GNT_TEXT_FLAG_BOLD) |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
524 | attr |= A_BOLD; |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
525 | if (flags & GNT_TEXT_FLAG_UNDERLINE) |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
526 | attr |= A_UNDERLINE; |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
527 | if (flags & GNT_TEXT_FLAG_BLINK) |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
528 | attr |= A_BLINK; |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
529 | |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
530 | if (row == tree->current) |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
531 | { |
|
26650
cfa29f8cf9b7
Update hardware cursor correctly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25351
diff
changeset
|
532 | current = i; |
|
25351
6a90d6dd2963
Boldify the selected row in the tree. This is helpful when, for example,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23485
diff
changeset
|
533 | attr |= A_BOLD; |
|
13958
bd1c3bb3f33d
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13950
diff
changeset
|
534 | if (gnt_widget_has_focus(widget)) |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
535 | attr |= gnt_color_pair(GNT_COLOR_HIGHLIGHT); |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
536 | else |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
537 | attr |= gnt_color_pair(GNT_COLOR_HIGHLIGHT_D); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
538 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
539 | else |
|
13989
9a647311c9ac
[gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13969
diff
changeset
|
540 | { |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
541 | if (flags & GNT_TEXT_FLAG_DIM) |
|
21804
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
542 | if (row->color) |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
543 | attr |= (A_DIM | gnt_color_pair(row->color)); |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
544 | else |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
545 | attr |= (A_DIM | gnt_color_pair(GNT_COLOR_DISABLED)); |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
546 | else if (flags & GNT_TEXT_FLAG_HIGHLIGHT) |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
547 | attr |= (A_DIM | gnt_color_pair(GNT_COLOR_HIGHLIGHT)); |
|
21804
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
548 | else if (row->color) |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
549 | attr |= gnt_color_pair(row->color); |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
550 | else |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
551 | attr |= gnt_color_pair(GNT_COLOR_NORMAL); |
|
13989
9a647311c9ac
[gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13969
diff
changeset
|
552 | } |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
553 | |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
554 | wbkgdset(widget->window, '\0' | attr); |
|
28937
5f87e66597d9
Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28822
diff
changeset
|
555 | mvwaddstr(widget->window, i, pos, C_(str)); |
|
14886
9f76d3a61aa7
[gaim-migrate @ 17591]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14885
diff
changeset
|
556 | whline(widget->window, ' ', scrcol - wr); |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
557 | tree->bottom = row; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
558 | g_free(str); |
|
14675
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
559 | tree_mark_columns(tree, pos, i, |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
560 | (tree->show_separator ? ACS_VLINE : ' ') | attr); |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
561 | } |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
562 | |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
563 | wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_NORMAL)); |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
564 | while (i < widget->priv.height - pos) |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
565 | { |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
566 | mvwhline(widget->window, i, pos, ' ', |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
567 | widget->priv.width - pos * 2 - 1); |
|
14675
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
568 | tree_mark_columns(tree, pos, i, |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
569 | (tree->show_separator ? ACS_VLINE : ' ')); |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
570 | i++; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
571 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
572 | |
|
14886
9f76d3a61aa7
[gaim-migrate @ 17591]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14885
diff
changeset
|
573 | scrcol = widget->priv.width - pos - 1; /* position of the scrollbar */ |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
574 | rows--; |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
575 | if (rows > 0) |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
576 | { |
|
18793
30a5e011f4b3
Fix compile warnings that only shows up with -O3. This may have caused
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18787
diff
changeset
|
577 | int total = 0; |
|
14193
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
578 | int showing, position; |
|
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
579 | |
|
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
580 | get_next_n_opt(tree->root, g_list_length(tree->list), &total); |
|
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
581 | showing = rows * rows / MAX(total, 1) + 1; |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
582 | showing = MIN(rows, showing); |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
583 | |
|
14193
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
584 | total -= rows; |
|
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
585 | up = get_distance(tree->root, tree->top); |
|
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
586 | down = total - up; |
|
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
587 | |
|
fcfd3eea2160
[gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14188
diff
changeset
|
588 | position = (rows - showing) * up / MAX(1, up + down); |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
589 | position = MAX((tree->top != tree->root), position); |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
590 | |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
591 | if (showing + position > rows) |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
592 | position = rows - showing; |
|
14169
90d1d4697e23
[gaim-migrate @ 16741]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
593 | |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
594 | if (showing + position == rows && row) |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
595 | position = MAX(0, rows - 1 - showing); |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
596 | else if (showing + position < rows && !row) |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
597 | position = rows - showing; |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
598 | |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
599 | position += pos + start + 1; |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
600 | |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
601 | mvwvline(widget->window, pos + start + 1, scrcol, |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
602 | ' ' | gnt_color_pair(GNT_COLOR_NORMAL), rows); |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
603 | mvwvline(widget->window, position, scrcol, |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
604 | ACS_CKBOARD | gnt_color_pair(GNT_COLOR_HIGHLIGHT_D), showing); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
605 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
606 | |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
607 | mvwaddch(widget->window, start + pos, scrcol, |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
608 | ((tree->top != tree->root) ? ACS_UARROW : ' ') | |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
609 | gnt_color_pair(GNT_COLOR_HIGHLIGHT_D)); |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
610 | |
|
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
611 | mvwaddch(widget->window, widget->priv.height - pos - 1, scrcol, |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
612 | (row ? ACS_DARROW : ' ') | gnt_color_pair(GNT_COLOR_HIGHLIGHT_D)); |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
613 | |
|
16310
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
614 | /* If there's a search-text, show it in the bottom of the tree */ |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
615 | if (tree->priv->search && tree->priv->search->len > 0) { |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
616 | const char *str = gnt_util_onscreen_width_to_pointer(tree->priv->search->str, scrcol - 1, NULL); |
|
21240
b78eaddaae02
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20198
diff
changeset
|
617 | wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_HIGHLIGHT_D)); |
|
16310
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
618 | mvwaddnstr(widget->window, widget->priv.height - pos - 1, pos, |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
619 | tree->priv->search->str, str - tree->priv->search->str); |
|
16310
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
620 | } |
|
26650
cfa29f8cf9b7
Update hardware cursor correctly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25351
diff
changeset
|
621 | wmove(widget->window, current, pos); |
|
16310
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
622 | |
|
13940
26ed45b11483
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13927
diff
changeset
|
623 | gnt_widget_queue_update(widget); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
624 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
625 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
626 | static void |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
627 | gnt_tree_draw(GntWidget *widget) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
628 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
629 | GntTree *tree = GNT_TREE(widget); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
630 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
631 | redraw_tree(tree); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30499
diff
changeset
|
632 | |
|
14494
3575eac3a518
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14446
diff
changeset
|
633 | GNTDEBUG; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
634 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
635 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
636 | static void |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
637 | gnt_tree_size_request(GntWidget *widget) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
638 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
639 | if (widget->priv.height == 0) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
640 | widget->priv.height = 10; /* XXX: Why?! */ |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
641 | if (widget->priv.width == 0) |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
642 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
643 | GntTree *tree = GNT_TREE(widget); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
644 | int i, width = 0; |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
645 | width = 1 + 2 * (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER)); |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
646 | for (i = 0; i < tree->ncol; i++) |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
647 | if (!COLUMN_INVISIBLE(tree, i)) { |
|
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
648 | width = width + tree->columns[i].width; |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
649 | if (tree->priv->lastvisible != i) |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
650 | width++; |
|
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
651 | } |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
652 | widget->priv.width = width; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
653 | } |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
654 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
655 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
656 | static void |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
657 | gnt_tree_map(GntWidget *widget) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
658 | { |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
659 | GntTree *tree = GNT_TREE(widget); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
660 | if (widget->priv.width == 0 || widget->priv.height == 0) |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
661 | { |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
662 | gnt_widget_size_request(widget); |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
663 | } |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
664 | tree->top = tree->root; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
665 | tree->current = tree->root; |
|
14494
3575eac3a518
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14446
diff
changeset
|
666 | GNTDEBUG; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
667 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
668 | |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
669 | static void |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
670 | tree_selection_changed(GntTree *tree, GntTreeRow *old, GntTreeRow *current) |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
671 | { |
|
15702
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15647
diff
changeset
|
672 | g_signal_emit(tree, signals[SIG_SELECTION_CHANGED], 0, old ? old->key : NULL, |
|
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15647
diff
changeset
|
673 | current ? current->key : NULL); |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
674 | } |
|
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
675 | |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
676 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
677 | action_down(GntBindable *bind, GList *null) |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
678 | { |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
679 | int dist; |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
680 | GntTree *tree = GNT_TREE(bind); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
681 | GntTreeRow *old = tree->current; |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
682 | GntTreeRow *row = get_next(tree->current); |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
683 | if (row == NULL) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
684 | return FALSE; |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
685 | tree->current = row; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
686 | if ((dist = get_distance(tree->current, tree->bottom)) < 0) |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
687 | gnt_tree_scroll(tree, -dist); |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
688 | else |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
689 | redraw_tree(tree); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
690 | if (old != tree->current) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
691 | tree_selection_changed(tree, old, tree->current); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
692 | return TRUE; |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
693 | } |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
694 | |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
695 | static gboolean |
|
16032
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
696 | action_move_parent(GntBindable *bind, GList *null) |
|
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
697 | { |
|
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
698 | GntTree *tree = GNT_TREE(bind); |
|
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
699 | GntTreeRow *row = tree->current; |
|
16310
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
700 | int dist; |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
701 | |
|
22361
1ae443e7fe45
Fix a crash when pressing backspace at a menu
Richard Nelson <wabz@pidgin.im>
parents:
22311
diff
changeset
|
702 | if (!row || !row->parent || SEARCHING(tree)) |
|
16310
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
703 | return FALSE; |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
704 | |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
705 | tree->current = row->parent; |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
706 | if ((dist = get_distance(tree->current, tree->top)) > 0) |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
707 | gnt_tree_scroll(tree, -dist); |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
708 | else |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
709 | redraw_tree(tree); |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
710 | tree_selection_changed(tree, row, tree->current); |
|
16032
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
711 | return TRUE; |
|
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
712 | } |
|
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
713 | |
|
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
714 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
715 | action_up(GntBindable *bind, GList *list) |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
716 | { |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
717 | int dist; |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
718 | GntTree *tree = GNT_TREE(bind); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
719 | GntTreeRow *old = tree->current; |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
720 | GntTreeRow *row = get_prev(tree->current); |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
721 | if (!row) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
722 | return FALSE; |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
723 | tree->current = row; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
724 | if ((dist = get_distance(tree->current, tree->top)) > 0) |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
725 | gnt_tree_scroll(tree, -dist); |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
726 | else |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
727 | redraw_tree(tree); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
728 | if (old != tree->current) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
729 | tree_selection_changed(tree, old, tree->current); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
730 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
731 | return TRUE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
732 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
733 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
734 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
735 | action_page_down(GntBindable *bind, GList *null) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
736 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
737 | GntTree *tree = GNT_TREE(bind); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
738 | GntTreeRow *old = tree->current; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
739 | GntTreeRow *row = get_next(tree->bottom); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
740 | if (row) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
741 | { |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
742 | int dist = get_distance(tree->top, tree->current); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
743 | tree->top = tree->bottom; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
744 | tree->current = get_next_n_opt(tree->top, dist, NULL); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
745 | redraw_tree(tree); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
746 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
747 | else if (tree->current != tree->bottom) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
748 | { |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
749 | tree->current = tree->bottom; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
750 | redraw_tree(tree); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
751 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
752 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
753 | if (old != tree->current) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
754 | tree_selection_changed(tree, old, tree->current); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
755 | return TRUE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
756 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
757 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
758 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
759 | action_page_up(GntBindable *bind, GList *null) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
760 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
761 | GntWidget *widget = GNT_WIDGET(bind); |
|
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
762 | GntTree *tree = GNT_TREE(bind); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
763 | GntTreeRow *row; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
764 | GntTreeRow *old = tree->current; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
765 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
766 | if (tree->top != tree->root) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
767 | { |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
768 | int dist = get_distance(tree->top, tree->current); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
769 | row = get_prev_n(tree->top, widget->priv.height - 1 - |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
770 | tree->show_title * 2 - 2 * (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER) == 0)); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
771 | if (row == NULL) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
772 | row = tree->root; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
773 | tree->top = row; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
774 | tree->current = get_next_n_opt(tree->top, dist, NULL); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
775 | redraw_tree(tree); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
776 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
777 | else if (tree->current != tree->top) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
778 | { |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
779 | tree->current = tree->top; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
780 | redraw_tree(tree); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
781 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
782 | if (old != tree->current) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
783 | tree_selection_changed(tree, old, tree->current); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
784 | return TRUE; |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
785 | } |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
786 | |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
787 | static void |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
788 | end_search(GntTree *tree) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
789 | { |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
790 | if (tree->priv->search) { |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
791 | g_source_remove(tree->priv->search_timeout); |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
792 | g_string_free(tree->priv->search, TRUE); |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
793 | tree->priv->search = NULL; |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
794 | tree->priv->search_timeout = 0; |
|
19184
72003b472bdc
Fix a /-search bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18832
diff
changeset
|
795 | GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(tree), GNT_WIDGET_DISABLE_ACTIONS); |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
796 | } |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
797 | } |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
798 | |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
799 | static gboolean |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
800 | search_timeout(gpointer data) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
801 | { |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
802 | GntTree *tree = data; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
803 | |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
804 | end_search(tree); |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
805 | redraw_tree(tree); |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
806 | |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
807 | return FALSE; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
808 | } |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
809 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
810 | static gboolean |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
811 | gnt_tree_key_pressed(GntWidget *widget, const char *text) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
812 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
813 | GntTree *tree = GNT_TREE(widget); |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
814 | GntTreeRow *old = tree->current; |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
815 | |
|
22421
ccddf3ffaf41
'\n' (ctrl-j) should behave similar to '\r' (ctrl-m). Fixes #4833.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22361
diff
changeset
|
816 | if (text[0] == '\r' || text[0] == '\n') { |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
817 | end_search(tree); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
818 | gnt_widget_activate(widget); |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
819 | } else if (tree->priv->search) { |
|
16310
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
820 | gboolean changed = TRUE; |
|
28822
a4fe79ebdcfe
Allow printable chars when searching the tree
Richard Nelson <wabz@pidgin.im>
parents:
26734
diff
changeset
|
821 | if (g_unichar_isprint(*text)) { |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
822 | tree->priv->search = g_string_append_c(tree->priv->search, *text); |
|
16310
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
823 | } else if (g_utf8_collate(text, GNT_KEY_BACKSPACE) == 0) { |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
824 | if (tree->priv->search->len) |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
825 | tree->priv->search->str[--tree->priv->search->len] = '\0'; |
|
16310
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
826 | } else |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
827 | changed = FALSE; |
|
9883dbf9bab6
Show the search string in the tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16264
diff
changeset
|
828 | if (changed) { |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
829 | redraw_tree(tree); |
|
18832
177a16b4b9f3
Allow disabling the widget actions on specific widgets. This allows, for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18830
diff
changeset
|
830 | } else { |
|
177a16b4b9f3
Allow disabling the widget actions on specific widgets. This allows, for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18830
diff
changeset
|
831 | gnt_bindable_perform_action_key(GNT_BINDABLE(tree), text); |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
832 | } |
|
23221
b63527bd6e1c
Pressing arrow keys should reset the search timer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22421
diff
changeset
|
833 | g_source_remove(tree->priv->search_timeout); |
|
26651
d9f1eeefb89c
Save the world.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26650
diff
changeset
|
834 | tree->priv->search_timeout = g_timeout_add_seconds(SEARCH_TIMEOUT_S, search_timeout, tree); |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
835 | return TRUE; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
836 | } else if (text[0] == ' ' && text[1] == 0) { |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
837 | /* Space pressed */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
838 | GntTreeRow *row = tree->current; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
839 | if (row && row->child) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
840 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
841 | row->collapsed = !row->collapsed; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
842 | redraw_tree(tree); |
|
16165
24ec117bc52c
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
16032
diff
changeset
|
843 | g_signal_emit(tree, signals[SIG_COLLAPSED], 0, row->key, row->collapsed); |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
844 | } |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
845 | else if (row && row->choice) |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
846 | { |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
847 | row->isselected = !row->isselected; |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
848 | g_signal_emit(tree, signals[SIG_TOGGLED], 0, row->key); |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
849 | redraw_tree(tree); |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
850 | } |
|
18171
dd5c73b7a3b8
I am not sure why I made this change. But it looks good.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18132
diff
changeset
|
851 | } else { |
|
dd5c73b7a3b8
I am not sure why I made this change. But it looks good.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18132
diff
changeset
|
852 | return FALSE; |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
853 | } |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
854 | |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
855 | if (old != tree->current) |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
856 | { |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
857 | tree_selection_changed(tree, old, tree->current); |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
858 | } |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
859 | |
|
18171
dd5c73b7a3b8
I am not sure why I made this change. But it looks good.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18132
diff
changeset
|
860 | return TRUE; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
861 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
862 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
863 | static void |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
864 | gnt_tree_free_columns(GntTree *tree) |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
865 | { |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
866 | int i; |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
867 | for (i = 0; i < tree->ncol; i++) { |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
868 | g_free(tree->columns[i].title); |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
869 | } |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
870 | g_free(tree->columns); |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
871 | } |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
872 | |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
873 | static void |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
874 | gnt_tree_destroy(GntWidget *widget) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
875 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
876 | GntTree *tree = GNT_TREE(widget); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
877 | |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
878 | end_search(tree); |
|
15702
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15647
diff
changeset
|
879 | if (tree->hash) |
|
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15647
diff
changeset
|
880 | g_hash_table_destroy(tree->hash); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
881 | g_list_free(tree->list); |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
882 | gnt_tree_free_columns(tree); |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
883 | g_free(tree->priv); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
884 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
885 | |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
886 | static gboolean |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
887 | gnt_tree_clicked(GntWidget *widget, GntMouseEvent event, int x, int y) |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
888 | { |
| 14441 | 889 | GntTree *tree = GNT_TREE(widget); |
| 890 | GntTreeRow *old = tree->current; | |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
891 | if (event == GNT_MOUSE_SCROLL_UP) { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
892 | action_up(GNT_BINDABLE(widget), NULL); |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
893 | } else if (event == GNT_MOUSE_SCROLL_DOWN) { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
894 | action_down(GNT_BINDABLE(widget), NULL); |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
895 | } else if (event == GNT_LEFT_MOUSE_DOWN) { |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
896 | GntTreeRow *row; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
897 | GntTree *tree = GNT_TREE(widget); |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
898 | int pos = 1; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
899 | if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
900 | pos = 0; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
901 | if (tree->show_title) |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
902 | pos += 2; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
903 | pos = y - widget->priv.y - pos; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
904 | row = get_next_n(tree->top, pos); |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
905 | if (row && tree->current != row) { |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
906 | GntTreeRow *old = tree->current; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
907 | tree->current = row; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
908 | redraw_tree(tree); |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
909 | tree_selection_changed(tree, old, tree->current); |
|
14413
bd998fe17d82
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14405
diff
changeset
|
910 | } else if (row && row == tree->current) { |
|
bd998fe17d82
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14405
diff
changeset
|
911 | if (row->choice) { |
|
bd998fe17d82
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14405
diff
changeset
|
912 | row->isselected = !row->isselected; |
|
bd998fe17d82
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14405
diff
changeset
|
913 | g_signal_emit(tree, signals[SIG_TOGGLED], 0, row->key); |
|
bd998fe17d82
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14405
diff
changeset
|
914 | redraw_tree(tree); |
|
bd998fe17d82
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14405
diff
changeset
|
915 | } else { |
|
bd998fe17d82
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14405
diff
changeset
|
916 | gnt_widget_activate(widget); |
|
bd998fe17d82
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14405
diff
changeset
|
917 | } |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
918 | } |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
919 | } else { |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
920 | return FALSE; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
921 | } |
| 14441 | 922 | if (old != tree->current) { |
| 923 | tree_selection_changed(tree, old, tree->current); | |
| 924 | } | |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
925 | return TRUE; |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
926 | } |
|
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
927 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
928 | static void |
|
15113
956d8ac87bf6
[gaim-migrate @ 17835]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15039
diff
changeset
|
929 | gnt_tree_size_changed(GntWidget *widget, int w, int h) |
|
956d8ac87bf6
[gaim-migrate @ 17835]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15039
diff
changeset
|
930 | { |
|
956d8ac87bf6
[gaim-migrate @ 17835]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15039
diff
changeset
|
931 | GntTree *tree = GNT_TREE(widget); |
|
956d8ac87bf6
[gaim-migrate @ 17835]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15039
diff
changeset
|
932 | if (widget->priv.width <= 0) |
|
956d8ac87bf6
[gaim-migrate @ 17835]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15039
diff
changeset
|
933 | return; |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
934 | |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
935 | readjust_columns(tree); |
|
15113
956d8ac87bf6
[gaim-migrate @ 17835]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15039
diff
changeset
|
936 | } |
|
956d8ac87bf6
[gaim-migrate @ 17835]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15039
diff
changeset
|
937 | |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
938 | static gboolean |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
939 | start_search(GntBindable *bindable, GList *list) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
940 | { |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
941 | GntTree *tree = GNT_TREE(bindable); |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
942 | if (tree->priv->search) |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
943 | return FALSE; |
|
18832
177a16b4b9f3
Allow disabling the widget actions on specific widgets. This allows, for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18830
diff
changeset
|
944 | GNT_WIDGET_SET_FLAGS(GNT_WIDGET(tree), GNT_WIDGET_DISABLE_ACTIONS); |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
945 | tree->priv->search = g_string_new(NULL); |
|
26651
d9f1eeefb89c
Save the world.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26650
diff
changeset
|
946 | tree->priv->search_timeout = g_timeout_add_seconds(SEARCH_TIMEOUT_S, search_timeout, tree); |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
947 | return TRUE; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
948 | } |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
949 | |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
950 | static gboolean |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
951 | end_search_action(GntBindable *bindable, GList *list) |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
952 | { |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
953 | GntTree *tree = GNT_TREE(bindable); |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
954 | if (tree->priv->search == NULL) |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
955 | return FALSE; |
|
18832
177a16b4b9f3
Allow disabling the widget actions on specific widgets. This allows, for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18830
diff
changeset
|
956 | GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(tree), GNT_WIDGET_DISABLE_ACTIONS); |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
957 | end_search(tree); |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
958 | redraw_tree(tree); |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
959 | return TRUE; |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
960 | } |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
961 | |
|
29265
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
962 | static gboolean |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
963 | move_first_action(GntBindable *bind, GList *null) |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
964 | { |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
965 | GntTree *tree = GNT_TREE(bind); |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
966 | GntTreeRow *row = tree->root; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
967 | GntTreeRow *old = tree->current; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
968 | if (row && !row_matches_search(row)) |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
969 | row = get_next(row); |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
970 | if (row) { |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
971 | tree->current = row; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
972 | redraw_tree(tree); |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
973 | if (old != tree->current) |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
974 | tree_selection_changed(tree, old, tree->current); |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
975 | } |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
976 | |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
977 | return TRUE; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
978 | } |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
979 | |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
980 | static gboolean |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
981 | move_last_action(GntBindable *bind, GList *null) |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
982 | { |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
983 | GntTree *tree = GNT_TREE(bind); |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
984 | GntTreeRow *old = tree->current; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
985 | GntTreeRow *row = tree->bottom; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
986 | GntTreeRow *next; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
987 | |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
988 | while ((next = get_next(row))) |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
989 | row = next; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
990 | |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
991 | if (row) { |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
992 | tree->current = row; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
993 | redraw_tree(tree); |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
994 | if (old != tree->current) |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
995 | tree_selection_changed(tree, old, tree->current); |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
996 | } |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
997 | |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
998 | return TRUE; |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
999 | } |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
1000 | |
|
15113
956d8ac87bf6
[gaim-migrate @ 17835]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15039
diff
changeset
|
1001 | static void |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1002 | gnt_tree_set_property(GObject *obj, guint prop_id, const GValue *value, |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1003 | GParamSpec *spec) |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1004 | { |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1005 | GntTree *tree = GNT_TREE(obj); |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1006 | switch (prop_id) { |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1007 | case PROP_COLUMNS: |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1008 | _gnt_tree_init_internals(tree, g_value_get_int(value)); |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1009 | break; |
|
22311
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1010 | case PROP_EXPANDER: |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1011 | if (tree->priv->expander_level == g_value_get_int(value)) |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1012 | break; |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1013 | tree->priv->expander_level = g_value_get_int(value); |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1014 | default: |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1015 | break; |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1016 | } |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1017 | } |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1018 | |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1019 | static void |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1020 | gnt_tree_get_property(GObject *obj, guint prop_id, GValue *value, |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1021 | GParamSpec *spec) |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1022 | { |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1023 | GntTree *tree = GNT_TREE(obj); |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1024 | switch (prop_id) { |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1025 | case PROP_COLUMNS: |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1026 | g_value_set_int(value, tree->ncol); |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1027 | break; |
|
22311
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1028 | case PROP_EXPANDER: |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1029 | g_value_set_int(value, tree->priv->expander_level); |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1030 | break; |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1031 | default: |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1032 | break; |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1033 | } |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1034 | } |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1035 | |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1036 | static void |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1037 | gnt_tree_class_init(GntTreeClass *klass) |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1038 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
1039 | GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1040 | GObjectClass *gclass = G_OBJECT_CLASS(klass); |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1041 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1042 | parent_class = GNT_WIDGET_CLASS(klass); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1043 | parent_class->destroy = gnt_tree_destroy; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1044 | parent_class->draw = gnt_tree_draw; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1045 | parent_class->map = gnt_tree_map; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1046 | parent_class->size_request = gnt_tree_size_request; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1047 | parent_class->key_pressed = gnt_tree_key_pressed; |
|
14405
4398121ce889
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14398
diff
changeset
|
1048 | parent_class->clicked = gnt_tree_clicked; |
|
15113
956d8ac87bf6
[gaim-migrate @ 17835]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15039
diff
changeset
|
1049 | parent_class->size_changed = gnt_tree_size_changed; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1050 | |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1051 | gclass->set_property = gnt_tree_set_property; |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1052 | gclass->get_property = gnt_tree_get_property; |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1053 | g_object_class_install_property(gclass, |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1054 | PROP_COLUMNS, |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1055 | g_param_spec_int("columns", "Columns", |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1056 | "Number of columns in the tree.", |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1057 | 1, G_MAXINT, 1, |
|
35059
5fd94b14cc49
libgnt: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents:
31294
diff
changeset
|
1058 | G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1059 | ) |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1060 | ); |
|
22311
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1061 | g_object_class_install_property(gclass, |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1062 | PROP_EXPANDER, |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1063 | g_param_spec_int("expander-level", "Expander level", |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1064 | "Number of levels to show expander in the tree.", |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1065 | 0, G_MAXINT, 1, |
|
35059
5fd94b14cc49
libgnt: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents:
31294
diff
changeset
|
1066 | G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS |
|
22311
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1067 | ) |
|
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1068 | ); |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1069 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30499
diff
changeset
|
1070 | signals[SIG_SELECTION_CHANGED] = |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1071 | g_signal_new("selection-changed", |
|
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1072 | G_TYPE_FROM_CLASS(klass), |
|
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1073 | G_SIGNAL_RUN_LAST, |
|
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1074 | G_STRUCT_OFFSET(GntTreeClass, selection_changed), |
|
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1075 | NULL, NULL, |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1076 | gnt_closure_marshal_VOID__POINTER_POINTER, |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1077 | G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30499
diff
changeset
|
1078 | signals[SIG_SCROLLED] = |
|
13927
c2f57a00bc1f
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13926
diff
changeset
|
1079 | g_signal_new("scrolled", |
|
c2f57a00bc1f
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13926
diff
changeset
|
1080 | G_TYPE_FROM_CLASS(klass), |
|
c2f57a00bc1f
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13926
diff
changeset
|
1081 | G_SIGNAL_RUN_LAST, |
|
c2f57a00bc1f
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13926
diff
changeset
|
1082 | 0, |
|
c2f57a00bc1f
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13926
diff
changeset
|
1083 | NULL, NULL, |
|
c2f57a00bc1f
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13926
diff
changeset
|
1084 | g_cclosure_marshal_VOID__INT, |
|
c2f57a00bc1f
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13926
diff
changeset
|
1085 | G_TYPE_NONE, 1, G_TYPE_INT); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30499
diff
changeset
|
1086 | signals[SIG_TOGGLED] = |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1087 | g_signal_new("toggled", |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1088 | G_TYPE_FROM_CLASS(klass), |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1089 | G_SIGNAL_RUN_LAST, |
|
14905
23f31a7acc73
[gaim-migrate @ 17612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14898
diff
changeset
|
1090 | G_STRUCT_OFFSET(GntTreeClass, toggled), |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1091 | NULL, NULL, |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1092 | g_cclosure_marshal_VOID__POINTER, |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1093 | G_TYPE_NONE, 1, G_TYPE_POINTER); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30499
diff
changeset
|
1094 | signals[SIG_COLLAPSED] = |
|
16165
24ec117bc52c
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
16032
diff
changeset
|
1095 | g_signal_new("collapse-toggled", |
|
24ec117bc52c
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
16032
diff
changeset
|
1096 | G_TYPE_FROM_CLASS(klass), |
|
24ec117bc52c
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
16032
diff
changeset
|
1097 | G_SIGNAL_RUN_LAST, |
|
24ec117bc52c
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
16032
diff
changeset
|
1098 | 0, |
|
24ec117bc52c
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
16032
diff
changeset
|
1099 | NULL, NULL, |
|
24ec117bc52c
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
16032
diff
changeset
|
1100 | gnt_closure_marshal_VOID__POINTER_BOOLEAN, |
|
24ec117bc52c
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
16032
diff
changeset
|
1101 | G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_BOOLEAN); |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1102 | |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
1103 | gnt_bindable_class_register_action(bindable, "move-up", action_up, |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14928
diff
changeset
|
1104 | GNT_KEY_UP, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
1105 | gnt_bindable_register_binding(bindable, "move-up", GNT_KEY_CTRL_P, NULL); |
|
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
1106 | gnt_bindable_class_register_action(bindable, "move-down", action_down, |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14928
diff
changeset
|
1107 | GNT_KEY_DOWN, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
1108 | gnt_bindable_register_binding(bindable, "move-down", GNT_KEY_CTRL_N, NULL); |
|
16032
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
1109 | gnt_bindable_class_register_action(bindable, "move-parent", action_move_parent, |
|
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
1110 | GNT_KEY_BACKSPACE, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
1111 | gnt_bindable_class_register_action(bindable, "page-up", action_page_up, |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14928
diff
changeset
|
1112 | GNT_KEY_PGUP, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
1113 | gnt_bindable_class_register_action(bindable, "page-down", action_page_down, |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14928
diff
changeset
|
1114 | GNT_KEY_PGDOWN, NULL); |
|
15222
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
1115 | gnt_bindable_class_register_action(bindable, "start-search", start_search, |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
1116 | "/", NULL); |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
1117 | gnt_bindable_class_register_action(bindable, "end-search", end_search_action, |
|
7662507d2b35
[gaim-migrate @ 17946]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15220
diff
changeset
|
1118 | "\033", NULL); |
|
29265
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
1119 | gnt_bindable_class_register_action(bindable, "move-first", move_first_action, |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
1120 | GNT_KEY_HOME, NULL); |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
1121 | gnt_bindable_class_register_action(bindable, "move-last", move_last_action, |
|
7461ac2b3467
move-start (home) and move-last (end) actions for trees.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28937
diff
changeset
|
1122 | GNT_KEY_END, NULL); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14817
diff
changeset
|
1123 | |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
1124 | gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable); |
|
14494
3575eac3a518
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14446
diff
changeset
|
1125 | GNTDEBUG; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1126 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1127 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1128 | static void |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1129 | gnt_tree_init(GTypeInstance *instance, gpointer class) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1130 | { |
|
14005
198d1658b390
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13999
diff
changeset
|
1131 | GntWidget *widget = GNT_WIDGET(instance); |
|
14675
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1132 | GntTree *tree = GNT_TREE(widget); |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1133 | tree->show_separator = TRUE; |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1134 | tree->priv = g_new0(GntTreePriv, 1); |
|
19184
72003b472bdc
Fix a /-search bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18832
diff
changeset
|
1135 | GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X | GNT_WIDGET_GROW_Y | |
|
72003b472bdc
Fix a /-search bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18832
diff
changeset
|
1136 | GNT_WIDGET_CAN_TAKE_FOCUS | GNT_WIDGET_NO_SHADOW); |
|
72003b472bdc
Fix a /-search bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18832
diff
changeset
|
1137 | gnt_widget_set_take_focus(widget, TRUE); |
|
14005
198d1658b390
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13999
diff
changeset
|
1138 | widget->priv.minw = 4; |
|
15822
3914c5c41521
gnttree can have a size of 1. This fixes <sadrul> meh. gntcombobox crashes if it has only one item in it
Richard Nelson <wabz@pidgin.im>
parents:
15806
diff
changeset
|
1139 | widget->priv.minh = 1; |
|
14494
3575eac3a518
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14446
diff
changeset
|
1140 | GNTDEBUG; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1141 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1142 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1143 | /****************************************************************************** |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1144 | * GntTree API |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1145 | *****************************************************************************/ |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1146 | GType |
|
35379
ea1a0327001e
Rename _get_gtype() functions in libgnt to _get_type()
Ankit Vani <a@nevitus.org>
parents:
35059
diff
changeset
|
1147 | gnt_tree_get_type(void) |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1148 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1149 | static GType type = 0; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1150 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1151 | if(type == 0) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1152 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1153 | static const GTypeInfo info = { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1154 | sizeof(GntTreeClass), |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1155 | NULL, /* base_init */ |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1156 | NULL, /* base_finalize */ |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1157 | (GClassInitFunc)gnt_tree_class_init, |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1158 | NULL, /* class_finalize */ |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1159 | NULL, /* class_data */ |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1160 | sizeof(GntTree), |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1161 | 0, /* n_preallocs */ |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1162 | gnt_tree_init, /* instance_init */ |
|
15874
46df7421a1b5
Enable DEBUG_CFLAGS in libgnt and fix up a number of compile warnings and
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15822
diff
changeset
|
1163 | NULL /* value_table */ |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1164 | }; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1165 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1166 | type = g_type_register_static(GNT_TYPE_WIDGET, |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1167 | "GntTree", |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1168 | &info, 0); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1169 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1170 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1171 | return type; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1172 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1173 | |
|
13920
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
1174 | static void |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1175 | free_tree_col(gpointer data) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1176 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1177 | GntTreeCol *col = data; |
| 19106 | 1178 | if (!col->isbinary) |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1179 | g_free(col->text); |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1180 | g_free(col); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1181 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1182 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1183 | static void |
|
13920
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
1184 | free_tree_row(gpointer data) |
|
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
1185 | { |
|
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
1186 | GntTreeRow *row = data; |
|
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
1187 | |
|
13923
5552f69232b8
[gaim-migrate @ 16322]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13922
diff
changeset
|
1188 | if (!row) |
|
5552f69232b8
[gaim-migrate @ 16322]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13922
diff
changeset
|
1189 | return; |
|
5552f69232b8
[gaim-migrate @ 16322]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13922
diff
changeset
|
1190 | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1191 | g_list_foreach(row->columns, (GFunc)free_tree_col, NULL); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1192 | g_list_free(row->columns); |
|
13920
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
1193 | g_free(row); |
|
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
1194 | } |
|
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
1195 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1196 | GntWidget *gnt_tree_new() |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1197 | { |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1198 | return gnt_tree_new_with_columns(1); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1199 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1200 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1201 | void gnt_tree_set_visible_rows(GntTree *tree, int rows) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1202 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1203 | GntWidget *widget = GNT_WIDGET(tree); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1204 | widget->priv.height = rows; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1205 | if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1206 | widget->priv.height += 2; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1207 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1208 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1209 | int gnt_tree_get_visible_rows(GntTree *tree) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1210 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1211 | GntWidget *widget = GNT_WIDGET(tree); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1212 | int ret = widget->priv.height; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1213 | if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) |
|
13950
bd8d39b3a9e2
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13944
diff
changeset
|
1214 | ret -= 2; |
|
bd8d39b3a9e2
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13944
diff
changeset
|
1215 | return ret; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1216 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1217 | |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
18171
diff
changeset
|
1218 | GList *gnt_tree_get_rows(GntTree *tree) |
| 14817 | 1219 | { |
| 1220 | return tree->list; | |
| 1221 | } | |
| 1222 | ||
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1223 | void gnt_tree_scroll(GntTree *tree, int count) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1224 | { |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1225 | GntTreeRow *row; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1226 | |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1227 | if (count < 0) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1228 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1229 | if (get_root_distance(tree->top) == 0) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1230 | return; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1231 | row = get_prev_n(tree->top, -count); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1232 | if (row == NULL) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1233 | row = tree->root; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1234 | tree->top = row; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1235 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1236 | else |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1237 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1238 | get_next_n_opt(tree->bottom, count, &count); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1239 | tree->top = get_next_n(tree->top, count); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1240 | } |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1241 | |
|
13915
15a38b312abe
[gaim-migrate @ 16312]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13913
diff
changeset
|
1242 | redraw_tree(tree); |
|
13927
c2f57a00bc1f
[gaim-migrate @ 16331]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13926
diff
changeset
|
1243 | g_signal_emit(tree, signals[SIG_SCROLLED], 0, count); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1244 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1245 | |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1246 | static gpointer |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1247 | find_position(GntTree *tree, gpointer key, gpointer parent) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1248 | { |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1249 | GntTreeRow *row; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1250 | |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1251 | if (tree->priv->compare == NULL) |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1252 | return NULL; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1253 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1254 | if (parent == NULL) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1255 | row = tree->root; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1256 | else |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1257 | row = g_hash_table_lookup(tree->hash, parent); |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1258 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1259 | if (!row) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1260 | return NULL; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1261 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1262 | if (parent) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1263 | row = row->child; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1264 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1265 | while (row) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1266 | { |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1267 | if (tree->priv->compare(key, row->key) < 0) |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1268 | return (row->prev ? row->prev->key : NULL); |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1269 | if (row->next) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1270 | row = row->next; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1271 | else |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1272 | return row->key; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1273 | } |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1274 | return NULL; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1275 | } |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1276 | |
| 14774 | 1277 | void gnt_tree_sort_row(GntTree *tree, gpointer key) |
| 1278 | { | |
| 1279 | GntTreeRow *row, *q, *s; | |
| 1280 | int current, newp; | |
| 1281 | ||
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1282 | if (!tree->priv->compare) |
| 14774 | 1283 | return; |
| 1284 | ||
| 1285 | row = g_hash_table_lookup(tree->hash, key); | |
| 1286 | g_return_if_fail(row != NULL); | |
| 1287 | ||
| 1288 | current = g_list_index(tree->list, key); | |
| 1289 | ||
| 1290 | if (row->parent) | |
| 1291 | s = row->parent->child; | |
| 1292 | else | |
| 1293 | s = tree->root; | |
| 1294 | ||
| 1295 | q = NULL; | |
| 1296 | while (s) { | |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1297 | if (tree->priv->compare(row->key, s->key) < 0) |
| 14774 | 1298 | break; |
| 1299 | q = s; | |
| 1300 | s = s->next; | |
| 1301 | } | |
| 1302 | ||
| 1303 | /* Move row between q and s */ | |
| 1304 | if (row == q || row == s) | |
| 1305 | return; | |
| 1306 | ||
| 1307 | if (q == NULL) { | |
| 1308 | /* row becomes the first child of its parent */ | |
| 1309 | row->prev->next = row->next; /* row->prev cannot be NULL at this point */ | |
| 1310 | if (row->next) | |
| 1311 | row->next->prev = row->prev; | |
| 1312 | if (row->parent) | |
| 1313 | row->parent->child = row; | |
| 1314 | else | |
| 1315 | tree->root = row; | |
| 1316 | row->next = s; | |
|
35690
5ef990c032ad
Fix Finch clang scan-build warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35596
diff
changeset
|
1317 | g_return_if_fail(s != NULL); /* s cannot be NULL */ |
|
5ef990c032ad
Fix Finch clang scan-build warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35596
diff
changeset
|
1318 | s->prev = row; |
| 14774 | 1319 | row->prev = NULL; |
| 1320 | newp = g_list_index(tree->list, s) - 1; | |
| 1321 | } else { | |
| 1322 | if (row->prev) { | |
| 1323 | row->prev->next = row->next; | |
| 1324 | } else { | |
| 1325 | /* row was the first child of its parent */ | |
| 1326 | if (row->parent) | |
| 1327 | row->parent->child = row->next; | |
| 1328 | else | |
| 1329 | tree->top = row->next; | |
| 1330 | } | |
| 1331 | ||
| 1332 | if (row->next) | |
| 1333 | row->next->prev = row->prev; | |
| 1334 | ||
| 1335 | q->next = row; | |
| 1336 | row->prev = q; | |
| 1337 | if (s) | |
| 1338 | s->prev = row; | |
| 1339 | row->next = s; | |
| 1340 | newp = g_list_index(tree->list, q) + 1; | |
| 1341 | } | |
| 1342 | tree->list = g_list_reposition_child(tree->list, current, newp); | |
| 1343 | ||
| 1344 | redraw_tree(tree); | |
| 1345 | } | |
| 1346 | ||
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1347 | GntTreeRow *gnt_tree_add_row_after(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro) |
|
13920
c51758bc563c
[gaim-migrate @ 16317]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13919
diff
changeset
|
1348 | { |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1349 | GntTreeRow *pr = NULL; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1350 | |
|
29377
6c8add94b5a4
Fix CVE-2010-0420, a possible remote crash when handling chat room
Mark Doliner <markdoliner@pidgin.im>
parents:
29342
diff
changeset
|
1351 | if (g_hash_table_lookup(tree->hash, key)) { |
|
6c8add94b5a4
Fix CVE-2010-0420, a possible remote crash when handling chat room
Mark Doliner <markdoliner@pidgin.im>
parents:
29342
diff
changeset
|
1352 | gnt_tree_remove(tree, key); |
|
6c8add94b5a4
Fix CVE-2010-0420, a possible remote crash when handling chat room
Mark Doliner <markdoliner@pidgin.im>
parents:
29342
diff
changeset
|
1353 | } |
|
6c8add94b5a4
Fix CVE-2010-0420, a possible remote crash when handling chat room
Mark Doliner <markdoliner@pidgin.im>
parents:
29342
diff
changeset
|
1354 | |
|
20198
90ae53934c28
applied changes from 88f296b3653b5a7578a7581c1582d37390c9d212
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
1355 | row->tree = tree; |
|
90ae53934c28
applied changes from 88f296b3653b5a7578a7581c1582d37390c9d212
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
1356 | row->key = key; |
|
90ae53934c28
applied changes from 88f296b3653b5a7578a7581c1582d37390c9d212
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
1357 | row->data = NULL; |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1358 | g_hash_table_replace(tree->hash, key, row); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1359 | |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1360 | if (bigbro == NULL && tree->priv->compare) |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1361 | { |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1362 | bigbro = find_position(tree, key, parent); |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1363 | } |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1364 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1365 | if (tree->root == NULL) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1366 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1367 | tree->root = row; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1368 | tree->list = g_list_prepend(tree->list, key); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1369 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1370 | else |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1371 | { |
|
13989
9a647311c9ac
[gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13969
diff
changeset
|
1372 | int position = 0; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1373 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1374 | if (bigbro) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1375 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1376 | pr = g_hash_table_lookup(tree->hash, bigbro); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1377 | if (pr) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1378 | { |
|
13919
94caf5dc02b4
[gaim-migrate @ 16316]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13918
diff
changeset
|
1379 | if (pr->next) pr->next->prev = row; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1380 | row->next = pr->next; |
|
13919
94caf5dc02b4
[gaim-migrate @ 16316]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13918
diff
changeset
|
1381 | row->prev = pr; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1382 | pr->next = row; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1383 | row->parent = pr->parent; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1384 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1385 | position = g_list_index(tree->list, bigbro); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1386 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1387 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1388 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30499
diff
changeset
|
1389 | if (pr == NULL && parent) |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1390 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1391 | pr = g_hash_table_lookup(tree->hash, parent); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1392 | if (pr) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1393 | { |
|
13919
94caf5dc02b4
[gaim-migrate @ 16316]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13918
diff
changeset
|
1394 | if (pr->child) pr->child->prev = row; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1395 | row->next = pr->child; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1396 | pr->child = row; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1397 | row->parent = pr; |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1398 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1399 | position = g_list_index(tree->list, parent); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1400 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1401 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1402 | |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1403 | if (pr == NULL) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1404 | { |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1405 | GntTreeRow *r = tree->root; |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1406 | row->next = r; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1407 | if (r) r->prev = row; |
|
15220
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1408 | if (tree->current == tree->root) |
|
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1409 | tree->current = row; |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1410 | tree->root = row; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1411 | tree->list = g_list_prepend(tree->list, key); |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1412 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1413 | else |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1414 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1415 | tree->list = g_list_insert(tree->list, key, position + 1); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1416 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1417 | } |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1418 | redraw_tree(tree); |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1419 | |
|
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1420 | return row; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1421 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1422 | |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1423 | GntTreeRow *gnt_tree_add_row_last(GntTree *tree, void *key, GntTreeRow *row, void *parent) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1424 | { |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1425 | GntTreeRow *pr = NULL, *br = NULL; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1426 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1427 | if (parent) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1428 | pr = g_hash_table_lookup(tree->hash, parent); |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1429 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1430 | if (pr) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1431 | br = pr->child; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1432 | else |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1433 | br = tree->root; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1434 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1435 | if (br) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1436 | { |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1437 | while (br->next) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1438 | br = br->next; |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1439 | } |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1440 | |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1441 | return gnt_tree_add_row_after(tree, key, row, parent, br ? br->key : NULL); |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1442 | } |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1443 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1444 | gpointer gnt_tree_get_selection_data(GntTree *tree) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1445 | { |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1446 | if (tree->current) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1447 | return tree->current->key; /* XXX: perhaps we should just get rid of 'data' */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1448 | return NULL; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1449 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1450 | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1451 | char *gnt_tree_get_selection_text(GntTree *tree) |
|
13997
546ca912cb25
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13996
diff
changeset
|
1452 | { |
|
546ca912cb25
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13996
diff
changeset
|
1453 | if (tree->current) |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1454 | return update_row_text(tree, tree->current); |
|
13997
546ca912cb25
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13996
diff
changeset
|
1455 | return NULL; |
|
546ca912cb25
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13996
diff
changeset
|
1456 | } |
|
546ca912cb25
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13996
diff
changeset
|
1457 | |
|
18830
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1458 | GList *gnt_tree_get_row_text_list(GntTree *tree, gpointer key) |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1459 | { |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1460 | GList *list = NULL, *iter; |
|
18830
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1461 | GntTreeRow *row = key ? g_hash_table_lookup(tree->hash, key) : tree->current; |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1462 | int i; |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1463 | |
|
18830
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1464 | if (!row) |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1465 | return NULL; |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1466 | |
|
18830
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1467 | for (i = 0, iter = row->columns; i < tree->ncol && iter; |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1468 | i++, iter = iter->next) |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1469 | { |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1470 | GntTreeCol *col = iter->data; |
|
18830
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1471 | list = g_list_append(list, BINARY_DATA(tree, i) ? col->text : g_strdup(col->text)); |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1472 | } |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1473 | |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1474 | return list; |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1475 | } |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1476 | |
|
18830
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1477 | GList *gnt_tree_get_selection_text_list(GntTree *tree) |
|
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1478 | { |
|
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1479 | return gnt_tree_get_row_text_list(tree, NULL); |
|
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1480 | } |
|
7e9784f65d5d
Anoter patch from Javeed Shaikh to introduce a utility function for a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18829
diff
changeset
|
1481 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1482 | void gnt_tree_remove(GntTree *tree, gpointer key) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1483 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1484 | GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
|
15761
3e83050bff0a
recursively remove child nodes. This fixes a crash (often caused by going offline)
Richard Nelson <wabz@pidgin.im>
parents:
15702
diff
changeset
|
1485 | static int depth = 0; /* Only redraw after all child nodes are removed */ |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1486 | if (row) |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1487 | { |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1488 | gboolean redraw = FALSE; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1489 | |
|
15039
20a0d0117a47
[gaim-migrate @ 17756]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14962
diff
changeset
|
1490 | if (row->child) { |
|
15761
3e83050bff0a
recursively remove child nodes. This fixes a crash (often caused by going offline)
Richard Nelson <wabz@pidgin.im>
parents:
15702
diff
changeset
|
1491 | depth++; |
|
3e83050bff0a
recursively remove child nodes. This fixes a crash (often caused by going offline)
Richard Nelson <wabz@pidgin.im>
parents:
15702
diff
changeset
|
1492 | while (row->child) { |
|
3e83050bff0a
recursively remove child nodes. This fixes a crash (often caused by going offline)
Richard Nelson <wabz@pidgin.im>
parents:
15702
diff
changeset
|
1493 | gnt_tree_remove(tree, row->child->key); |
|
15039
20a0d0117a47
[gaim-migrate @ 17756]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14962
diff
changeset
|
1494 | } |
|
15761
3e83050bff0a
recursively remove child nodes. This fixes a crash (often caused by going offline)
Richard Nelson <wabz@pidgin.im>
parents:
15702
diff
changeset
|
1495 | depth--; |
|
15039
20a0d0117a47
[gaim-migrate @ 17756]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14962
diff
changeset
|
1496 | } |
|
20a0d0117a47
[gaim-migrate @ 17756]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14962
diff
changeset
|
1497 | |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1498 | if (get_distance(tree->top, row) >= 0 && get_distance(row, tree->bottom) >= 0) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1499 | redraw = TRUE; |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1500 | |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1501 | /* Update root/top/current/bottom if necessary */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1502 | if (tree->root == row) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1503 | tree->root = get_next(row); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1504 | if (tree->top == row) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1505 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1506 | if (tree->top != tree->root) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1507 | tree->top = get_prev(row); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1508 | else |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1509 | tree->top = get_next(row); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1510 | } |
|
15617
f4813fc9b095
Patch from Richard 'wabz' Nelson: Make sure selection-changed signal is emitted if selected item is removed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15480
diff
changeset
|
1511 | if (tree->current == row) |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1512 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1513 | if (tree->current != tree->root) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1514 | tree->current = get_prev(row); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1515 | else |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1516 | tree->current = get_next(row); |
|
15617
f4813fc9b095
Patch from Richard 'wabz' Nelson: Make sure selection-changed signal is emitted if selected item is removed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15480
diff
changeset
|
1517 | tree_selection_changed(tree, row, tree->current); |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1518 | } |
|
15617
f4813fc9b095
Patch from Richard 'wabz' Nelson: Make sure selection-changed signal is emitted if selected item is removed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15480
diff
changeset
|
1519 | if (tree->bottom == row) |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1520 | { |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1521 | tree->bottom = get_prev(row); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1522 | } |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1523 | |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1524 | /* Fix the links */ |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1525 | if (row->next) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1526 | row->next->prev = row->prev; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1527 | if (row->parent && row->parent->child == row) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1528 | row->parent->child = row->next; |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1529 | if (row->prev) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1530 | row->prev->next = row->next; |
|
15761
3e83050bff0a
recursively remove child nodes. This fixes a crash (often caused by going offline)
Richard Nelson <wabz@pidgin.im>
parents:
15702
diff
changeset
|
1531 | |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1532 | g_hash_table_remove(tree->hash, key); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1533 | tree->list = g_list_remove(tree->list, key); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1534 | |
|
15761
3e83050bff0a
recursively remove child nodes. This fixes a crash (often caused by going offline)
Richard Nelson <wabz@pidgin.im>
parents:
15702
diff
changeset
|
1535 | if (redraw && depth == 0) |
|
13852
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1536 | { |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1537 | redraw_tree(tree); |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1538 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1539 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1540 | } |
|
1d3ae9f34d42
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1541 | |
|
14270
710ef4096bac
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14193
diff
changeset
|
1542 | static gboolean |
|
710ef4096bac
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14193
diff
changeset
|
1543 | return_true(gpointer key, gpointer data, gpointer null) |
|
710ef4096bac
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14193
diff
changeset
|
1544 | { |
|
710ef4096bac
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14193
diff
changeset
|
1545 | return TRUE; |
|
710ef4096bac
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14193
diff
changeset
|
1546 | } |
|
710ef4096bac
[gaim-migrate @ 16883]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14193
diff
changeset
|
1547 | |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14072
diff
changeset
|
1548 | void gnt_tree_remove_all(GntTree *tree) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14072
diff
changeset
|
1549 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14072
diff
changeset
|
1550 | tree->root = NULL; |
|
15220
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1551 | g_hash_table_foreach_remove(tree->hash, (GHRFunc)return_true, tree); |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14072
diff
changeset
|
1552 | g_list_free(tree->list); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14072
diff
changeset
|
1553 | tree->list = NULL; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14072
diff
changeset
|
1554 | tree->current = tree->top = tree->bottom = NULL; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14072
diff
changeset
|
1555 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14072
diff
changeset
|
1556 | |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1557 | int gnt_tree_get_selection_visible_line(GntTree *tree) |
|
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1558 | { |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1559 | return get_distance(tree->top, tree->current) + |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1560 | !!(GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER)); |
|
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1561 | } |
|
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13920
diff
changeset
|
1562 | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1563 | void gnt_tree_change_text(GntTree *tree, gpointer key, int colno, const char *text) |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1564 | { |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1565 | GntTreeRow *row; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1566 | GntTreeCol *col; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1567 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1568 | g_return_if_fail(colno < tree->ncol); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30499
diff
changeset
|
1569 | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1570 | row = g_hash_table_lookup(tree->hash, key); |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1571 | if (row) |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1572 | { |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1573 | col = g_list_nth_data(row->columns, colno); |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1574 | if (BINARY_DATA(tree, colno)) { |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1575 | col->text = (gpointer)text; |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1576 | } else { |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1577 | g_free(col->text); |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1578 | col->text = g_strdup(text ? text : ""); |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1579 | } |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1580 | |
|
21261
eaf551849532
Do not do unnecessary processing when updating text in a column.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21254
diff
changeset
|
1581 | if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED) && |
|
eaf551849532
Do not do unnecessary processing when updating text in a column.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21254
diff
changeset
|
1582 | get_distance(tree->top, row) >= 0 && get_distance(row, tree->bottom) >= 0) |
|
13926
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1583 | redraw_tree(tree); |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1584 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1585 | } |
|
d2c1522276b3
[gaim-migrate @ 16328]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13923
diff
changeset
|
1586 | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1587 | GntTreeRow *gnt_tree_add_choice(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro) |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1588 | { |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1589 | GntTreeRow *r; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1590 | r = g_hash_table_lookup(tree->hash, key); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1591 | g_return_val_if_fail(!r || !r->choice, NULL); |
|
14398
351f2af228f1
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14278
diff
changeset
|
1592 | |
|
351f2af228f1
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14278
diff
changeset
|
1593 | if (bigbro == NULL) { |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1594 | if (tree->priv->compare) |
|
15806
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1595 | bigbro = find_position(tree, key, parent); |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1596 | else { |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1597 | r = g_hash_table_lookup(tree->hash, parent); |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1598 | if (!r) |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1599 | r = tree->root; |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1600 | else |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1601 | r = r->child; |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1602 | if (r) { |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1603 | while (r->next) |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1604 | r = r->next; |
|
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1605 | bigbro = r->key; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30499
diff
changeset
|
1606 | } |
|
15806
1972a83ada1f
Sort the plugin list.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15761
diff
changeset
|
1607 | } |
|
14398
351f2af228f1
[gaim-migrate @ 17032]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14278
diff
changeset
|
1608 | } |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1609 | row = gnt_tree_add_row_after(tree, key, row, parent, bigbro); |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1610 | row->choice = TRUE; |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1611 | |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1612 | return row; |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1613 | } |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1614 | |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1615 | void gnt_tree_set_choice(GntTree *tree, void *key, gboolean set) |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1616 | { |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1617 | GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1618 | |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1619 | if (!row) |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1620 | return; |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1621 | g_return_if_fail(row->choice); |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1622 | |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1623 | row->isselected = set; |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1624 | redraw_tree(tree); |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1625 | } |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1626 | |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1627 | gboolean gnt_tree_get_choice(GntTree *tree, void *key) |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1628 | { |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1629 | GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1630 | |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1631 | if (!row) |
|
13989
9a647311c9ac
[gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13969
diff
changeset
|
1632 | return FALSE; |
|
13969
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1633 | g_return_val_if_fail(row->choice, FALSE); |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1634 | |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1635 | return row->isselected; |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1636 | } |
|
0541f389442e
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
1637 | |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
1638 | void gnt_tree_set_row_flags(GntTree *tree, void *key, GntTextFormatFlags flags) |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
1639 | { |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
1640 | GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
|
13996
fa46d71780ff
[gaim-migrate @ 16462]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13993
diff
changeset
|
1641 | if (!row || row->flags == flags) |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
1642 | return; |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
1643 | |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
1644 | row->flags = flags; |
|
13997
546ca912cb25
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13996
diff
changeset
|
1645 | redraw_tree(tree); /* XXX: It shouldn't be necessary to redraw the whole darned tree */ |
|
13993
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
1646 | } |
|
8c12e7d15b40
[gaim-migrate @ 16458]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
1647 | |
|
21804
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1648 | void gnt_tree_set_row_color(GntTree *tree, void *key, int color) |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1649 | { |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1650 | GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1651 | if (!row || row->color == color) |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1652 | return; |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1653 | |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1654 | row->color = color; |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1655 | redraw_tree(tree); |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1656 | } |
|
931ef2cc7cfb
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21273
diff
changeset
|
1657 | |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1658 | void gnt_tree_set_selected(GntTree *tree , void *key) |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1659 | { |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1660 | int dist; |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1661 | GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
|
16264
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16185
diff
changeset
|
1662 | if (!row || row == tree->current) |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1663 | return; |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1664 | |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1665 | if (tree->top == NULL) |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1666 | tree->top = row; |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1667 | if (tree->bottom == NULL) |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1668 | tree->bottom = row; |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1669 | |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1670 | tree->current = row; |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1671 | if ((dist = get_distance(tree->current, tree->bottom)) < 0) |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1672 | gnt_tree_scroll(tree, -dist); |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1673 | else if ((dist = get_distance(tree->current, tree->top)) > 0) |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1674 | gnt_tree_scroll(tree, -dist); |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1675 | else |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1676 | redraw_tree(tree); |
|
16264
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16185
diff
changeset
|
1677 | tree_selection_changed(tree, row, tree->current); |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1678 | } |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
1679 | |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1680 | static void _gnt_tree_init_internals(GntTree *tree, int col) |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1681 | { |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1682 | gnt_tree_free_columns(tree); |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1683 | |
|
14675
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1684 | tree->ncol = col; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1685 | tree->hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_tree_row); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1686 | tree->columns = g_new0(struct _GntTreeColInfo, col); |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1687 | tree->priv->lastvisible = col - 1; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1688 | while (col--) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1689 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1690 | tree->columns[col].width = 15; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1691 | } |
|
14678
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1692 | tree->list = NULL; |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1693 | tree->show_title = FALSE; |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1694 | g_object_notify(G_OBJECT(tree), "columns"); |
|
14675
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1695 | } |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1696 | |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1697 | GntWidget *gnt_tree_new_with_columns(int col) |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1698 | { |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1699 | GntWidget *widget = g_object_new(GNT_TYPE_TREE, |
|
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1700 | "columns", col, |
|
22311
f3b63d7c4601
Allow customizing the expander in the tree. This is mostly a hack ;)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22301
diff
changeset
|
1701 | "expander-level", 1, |
|
18783
ca193fb6d9a2
Use gobject properties instead of hacks when creating columns in a tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18632
diff
changeset
|
1702 | NULL); |
|
14675
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1703 | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1704 | return widget; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1705 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1706 | |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1707 | GntTreeRow *gnt_tree_create_row_from_list(GntTree *tree, GList *list) |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1708 | { |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1709 | GList *iter; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1710 | int i; |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1711 | GntTreeRow *row = g_new0(GntTreeRow, 1); |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1712 | |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1713 | for (i = 0, iter = list; i < tree->ncol && iter; iter = iter->next, i++) |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1714 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1715 | GntTreeCol *col = g_new0(GntTreeCol, 1); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1716 | col->span = 1; |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1717 | if (BINARY_DATA(tree, i)) { |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1718 | col->text = iter->data; |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1719 | col->isbinary = TRUE; |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1720 | } else { |
|
19235
a6b00192295b
disapproval of revision '8d049f26f06abbea924dc65289b6edaf4f4adcd0'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19234
diff
changeset
|
1721 | col->text = g_strdup(iter->data ? iter->data : ""); |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1722 | col->isbinary = FALSE; |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1723 | } |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1724 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1725 | row->columns = g_list_append(row->columns, col); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1726 | } |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1727 | |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1728 | return row; |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1729 | } |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1730 | |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1731 | GntTreeRow *gnt_tree_create_row(GntTree *tree, ...) |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1732 | { |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1733 | int i; |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1734 | va_list args; |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1735 | GList *list = NULL; |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1736 | GntTreeRow *row; |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1737 | |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1738 | va_start(args, tree); |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1739 | for (i = 0; i < tree->ncol; i++) |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1740 | { |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
1741 | list = g_list_append(list, va_arg(args, char *)); |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1742 | } |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1743 | va_end(args); |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1744 | |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1745 | row = gnt_tree_create_row_from_list(tree, list); |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1746 | g_list_free(list); |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14033
diff
changeset
|
1747 | |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1748 | return row; |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1749 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1750 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1751 | void gnt_tree_set_col_width(GntTree *tree, int col, int width) |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1752 | { |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1753 | g_return_if_fail(col < tree->ncol); |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1754 | |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1755 | tree->columns[col].width = width; |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1756 | if (tree->columns[col].width_ratio == 0) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1757 | tree->columns[col].width_ratio = width; |
|
14026
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1758 | } |
|
ad91ce0effe2
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1759 | |
|
18403
218a6f247a1c
Oops. I missed this. This allows setting tree-column titles one by one.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18255
diff
changeset
|
1760 | void gnt_tree_set_column_title(GntTree *tree, int index, const char *title) |
|
218a6f247a1c
Oops. I missed this. This allows setting tree-column titles one by one.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18255
diff
changeset
|
1761 | { |
|
218a6f247a1c
Oops. I missed this. This allows setting tree-column titles one by one.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18255
diff
changeset
|
1762 | g_free(tree->columns[index].title); |
|
218a6f247a1c
Oops. I missed this. This allows setting tree-column titles one by one.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18255
diff
changeset
|
1763 | tree->columns[index].title = g_strdup(title); |
|
218a6f247a1c
Oops. I missed this. This allows setting tree-column titles one by one.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18255
diff
changeset
|
1764 | } |
|
218a6f247a1c
Oops. I missed this. This allows setting tree-column titles one by one.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18255
diff
changeset
|
1765 | |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1766 | void gnt_tree_set_column_titles(GntTree *tree, ...) |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1767 | { |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1768 | int i; |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1769 | va_list args; |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1770 | |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1771 | va_start(args, tree); |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1772 | for (i = 0; i < tree->ncol; i++) |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1773 | { |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1774 | const char *title = va_arg(args, const char *); |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1775 | tree->columns[i].title = g_strdup(title); |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1776 | } |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1777 | va_end(args); |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1778 | } |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1779 | |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1780 | void gnt_tree_set_show_title(GntTree *tree, gboolean set) |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1781 | { |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1782 | tree->show_title = set; |
|
14185
394aa8aa00a3
[gaim-migrate @ 16761]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14169
diff
changeset
|
1783 | GNT_WIDGET(tree)->priv.minh = (set ? 6 : 4); |
|
14033
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1784 | } |
|
127990de806d
[gaim-migrate @ 16529]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14026
diff
changeset
|
1785 | |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1786 | void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func) |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1787 | { |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1788 | tree->priv->compare = func; |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1789 | } |
|
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
1790 | |
|
14446
5f36f08183e8
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14441
diff
changeset
|
1791 | void gnt_tree_set_expanded(GntTree *tree, void *key, gboolean expanded) |
|
5f36f08183e8
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14441
diff
changeset
|
1792 | { |
|
5f36f08183e8
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14441
diff
changeset
|
1793 | GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
|
5f36f08183e8
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14441
diff
changeset
|
1794 | if (row) { |
|
5f36f08183e8
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14441
diff
changeset
|
1795 | row->collapsed = !expanded; |
|
5f36f08183e8
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14441
diff
changeset
|
1796 | if (GNT_WIDGET(tree)->window) |
|
5f36f08183e8
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14441
diff
changeset
|
1797 | gnt_widget_draw(GNT_WIDGET(tree)); |
|
16264
03aaf9aae68b
emit/handle gnttree signals appropriately
Richard Nelson <wabz@pidgin.im>
parents:
16185
diff
changeset
|
1798 | g_signal_emit(tree, signals[SIG_COLLAPSED], 0, key, row->collapsed); |
|
14446
5f36f08183e8
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14441
diff
changeset
|
1799 | } |
|
5f36f08183e8
[gaim-migrate @ 17090]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14441
diff
changeset
|
1800 | } |
|
14675
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1801 | |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1802 | void gnt_tree_set_show_separator(GntTree *tree, gboolean set) |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1803 | { |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1804 | tree->show_separator = set; |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1805 | } |
|
be8af28d1980
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
1806 | |
|
14678
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1807 | void gnt_tree_adjust_columns(GntTree *tree) |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1808 | { |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1809 | GntTreeRow *row = tree->root; |
|
16185
b19597267ec1
We don't need to do anything about the heights here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16165
diff
changeset
|
1810 | int *widths, i, twidth; |
|
14678
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1811 | |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1812 | widths = g_new0(int, tree->ncol); |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1813 | while (row) { |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1814 | GList *iter; |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1815 | for (i = 0, iter = row->columns; iter; iter = iter->next, i++) { |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1816 | GntTreeCol *col = iter->data; |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1817 | int w = gnt_util_onscreen_width(col->text, NULL); |
|
16027
931890920563
check-items are wider.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15991
diff
changeset
|
1818 | if (i == 0 && row->choice) |
|
931890920563
check-items are wider.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15991
diff
changeset
|
1819 | w += 4; |
|
16032
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
1820 | if (i == 0) { |
|
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
1821 | w += find_depth(row) * TAB_SIZE; |
|
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
1822 | } |
|
14678
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1823 | if (widths[i] < w) |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1824 | widths[i] = w; |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1825 | } |
|
16032
55ba12884571
Backspace to jump to parent.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16031
diff
changeset
|
1826 | row = get_next(row); |
|
14678
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1827 | } |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1828 | |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1829 | twidth = 1 + 2 * (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER)); |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1830 | for (i = 0; i < tree->ncol; i++) { |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1831 | if (tree->columns[i].flags & GNT_TREE_COLUMN_FIXED_SIZE) |
|
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1832 | widths[i] = tree->columns[i].width; |
|
14678
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1833 | gnt_tree_set_col_width(tree, i, widths[i]); |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1834 | if (!COLUMN_INVISIBLE(tree, i)) { |
|
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1835 | twidth = twidth + widths[i]; |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1836 | if (tree->priv->lastvisible != i) |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1837 | twidth += 1; |
|
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1838 | } |
|
14678
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1839 | } |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1840 | g_free(widths); |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1841 | |
|
16185
b19597267ec1
We don't need to do anything about the heights here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16165
diff
changeset
|
1842 | gnt_widget_set_size(GNT_WIDGET(tree), twidth, -1); |
|
14678
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1843 | } |
|
97f57691faab
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14675
diff
changeset
|
1844 | |
|
15220
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1845 | void gnt_tree_set_hash_fns(GntTree *tree, gpointer hash, gpointer eq, gpointer kd) |
|
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1846 | { |
|
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1847 | g_hash_table_foreach_remove(tree->hash, return_true, NULL); |
|
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1848 | g_hash_table_destroy(tree->hash); |
|
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1849 | tree->hash = g_hash_table_new_full(hash, eq, kd, free_tree_row); |
|
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1850 | } |
|
fc8b223f4b75
[gaim-migrate @ 17944]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15113
diff
changeset
|
1851 | |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1852 | static void |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1853 | set_column_flag(GntTree *tree, int col, GntTreeColumnFlag flag, gboolean set) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1854 | { |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1855 | if (set) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1856 | tree->columns[col].flags |= flag; |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1857 | else |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1858 | tree->columns[col].flags &= ~flag; |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1859 | } |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1860 | |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
1861 | void gnt_tree_set_column_visible(GntTree *tree, int col, gboolean vis) |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
1862 | { |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
1863 | g_return_if_fail(col < tree->ncol); |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1864 | set_column_flag(tree, col, GNT_TREE_COLUMN_INVISIBLE, !vis); |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1865 | if (vis) { |
|
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1866 | /* the column is visible */ |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1867 | if (tree->priv->lastvisible < col) |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1868 | tree->priv->lastvisible = col; |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1869 | } else { |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1870 | if (tree->priv->lastvisible == col) |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1871 | while (tree->priv->lastvisible) { |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1872 | tree->priv->lastvisible--; |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1873 | if (!COLUMN_INVISIBLE(tree, tree->priv->lastvisible)) |
|
18624
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1874 | break; |
|
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1875 | } |
|
03d4eb6b6684
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18598
diff
changeset
|
1876 | } |
|
21273
2f91b326b3f0
Minor adjustments to prevent a crash, correct a data type and fix drawing.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21263
diff
changeset
|
1877 | if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED)) |
|
2f91b326b3f0
Minor adjustments to prevent a crash, correct a data type and fix drawing.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21263
diff
changeset
|
1878 | readjust_columns(tree); |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1879 | } |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1880 | |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1881 | void gnt_tree_set_column_resizable(GntTree *tree, int col, gboolean res) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1882 | { |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1883 | g_return_if_fail(col < tree->ncol); |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1884 | set_column_flag(tree, col, GNT_TREE_COLUMN_FIXED_SIZE, !res); |
|
16030
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
1885 | } |
|
fb61f4100934
Allow making some columns invisible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16027
diff
changeset
|
1886 | |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1887 | void gnt_tree_set_column_is_binary(GntTree *tree, int col, gboolean bin) |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1888 | { |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1889 | g_return_if_fail(col < tree->ncol); |
| 29342 | 1890 | set_column_flag(tree, col, GNT_TREE_COLUMN_BINARY_DATA, bin); |
|
18598
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1891 | } |
|
946f9240fe5c
Allow storing non-string binary data in tree columns.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18559
diff
changeset
|
1892 | |
|
18632
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
1893 | void gnt_tree_set_column_is_right_aligned(GntTree *tree, int col, gboolean right) |
|
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
1894 | { |
|
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
1895 | g_return_if_fail(col < tree->ncol); |
|
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
1896 | set_column_flag(tree, col, GNT_TREE_COLUMN_RIGHT_ALIGNED, right); |
|
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
1897 | } |
|
c7a3b70f0ae7
Allow showing right-aligned text trees. Right-align the size in the file
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18624
diff
changeset
|
1898 | |
|
18558
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1899 | void gnt_tree_set_column_width_ratio(GntTree *tree, int cols[]) |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1900 | { |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1901 | int i; |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1902 | for (i = 0; i < tree->ncol && cols[i]; i++) { |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1903 | tree->columns[i].width_ratio = cols[i]; |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1904 | } |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1905 | } |
|
1a90a2b56443
Resize tree-columns nicely when the tree is resized. We can tell it to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18403
diff
changeset
|
1906 | |
|
18786
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1907 | void gnt_tree_set_search_column(GntTree *tree, int col) |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1908 | { |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1909 | g_return_if_fail(col < tree->ncol); |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1910 | g_return_if_fail(!BINARY_DATA(tree, col)); |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1911 | tree->priv->search_column = col; |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1912 | } |
|
87d4f1e609cb
Allow setting the search column in a tree to use for typeahead searching.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18783
diff
changeset
|
1913 | |
|
18787
a96af97dc501
New feature: successful compilation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18786
diff
changeset
|
1914 | gboolean gnt_tree_is_searching(GntTree *tree) |
|
a96af97dc501
New feature: successful compilation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18786
diff
changeset
|
1915 | { |
|
a96af97dc501
New feature: successful compilation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18786
diff
changeset
|
1916 | return (tree->priv->search != NULL); |
|
a96af97dc501
New feature: successful compilation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18786
diff
changeset
|
1917 | } |
|
a96af97dc501
New feature: successful compilation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18786
diff
changeset
|
1918 | |
|
18827
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
1919 | void gnt_tree_set_search_function(GntTree *tree, |
|
18829
35138e0fbf77
Patch from Javeed Shaikh to make the search function non-braindamaged.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18827
diff
changeset
|
1920 | gboolean (*func)(GntTree *tree, gpointer key, const char *search, const char *current)) |
|
18827
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
1921 | { |
|
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
1922 | tree->priv->search_func = func; |
|
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
1923 | } |
|
822e004cae0c
Allow using custom search functions.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
1924 | |
|
22284
1eaf3526de19
Function to get the parent key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21804
diff
changeset
|
1925 | gpointer gnt_tree_get_parent_key(GntTree *tree, gpointer key) |
|
1eaf3526de19
Function to get the parent key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21804
diff
changeset
|
1926 | { |
|
1eaf3526de19
Function to get the parent key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21804
diff
changeset
|
1927 | GntTreeRow *row = g_hash_table_lookup(tree->hash, key); |
|
22301
75467c2623a0
This is supposed to return the key, not the row itself.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22284
diff
changeset
|
1928 | return (row && row->parent) ? row->parent->key : NULL; |
|
22284
1eaf3526de19
Function to get the parent key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21804
diff
changeset
|
1929 | } |
|
1eaf3526de19
Function to get the parent key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21804
diff
changeset
|
1930 | |
|
30499
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1931 | gpointer gnt_tree_row_get_key(GntTree *tree, GntTreeRow *row) |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1932 | { |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1933 | g_return_val_if_fail(row && row->tree == tree, NULL); |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1934 | return row->key; |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1935 | } |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1936 | |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1937 | GntTreeRow * gnt_tree_row_get_next(GntTree *tree, GntTreeRow *row) |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1938 | { |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1939 | g_return_val_if_fail(row && row->tree == tree, NULL); |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1940 | return row->next; |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1941 | } |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1942 | |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1943 | GntTreeRow * gnt_tree_row_get_prev(GntTree *tree, GntTreeRow *row) |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1944 | { |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1945 | g_return_val_if_fail(row && row->tree == tree, NULL); |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1946 | return row->prev; |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1947 | } |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1948 | |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1949 | GntTreeRow * gnt_tree_row_get_child(GntTree *tree, GntTreeRow *row) |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1950 | { |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1951 | g_return_val_if_fail(row && row->tree == tree, NULL); |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1952 | return row->child; |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1953 | } |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1954 | |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1955 | GntTreeRow * gnt_tree_row_get_parent(GntTree *tree, GntTreeRow *row) |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1956 | { |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1957 | g_return_val_if_fail(row && row->tree == tree, NULL); |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1958 | return row->parent; |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1959 | } |
|
19e9d4a69086
Make the combobox a tiny bit friendlier.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29377
diff
changeset
|
1960 | |
| 35594 | 1961 | /************************************************************************** |
| 1962 | * GntTreeRow GBoxed API | |
| 1963 | **************************************************************************/ | |
| 1964 | static GntTreeRow * | |
|
35596
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1965 | gnt_tree_row_ref(GntTreeRow *row) |
| 35594 | 1966 | { |
| 1967 | g_return_val_if_fail(row != NULL, NULL); | |
| 1968 | ||
|
35596
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1969 | row->box_count++; |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1970 | |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1971 | return row; |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1972 | } |
| 35594 | 1973 | |
|
35596
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1974 | static void |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1975 | gnt_tree_row_unref(GntTreeRow *row) |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1976 | { |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1977 | g_return_if_fail(row != NULL); |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1978 | g_return_if_fail(row->box_count >= 0); |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1979 | |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1980 | if (!row->box_count--) |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1981 | free_tree_row(row); |
| 35594 | 1982 | } |
| 1983 | ||
| 1984 | GType | |
| 1985 | gnt_tree_row_get_type(void) | |
| 1986 | { | |
| 1987 | static GType type = 0; | |
| 1988 | ||
| 1989 | if (type == 0) { | |
| 1990 | type = g_boxed_type_register_static("GntTreeRow", | |
|
35596
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1991 | (GBoxedCopyFunc)gnt_tree_row_ref, |
|
5b4df5b31fb2
Use a box reference count for GntTreeRow's GBoxed copy and free functions
Ankit Vani <a@nevitus.org>
parents:
35594
diff
changeset
|
1992 | (GBoxedFreeFunc)gnt_tree_row_unref); |
| 35594 | 1993 | } |
| 1994 | ||
| 1995 | return type; | |
| 1996 | } |