annotate console/libgnt/gntcombobox.c @ 15806:a0a5e323a6ac

libpurplify the 'make check' tests so they work again
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 17 Mar 2007 17:29:40 +0000
parents 2273694a865d
children 1c8f1dc50685
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
15741
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
36 hide_popup(GntComboBox *box, gboolean set)
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
37 {
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
38 gnt_widget_set_size(box->dropdown,
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
39 box->dropdown->priv.width - 1, box->dropdown->priv.height);
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
40 if (set)
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
41 set_selection(box, gnt_tree_get_selection_data(GNT_TREE(box->dropdown)));
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
42 else
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
43 gnt_tree_set_selected(GNT_TREE(box->dropdown), box->selected);
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
44 gnt_widget_hide(box->dropdown->parent);
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
45 }
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
46
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
47 static void
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 gnt_combo_box_draw(GntWidget *widget)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 GntComboBox *box = GNT_COMBO_BOX(widget);
14420
c4a32405af68 [gaim-migrate @ 17128]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14344
diff changeset
51 char *text = NULL, *s;
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 GntColorType type;
13936
669898e6aa11 [gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
53 int len;
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54
14344
ed771d01239b [gaim-migrate @ 17046]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
55 if (box->dropdown && box->selected)
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
56 text = gnt_tree_get_selection_text(GNT_TREE(box->dropdown));
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 if (text == NULL)
14344
ed771d01239b [gaim-migrate @ 17046]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
59 text = g_strdup("");
13936
669898e6aa11 [gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
60
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 if (gnt_widget_has_focus(widget))
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 type = GNT_COLOR_HIGHLIGHT;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 else
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 type = GNT_COLOR_NORMAL;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 wbkgdset(widget->window, '\0' | COLOR_PAIR(type));
13936
669898e6aa11 [gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
67
14420
c4a32405af68 [gaim-migrate @ 17128]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14344
diff changeset
68 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
69 *s = '\0';
13936
669898e6aa11 [gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
70
15587
d059cfbb62ae Patch from Richard 'wabz' Nelson. This fixes some possible crashes/exploits.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
71 mvwaddstr(widget->window, 1, 1, text);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
72 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
73 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
74 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
75
13936
669898e6aa11 [gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
76 g_free(text);
14432
3ac156db9cb6 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14420
diff changeset
77 GNTDEBUG;
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_size_request(GntWidget *widget)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
83 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED))
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
84 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
85 GntWidget *dd = GNT_COMBO_BOX(widget)->dropdown;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
86 gnt_widget_size_request(dd);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
87 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
88 widget->priv.width = MAX(10, dd->priv.width + 4);
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
89 }
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 }
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 static void
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 gnt_combo_box_map(GntWidget *widget)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 if (widget->priv.width == 0 || widget->priv.height == 0)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 gnt_widget_size_request(widget);
14432
3ac156db9cb6 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14420
diff changeset
97 GNTDEBUG;
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 }
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
100 static void
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
101 popup_dropdown(GntComboBox *box)
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
102 {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
103 GntWidget *widget = GNT_WIDGET(box);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
104 GntWidget *parent = box->dropdown->parent;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
105 int height = g_list_length(GNT_TREE(box->dropdown)->list);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
106 int y = widget->priv.y + widget->priv.height - 1;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
107 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
108
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
109 if (y + height + 2 >= getmaxy(stdscr))
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
110 y = widget->priv.y - height - 1;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
111 gnt_widget_set_position(parent, widget->priv.x, y);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
112 if (parent->window)
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
113 {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
114 mvwin(parent->window, y, widget->priv.x);
14344
ed771d01239b [gaim-migrate @ 17046]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
115 wresize(parent->window, height+2, widget->priv.width);
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
116 }
14723
d18b9360ba54 [gaim-migrate @ 17477]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
117 parent->priv.width = widget->priv.width;
d18b9360ba54 [gaim-migrate @ 17477]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
118 parent->priv.height = height + 2;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
119
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14876
diff changeset
120 GNT_WIDGET_UNSET_FLAGS(parent, GNT_WIDGET_INVISIBLE);
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
121 gnt_widget_draw(parent);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
122 }
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
123
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 static gboolean
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 gnt_combo_box_key_pressed(GntWidget *widget, const char *text)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 GntComboBox *box = GNT_COMBO_BOX(widget);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 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
129 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 if (text[1] == 0)
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 switch (text[0])
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 case '\r':
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 case '\t':
15741
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
136 hide_popup(box, TRUE);
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
137 return TRUE;
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 case 27:
15741
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
139 hide_popup(box, FALSE);
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 if (gnt_widget_key_pressed(box->dropdown, text))
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 return TRUE;
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 else
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 if (text[0] == 27)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 {
14876
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14723
diff changeset
150 if (strcmp(text, GNT_KEY_UP) == 0 ||
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14723
diff changeset
151 strcmp(text, GNT_KEY_DOWN) == 0)
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 {
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
153 popup_dropdown(box);
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154 return TRUE;
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 }
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157 }
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 return FALSE;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 }
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 static void
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 gnt_combo_box_destroy(GntWidget *widget)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 gnt_widget_destroy(GNT_COMBO_BOX(widget)->dropdown->parent);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 }
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 static void
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 gnt_combo_box_lost_focus(GntWidget *widget)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 GntComboBox *combo = GNT_COMBO_BOX(widget);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 if (GNT_WIDGET_IS_FLAG_SET(combo->dropdown->parent, GNT_WIDGET_MAPPED))
15741
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
173 hide_popup(combo, FALSE);
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 widget_lost_focus(widget);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 }
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
177 static gboolean
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
178 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
179 {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
180 GntComboBox *box = GNT_COMBO_BOX(widget);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
181 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
182
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
183 if (event == GNT_MOUSE_SCROLL_UP) {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
184 if (dshowing)
14876
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14723
diff changeset
185 gnt_widget_key_pressed(box->dropdown, GNT_KEY_UP);
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
186 } else if (event == GNT_MOUSE_SCROLL_DOWN) {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
187 if (dshowing)
14876
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14723
diff changeset
188 gnt_widget_key_pressed(box->dropdown, GNT_KEY_DOWN);
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
189 } else if (event == GNT_LEFT_MOUSE_DOWN) {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
190 if (dshowing) {
15741
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
191 hide_popup(box, TRUE);
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
192 } else {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
193 popup_dropdown(GNT_COMBO_BOX(widget));
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
194 }
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
195 } else
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
196 return FALSE;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
197 return TRUE;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
198 }
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
199
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 static void
15741
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
201 gnt_combo_box_size_changed(GntWidget *widget, int oldw, int oldh)
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
202 {
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
203 GntComboBox *box = GNT_COMBO_BOX(widget);
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
204 gnt_widget_set_size(box->dropdown, widget->priv.width - 1, box->dropdown->priv.height);
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
205 }
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
206
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
207 static void
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 gnt_combo_box_class_init(GntComboBoxClass *klass)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 parent_class = GNT_WIDGET_CLASS(klass);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 parent_class->destroy = gnt_combo_box_destroy;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 parent_class->draw = gnt_combo_box_draw;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 parent_class->map = gnt_combo_box_map;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 parent_class->size_request = gnt_combo_box_size_request;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216 parent_class->key_pressed = gnt_combo_box_key_pressed;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
217 parent_class->clicked = gnt_combo_box_clicked;
15741
2273694a865d gntcombobox: lost_focus fix, tidy tree size
Richard Nelson <wabz@pidgin.im>
parents: 15587
diff changeset
218 parent_class->size_changed = gnt_combo_box_size_changed;
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 widget_lost_focus = parent_class->lost_focus;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 parent_class->lost_focus = gnt_combo_box_lost_focus;
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 signals[SIG_SELECTION_CHANGED] =
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 g_signal_new("selection-changed",
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 G_TYPE_FROM_CLASS(klass),
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 G_SIGNAL_RUN_LAST,
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 0,
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 NULL, NULL,
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 gnt_closure_marshal_VOID__POINTER_POINTER,
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231
14432
3ac156db9cb6 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14420
diff changeset
232 GNTDEBUG;
13935
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 static void
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 gnt_combo_box_init(GTypeInstance *instance, gpointer class)
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 GntWidget *box;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
239 GntWidget *widget = GNT_WIDGET(instance);
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 GntComboBox *combo = GNT_COMBO_BOX(instance);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(instance),
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 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
244 combo->dropdown = gnt_tree_new();
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246 box = gnt_box_new(FALSE, FALSE);
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
247 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
248 gnt_box_set_pad(GNT_BOX(box), 0);
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 gnt_box_add_widget(GNT_BOX(box), combo->dropdown);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
251 widget->priv.minw = 4;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
252 widget->priv.minh = 3;
14432
3ac156db9cb6 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14420
diff changeset
253 GNTDEBUG;
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 }
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 * GntComboBox API
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 GType
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 gnt_combo_box_get_gtype(void)
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 static GType type = 0;
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 if(type == 0)
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 static const GTypeInfo info = {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267 sizeof(GntComboBoxClass),
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268 NULL, /* base_init */
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 NULL, /* base_finalize */
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270 (GClassInitFunc)gnt_combo_box_class_init,
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 NULL, /* class_finalize */
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272 NULL, /* class_data */
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 sizeof(GntComboBox),
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 0, /* n_preallocs */
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275 gnt_combo_box_init, /* instance_init */
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 };
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 type = g_type_register_static(GNT_TYPE_WIDGET,
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279 "GntComboBox",
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280 &info, 0);
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
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
283 return type;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 }
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 GntWidget *gnt_combo_box_new()
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288 GntWidget *widget = g_object_new(GNT_TYPE_COMBO_BOX, NULL);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290 return widget;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291 }
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 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
294 {
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
295 gnt_tree_add_row_last(GNT_TREE(box->dropdown), key,
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
296 gnt_tree_create_row(GNT_TREE(box->dropdown), text), NULL);
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297 if (box->selected == NULL)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
298 set_selection(box, key);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299 }
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301 gpointer gnt_combo_box_get_selected_data(GntComboBox *box)
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 return box->selected;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304 }
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305
13979
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
306 void gnt_combo_box_set_selected(GntComboBox *box, gpointer key)
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
307 {
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
308 set_selection(box, key);
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
309 }
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
310
14493
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
311 void gnt_combo_box_remove(GntComboBox *box, gpointer key)
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
312 {
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
313 gnt_tree_remove(GNT_TREE(box->dropdown), key);
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
314 if (box->selected == key)
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
315 set_selection(box, NULL);
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
316 }
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
317
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
318 void gnt_combo_box_remove_all(GntComboBox *box)
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
319 {
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
320 gnt_tree_remove_all(GNT_TREE(box->dropdown));
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
321 set_selection(box, NULL);
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
322 }
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14432
diff changeset
323