[gtk+] combobox: Also preselect active item in grid popup
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] combobox: Also preselect active item in grid popup
- Date: Thu, 19 Jan 2017 03:18:40 +0000 (UTC)
commit c83ead5eeadf5ad1b6765049f65e815da48b37eb
Author: Daniel Boles <dboles src gnome org>
Date: Thu Jan 19 03:12:32 2017 +0000
combobox: Also preselect active item in grid popup
i.e. when wrap-width > 0. This was only being done for non-grid cases.
So, ComboBoxes in grid mode did not indicate their selection when popped
up and required users to keynav from ‘nothing’ (at the top-left) to the
item they wanted to select. By selecting the active item in advance, now
it’s highlighted & acts as the starting point for keynav around the grid
gtk/gtkcombobox.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 8173876..72e94a1 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1694,6 +1694,7 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
gint active_item;
GtkAllocation border_allocation;
GtkAllocation content_allocation;
+ GtkWidget *active;
update_menu_sensitivity (combo_box, priv->popup_widget);
@@ -1733,6 +1734,8 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
g_object_set (priv->popup_widget, "menu-type-hint", GDK_WINDOW_TYPE_HINT_COMBO, NULL);
+ active = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
+
if (priv->wrap_width > 0 || priv->cell_view == NULL)
{
gtk_css_gadget_get_border_allocation (priv->gadget, &border_allocation, NULL);
@@ -1754,7 +1757,6 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
else
{
/* FIXME handle nested menus better */
- GtkWidget *active = gtk_menu_get_active (GTK_MENU (priv->popup_widget));;
gint rect_anchor_dy = -2;
GList *i;
GtkWidget *child;
@@ -1805,15 +1807,15 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
GDK_GRAVITY_WEST,
GDK_GRAVITY_NORTH_WEST,
trigger_event);
-
- /* As a hack, re-get the active item, in case a popup handler, like that
- * of FileChooserButton, just caused the menu to be refiltered, making the
- * previous active item pointer invalid now. This seems pretty ugly and
- * makes the y-offset loop pointless for such cases, so FIXME later? */
- active = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
- if (active)
- gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->popup_widget), active);
}
+
+ /* Re-get the active item before selecting it, as a popped-up handler – like
+ * that of FileChooserButton in folder mode – can refilter the model, making
+ * the original active item pointer invalid. This seems ugly and makes some
+ * of the above code pointless in such cases, so hopefully we can FIXME. */
+ active = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
+ if (active && gtk_widget_get_visible (active))
+ gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->popup_widget), active);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]