1 --- gtk+-2.6.4/gtk/gtkcombobox.c 2005-02-25 21:11:08.000000000 +0200
2 +++ gtk+-2.6.4/gtk/gtkcombobox.c 2005-04-06 16:19:36.406003808 +0300
4 * Boston, MA 02111-1307, USA.
8 + * Modified for Nokia Oyj during 2002-2004.
13 #include "gtkcombobox.h"
15 #include "gtktreeselection.h"
16 #include "gtkvseparator.h"
17 #include "gtkwindow.h"
18 +#include "gtkcomboboxentry.h"
19 +#include "gtktoolbar.h"
21 #include <gdk/gdkkeysyms.h>
25 #include "gtktreeprivate.h"
27 +#define HILDON_MAX_WIDTH 406
28 +#define HILDON_MAX_HEIGHT 305
29 +#define HILDON_MAX_ITEMS 8
30 +/* this is also defined in gtkmenu.c and should be replaced with
32 +#define MENU_SCROLL_ARROW_HEIGHT 20
34 /* WELCOME, to THE house of evil code */
36 typedef struct _ComboCellInfo ComboCellInfo;
38 GtkTreeViewRowSeparatorFunc row_separator_func;
39 gpointer row_separator_data;
40 GtkDestroyNotify row_separator_destroy;
42 + /* Hildon hack: state of our style property */
43 + gboolean autodimmed_button;
46 /* While debugging this evil code, I have learned that
49 #define BONUS_PADDING 4
50 #define SCROLL_TIME 100
51 +#define HILDON_PADDING 25
54 static void gtk_combo_box_class_init (GtkComboBoxClass *klass);
56 gboolean include_internals,
58 gpointer callback_data);
59 +static gboolean gtk_combo_box_focus_in (GtkWidget *widget,
60 + GdkEventFocus *event);
61 +static gint gtk_combo_box_focus (GtkWidget *widget,
62 + GtkDirectionType dir);
63 +static void gtk_combo_box_child_focus_in (GtkWidget *widget,
64 + GdkEventFocus *event);
65 +static void gtk_combo_box_child_focus_out (GtkWidget *widget,
66 + GdkEventFocus *event);
67 static gboolean gtk_combo_box_expose_event (GtkWidget *widget,
68 GdkEventExpose *event);
69 static gboolean gtk_combo_box_scroll_event (GtkWidget *widget,
72 static void gtk_combo_box_check_appearance (GtkComboBox *combo_box);
74 +/* <Hildon addition> */
75 +extern void gtk_grab_combo_box_entry_focus (GtkComboBoxEntry *entry_box);
77 +static void gtk_combo_box_grab_focus (GtkWidget *focus_widget);
78 +/* </hildon addition> */
80 /* listening to the model */
81 static void gtk_combo_box_model_row_inserted (GtkTreeModel *model,
84 static void gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
87 +static void gtk_combo_box_menu_position_above (GtkMenu *menu, gint *x,
88 + gint *y, gboolean *push_in,
89 + gpointer user_data);
92 gtk_combo_box_get_type (void)
94 return combo_box_type;
97 +/* Hildon addition: Check if the button needs to be dimmed */
98 +static void hildon_check_autodim(GtkComboBox *combo_box)
101 + GtkTreeModel *model;
104 + widget = combo_box->priv->button;
105 + model = combo_box->priv->model;
107 + if (combo_box->priv->autodimmed_button && widget != NULL)
109 + if (model && gtk_tree_model_get_iter_first(model, &iter))
110 + gtk_widget_set_sensitive(widget, TRUE);
112 + gtk_widget_set_sensitive(widget, FALSE);
118 gtk_combo_box_class_init (GtkComboBoxClass *klass)
120 widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
121 widget_class->style_set = gtk_combo_box_style_set;
122 widget_class->state_changed = gtk_combo_box_state_changed;
124 + /* Hildon addition */
125 + widget_class->grab_focus = gtk_combo_box_grab_focus;
126 + widget_class->focus_in_event = gtk_combo_box_focus_in;
127 + widget_class->focus = gtk_combo_box_focus;
129 gtk_object_class = (GtkObjectClass *)klass;
130 gtk_object_class->destroy = gtk_combo_box_destroy;
135 + gtk_widget_class_install_style_property (widget_class,
136 + g_param_spec_boolean ("hildonlike",
138 + _("Size allocate"),
140 + G_PARAM_READABLE));
142 + gtk_widget_class_install_style_property (widget_class,
143 + g_param_spec_int ("arrow-height",
144 + P_("Arrow height for option menu"),
145 + P_("Sets arrow height"),
149 + G_PARAM_READWRITE));
151 + gtk_widget_class_install_style_property (widget_class,
152 + g_param_spec_int ("arrow-width",
153 + P_("Arrow width for option menu"),
154 + P_("Sets arrow width"),
158 + G_PARAM_READWRITE));
161 + /* Hildon hack: style property for enabling the autodimming hack */
162 + gtk_widget_class_install_style_property (
164 + g_param_spec_boolean ("autodimmed_button",
165 + _("Autodimmed button"),
166 + _("Automatically dims the button if the list is empty"),
168 + G_PARAM_READABLE));
170 g_type_class_add_private (object_class, sizeof (GtkComboBoxPrivate));
174 combo_box->priv->editing_canceled = FALSE;
175 combo_box->priv->auto_scroll = FALSE;
176 combo_box->priv->focus_on_click = TRUE;
178 + /* Hildon hack: default value for our style property if it is queried before
179 + * the style is set */
180 + combo_box->priv->autodimmed_button = FALSE;
181 + GTK_WIDGET_SET_FLAGS ( combo_box, GTK_CAN_FOCUS );
185 @@ -911,7 +1009,19 @@
187 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
189 + /* Hildon hack: read the state of our style property */
190 + gtk_widget_style_get (GTK_WIDGET(combo_box),
191 + "autodimmed_button", &(combo_box->priv->autodimmed_button), NULL);
193 gtk_combo_box_check_appearance (combo_box);
195 + /* Hildon hack: handle the dimmed state of the button in regards whether
196 + * the list is empty or not. This has to be done here because
197 + * in the callback functions of GtkTreeModel the button widget
198 + * may have not yet been set. However, we repeat this stuff in
199 + * those functions, because later the button will be set and
200 + * we want to update our state. */
201 + hildon_check_autodim(combo_box);
203 if (combo_box->priv->tree_view && combo_box->priv->cell_view)
204 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
205 @@ -922,10 +1032,17 @@
206 gtk_combo_box_button_toggled (GtkWidget *widget,
209 + gboolean hildonlike;
210 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
212 + gtk_widget_style_get (GTK_WIDGET (combo_box), "hildonlike", &hildonlike, NULL);
214 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
217 + gtk_combo_box_grab_focus(GTK_WIDGET(combo_box));
220 if (!combo_box->priv->popup_in_progress)
221 gtk_combo_box_popup (combo_box);
223 @@ -1103,7 +1220,7 @@
225 gtk_container_remove (GTK_CONTAINER (combo_box->priv->popup_frame),
226 combo_box->priv->popup_widget);
227 - g_object_unref (combo_box->priv->popup_widget);
228 + g_object_unref (G_OBJECT (combo_box->priv->popup_widget));
229 combo_box->priv->popup_widget = NULL;
232 @@ -1175,7 +1292,7 @@
235 gtk_widget_show (popup);
236 - g_object_ref (popup);
237 + g_object_ref (G_OBJECT (popup));
238 combo_box->priv->popup_widget = popup;
241 @@ -1250,9 +1367,13 @@
242 GtkRequisition requisition;
245 + gint screen_height;
249 + gint menu_width, menu_height;
251 + gint scroll_offset = 0;
252 + gint max_items = 0;
254 g_return_if_fail (GTK_IS_COMBO_BOX (user_data));
256 @@ -1261,6 +1382,7 @@
258 gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
259 menu_width = requisition.width;
260 + menu_height = requisition.height;
262 active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
263 gdk_window_get_origin (widget->window, &menu_xpos, &menu_ypos);
264 @@ -1275,6 +1397,11 @@
267 children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children;
268 + child = children->data;
269 + gtk_widget_get_child_requisition (child, &requisition);
270 + max_items = (HILDON_MAX_HEIGHT-2*MENU_SCROLL_ARROW_HEIGHT)/requisition.height;
275 child = children->data;
276 @@ -1284,27 +1411,119 @@
278 if (GTK_WIDGET_VISIBLE (child))
280 - gtk_widget_get_child_requisition (child, &requisition);
281 - menu_ypos -= requisition.height;
282 + if (counter < max_items - 2)
283 + menu_ypos -= requisition.height;
284 + if (counter > max_items - 3)
285 + scroll_offset += requisition.height;
290 children = children->next;
292 + gtk_widget_get_child_requisition (GTK_WIDGET(menu), &requisition);
294 + if ( requisition.height >= HILDON_MAX_HEIGHT )
295 + menu_ypos -= MENU_SCROLL_ARROW_HEIGHT;
297 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
298 menu_xpos = menu_xpos + widget->allocation.width - menu_width;
301 + gint menu_xpad, menu_ypad;
302 + gtk_widget_style_get (GTK_WIDGET (menu),
303 + "horizontal-padding", &menu_xpad,
304 + "vertical-padding", &menu_ypad,
306 + menu_xpos -= menu_xpad - 3;
307 + menu_ypos -= menu_ypad - 1;
310 /* Clamp the position on screen */
311 screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
312 + screen_height = gdk_screen_get_height (gtk_widget_get_screen (widget));
316 else if ((menu_xpos + menu_width) > screen_width)
317 menu_xpos -= ((menu_xpos + menu_width) - screen_width);
319 + if (menu_ypos + menu_height > screen_height)
321 + menu_ypos = screen_height - menu_height;
328 + GTK_MENU(combo_box->priv->popup_widget)->scroll_offset = scroll_offset;
337 +gtk_combo_box_menu_position_above (GtkMenu *menu,
341 + gpointer user_data)
344 + * This function positiones the menu above widgets.
345 + * This is a modified version of the position function
346 + * gtk_combo_box_position_over.
347 + * NB: This is only used when gtkcombobox is in toolbar!
351 + GtkRequisition requisition;
360 + widget = GTK_WIDGET(user_data);
362 + gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
363 + menu_width = requisition.width;
365 + gdk_window_get_position(GDK_WINDOW(widget->window), &gx, &gy);
366 + gtk_widget_translate_coordinates (widget, gtk_widget_get_toplevel(widget),
367 + gx, gy, &menu_xpos, &menu_ypos);
369 + menu_ypos -= GTK_WIDGET(menu)->style->ythickness * 2;
370 + menu_ypos -= GTK_WIDGET(widget)->style->ythickness * 2;
372 + menu_ypos -= widget->allocation.height;
374 + children = GTK_MENU_SHELL (menu)->children;
376 + child = children->data;
377 + if (GTK_WIDGET_VISIBLE (child)){
378 + gtk_widget_get_child_requisition (child, &requisition);
379 + menu_ypos -= requisition.height;
381 + children = children->next;
384 + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
385 + menu_xpos = menu_xpos + widget->allocation.width - menu_width;
387 + screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
391 + else if ((menu_xpos + menu_width) > screen_width)
392 + menu_xpos -= ((menu_xpos + menu_width) - screen_width);
399 @@ -1318,21 +1537,44 @@
400 GtkComboBox *combo_box;
401 GtkWidget *menu_item;
403 + gboolean hildonlike;
405 combo_box = GTK_COMBO_BOX (user_data);
407 - if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL)
408 - gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
410 + gtk_widget_style_get (GTK_WIDGET (combo_box), "hildonlike", &hildonlike, NULL);
412 + if (!(combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL))
414 /* FIXME handle nested menus better */
415 menu_item = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
417 gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget),
421 - gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
424 + /* HILDON: we check if combobox is in a toolbar */
425 + gboolean in_toolbar = gtk_widget_get_ancestor(GTK_WIDGET(combo_box), GTK_TYPE_TOOLBAR) != NULL;
428 + /*due to limits in combo's sizes we use position_over here also*/
429 + gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
434 + if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL)
436 + * Changed because we always want the combo box position to be over
437 + * the combo box, unless it's in toolbar.
439 + gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
441 + gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
443 + gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
448 @@ -1430,7 +1672,7 @@
452 - g_object_get (list->data, "sensitive", &sensitive, NULL);
453 + g_object_get (G_OBJECT (list->data), "sensitive", &sensitive, NULL);
457 @@ -1469,7 +1711,7 @@
461 - g_object_get (list->data, "sensitive", &sensitive, NULL);
462 + g_object_get (G_OBJECT (list->data), "sensitive", &sensitive, NULL);
466 @@ -1516,8 +1758,8 @@
467 if (menu != combo_box->priv->popup_widget && child == children)
469 separator = GTK_WIDGET (child->next->data);
470 - g_object_set (item, "visible", sensitive, NULL);
471 - g_object_set (separator, "visible", sensitive, NULL);
472 + g_object_set (G_OBJECT (item), "visible", sensitive, NULL);
473 + g_object_set (G_OBJECT (separator), "visible", sensitive, NULL);
476 gtk_widget_set_sensitive (item, sensitive);
477 @@ -1543,16 +1785,19 @@
478 if (gtk_tree_row_reference_valid (combo_box->priv->active_row))
480 path = gtk_tree_row_reference_get_path (combo_box->priv->active_row);
481 - active_item = gtk_tree_path_get_indices (path)[0];
482 - gtk_tree_path_free (path);
484 - if (combo_box->priv->add_tearoffs)
488 + active_item = gtk_tree_path_get_indices (path)[0];
489 + gtk_tree_path_free (path);
491 + if (combo_box->priv->add_tearoffs)
496 /* FIXME handle nested menus better */
497 - gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget), active_item);
499 + gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget), active_item);
501 if (combo_box->priv->wrap_width == 0)
503 width = GTK_WIDGET (combo_box)->allocation.width;
504 @@ -1684,6 +1929,7 @@
508 + gboolean hildonlike;
510 if (combo_box->priv->cell_view)
511 gtk_widget_style_get (combo_box->priv->cell_view,
512 @@ -1691,9 +1937,17 @@
517 + gtk_widget_style_get (GTK_WIDGET (combo_box), "hildonlike", &hildonlike,
520 /* add some pixels for good measure */
521 - padding += BONUS_PADDING;
522 + /* Hildon: we need more padding because our theming
523 + * Not elegent way to do it anyway ... */
525 + padding += HILDON_PADDING;
527 + padding += BONUS_PADDING;
529 if (combo_box->priv->cell_view)
530 gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view),
531 @@ -1709,6 +1963,7 @@
535 + gboolean hildonlike;
537 if (!combo_box->priv->model ||
538 !gtk_tree_model_get_iter_first (combo_box->priv->model, &iter))
539 @@ -1717,6 +1972,7 @@
540 combo_box->priv->width = 0;
542 path = gtk_tree_path_new_from_indices (0, -1);
543 + gtk_widget_style_get (GTK_WIDGET (combo_box), "hildonlike", &hildonlike, NULL);
547 @@ -1727,8 +1983,11 @@
551 + /* Hildon: we need more padding because our theming
552 + * Not elegent way to do it anyway ... */
554 - combo_box->priv->width = MAX (combo_box->priv->width, req.width);
555 + combo_box->priv->width = MAX (combo_box->priv->width,
556 + req.width + (hildonlike == 1) ? HILDON_PADDING : 0 );
558 gtk_tree_path_next (path);
560 @@ -1744,10 +2003,19 @@
562 gint focus_width, focus_pad;
563 GtkRequisition bin_req;
564 + gboolean hildonlike;
568 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
570 gtk_combo_box_check_appearance (combo_box);
572 + /* get hildonlike style property */
573 + gtk_widget_style_get (widget, "hildonlike",
574 + &hildonlike, "arrow-width",
575 + &arrow_width, "arrow-height",
576 + &arrow_height, NULL);
579 gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req);
580 @@ -1829,6 +2097,13 @@
581 requisition->height = MAX (requisition->height, button_req.height);
582 requisition->width += button_req.width;
585 + requisition->width = MIN (requisition->width, HILDON_MAX_WIDTH);
587 + /* HILDON quick fix: height forced to be 28px as specified by Hildon specs. */
589 + if (requisition->height > arrow_height)
590 + requisition->height = arrow_height;
594 @@ -1839,17 +2114,32 @@
595 gint focus_width, focus_pad;
598 + GtkRequisition child_req;
599 gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
600 + gboolean hildonlike;
604 gtk_combo_box_check_appearance (combo_box);
606 - widget->allocation = *allocation;
608 gtk_widget_style_get (GTK_WIDGET (widget),
609 "focus-line-width", &focus_width,
610 "focus-padding", &focus_pad,
611 + "hildonlike", &hildonlike,
612 + "arrow-width", &arrow_width,
613 + "arrow-height", &arrow_height,
616 + /* HILDON: set height to fixed value */
618 + if (allocation->height > arrow_height)
620 + allocation->y += (allocation->height - arrow_height) / 2;
621 + allocation->height = arrow_height;
624 + widget->allocation = *allocation;
626 if (!combo_box->priv->tree_view)
628 if (combo_box->priv->cell_view)
629 @@ -1909,7 +2199,16 @@
630 child.width = child.x;
631 child.x = allocation->x
632 + border_width + xthickness + focus_width + focus_pad;
633 - child.width -= child.x;
634 + child.width -= child.x + xthickness;
639 + gtk_widget_size_request(GTK_BIN(widget)->child, &child_req);
640 + child.y += (child.height - child_req.height) / 2;
641 + child.height = child_req.height;
642 + gtk_widget_hide(combo_box->priv->separator);
643 + gtk_widget_hide(combo_box->priv->arrow);
646 child.width = MAX (1, child.width);
647 @@ -1928,6 +2227,11 @@
648 child.height = allocation->height;
649 child.width = MAX (1, child.width);
650 child.height = MAX (1, child.height);
652 + /* HILDON quick fix */
654 + child.width = arrow_width;
656 gtk_widget_size_allocate (combo_box->priv->button, &child);
659 @@ -1938,6 +2242,13 @@
660 child.width = allocation->width - req.width;
661 child.width = MAX (1, child.width);
662 child.height = MAX (1, child.height);
666 + gtk_widget_size_request(GTK_BIN(widget)->child, &child_req);
667 + child.y += (child.height - child_req.height) / 2;
668 + child.height = child_req.height;
670 gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
673 @@ -1990,6 +2301,11 @@
674 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness);
678 + gtk_widget_size_request(GTK_BIN(widget)->child, &child_req);
680 + child.y += (child.height - child_req.height) / 2;
681 + child.height = child_req.height;
683 child.width = MAX (1, child.width);
684 child.height = MAX (1, child.height);
685 @@ -2036,6 +2352,8 @@
686 gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), NULL);
692 gtk_combo_box_forall (GtkContainer *container,
693 gboolean include_internals,
694 @@ -2057,6 +2375,46 @@
698 +gtk_combo_box_focus_in (GtkWidget *widget,
699 + GdkEventFocus *event)
701 + g_return_val_if_fail( widget, FALSE );
703 + if ( !GTK_CONTAINER( widget )->focus_child )
705 + gtk_combo_box_grab_focus ( GTK_WIDGET(widget) );
712 +gtk_combo_box_focus (GtkWidget *widget,
713 + GtkDirectionType dir)
715 + g_return_val_if_fail (widget, FALSE);
716 + if (GTK_WIDGET_HAS_FOCUS(widget)||GTK_CONTAINER(widget)->focus_child)
719 + gtk_widget_grab_focus (widget);
724 +gtk_combo_box_child_focus_in (GtkWidget * widget,
725 + GdkEventFocus *event)
727 + gtk_widget_event( widget, (GdkEvent*)event );
731 +gtk_combo_box_child_focus_out (GtkWidget * widget,
732 + GdkEventFocus *event)
734 + gtk_widget_event( widget, (GdkEvent*)event );
738 gtk_combo_box_expose_event (GtkWidget *widget,
739 GdkEventExpose *event)
741 @@ -2357,11 +2715,13 @@
742 gboolean add_children)
745 + gboolean hildonlike;
747 + gtk_widget_style_get (GTK_WIDGET (combo_box), "hildonlike", &hildonlike, NULL);
749 if (combo_box->priv->cell_view)
751 combo_box->priv->button = gtk_toggle_button_new ();
753 g_signal_connect (combo_box->priv->button, "toggled",
754 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
755 g_signal_connect_after (combo_box->priv->button,
756 @@ -2400,6 +2760,9 @@
757 gtk_widget_show_all (combo_box->priv->button);
760 + g_signal_connect_swapped (combo_box->priv->button, "focus_in_event", G_CALLBACK (gtk_combo_box_child_focus_in), combo_box);
761 + g_signal_connect_swapped (combo_box->priv->button, "focus_out_event", G_CALLBACK (gtk_combo_box_child_focus_out), combo_box);
763 g_signal_connect (combo_box->priv->button, "button_press_event",
764 G_CALLBACK (gtk_combo_box_menu_button_press),
766 @@ -2749,6 +3112,9 @@
768 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
770 + /* Hildon hack: sets the popup button sensitive if we have items in the list */
771 + hildon_check_autodim(combo_box);
773 gtk_tree_row_reference_inserted (G_OBJECT (user_data), path);
775 if (combo_box->priv->tree_view)
776 @@ -2783,7 +3149,10 @@
777 if (combo_box->priv->tree_view)
778 gtk_combo_box_list_popup_resize (combo_box);
780 - gtk_combo_box_menu_row_deleted (model, path, user_data);
781 + gtk_combo_box_menu_row_deleted (model, path, user_data);
783 + /* Hildon hack: dim the popup button in case item count reaches 0 */
784 + hildon_check_autodim(combo_box);
788 @@ -3458,10 +3827,46 @@
791 GtkTreeIter new_iter;
792 + gboolean hildonlike;
793 + gint index = gtk_combo_box_get_active (combo_box);
797 if (combo_box->priv->model == NULL)
800 + items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
802 + gtk_widget_style_get (GTK_WIDGET (combo_box), "hildonlike",
803 + &hildonlike, NULL);
805 + /* Hildon select key */
808 + if (event->keyval == GDK_KP_Enter || event->keyval == GDK_Return)
810 + gtk_combo_box_popup (combo_box);
813 + else if (event->keyval == GDK_Left && items != 0)
815 + new_index = (index == 0) ? items - 1 : index - 1;
816 + gtk_combo_box_set_active (combo_box, new_index);
819 + else if (event->keyval == GDK_Right && items != 0)
821 + new_index = (index == items - 1) ? 0 : index + 1;
822 + gtk_combo_box_set_active (combo_box, new_index);
825 + else if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down)
826 + || (event->keyval == GDK_Up || event->keyval == GDK_KP_Up))
832 if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) &&
833 state == GDK_MOD1_MASK)
835 @@ -3714,7 +4119,7 @@
837 combo_box = GTK_COMBO_BOX (layout);
839 - g_object_ref (cell);
840 + g_object_ref (G_OBJECT (cell));
841 gtk_object_sink (GTK_OBJECT (cell));
843 info = g_new0 (ComboCellInfo, 1);
844 @@ -3771,7 +4176,7 @@
846 combo_box = GTK_COMBO_BOX (layout);
848 - g_object_ref (cell);
849 + g_object_ref (G_OBJECT (cell));
850 gtk_object_sink (GTK_OBJECT (cell));
852 info = g_new0 (ComboCellInfo, 1);
853 @@ -3833,7 +4238,7 @@
854 ComboCellInfo *info = (ComboCellInfo *)i->data;
856 gtk_combo_box_cell_layout_clear_attributes (layout, info->cell);
857 - g_object_unref (info->cell);
858 + g_object_unref (G_OBJECT (info->cell));
862 @@ -3922,7 +4327,7 @@
864 if (GTK_IS_MENU_ITEM (parent) &&
865 gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent)))
866 - g_object_set (cell, "sensitive", TRUE, NULL);
867 + g_object_set (G_OBJECT (cell), "sensitive", TRUE, NULL);
871 @@ -4137,7 +4542,7 @@
873 gtk_combo_box_new (void)
875 - return g_object_new (GTK_TYPE_COMBO_BOX, NULL);
876 + return GTK_WIDGET (g_object_new (GTK_TYPE_COMBO_BOX, NULL));
880 @@ -4157,7 +4562,9 @@
882 g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
884 - combo_box = g_object_new (GTK_TYPE_COMBO_BOX, "model", model, NULL);
885 + combo_box = GTK_COMBO_BOX (g_object_new (GTK_TYPE_COMBO_BOX,
889 return GTK_WIDGET (combo_box);
891 @@ -4512,6 +4919,7 @@
894 gtk_combo_box_unset_model (combo_box);
895 + hildon_check_autodim(combo_box);
899 @@ -4524,7 +4932,7 @@
900 gtk_combo_box_unset_model (combo_box);
902 combo_box->priv->model = model;
903 - g_object_ref (combo_box->priv->model);
904 + g_object_ref (G_OBJECT (combo_box->priv->model));
906 combo_box->priv->inserted_id =
907 g_signal_connect (combo_box->priv->model, "row_inserted",
908 @@ -4561,6 +4969,8 @@
909 if (combo_box->priv->cell_view)
910 gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view),
911 combo_box->priv->model);
913 + hildon_check_autodim(combo_box);
917 @@ -5140,3 +5550,33 @@
919 return combo->priv->focus_on_click;
922 + * This is added, because we need to be able grab focus for our widget.
923 + * Focus grabbing can happen it two ways: If we are using combobox entry
924 + * we grab entry widget focus, otherwise togglebutton focus
926 +static void gtk_combo_box_grab_focus (GtkWidget *focus_widget)
928 + GtkComboBox *combo_box;
929 + GtkComboBoxEntry *combo_entry;
930 + gboolean hildonlike;
932 + combo_box = GTK_COMBO_BOX (focus_widget);
934 + gtk_widget_style_get (focus_widget, "hildonlike",
935 + &hildonlike, NULL);
939 + /* Are we in entry mode ? */
940 + if ( GTK_IS_COMBO_BOX_ENTRY(combo_box))
942 + combo_entry = GTK_COMBO_BOX_ENTRY (combo_box);
943 + gtk_grab_combo_box_entry_focus (combo_entry);
947 + gtk_widget_grab_focus (combo_box->priv->button);