Mercurial > pidgin.yaz
annotate console/libgnt/gntcombobox.c @ 14876:70623f0d5cdc
[gaim-migrate @ 17645]
Use terminfo/termcap information (from ncurses) as much as possible. There
still need to be some manual 'refinement' based on $TERM. I'll see if I
can get rid of those. Also, I am probably going to allow users to provide
information that terminfo can't provide, like the keycode for ctrl+up etc.
Let me know if any of the keybinding doesn't work.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 01 Nov 2006 03:38:23 +0000 |
parents | d18b9360ba54 |
children | 065e7ac30338 |
rev | line source |
---|---|
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gntbox.h" |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 #include "gntcombobox.h" |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 #include "gnttree.h" |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 #include "gntmarshal.h" |
14344
ed771d01239b
[gaim-migrate @ 17046]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
5 #include "gntutils.h" |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 #include <string.h> |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 enum |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 SIG_SELECTION_CHANGED, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 SIGS, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 }; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 static GntWidgetClass *parent_class = NULL; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 static guint signals[SIGS] = { 0 }; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 static void (*widget_lost_focus)(GntWidget *widget); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 set_selection(GntComboBox *box, gpointer key) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 if (box->selected != key) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 { |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
24 /* XXX: make sure the key actually does exist */ |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 gpointer old = box->selected; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 box->selected = key; |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
27 if (GNT_WIDGET(box)->window) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
28 gnt_widget_draw(GNT_WIDGET(box)); |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
29 if (box->dropdown) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
30 gnt_tree_set_selected(GNT_TREE(box->dropdown), key); |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
31 g_signal_emit(box, signals[SIG_SELECTION_CHANGED], 0, old, key); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 gnt_combo_box_draw(GntWidget *widget) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 GntComboBox *box = GNT_COMBO_BOX(widget); |
14420
c4a32405af68
[gaim-migrate @ 17128]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14344
diff
changeset
|
39 char *text = NULL, *s; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 GntColorType type; |
13936
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
41 int len; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 |
14344
ed771d01239b
[gaim-migrate @ 17046]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
43 if (box->dropdown && box->selected) |
14047
c5bfede33622
[gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14042
diff
changeset
|
44 text = gnt_tree_get_selection_text(GNT_TREE(box->dropdown)); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 if (text == NULL) |
14344
ed771d01239b
[gaim-migrate @ 17046]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
47 text = g_strdup(""); |
13936
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
48 |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 if (gnt_widget_has_focus(widget)) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 type = GNT_COLOR_HIGHLIGHT; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 else |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 type = GNT_COLOR_NORMAL; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 wbkgdset(widget->window, '\0' | COLOR_PAIR(type)); |
13936
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
55 |
14420
c4a32405af68
[gaim-migrate @ 17128]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14344
diff
changeset
|
56 s = (char*)gnt_util_onscreen_width_to_pointer(text, widget->priv.width - 4, &len); |
c4a32405af68
[gaim-migrate @ 17128]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14344
diff
changeset
|
57 *s = '\0'; |
13936
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
58 |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 mvwprintw(widget->window, 1, 1, text); |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
60 whline(widget->window, ' ' | COLOR_PAIR(type), widget->priv.width - 4 - len); |
13936
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
61 mvwaddch(widget->window, 1, widget->priv.width - 3, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL)); |
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
62 mvwaddch(widget->window, 1, widget->priv.width - 2, ACS_DARROW | COLOR_PAIR(GNT_COLOR_NORMAL)); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 |
13936
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
64 g_free(text); |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14420
diff
changeset
|
65 GNTDEBUG; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
69 gnt_combo_box_size_request(GntWidget *widget) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 { |
14062
fa8f65cd912c
[gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14047
diff
changeset
|
71 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED)) |
fa8f65cd912c
[gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14047
diff
changeset
|
72 { |
fa8f65cd912c
[gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14047
diff
changeset
|
73 GntWidget *dd = GNT_COMBO_BOX(widget)->dropdown; |
fa8f65cd912c
[gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14047
diff
changeset
|
74 gnt_widget_size_request(dd); |
fa8f65cd912c
[gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14047
diff
changeset
|
75 widget->priv.height = 3; /* For now, a combobox will have border */ |
14132
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
76 widget->priv.width = MAX(10, dd->priv.width + 4); |
14062
fa8f65cd912c
[gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14047
diff
changeset
|
77 } |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
79 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
80 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
81 gnt_combo_box_map(GntWidget *widget) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
83 if (widget->priv.width == 0 || widget->priv.height == 0) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 gnt_widget_size_request(widget); |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14420
diff
changeset
|
85 GNTDEBUG; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
86 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
88 static void |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
89 popup_dropdown(GntComboBox *box) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
90 { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
91 GntWidget *widget = GNT_WIDGET(box); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
92 GntWidget *parent = box->dropdown->parent; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
93 int height = g_list_length(GNT_TREE(box->dropdown)->list); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
94 int y = widget->priv.y + widget->priv.height - 1; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
95 gnt_widget_set_size(box->dropdown, widget->priv.width, height + 2); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
96 |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
97 if (y + height + 2 >= getmaxy(stdscr)) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
98 y = widget->priv.y - height - 1; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
99 gnt_widget_set_position(parent, widget->priv.x, y); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
100 if (parent->window) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
101 { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
102 mvwin(parent->window, y, widget->priv.x); |
14344
ed771d01239b
[gaim-migrate @ 17046]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
103 wresize(parent->window, height+2, widget->priv.width); |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
104 } |
14723
d18b9360ba54
[gaim-migrate @ 17477]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14493
diff
changeset
|
105 parent->priv.width = widget->priv.width; |
d18b9360ba54
[gaim-migrate @ 17477]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14493
diff
changeset
|
106 parent->priv.height = height + 2; |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
107 |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
108 gnt_widget_draw(parent); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
109 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
110 |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 static gboolean |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 gnt_combo_box_key_pressed(GntWidget *widget, const char *text) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 GntComboBox *box = GNT_COMBO_BOX(widget); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 if (GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED)) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 if (text[1] == 0) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 switch (text[0]) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 case '\r': |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 case '\t': |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 set_selection(box, gnt_tree_get_selection_data(GNT_TREE(box->dropdown))); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 case 27: |
14047
c5bfede33622
[gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14042
diff
changeset
|
125 gnt_tree_set_selected(GNT_TREE(box->dropdown), box->selected); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 gnt_widget_hide(box->dropdown->parent); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 return TRUE; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 break; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 if (gnt_widget_key_pressed(box->dropdown, text)) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 return TRUE; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 else |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 if (text[0] == 27) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 { |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14723
diff
changeset
|
138 if (strcmp(text, GNT_KEY_UP) == 0 || |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14723
diff
changeset
|
139 strcmp(text, GNT_KEY_DOWN) == 0) |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 { |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
141 popup_dropdown(box); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 return TRUE; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 return FALSE; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 gnt_combo_box_destroy(GntWidget *widget) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 gnt_widget_destroy(GNT_COMBO_BOX(widget)->dropdown->parent); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
154 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 gnt_combo_box_lost_focus(GntWidget *widget) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
158 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 GntComboBox *combo = GNT_COMBO_BOX(widget); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 if (GNT_WIDGET_IS_FLAG_SET(combo->dropdown->parent, GNT_WIDGET_MAPPED)) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 gnt_widget_hide(GNT_COMBO_BOX(widget)->dropdown->parent); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 widget_lost_focus(widget); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
163 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
164 |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
165 static gboolean |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
166 gnt_combo_box_clicked(GntWidget *widget, GntMouseEvent event, int x, int y) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
167 { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
168 GntComboBox *box = GNT_COMBO_BOX(widget); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
169 gboolean dshowing = GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
170 |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
171 if (event == GNT_MOUSE_SCROLL_UP) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
172 if (dshowing) |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14723
diff
changeset
|
173 gnt_widget_key_pressed(box->dropdown, GNT_KEY_UP); |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
174 } else if (event == GNT_MOUSE_SCROLL_DOWN) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
175 if (dshowing) |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14723
diff
changeset
|
176 gnt_widget_key_pressed(box->dropdown, GNT_KEY_DOWN); |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
177 } else if (event == GNT_LEFT_MOUSE_DOWN) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
178 if (dshowing) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
179 set_selection(box, gnt_tree_get_selection_data(GNT_TREE(box->dropdown))); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
180 gnt_widget_hide(box->dropdown->parent); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
181 } else { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
182 popup_dropdown(GNT_COMBO_BOX(widget)); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
183 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
184 } else |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
185 return FALSE; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
186 return TRUE; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
187 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
188 |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
189 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
190 gnt_combo_box_class_init(GntComboBoxClass *klass) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
191 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
192 parent_class = GNT_WIDGET_CLASS(klass); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
193 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
194 parent_class->destroy = gnt_combo_box_destroy; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
195 parent_class->draw = gnt_combo_box_draw; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
196 parent_class->map = gnt_combo_box_map; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
197 parent_class->size_request = gnt_combo_box_size_request; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
198 parent_class->key_pressed = gnt_combo_box_key_pressed; |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
199 parent_class->clicked = gnt_combo_box_clicked; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
200 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
201 widget_lost_focus = parent_class->lost_focus; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
202 parent_class->lost_focus = gnt_combo_box_lost_focus; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
203 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
204 signals[SIG_SELECTION_CHANGED] = |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
205 g_signal_new("selection-changed", |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
206 G_TYPE_FROM_CLASS(klass), |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
207 G_SIGNAL_RUN_LAST, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
208 0, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
209 NULL, NULL, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
210 gnt_closure_marshal_VOID__POINTER_POINTER, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
211 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
212 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14420
diff
changeset
|
213 GNTDEBUG; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
214 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
215 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 gnt_combo_box_init(GTypeInstance *instance, gpointer class) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
218 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
219 GntWidget *box; |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13936
diff
changeset
|
220 GntWidget *widget = GNT_WIDGET(instance); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
221 GntComboBox *combo = GNT_COMBO_BOX(instance); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
222 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
223 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(instance), |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
224 GNT_WIDGET_GROW_X | GNT_WIDGET_CAN_TAKE_FOCUS | GNT_WIDGET_NO_SHADOW); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
225 combo->dropdown = gnt_tree_new(); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
226 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
227 box = gnt_box_new(FALSE, FALSE); |
14047
c5bfede33622
[gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14042
diff
changeset
|
228 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER | GNT_WIDGET_TRANSIENT); |
13936
669898e6aa11
[gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13935
diff
changeset
|
229 gnt_box_set_pad(GNT_BOX(box), 0); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
230 gnt_box_add_widget(GNT_BOX(box), combo->dropdown); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
231 |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13936
diff
changeset
|
232 widget->priv.minw = 4; |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13936
diff
changeset
|
233 widget->priv.minh = 3; |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14420
diff
changeset
|
234 GNTDEBUG; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
235 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
236 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
237 /****************************************************************************** |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
238 * GntComboBox API |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
239 *****************************************************************************/ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
240 GType |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
241 gnt_combo_box_get_gtype(void) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
242 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
243 static GType type = 0; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
244 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
245 if(type == 0) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
246 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
247 static const GTypeInfo info = { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
248 sizeof(GntComboBoxClass), |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
249 NULL, /* base_init */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
250 NULL, /* base_finalize */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
251 (GClassInitFunc)gnt_combo_box_class_init, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 NULL, /* class_finalize */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
253 NULL, /* class_data */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 sizeof(GntComboBox), |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 0, /* n_preallocs */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 gnt_combo_box_init, /* instance_init */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
257 }; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
258 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
259 type = g_type_register_static(GNT_TYPE_WIDGET, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
260 "GntComboBox", |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
261 &info, 0); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
262 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
263 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
264 return type; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
265 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
266 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
267 GntWidget *gnt_combo_box_new() |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
268 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
269 GntWidget *widget = g_object_new(GNT_TYPE_COMBO_BOX, NULL); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
270 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 return widget; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
272 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
273 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
274 void gnt_combo_box_add_data(GntComboBox *box, gpointer key, const char *text) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
275 { |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
276 gnt_tree_add_row_last(GNT_TREE(box->dropdown), key, |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
277 gnt_tree_create_row(GNT_TREE(box->dropdown), text), NULL); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
278 if (box->selected == NULL) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
279 set_selection(box, key); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
280 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
281 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
282 gpointer gnt_combo_box_get_selected_data(GntComboBox *box) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
283 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
284 return box->selected; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
285 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
286 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
287 void gnt_combo_box_set_selected(GntComboBox *box, gpointer key) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
288 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
289 set_selection(box, key); |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
290 } |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
291 |
14493
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
292 void gnt_combo_box_remove(GntComboBox *box, gpointer key) |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
293 { |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
294 gnt_tree_remove(GNT_TREE(box->dropdown), key); |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
295 if (box->selected == key) |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
296 set_selection(box, NULL); |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
297 } |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
298 |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
299 void gnt_combo_box_remove_all(GntComboBox *box) |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
300 { |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
301 gnt_tree_remove_all(GNT_TREE(box->dropdown)); |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
302 set_selection(box, NULL); |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
303 } |
5ac8f22e7b08
[gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
304 |