Mercurial > pidgin.yaz
comparison console/libgnt/gntcombobox.c @ 15741:2273694a865d
gntcombobox: lost_focus fix, tidy tree size
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Tue, 27 Feb 2007 04:58:18 +0000 |
parents | d059cfbb62ae |
children | 1c8f1dc50685 |
comparison
equal
deleted
inserted
replaced
15740:73219517f583 | 15741:2273694a865d |
---|---|
31 g_signal_emit(box, signals[SIG_SELECTION_CHANGED], 0, old, key); | 31 g_signal_emit(box, signals[SIG_SELECTION_CHANGED], 0, old, key); |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
35 static void | 35 static void |
36 hide_popup(GntComboBox *box, gboolean set) | |
37 { | |
38 gnt_widget_set_size(box->dropdown, | |
39 box->dropdown->priv.width - 1, box->dropdown->priv.height); | |
40 if (set) | |
41 set_selection(box, gnt_tree_get_selection_data(GNT_TREE(box->dropdown))); | |
42 else | |
43 gnt_tree_set_selected(GNT_TREE(box->dropdown), box->selected); | |
44 gnt_widget_hide(box->dropdown->parent); | |
45 } | |
46 | |
47 static void | |
36 gnt_combo_box_draw(GntWidget *widget) | 48 gnt_combo_box_draw(GntWidget *widget) |
37 { | 49 { |
38 GntComboBox *box = GNT_COMBO_BOX(widget); | 50 GntComboBox *box = GNT_COMBO_BOX(widget); |
39 char *text = NULL, *s; | 51 char *text = NULL, *s; |
40 GntColorType type; | 52 GntColorType type; |
119 { | 131 { |
120 switch (text[0]) | 132 switch (text[0]) |
121 { | 133 { |
122 case '\r': | 134 case '\r': |
123 case '\t': | 135 case '\t': |
124 set_selection(box, gnt_tree_get_selection_data(GNT_TREE(box->dropdown))); | 136 hide_popup(box, TRUE); |
137 return TRUE; | |
125 case 27: | 138 case 27: |
126 gnt_tree_set_selected(GNT_TREE(box->dropdown), box->selected); | 139 hide_popup(box, FALSE); |
127 gnt_widget_hide(box->dropdown->parent); | |
128 return TRUE; | 140 return TRUE; |
129 break; | |
130 } | 141 } |
131 } | 142 } |
132 if (gnt_widget_key_pressed(box->dropdown, text)) | 143 if (gnt_widget_key_pressed(box->dropdown, text)) |
133 return TRUE; | 144 return TRUE; |
134 } | 145 } |
157 static void | 168 static void |
158 gnt_combo_box_lost_focus(GntWidget *widget) | 169 gnt_combo_box_lost_focus(GntWidget *widget) |
159 { | 170 { |
160 GntComboBox *combo = GNT_COMBO_BOX(widget); | 171 GntComboBox *combo = GNT_COMBO_BOX(widget); |
161 if (GNT_WIDGET_IS_FLAG_SET(combo->dropdown->parent, GNT_WIDGET_MAPPED)) | 172 if (GNT_WIDGET_IS_FLAG_SET(combo->dropdown->parent, GNT_WIDGET_MAPPED)) |
162 gnt_widget_hide(GNT_COMBO_BOX(widget)->dropdown->parent); | 173 hide_popup(combo, FALSE); |
163 widget_lost_focus(widget); | 174 widget_lost_focus(widget); |
164 } | 175 } |
165 | 176 |
166 static gboolean | 177 static gboolean |
167 gnt_combo_box_clicked(GntWidget *widget, GntMouseEvent event, int x, int y) | 178 gnt_combo_box_clicked(GntWidget *widget, GntMouseEvent event, int x, int y) |
175 } else if (event == GNT_MOUSE_SCROLL_DOWN) { | 186 } else if (event == GNT_MOUSE_SCROLL_DOWN) { |
176 if (dshowing) | 187 if (dshowing) |
177 gnt_widget_key_pressed(box->dropdown, GNT_KEY_DOWN); | 188 gnt_widget_key_pressed(box->dropdown, GNT_KEY_DOWN); |
178 } else if (event == GNT_LEFT_MOUSE_DOWN) { | 189 } else if (event == GNT_LEFT_MOUSE_DOWN) { |
179 if (dshowing) { | 190 if (dshowing) { |
180 set_selection(box, gnt_tree_get_selection_data(GNT_TREE(box->dropdown))); | 191 hide_popup(box, TRUE); |
181 gnt_widget_hide(box->dropdown->parent); | |
182 } else { | 192 } else { |
183 popup_dropdown(GNT_COMBO_BOX(widget)); | 193 popup_dropdown(GNT_COMBO_BOX(widget)); |
184 } | 194 } |
185 } else | 195 } else |
186 return FALSE; | 196 return FALSE; |
187 return TRUE; | 197 return TRUE; |
188 } | 198 } |
189 | 199 |
190 static void | 200 static void |
201 gnt_combo_box_size_changed(GntWidget *widget, int oldw, int oldh) | |
202 { | |
203 GntComboBox *box = GNT_COMBO_BOX(widget); | |
204 gnt_widget_set_size(box->dropdown, widget->priv.width - 1, box->dropdown->priv.height); | |
205 } | |
206 | |
207 static void | |
191 gnt_combo_box_class_init(GntComboBoxClass *klass) | 208 gnt_combo_box_class_init(GntComboBoxClass *klass) |
192 { | 209 { |
193 parent_class = GNT_WIDGET_CLASS(klass); | 210 parent_class = GNT_WIDGET_CLASS(klass); |
194 | 211 |
195 parent_class->destroy = gnt_combo_box_destroy; | 212 parent_class->destroy = gnt_combo_box_destroy; |
196 parent_class->draw = gnt_combo_box_draw; | 213 parent_class->draw = gnt_combo_box_draw; |
197 parent_class->map = gnt_combo_box_map; | 214 parent_class->map = gnt_combo_box_map; |
198 parent_class->size_request = gnt_combo_box_size_request; | 215 parent_class->size_request = gnt_combo_box_size_request; |
199 parent_class->key_pressed = gnt_combo_box_key_pressed; | 216 parent_class->key_pressed = gnt_combo_box_key_pressed; |
200 parent_class->clicked = gnt_combo_box_clicked; | 217 parent_class->clicked = gnt_combo_box_clicked; |
218 parent_class->size_changed = gnt_combo_box_size_changed; | |
201 | 219 |
202 widget_lost_focus = parent_class->lost_focus; | 220 widget_lost_focus = parent_class->lost_focus; |
203 parent_class->lost_focus = gnt_combo_box_lost_focus; | 221 parent_class->lost_focus = gnt_combo_box_lost_focus; |
204 | 222 |
205 signals[SIG_SELECTION_CHANGED] = | 223 signals[SIG_SELECTION_CHANGED] = |