Mercurial > pidgin
comparison console/libgnt/gnttree.c @ 14900:065e7ac30338
[gaim-migrate @ 17672]
Rearranging a bunch of stuff. Users shouldn't notice any change, apart from
the added ability to bind keys for the window-manager. I will update the manual
in a while.
I need to know how to revert a commit in case things go terribly wrong.
... I am going to remind everyone that Dido is AWESOME!
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 05 Nov 2006 17:28:33 +0000 |
parents | 70623f0d5cdc |
children | e601bc7880a6 |
comparison
equal
deleted
inserted
replaced
14899:a8f92a837590 | 14900:065e7ac30338 |
---|---|
481 { | 481 { |
482 g_signal_emit(tree, signals[SIG_SELECTION_CHANGED], 0, old->key, current->key); | 482 g_signal_emit(tree, signals[SIG_SELECTION_CHANGED], 0, old->key, current->key); |
483 } | 483 } |
484 | 484 |
485 static gboolean | 485 static gboolean |
486 action_down(GntWidget *widget, GList *null) | 486 action_down(GntBindable *bind, GList *null) |
487 { | 487 { |
488 int dist; | 488 int dist; |
489 GntTree *tree = GNT_TREE(widget); | 489 GntTree *tree = GNT_TREE(bind); |
490 GntTreeRow *old = tree->current; | 490 GntTreeRow *old = tree->current; |
491 GntTreeRow *row = get_next(tree->current); | 491 GntTreeRow *row = get_next(tree->current); |
492 if (row == NULL) | 492 if (row == NULL) |
493 return FALSE; | 493 return FALSE; |
494 tree->current = row; | 494 tree->current = row; |
500 tree_selection_changed(tree, old, tree->current); | 500 tree_selection_changed(tree, old, tree->current); |
501 return TRUE; | 501 return TRUE; |
502 } | 502 } |
503 | 503 |
504 static gboolean | 504 static gboolean |
505 action_up(GntWidget *widget, GList *list) | 505 action_up(GntBindable *bind, GList *list) |
506 { | 506 { |
507 int dist; | 507 int dist; |
508 GntTree *tree = GNT_TREE(widget); | 508 GntTree *tree = GNT_TREE(bind); |
509 GntTreeRow *old = tree->current; | 509 GntTreeRow *old = tree->current; |
510 GntTreeRow *row = get_prev(tree->current); | 510 GntTreeRow *row = get_prev(tree->current); |
511 if (!row) | 511 if (!row) |
512 return FALSE; | 512 return FALSE; |
513 tree->current = row; | 513 tree->current = row; |
520 | 520 |
521 return TRUE; | 521 return TRUE; |
522 } | 522 } |
523 | 523 |
524 static gboolean | 524 static gboolean |
525 action_page_down(GntWidget *widget, GList *null) | 525 action_page_down(GntBindable *bind, GList *null) |
526 { | 526 { |
527 GntTree *tree = GNT_TREE(widget); | 527 GntTree *tree = GNT_TREE(bind); |
528 GntTreeRow *old = tree->current; | 528 GntTreeRow *old = tree->current; |
529 GntTreeRow *row = get_next(tree->bottom); | 529 GntTreeRow *row = get_next(tree->bottom); |
530 if (row) | 530 if (row) |
531 { | 531 { |
532 int dist = get_distance(tree->top, tree->current); | 532 int dist = get_distance(tree->top, tree->current); |
544 tree_selection_changed(tree, old, tree->current); | 544 tree_selection_changed(tree, old, tree->current); |
545 return TRUE; | 545 return TRUE; |
546 } | 546 } |
547 | 547 |
548 static gboolean | 548 static gboolean |
549 action_page_up(GntWidget *widget, GList *null) | 549 action_page_up(GntBindable *bind, GList *null) |
550 { | 550 { |
551 GntTree *tree = GNT_TREE(widget); | 551 GntWidget *widget = GNT_WIDGET(bind); |
552 GntTree *tree = GNT_TREE(bind); | |
552 GntTreeRow *row; | 553 GntTreeRow *row; |
553 GntTreeRow *old = tree->current; | 554 GntTreeRow *old = tree->current; |
554 | 555 |
555 if (tree->top != tree->root) | 556 if (tree->top != tree->root) |
556 { | 557 { |
629 gnt_tree_clicked(GntWidget *widget, GntMouseEvent event, int x, int y) | 630 gnt_tree_clicked(GntWidget *widget, GntMouseEvent event, int x, int y) |
630 { | 631 { |
631 GntTree *tree = GNT_TREE(widget); | 632 GntTree *tree = GNT_TREE(widget); |
632 GntTreeRow *old = tree->current; | 633 GntTreeRow *old = tree->current; |
633 if (event == GNT_MOUSE_SCROLL_UP) { | 634 if (event == GNT_MOUSE_SCROLL_UP) { |
634 action_up(widget, NULL); | 635 action_up(GNT_BINDABLE(widget), NULL); |
635 } else if (event == GNT_MOUSE_SCROLL_DOWN) { | 636 } else if (event == GNT_MOUSE_SCROLL_DOWN) { |
636 action_down(widget, NULL); | 637 action_down(GNT_BINDABLE(widget), NULL); |
637 } else if (event == GNT_LEFT_MOUSE_DOWN) { | 638 } else if (event == GNT_LEFT_MOUSE_DOWN) { |
638 GntTreeRow *row; | 639 GntTreeRow *row; |
639 GntTree *tree = GNT_TREE(widget); | 640 GntTree *tree = GNT_TREE(widget); |
640 int pos = 1; | 641 int pos = 1; |
641 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) | 642 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) |
668 } | 669 } |
669 | 670 |
670 static void | 671 static void |
671 gnt_tree_class_init(GntTreeClass *klass) | 672 gnt_tree_class_init(GntTreeClass *klass) |
672 { | 673 { |
674 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); | |
673 parent_class = GNT_WIDGET_CLASS(klass); | 675 parent_class = GNT_WIDGET_CLASS(klass); |
674 parent_class->destroy = gnt_tree_destroy; | 676 parent_class->destroy = gnt_tree_destroy; |
675 parent_class->draw = gnt_tree_draw; | 677 parent_class->draw = gnt_tree_draw; |
676 parent_class->map = gnt_tree_map; | 678 parent_class->map = gnt_tree_map; |
677 parent_class->size_request = gnt_tree_size_request; | 679 parent_class->size_request = gnt_tree_size_request; |
701 G_STRUCT_OFFSET(GntTreeClass, toggled), | 703 G_STRUCT_OFFSET(GntTreeClass, toggled), |
702 NULL, NULL, | 704 NULL, NULL, |
703 g_cclosure_marshal_VOID__POINTER, | 705 g_cclosure_marshal_VOID__POINTER, |
704 G_TYPE_NONE, 1, G_TYPE_POINTER); | 706 G_TYPE_NONE, 1, G_TYPE_POINTER); |
705 | 707 |
706 parent_class->actions = g_hash_table_duplicate(parent_class->actions, g_str_hash, | 708 gnt_bindable_class_register_action(bindable, "move-up", action_up, |
707 g_str_equal, g_free, (GDestroyNotify)gnt_widget_action_free); | |
708 parent_class->bindings = g_hash_table_duplicate(parent_class->bindings, g_str_hash, | |
709 g_str_equal, g_free, (GDestroyNotify)gnt_widget_action_param_free); | |
710 | |
711 gnt_widget_class_register_action(parent_class, "move-up", action_up, | |
712 GNT_KEY_UP, NULL); | 709 GNT_KEY_UP, NULL); |
713 gnt_widget_register_binding(parent_class, "move-up", GNT_KEY_CTRL_P, NULL); | 710 gnt_bindable_register_binding(bindable, "move-up", GNT_KEY_CTRL_P, NULL); |
714 gnt_widget_class_register_action(parent_class, "move-down", action_down, | 711 gnt_bindable_class_register_action(bindable, "move-down", action_down, |
715 GNT_KEY_DOWN, NULL); | 712 GNT_KEY_DOWN, NULL); |
716 gnt_widget_register_binding(parent_class, "move-down", GNT_KEY_CTRL_N, NULL); | 713 gnt_bindable_register_binding(bindable, "move-down", GNT_KEY_CTRL_N, NULL); |
717 gnt_widget_class_register_action(parent_class, "page-up", action_page_up, | 714 gnt_bindable_class_register_action(bindable, "page-up", action_page_up, |
718 GNT_KEY_PGUP, NULL); | 715 GNT_KEY_PGUP, NULL); |
719 gnt_widget_class_register_action(parent_class, "page-down", action_page_down, | 716 gnt_bindable_class_register_action(bindable, "page-down", action_page_down, |
720 GNT_KEY_PGDOWN, NULL); | 717 GNT_KEY_PGDOWN, NULL); |
721 | 718 |
722 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), parent_class); | 719 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable); |
723 | |
724 GNTDEBUG; | 720 GNTDEBUG; |
725 } | 721 } |
726 | 722 |
727 static void | 723 static void |
728 gnt_tree_init(GTypeInstance *instance, gpointer class) | 724 gnt_tree_init(GTypeInstance *instance, gpointer class) |