comparison finch/libgnt/gnttree.h @ 18419:e79da0369a6d

Docs for GntTree.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 03 Jul 2007 01:50:16 +0000
parents 9a0f99ea664d
children e2b8b17fc62c
comparison
equal deleted inserted replaced
18418:b51dcbac4798 18419:e79da0369a6d
101 }; 101 };
102 102
103 G_BEGIN_DECLS 103 G_BEGIN_DECLS
104 104
105 /** 105 /**
106 * 106 * @return The GType for GntTree
107 *
108 * @return
109 */ 107 */
110 GType gnt_tree_get_gtype(void); 108 GType gnt_tree_get_gtype(void);
111 109
112 /** 110 /**
113 * 111 * Create a tree with one column.
114 * 112 *
115 * @return 113 * @return The newly created tree
114 *
115 * @see gnt_tree_new_with_columns
116 */ 116 */
117 GntWidget * gnt_tree_new(void); 117 GntWidget * gnt_tree_new(void);
118 118
119 /* A tree with just one column */ 119 /**
120 120 * Create a tree with a specified number of columns.
121 /** 121 *
122 * 122 * @param columns Number of columns
123 * @param columns 123 *
124 * 124 * @return The newly created tree
125 * @return 125 *
126 * @see gnt_tree_new
126 */ 127 */
127 GntWidget * gnt_tree_new_with_columns(int columns); 128 GntWidget * gnt_tree_new_with_columns(int columns);
128 129
129 /** 130 /**
130 * 131 * The number of rows the tree should display at a time.
131 * @param tree 132 *
132 * @param rows 133 * @param tree The tree
134 * @param rows The number of rows
133 */ 135 */
134 void gnt_tree_set_visible_rows(GntTree *tree, int rows); 136 void gnt_tree_set_visible_rows(GntTree *tree, int rows);
135 137
136 /** 138 /**
137 * 139 * Get the number visible rows.
138 * @param tree 140 *
139 * 141 * @param tree The tree
140 * @return 142 *
143 * @return The number of visible rows
141 */ 144 */
142 int gnt_tree_get_visible_rows(GntTree *tree); 145 int gnt_tree_get_visible_rows(GntTree *tree);
143 146
144 /** 147 /**
145 * 148 * Scroll the contents of the tree.
146 * @param tree 149 *
147 * @param count 150 * @param tree The tree
151 * @param count If positive, the tree will be scrolled down by count rows,
152 * otherwise, it will be scrolled up by count rows.
148 */ 153 */
149 void gnt_tree_scroll(GntTree *tree, int count); 154 void gnt_tree_scroll(GntTree *tree, int count);
150 155
151 /** 156 /**
152 * 157 * Insert a row in the tree.
153 * @param tree 158 *
154 * @param key 159 * @param tree The tree
155 * @param row 160 * @param key The key for the row
156 * @param parent 161 * @param row The row to insert
157 * @param bigbro 162 * @param parent The key for the parent row
158 * 163 * @param bigbro The key for the row to insert the new row after.
159 * @return 164 *
165 * @return The inserted row
166 *
167 * @see gnt_tree_create_row
168 * @see gnt_tree_add_row_last
169 * @see gnt_tree_add_choice
160 */ 170 */
161 GntTreeRow * gnt_tree_add_row_after(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro); 171 GntTreeRow * gnt_tree_add_row_after(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro);
162 172
163 /** 173 /**
164 * 174 * Insert a row at the end of the tree.
165 * @param tree 175 *
166 * @param key 176 * @param tree The tree
167 * @param row 177 * @param key The key for the row
168 * @param parent 178 * @param row The row to insert
169 * 179 * @param parent The key for the parent row
170 * @return 180 *
181 * @return The inserted row
182 *
183 * @see gnt_tree_create_row
184 * @see gnt_tree_add_row_after
185 * @see gnt_tree_add_choice
171 */ 186 */
172 GntTreeRow * gnt_tree_add_row_last(GntTree *tree, void *key, GntTreeRow *row, void *parent); 187 GntTreeRow * gnt_tree_add_row_last(GntTree *tree, void *key, GntTreeRow *row, void *parent);
173 188
174 /** 189 /**
175 * 190 * Get the key for the selected row.
176 * @param tree 191 *
177 * 192 * @param tree The tree
178 * @return 193 *
194 * @return The key for the selected row
179 */ 195 */
180 gpointer gnt_tree_get_selection_data(GntTree *tree); 196 gpointer gnt_tree_get_selection_data(GntTree *tree);
181 197
182 /* Returned string needs to be freed */ 198 /**
183 /** 199 * Get the text displayed for the selected row.
184 * 200 *
185 * @param tree 201 * @param tree The tree
186 * 202 *
187 * @return 203 * @return The text, which needs to be freed by the caller
188 */ 204 */
189 char * gnt_tree_get_selection_text(GntTree *tree); 205 char * gnt_tree_get_selection_text(GntTree *tree);
190 206
191 /** 207 /**
192 * 208 * Get a list of text of the current row.
193 * @param tree 209 *
194 * 210 * @param tree The tree
195 * @return 211 *
212 * @return A list of texts of the currently selected row. The list
213 * and its data should be freed by the caller.
196 */ 214 */
197 GList * gnt_tree_get_selection_text_list(GntTree *tree); 215 GList * gnt_tree_get_selection_text_list(GntTree *tree);
198 216
199 /** 217 /**
200 * 218 * Returns the list of rows in the tree.
201 * @param tree 219 *
202 * 220 * @param tree The tree
203 * @constreturn 221 *
222 * @return The list of the rows. The list should not be modified by the caller.
204 */ 223 */
205 GList *gnt_tree_get_rows(GntTree *tree); 224 GList *gnt_tree_get_rows(GntTree *tree);
206 225
207 /** 226 /**
208 * 227 * Remove a row from the tree.
209 * @param tree 228 *
210 * @param key 229 * @param tree The tree
230 * @param key The key for the row to remove
211 */ 231 */
212 void gnt_tree_remove(GntTree *tree, gpointer key); 232 void gnt_tree_remove(GntTree *tree, gpointer key);
213 233
214 /** 234 /**
215 * 235 * Remove all the item from the tree.
216 * @param tree 236 *
237 * @param tree The tree
217 */ 238 */
218 void gnt_tree_remove_all(GntTree *tree); 239 void gnt_tree_remove_all(GntTree *tree);
219 240
220 /* Returns the visible line number of the selected row */ 241 /**
221 /** 242 * Get the visible line number of the selected row.
222 * 243 *
223 * @param tree 244 * @param tree The tree
224 * 245 *
225 * @return 246 * @return The line number of the currently selected row
226 */ 247 */
227 int gnt_tree_get_selection_visible_line(GntTree *tree); 248 int gnt_tree_get_selection_visible_line(GntTree *tree);
228 249
229 /** 250 /**
230 * 251 * Change the text of a column in a row.
231 * @param tree 252 *
232 * @param key 253 * @param tree The tree
233 * @param colno 254 * @param key The key for the row
234 * @param text 255 * @param colno The index of the column
256 * @param text The new text
235 */ 257 */
236 void gnt_tree_change_text(GntTree *tree, gpointer key, int colno, const char *text); 258 void gnt_tree_change_text(GntTree *tree, gpointer key, int colno, const char *text);
237 259
238 /** 260 /**
239 * 261 * Add a checkable item in the tree.
240 * @param tree 262 *
241 * @param key 263 * @param tree The tree
242 * @param row 264 * @param key The key for the row
243 * @param parent 265 * @param row The row to add
244 * @param bigbro 266 * @param parent The parent of the row, or @c NULL
245 * 267 * @param bigbro The row to insert after, or @c NULL
246 * @return 268 *
269 * @return The row inserted.
270 *
271 * @see gnt_tree_create_row
272 * @see gnt_tree_create_row_from_list
273 * @see gnt_tree_add_row_last
274 * @see gnt_tree_add_row_after
247 */ 275 */
248 GntTreeRow * gnt_tree_add_choice(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro); 276 GntTreeRow * gnt_tree_add_choice(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro);
249 277
250 /** 278 /**
251 * 279 * Set whether a checkable item is checked or not.
252 * @param tree 280 *
253 * @param key 281 * @param tree The tree
254 * @param set 282 * @param key The key for the row
283 * @param set @c TRUE if the item should be checked, @c FALSE if not
255 */ 284 */
256 void gnt_tree_set_choice(GntTree *tree, void *key, gboolean set); 285 void gnt_tree_set_choice(GntTree *tree, void *key, gboolean set);
257 286
258 /** 287 /**
259 * 288 * Return whether a row is selected or not, where the row is a checkable item.
260 * @param tree 289 *
261 * @param key 290 * @param tree The tree
262 * 291 * @param key The key for the row
263 * @return 292 *
293 * @return @c TRUE if the row is checked, @c FALSE otherwise.
264 */ 294 */
265 gboolean gnt_tree_get_choice(GntTree *tree, void *key); 295 gboolean gnt_tree_get_choice(GntTree *tree, void *key);
266 296
267 /** 297 /**
268 * 298 * Set flags for the text in a row in the tree.
269 * @param tree 299 *
270 * @param key 300 * @param tree The tree
271 * @param flags 301 * @param key The key for the row
302 * @param flags The flags to set
272 */ 303 */
273 void gnt_tree_set_row_flags(GntTree *tree, void *key, GntTextFormatFlags flags); 304 void gnt_tree_set_row_flags(GntTree *tree, void *key, GntTextFormatFlags flags);
274 305
275 /** 306 /**
276 * 307 * Select a row.
277 * @param key 308 *
309 * @param tree The tree
310 * @param key The key of the row to select
278 */ 311 */
279 void gnt_tree_set_selected(GntTree *tree , void *key); 312 void gnt_tree_set_selected(GntTree *tree , void *key);
280 313
281 /** 314 /**
282 * 315 * Create a row to insert in the tree.
283 * @param tree 316 *
284 * 317 * @param tree The tree
285 * @return 318 * @param ... A string for each column in the tree
319 *
320 * @return The row
321 *
322 * @see gnt_tree_create_row_from_list
323 * @see gnt_tree_add_row_after
324 * @see gnt_tree_add_row_last
325 * @see gnt_tree_add_choice
286 */ 326 */
287 GntTreeRow * gnt_tree_create_row(GntTree *tree, ...); 327 GntTreeRow * gnt_tree_create_row(GntTree *tree, ...);
288 328
289 /** 329 /**
290 * 330 * Create a row from a list of text.
291 * @param tree 331 *
292 * @param list 332 * @param tree The tree
293 * 333 * @param list The list containing the text for each column
294 * @return 334 *
335 * @return The row
336 *
337 * @see gnt_tree_create_row
338 * @see gnt_tree_add_row_after
339 * @see gnt_tree_add_row_last
340 * @see gnt_tree_add_choice
295 */ 341 */
296 GntTreeRow * gnt_tree_create_row_from_list(GntTree *tree, GList *list); 342 GntTreeRow * gnt_tree_create_row_from_list(GntTree *tree, GList *list);
297 343
298 /** 344 /**
299 * 345 * Set the width of a column in the tree.
300 * @param tree 346 *
301 * @param col 347 * @param tree The tree
302 * @param width 348 * @param col The index of the column
349 * @param width The width for the column
350 *
351 * @see gnt_tree_set_column_width_ratio
352 * @see gnt_tree_set_column_resizable
303 */ 353 */
304 void gnt_tree_set_col_width(GntTree *tree, int col, int width); 354 void gnt_tree_set_col_width(GntTree *tree, int col, int width);
305 355
306 /** 356 /**
307 * Set the title for a column. 357 * Set the title for a column.
308 * 358 *
309 * @param tree The tree 359 * @param tree The tree
310 * @param index The index of the column 360 * @param index The index of the column
311 * @param title The title for the column 361 * @param title The title for the column
362 *
363 * @see gnt_tree_set_column_titles
364 * @see gnt_tree_set_show_title
312 */ 365 */
313 void gnt_tree_set_column_title(GntTree *tree, int index, const char *title); 366 void gnt_tree_set_column_title(GntTree *tree, int index, const char *title);
314 367
315 /** 368 /**
316 * 369 * Set the titles of the columns
317 * @param tree 370 *
371 * @param tree The tree
372 * @param ... One title for each column in the tree
373 *
374 * @see gnt_tree_set_column_title
375 * @see gnt_tree_set_show_title
318 */ 376 */
319 void gnt_tree_set_column_titles(GntTree *tree, ...); 377 void gnt_tree_set_column_titles(GntTree *tree, ...);
320 378
321 /** 379 /**
322 * 380 * Set whether to display the title of the columns.
323 * @param tree 381 *
324 * @param set 382 * @param tree The tree
383 * @param set If @c TRUE, the column titles are displayed
384 *
385 * @see gnt_tree_set_column_title
386 * @see gnt_tree_set_column_titles
325 */ 387 */
326 void gnt_tree_set_show_title(GntTree *tree, gboolean set); 388 void gnt_tree_set_show_title(GntTree *tree, gboolean set);
327 389
328 /** 390 /**
329 * 391 * Set the compare function for sorting the data.
330 * @param tree 392 *
331 * @param func 393 * @param tree The tree
394 * @param func The comparison function, which is used to compare
395 * the keys
396 *
397 * @see gnt_tree_sort_row
332 */ 398 */
333 void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func); 399 void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func);
334 400
335 /** 401 /**
336 * 402 * Set whether a row, which has child rows, should be expanded.
337 * @param tree 403 *
338 * @param key 404 * @param tree The tree
339 * @param expanded 405 * @param key The key of the row
406 * @param expanded Whether to expand the child rows
340 */ 407 */
341 void gnt_tree_set_expanded(GntTree *tree, void *key, gboolean expanded); 408 void gnt_tree_set_expanded(GntTree *tree, void *key, gboolean expanded);
342 409
343 /** 410 /**
344 * 411 * Set whether to show column separators.
345 * @param tree 412 *
346 * @param set 413 * @param tree The tree
414 * @param set If @c TRUE, the column separators are displayed
347 */ 415 */
348 void gnt_tree_set_show_separator(GntTree *tree, gboolean set); 416 void gnt_tree_set_show_separator(GntTree *tree, gboolean set);
349 417
350 /** 418 /**
351 * 419 * Sort a row in the tree.
352 * @param tree 420 *
353 * @param row 421 * @param tree The tree
422 * @param row The row to sort
423 *
424 * @see gnt_tree_set_compare_func
354 */ 425 */
355 void gnt_tree_sort_row(GntTree *tree, void *row); 426 void gnt_tree_sort_row(GntTree *tree, void *row);
356 427
357 /* This will try to automatically adjust the width of the columns in the tree */ 428 /**
358 /** 429 * Automatically adjust the width of the columns in the tree.
359 * 430 *
360 * @param tree 431 * @param tree The tree
361 */ 432 */
362 void gnt_tree_adjust_columns(GntTree *tree); 433 void gnt_tree_adjust_columns(GntTree *tree);
363 434
364 /** 435 /**
365 * 436 * Set the hash functions to use to hash, compare and free the keys.
366 * @param tree 437 *
367 * @param hash 438 * @param tree The tree
368 * @param eq 439 * @param hash The hashing function
369 * @param kd 440 * @param eq The function to compare keys
441 * @param kd The function to use to free the keys when a row is removed
442 * from the tree
370 */ 443 */
371 void gnt_tree_set_hash_fns(GntTree *tree, gpointer hash, gpointer eq, gpointer kd); 444 void gnt_tree_set_hash_fns(GntTree *tree, gpointer hash, gpointer eq, gpointer kd);
372 445
373 /** 446 /**
374 * Set whether a column is visible or not. 447 * Set whether a column is visible or not.
387 * 460 *
388 * @param tree The tree 461 * @param tree The tree
389 * @param col The index of the column 462 * @param col The index of the column
390 * @param res If @c FALSE, the column will not be resized when the 463 * @param res If @c FALSE, the column will not be resized when the
391 * tree is resized 464 * tree is resized
465 *
466 * @see gnt_tree_set_col_width
467 * @see gnt_tree_set_column_width_ratio
392 */ 468 */
393 void gnt_tree_set_column_resizable(GntTree *tree, int col, gboolean res); 469 void gnt_tree_set_column_resizable(GntTree *tree, int col, gboolean res);
394 470
395 /** 471 /**
396 * Set column widths to use when calculating column widths after a tree 472 * Set column widths to use when calculating column widths after a tree
398 * 474 *
399 * @param tree The tree 475 * @param tree The tree
400 * @param cols Array of widths. The width must have the same number 476 * @param cols Array of widths. The width must have the same number
401 * of entries as the number of columns in the tree, or 477 * of entries as the number of columns in the tree, or
402 * end with a negative value for a column-width. 478 * end with a negative value for a column-width.
479 *
480 * @see gnt_tree_set_col_width
481 * @see gnt_tree_set_column_resizable
403 */ 482 */
404 void gnt_tree_set_column_width_ratio(GntTree *tree, int cols[]); 483 void gnt_tree_set_column_width_ratio(GntTree *tree, int cols[]);
405 484
406 G_END_DECLS 485 G_END_DECLS
407 486
408 /* The following functions should NOT be used by applications. */ 487 /* The following functions should NOT be used by applications. */
409 488
410 /* This should be called by the subclasses of GntTree's in their _new function */ 489 /* This should be called by the subclasses of GntTree's in their _new function */
411 /**
412 *
413 * @param tree
414 * @param col
415 */
416 void _gnt_tree_init_internals(GntTree *tree, int col); 490 void _gnt_tree_init_internals(GntTree *tree, int col);
417 491
418 #endif /* GNT_TREE_H */ 492 #endif /* GNT_TREE_H */