Mercurial > pidgin.yaz
annotate console/libgnt/gntcombobox.c @ 14420:c4a32405af68
[gaim-migrate @ 17128]
Keep things neat and clean in gnt_util_onscreen_width_to_pointer.
The only use of this function currently is to truncate a string to
make sure it fits in the drawing area, eg, the title of a window,
or in the combobox. The function is called on a newly allocated
string, which is truncated (if necessary), printed, and freed.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 02 Sep 2006 18:55:27 +0000 |
parents | ed771d01239b |
children | 3ac156db9cb6 |
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); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 DEBUG; |
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); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 DEBUG; |
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 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
105 |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
106 gnt_widget_draw(parent); |
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 |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 static gboolean |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 gnt_combo_box_key_pressed(GntWidget *widget, const char *text) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 GntComboBox *box = GNT_COMBO_BOX(widget); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 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
|
114 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 if (text[1] == 0) |
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 switch (text[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 case '\r': |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 case '\t': |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 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
|
122 case 27: |
14047
c5bfede33622
[gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14042
diff
changeset
|
123 gnt_tree_set_selected(GNT_TREE(box->dropdown), box->selected); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 gnt_widget_hide(box->dropdown->parent); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 return TRUE; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 break; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 if (gnt_widget_key_pressed(box->dropdown, text)) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 return TRUE; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 else |
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 if (text[0] == 27) |
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 (strcmp(text + 1, GNT_KEY_UP) == 0 || |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 strcmp(text + 1, GNT_KEY_DOWN) == 0) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 { |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
139 popup_dropdown(box); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 return TRUE; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 } |
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 return FALSE; |
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 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 gnt_combo_box_destroy(GntWidget *widget) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 gnt_widget_destroy(GNT_COMBO_BOX(widget)->dropdown->parent); |
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 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
154 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 gnt_combo_box_lost_focus(GntWidget *widget) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 GntComboBox *combo = GNT_COMBO_BOX(widget); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
158 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
|
159 gnt_widget_hide(GNT_COMBO_BOX(widget)->dropdown->parent); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 widget_lost_focus(widget); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
163 static gboolean |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
164 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
|
165 { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
166 GntComboBox *box = GNT_COMBO_BOX(widget); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
167 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
|
168 |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
169 if (event == GNT_MOUSE_SCROLL_UP) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
170 if (dshowing) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
171 gnt_widget_key_pressed(box->dropdown, "\033" GNT_KEY_UP); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
172 } else if (event == GNT_MOUSE_SCROLL_DOWN) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
173 if (dshowing) |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
174 gnt_widget_key_pressed(box->dropdown, "\033" GNT_KEY_DOWN); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
175 } else if (event == GNT_LEFT_MOUSE_DOWN) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
176 if (dshowing) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
177 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
|
178 gnt_widget_hide(box->dropdown->parent); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
179 } else { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
180 popup_dropdown(GNT_COMBO_BOX(widget)); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
181 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
182 } else |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
183 return FALSE; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
184 return TRUE; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
185 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
186 |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
187 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
188 gnt_combo_box_class_init(GntComboBoxClass *klass) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
189 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
190 parent_class = GNT_WIDGET_CLASS(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->destroy = gnt_combo_box_destroy; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
193 parent_class->draw = gnt_combo_box_draw; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
194 parent_class->map = gnt_combo_box_map; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
195 parent_class->size_request = gnt_combo_box_size_request; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
196 parent_class->key_pressed = gnt_combo_box_key_pressed; |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14132
diff
changeset
|
197 parent_class->clicked = gnt_combo_box_clicked; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
198 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
199 widget_lost_focus = parent_class->lost_focus; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
200 parent_class->lost_focus = gnt_combo_box_lost_focus; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
201 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
202 signals[SIG_SELECTION_CHANGED] = |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
203 g_signal_new("selection-changed", |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
204 G_TYPE_FROM_CLASS(klass), |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
205 G_SIGNAL_RUN_LAST, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
206 0, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
207 NULL, NULL, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
208 gnt_closure_marshal_VOID__POINTER_POINTER, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
209 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
210 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
211 DEBUG; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
212 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
213 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
214 static void |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
215 gnt_combo_box_init(GTypeInstance *instance, gpointer class) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 GntWidget *box; |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13936
diff
changeset
|
218 GntWidget *widget = GNT_WIDGET(instance); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
219 GntComboBox *combo = GNT_COMBO_BOX(instance); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
220 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
221 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(instance), |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
222 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
|
223 combo->dropdown = gnt_tree_new(); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
224 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
225 box = gnt_box_new(FALSE, FALSE); |
14047
c5bfede33622
[gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14042
diff
changeset
|
226 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
|
227 gnt_box_set_pad(GNT_BOX(box), 0); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
228 gnt_box_add_widget(GNT_BOX(box), combo->dropdown); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
229 |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13936
diff
changeset
|
230 widget->priv.minw = 4; |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13936
diff
changeset
|
231 widget->priv.minh = 3; |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
232 DEBUG; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
233 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
234 |
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 * GntComboBox API |
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 GType |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
239 gnt_combo_box_get_gtype(void) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
240 { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
241 static GType type = 0; |
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 if(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 static const GTypeInfo info = { |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
246 sizeof(GntComboBoxClass), |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
247 NULL, /* base_init */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
248 NULL, /* base_finalize */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
249 (GClassInitFunc)gnt_combo_box_class_init, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
250 NULL, /* class_finalize */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
251 NULL, /* class_data */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 sizeof(GntComboBox), |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
253 0, /* n_preallocs */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 gnt_combo_box_init, /* instance_init */ |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 }; |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
257 type = g_type_register_static(GNT_TYPE_WIDGET, |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
258 "GntComboBox", |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
259 &info, 0); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
260 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
261 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
262 return type; |
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 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
265 GntWidget *gnt_combo_box_new() |
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 *widget = g_object_new(GNT_TYPE_COMBO_BOX, NULL); |
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 return widget; |
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 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
272 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
|
273 { |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
274 gnt_tree_add_row_last(GNT_TREE(box->dropdown), key, |
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
275 gnt_tree_create_row(GNT_TREE(box->dropdown), text), NULL); |
13935
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
276 if (box->selected == NULL) |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
277 set_selection(box, key); |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
278 } |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
279 |
cd2da4b079cf
[gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
280 gpointer gnt_combo_box_get_selected_data(GntComboBox *box) |
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 return box->selected; |
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 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
285 void gnt_combo_box_set_selected(GntComboBox *box, gpointer key) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
286 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
287 set_selection(box, 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 |