comparison finch/libgnt/gnttree.c @ 16203:4f6a6443a1e3

emit/handle gnttree signals appropriately
author Richard Nelson <wabz@pidgin.im>
date Mon, 16 Apr 2007 05:19:07 +0000
parents bc280c341679
children f02e611bdb6b
comparison
equal deleted inserted replaced
16201:36b09c6f7957 16203:4f6a6443a1e3
44 struct _GntTreeCol 44 struct _GntTreeCol
45 { 45 {
46 char *text; 46 char *text;
47 int span; /* How many columns does it span? */ 47 int span; /* How many columns does it span? */
48 }; 48 };
49
50 static void tree_selection_changed(GntTree *, GntTreeRow *, GntTreeRow *);
49 51
50 static GntWidgetClass *parent_class = NULL; 52 static GntWidgetClass *parent_class = NULL;
51 static guint signals[SIGS] = { 0 }; 53 static guint signals[SIGS] = { 0 };
52 54
53 /* Move the item at position old to position new */ 55 /* Move the item at position old to position new */
338 else 340 else
339 pos = 1; 341 pos = 1;
340 342
341 if (tree->top == NULL) 343 if (tree->top == NULL)
342 tree->top = tree->root; 344 tree->top = tree->root;
343 if (tree->current == NULL) 345 if (tree->current == NULL) {
344 tree->current = tree->root; 346 tree->current = tree->root;
347 tree_selection_changed(tree, NULL, tree->current);
348 }
345 349
346 wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL)); 350 wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL));
347 351
348 start = 0; 352 start = 0;
349 if (tree->show_title) 353 if (tree->show_title)
1392 1396
1393 void gnt_tree_set_selected(GntTree *tree , void *key) 1397 void gnt_tree_set_selected(GntTree *tree , void *key)
1394 { 1398 {
1395 int dist; 1399 int dist;
1396 GntTreeRow *row = g_hash_table_lookup(tree->hash, key); 1400 GntTreeRow *row = g_hash_table_lookup(tree->hash, key);
1397 if (!row) 1401 if (!row || row == tree->current)
1398 return; 1402 return;
1399 1403
1400 if (tree->top == NULL) 1404 if (tree->top == NULL)
1401 tree->top = row; 1405 tree->top = row;
1402 if (tree->bottom == NULL) 1406 if (tree->bottom == NULL)
1407 gnt_tree_scroll(tree, -dist); 1411 gnt_tree_scroll(tree, -dist);
1408 else if ((dist = get_distance(tree->current, tree->top)) > 0) 1412 else if ((dist = get_distance(tree->current, tree->top)) > 0)
1409 gnt_tree_scroll(tree, -dist); 1413 gnt_tree_scroll(tree, -dist);
1410 else 1414 else
1411 redraw_tree(tree); 1415 redraw_tree(tree);
1416 tree_selection_changed(tree, row, tree->current);
1412 } 1417 }
1413 1418
1414 void _gnt_tree_init_internals(GntTree *tree, int col) 1419 void _gnt_tree_init_internals(GntTree *tree, int col)
1415 { 1420 {
1416 tree->ncol = col; 1421 tree->ncol = col;
1512 GntTreeRow *row = g_hash_table_lookup(tree->hash, key); 1517 GntTreeRow *row = g_hash_table_lookup(tree->hash, key);
1513 if (row) { 1518 if (row) {
1514 row->collapsed = !expanded; 1519 row->collapsed = !expanded;
1515 if (GNT_WIDGET(tree)->window) 1520 if (GNT_WIDGET(tree)->window)
1516 gnt_widget_draw(GNT_WIDGET(tree)); 1521 gnt_widget_draw(GNT_WIDGET(tree));
1522 g_signal_emit(tree, signals[SIG_COLLAPSED], 0, key, row->collapsed);
1517 } 1523 }
1518 } 1524 }
1519 1525
1520 void gnt_tree_set_show_separator(GntTree *tree, gboolean set) 1526 void gnt_tree_set_show_separator(GntTree *tree, gboolean set)
1521 { 1527 {