Mercurial > pidgin
comparison console/gntblist.c @ 14010:7573bd40a190
[gaim-migrate @ 16602]
Allow plugins to be loaded and unloaded.
Remember the window positions and sizes.
All turning on/off shadow from ~/.gntrc (off by default).
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 31 Jul 2006 23:19:12 +0000 |
parents | 0a0d2a1fd2bc |
children | 35699556075f |
comparison
equal
deleted
inserted
replaced
14009:1e283c3566ab | 14010:7573bd40a190 |
---|---|
10 #include "gntlabel.h" | 10 #include "gntlabel.h" |
11 #include "gnttree.h" | 11 #include "gnttree.h" |
12 | 12 |
13 #include "gntblist.h" | 13 #include "gntblist.h" |
14 #include <string.h> | 14 #include <string.h> |
15 | |
16 #define PREF_ROOT "/gaim/gnt/blist" | |
15 | 17 |
16 typedef struct | 18 typedef struct |
17 { | 19 { |
18 GntWidget *window; | 20 GntWidget *window; |
19 GntWidget *tree; | 21 GntWidget *tree; |
272 | 274 |
273 static void | 275 static void |
274 gnt_append_menu_action(GntTree *tree, GaimMenuAction *action, gpointer parent) | 276 gnt_append_menu_action(GntTree *tree, GaimMenuAction *action, gpointer parent) |
275 { | 277 { |
276 GList *list; | 278 GList *list; |
279 if (action == NULL) | |
280 return; | |
277 | 281 |
278 gnt_tree_add_row_after(tree, action, | 282 gnt_tree_add_row_after(tree, action, |
279 gnt_tree_create_row(tree, action->label), parent, NULL); | 283 gnt_tree_create_row(tree, action->label), parent, NULL); |
280 for (list = action->children; list; list = list->next) | 284 for (list = action->children; list; list = list->next) |
281 gnt_append_menu_action(tree, list->data, action); | 285 gnt_append_menu_action(tree, list->data, action); |
675 remove_tooltip(ggblist); | 679 remove_tooltip(ggblist); |
676 else if (ggblist->context) | 680 else if (ggblist->context) |
677 remove_context_menu(ggblist); | 681 remove_context_menu(ggblist); |
678 } | 682 } |
679 | 683 |
684 static void | |
685 size_changed_cb(GntWidget *w, int width, int height) | |
686 { | |
687 gaim_prefs_set_int(PREF_ROOT "/size/width", width); | |
688 gaim_prefs_set_int(PREF_ROOT "/size/height", height); | |
689 } | |
690 | |
691 static void | |
692 save_position_cb(GntWidget *w, int x, int y) | |
693 { | |
694 gaim_prefs_set_int(PREF_ROOT "/position/x", x); | |
695 gaim_prefs_set_int(PREF_ROOT "/position/y", y); | |
696 } | |
697 | |
680 void gg_blist_init() | 698 void gg_blist_init() |
681 { | 699 { |
700 gaim_prefs_add_none(PREF_ROOT); | |
701 gaim_prefs_add_none(PREF_ROOT "/size"); | |
702 gaim_prefs_add_int(PREF_ROOT "/size/width", 20); | |
703 gaim_prefs_add_int(PREF_ROOT "/size/height", 20); | |
704 gaim_prefs_add_none(PREF_ROOT "/position"); | |
705 gaim_prefs_add_int(PREF_ROOT "/position/x", 0); | |
706 gaim_prefs_add_int(PREF_ROOT "/position/y", 0); | |
707 | |
682 ggblist = g_new0(GGBlist, 1); | 708 ggblist = g_new0(GGBlist, 1); |
683 | 709 |
684 gaim_get_blist()->ui_data = ggblist; | 710 gaim_get_blist()->ui_data = ggblist; |
685 | 711 |
686 ggblist->window = gnt_box_new(FALSE, FALSE); | 712 ggblist->window = gnt_box_new(FALSE, FALSE); |
690 gnt_box_set_pad(GNT_BOX(ggblist->window), 0); | 716 gnt_box_set_pad(GNT_BOX(ggblist->window), 0); |
691 | 717 |
692 ggblist->tree = gnt_tree_new(); | 718 ggblist->tree = gnt_tree_new(); |
693 GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER); | 719 GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER); |
694 gnt_tree_set_col_width(GNT_TREE(ggblist->tree), 0, 25); | 720 gnt_tree_set_col_width(GNT_TREE(ggblist->tree), 0, 25); |
695 gnt_widget_set_size(ggblist->tree, 0, getmaxy(stdscr) - 4); | 721 gnt_widget_set_size(ggblist->tree, gaim_prefs_get_int(PREF_ROOT "/size/width"), |
722 gaim_prefs_get_int(PREF_ROOT "/size/height")); | |
723 gnt_widget_set_position(ggblist->window, gaim_prefs_get_int(PREF_ROOT "/position/x"), | |
724 gaim_prefs_get_int(PREF_ROOT "/position/y")); | |
696 | 725 |
697 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree); | 726 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree); |
698 gnt_widget_show(ggblist->window); | 727 gnt_widget_show(ggblist->window); |
699 | 728 |
700 gaim_signal_connect(gaim_blist_get_handle(), "buddy-status-changed", gg_blist_get_handle(), | 729 gaim_signal_connect(gaim_blist_get_handle(), "buddy-status-changed", gg_blist_get_handle(), |
723 g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist); | 752 g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist); |
724 g_signal_connect_data(G_OBJECT(ggblist->tree), "gained-focus", G_CALLBACK(draw_tooltip), | 753 g_signal_connect_data(G_OBJECT(ggblist->tree), "gained-focus", G_CALLBACK(draw_tooltip), |
725 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); | 754 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); |
726 g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_peripherals), | 755 g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_peripherals), |
727 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); | 756 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); |
757 g_signal_connect(G_OBJECT(ggblist->tree), "size_changed", G_CALLBACK(size_changed_cb), NULL); | |
758 g_signal_connect(G_OBJECT(ggblist->window), "position_set", G_CALLBACK(save_position_cb), NULL); | |
759 | |
728 } | 760 } |
729 | 761 |
730 void gg_blist_uninit() | 762 void gg_blist_uninit() |
731 { | 763 { |
732 gnt_widget_destroy(ggblist->window); | 764 gnt_widget_destroy(ggblist->window); |