[egg-list-box/flow-box-enhancements] Work on focus handling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [egg-list-box/flow-box-enhancements] Work on focus handling
- Date: Sat, 28 Sep 2013 18:12:01 +0000 (UTC)
commit 2397d99331ea7b0266e76d5c7f8c1a1f6c73f0ba
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 28 01:22:52 2013 -0400
Work on focus handling
Consistently skip insensitive items.
egg-flow-box.c | 458 +++++++++++++++++++++++---------------------------------
1 files changed, 185 insertions(+), 273 deletions(-)
---
diff --git a/egg-flow-box.c b/egg-flow-box.c
index c939d81..ee0783b 100644
--- a/egg-flow-box.c
+++ b/egg-flow-box.c
@@ -264,9 +264,9 @@ egg_flow_box_child_focus (GtkWidget *widget,
else if (gtk_container_get_focus_child (GTK_CONTAINER (widget)) != NULL)
{
/* Child has focus, always navigate inside it first */
-
if (gtk_widget_child_focus (child, direction))
return TRUE;
+
/* If exiting child container to the left, select child */
if (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD)
{
@@ -1287,42 +1287,40 @@ egg_flow_box_add (GtkContainer *container,
static void
egg_flow_box_remove (GtkContainer *container,
- GtkWidget *child)
+ GtkWidget *widget)
{
EggFlowBox *box = EGG_FLOW_BOX (container);
EggFlowBoxPrivate *priv = box->priv;
gboolean was_visible;
gboolean was_selected;
- EggFlowBoxChild *child_info;
+ EggFlowBoxChild *child;
EggFlowBoxChildPrivate *child_priv;
- g_return_if_fail (child != NULL);
-
- if (EGG_IS_FLOW_BOX_CHILD (child))
- child_info = EGG_FLOW_BOX_CHILD (child);
+ if (EGG_IS_FLOW_BOX_CHILD (widget))
+ child = EGG_FLOW_BOX_CHILD (widget);
else
{
- child_info = (EggFlowBoxChild*)gtk_widget_get_parent (child);
- if (!EGG_IS_FLOW_BOX_CHILD (child_info))
+ child = (EggFlowBoxChild*)gtk_widget_get_parent (widget);
+ if (!EGG_IS_FLOW_BOX_CHILD (child))
{
- g_warning ("Tried to remove non-child %p\n", child);
+ g_warning ("Tried to remove non-child %p\n", widget);
return;
}
}
- child_priv = egg_flow_box_child_get_instance_private (child_info);
+ child_priv = egg_flow_box_child_get_instance_private (child);
- was_visible = child_is_visible (GTK_WIDGET (child_info));
+ was_visible = child_is_visible (GTK_WIDGET (child));
was_selected = child_priv->selected;
- if (child_info == priv->prelight_child)
+ if (child == priv->prelight_child)
priv->prelight_child = NULL;
- if (child_info == priv->active_child)
+ if (child == priv->active_child)
priv->active_child = NULL;
- if (child_info == priv->selected_child)
+ if (child == priv->selected_child)
priv->selected_child = NULL;
- gtk_widget_unparent (GTK_WIDGET (child_info));
+ gtk_widget_unparent (GTK_WIDGET (child));
g_sequence_remove (child_priv->iter);
if (was_visible && gtk_widget_get_visible (GTK_WIDGET (box)))
@@ -2336,12 +2334,12 @@ egg_flow_box_find_child_at_pos (EggFlowBox *box,
gint y)
{
EggFlowBoxPrivate *priv = box->priv;
- EggFlowBoxChild *child_info;
+ EggFlowBoxChild *child;
GSequenceIter *iter;
EggFlowBoxChild *info;
EggFlowBoxChildPrivate *child_priv;
- child_info = NULL;
+ child = NULL;
for (iter = g_sequence_get_begin_iter (priv->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
@@ -2351,12 +2349,12 @@ egg_flow_box_find_child_at_pos (EggFlowBox *box,
if (x >= child_priv->area.x && x < (child_priv->area.x + child_priv->area.width)
&& y >= child_priv->area.y && y < (child_priv->area.y + child_priv->area.height))
{
- child_info = info;
+ child = info;
break;
}
}
- return child_info;
+ return child;
}
static void
@@ -2393,15 +2391,15 @@ egg_flow_box_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxChild *child_info;
+ EggFlowBoxChild *child;
if (event->window != gtk_widget_get_window (GTK_WIDGET (box)))
return FALSE;
- child_info = egg_flow_box_find_child_at_pos (box, event->x, event->y);
- egg_flow_box_update_prelight (box, child_info);
- egg_flow_box_update_active (box, child_info);
+ child = egg_flow_box_find_child_at_pos (box, event->x, event->y);
+ egg_flow_box_update_prelight (box, child);
+ egg_flow_box_update_active (box, child);
return FALSE;
}
@@ -2411,18 +2409,18 @@ egg_flow_box_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxChild *child_info = NULL;
+ EggFlowBoxChild *child = NULL;
if (event->window != gtk_widget_get_window (GTK_WIDGET (box)))
return FALSE;
if (event->detail != GDK_NOTIFY_INFERIOR)
- child_info = NULL;
+ child = NULL;
else
- child_info = egg_flow_box_find_child_at_pos (box, event->x, event->y);
+ child = egg_flow_box_find_child_at_pos (box, event->x, event->y);
- egg_flow_box_update_prelight (box, child_info);
- egg_flow_box_update_active (box, child_info);
+ egg_flow_box_update_prelight (box, child);
+ egg_flow_box_update_active (box, child);
return FALSE;
}
@@ -2432,7 +2430,7 @@ egg_flow_box_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxChild *child_info;
+ EggFlowBoxChild *child;
GdkWindow *window;
GdkWindow *event_window;
gint relative_x;
@@ -2455,9 +2453,9 @@ egg_flow_box_motion_notify_event (GtkWidget *widget,
event_window = gdk_window_get_effective_parent (event_window);
}
- child_info = egg_flow_box_find_child_at_pos (box, relative_x, relative_y);
- egg_flow_box_update_prelight (box, child_info);
- egg_flow_box_update_active (box, child_info);
+ child = egg_flow_box_find_child_at_pos (box, relative_x, relative_y);
+ egg_flow_box_update_prelight (box, child);
+ egg_flow_box_update_active (box, child);
return FALSE;
}
@@ -2471,18 +2469,16 @@ egg_flow_box_button_press_event (GtkWidget *widget,
if (event->button == GDK_BUTTON_PRIMARY)
{
- EggFlowBoxChild *child_info;
- child_info = egg_flow_box_find_child_at_pos (box, event->x, event->y);
- if (child_info != NULL)
+ EggFlowBoxChild *child;
+ child = egg_flow_box_find_child_at_pos (box, event->x, event->y);
+ if (child != NULL)
{
- priv->active_child = child_info;
+ priv->active_child = child;
priv->active_child_active = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (box));
if (event->type == GDK_2BUTTON_PRESS &&
!priv->activate_on_single_click)
- g_signal_emit (box,
- signals[CHILD_ACTIVATED], 0,
- child_info);
+ g_signal_emit (box, signals[CHILD_ACTIVATED], 0, child);
}
}
@@ -2491,13 +2487,13 @@ egg_flow_box_button_press_event (GtkWidget *widget,
static void
egg_flow_box_queue_draw_child (EggFlowBox *box,
- EggFlowBoxChild *child_info)
+ EggFlowBoxChild *child)
{
EggFlowBoxChildPrivate *priv;
GdkRectangle rect;
GdkWindow *window;
- priv = egg_flow_box_child_get_instance_private (child_info);
+ priv = egg_flow_box_child_get_instance_private (child);
rect = priv->area;
window = gtk_widget_get_window (GTK_WIDGET (box));
@@ -2536,7 +2532,7 @@ egg_flow_box_child_set_selected (EggFlowBoxChild *child,
static gboolean
egg_flow_box_unselect_all_internal (EggFlowBox *box)
{
- EggFlowBoxChild *child_info;
+ EggFlowBoxChild *child;
EggFlowBoxChildPrivate *priv;
GSequenceIter *iter;
gboolean dirty = FALSE;
@@ -2548,8 +2544,8 @@ egg_flow_box_unselect_all_internal (EggFlowBox *box)
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
- child_info = g_sequence_get (iter);
- dirty != egg_flow_box_child_set_selected (child_info, FALSE);
+ child = g_sequence_get (iter);
+ dirty != egg_flow_box_child_set_selected (child, FALSE);
}
return dirty;
@@ -2557,11 +2553,11 @@ egg_flow_box_unselect_all_internal (EggFlowBox *box)
static void
egg_flow_box_unselect_child_info (EggFlowBox *box,
- EggFlowBoxChild *child_info)
+ EggFlowBoxChild *child)
{
EggFlowBoxChildPrivate *priv;
- priv = egg_flow_box_child_get_instance_private (child_info);
+ priv = egg_flow_box_child_get_instance_private (child);
if (!priv->selected)
return;
@@ -2570,7 +2566,7 @@ egg_flow_box_unselect_child_info (EggFlowBox *box,
else if (box->priv->selection_mode != GTK_SELECTION_MULTIPLE)
egg_flow_box_unselect_all_internal (box);
else
- egg_flow_box_child_set_selected (child_info, FALSE);
+ egg_flow_box_child_set_selected (child, FALSE);
g_signal_emit (box, signals[SELECTED_CHILDREN_CHANGED], 0);
}
@@ -2589,11 +2585,11 @@ egg_flow_box_update_cursor (EggFlowBox *box,
static void
egg_flow_box_select_child_info (EggFlowBox *box,
- EggFlowBoxChild *child_info)
+ EggFlowBoxChild *child)
{
EggFlowBoxChildPrivate *child_priv;
- child_priv = egg_flow_box_child_get_instance_private (child_info);
+ child_priv = egg_flow_box_child_get_instance_private (child);
if (child_priv->selected)
return;
if (box->priv->selection_mode == GTK_SELECTION_NONE)
@@ -2601,12 +2597,12 @@ egg_flow_box_select_child_info (EggFlowBox *box,
if (box->priv->selection_mode != GTK_SELECTION_MULTIPLE)
egg_flow_box_unselect_all_internal (box);
- egg_flow_box_child_set_selected (child_info, TRUE);
- box->priv->selected_child = child_info;
+ egg_flow_box_child_set_selected (child, TRUE);
+ box->priv->selected_child = child;
g_signal_emit (box, signals[SELECTED_CHILDREN_CHANGED], 0);
- egg_flow_box_update_cursor (box, child_info);
+ egg_flow_box_update_cursor (box, child);
}
static void
@@ -2655,14 +2651,16 @@ egg_flow_box_select_all_between (EggFlowBox *box,
static void
egg_flow_box_update_selection (EggFlowBox *box,
- EggFlowBoxChild *child_info,
+ EggFlowBoxChild *child,
gboolean modify,
gboolean extend)
{
EggFlowBoxPrivate *priv = box->priv;
EggFlowBoxChildPrivate *child_priv;
- child_priv = egg_flow_box_child_get_instance_private (child_info);
+ child_priv = egg_flow_box_child_get_instance_private (child);
+
+ egg_flow_box_update_cursor (box, child);
if (priv->selection_mode == GTK_SELECTION_NONE)
return;
@@ -2670,8 +2668,8 @@ egg_flow_box_update_selection (EggFlowBox *box,
if (priv->selection_mode == GTK_SELECTION_BROWSE)
{
egg_flow_box_unselect_all_internal (box);
- egg_flow_box_child_set_selected (child_info, TRUE);
- priv->selected_child = child_info;
+ egg_flow_box_child_set_selected (child, TRUE);
+ priv->selected_child = child;
}
else if (priv->selection_mode == GTK_SELECTION_SINGLE)
{
@@ -2679,8 +2677,8 @@ egg_flow_box_update_selection (EggFlowBox *box,
was_selected = child_priv->selected;
egg_flow_box_unselect_all_internal (box);
- egg_flow_box_child_set_selected (child_info, modify ? !was_selected : TRUE);
- priv->selected_child = child_priv->selected ? child_info : NULL;
+ egg_flow_box_child_set_selected (child, modify ? !was_selected : TRUE);
+ priv->selected_child = child_priv->selected ? child : NULL;
}
else /* GTK_SELECTION_MULTIPLE */
{
@@ -2689,34 +2687,32 @@ egg_flow_box_update_selection (EggFlowBox *box,
egg_flow_box_unselect_all_internal (box);
if (priv->selected_child == NULL)
{
- egg_flow_box_child_set_selected (child_info, TRUE);
- priv->selected_child = child_info;
+ egg_flow_box_child_set_selected (child, TRUE);
+ priv->selected_child = child;
}
else
- egg_flow_box_select_all_between (box, priv->selected_child, child_info);
+ egg_flow_box_select_all_between (box, priv->selected_child, child);
}
else
{
- egg_flow_box_child_set_selected (child_info, modify ? !child_priv->selected : TRUE);
- priv->selected_child = child_info;
+ egg_flow_box_child_set_selected (child, modify ? !child_priv->selected : TRUE);
+ priv->selected_child = child;
}
}
g_signal_emit (box, signals[SELECTED_CHILDREN_CHANGED], 0);
-
- egg_flow_box_update_cursor (box, child_info);
}
static void
egg_flow_box_select_and_activate (EggFlowBox *box,
- EggFlowBoxChild *child_info)
+ EggFlowBoxChild *child)
{
GtkWidget *w = NULL;
- if (child_info != NULL)
+ if (child != NULL)
{
- w = gtk_bin_get_child (GTK_BIN (child_info));
- egg_flow_box_select_child_info (box, child_info);
+ w = gtk_bin_get_child (GTK_BIN (child));
+ egg_flow_box_select_child_info (box, child);
}
if (w != NULL)
@@ -2770,146 +2766,121 @@ egg_flow_box_button_release_event (GtkWidget *widget,
return FALSE;
}
-static EggFlowBoxChild *
-egg_flow_box_get_first_visible (EggFlowBox *box)
-{
- EggFlowBoxPrivate *priv = box->priv;
- EggFlowBoxChild *child;
- GSequenceIter *iter;
-
- for (iter = g_sequence_get_begin_iter (priv->children);
- !g_sequence_iter_is_end (iter);
- iter = g_sequence_iter_next (iter))
- {
- child = g_sequence_get (iter);
- if (child_is_visible (GTK_WIDGET (child)))
- return child;
- }
-
- return NULL;
-}
-
-static EggFlowBoxChild *
-egg_flow_box_get_last_visible (EggFlowBox *box)
+static GSequenceIter *
+egg_flow_box_get_previous_focusable (EggFlowBox *box,
+ GSequenceIter *iter)
{
- EggFlowBoxPrivate *priv = box->priv;
EggFlowBoxChild *child;
- GSequenceIter *iter;
- iter = g_sequence_get_end_iter (priv->children);
while (!g_sequence_iter_is_begin (iter))
{
iter = g_sequence_iter_prev (iter);
child = g_sequence_get (iter);
- if (child_is_visible (GTK_WIDGET (child)))
- return child;
+ if (child_is_visible (GTK_WIDGET (child)) &&
+ gtk_widget_is_sensitive (GTK_WIDGET (child)))
+ return iter;
}
return NULL;
}
static GSequenceIter *
-egg_flow_box_get_previous_visible (EggFlowBox *box,
- GSequenceIter *iter)
+egg_flow_box_get_next_focusable (EggFlowBox *box,
+ GSequenceIter *iter)
{
EggFlowBoxChild *child;
- if (g_sequence_iter_is_begin (iter))
- return NULL;
-
- do
+ while (TRUE)
{
- iter = g_sequence_iter_prev (iter);
+ iter = g_sequence_iter_next (iter);
+ if (g_sequence_iter_is_end (iter))
+ return iter;
child = g_sequence_get (iter);
- if (child_is_visible (GTK_WIDGET (child)))
+ if (child_is_visible (GTK_WIDGET (child)) &&
+ gtk_widget_is_sensitive (GTK_WIDGET (child)))
return iter;
}
- while (!g_sequence_iter_is_begin (iter));
return NULL;
}
static GSequenceIter *
-egg_flow_box_get_next_visible (EggFlowBox *box,
- GSequenceIter *iter)
+egg_flow_box_get_first_focusable (EggFlowBox *box)
{
+ EggFlowBoxPrivate *priv = box->priv;
+ GSequenceIter *iter;
EggFlowBoxChild *child;
- if (g_sequence_iter_is_end (iter))
+ iter = g_sequence_get_begin_iter (priv->children);
+ child = g_sequence_get (iter);
+ if (child_is_visible (GTK_WIDGET (child)) &&
+ gtk_widget_is_sensitive (GTK_WIDGET (child)))
return iter;
- do
- {
- iter = g_sequence_iter_next (iter);
- if (!g_sequence_iter_is_end (iter))
- {
- child = g_sequence_get (iter);
- if (child_is_visible (GTK_WIDGET (child)))
- return iter;
- }
- }
- while (!g_sequence_iter_is_end (iter));
+ return egg_flow_box_get_next_focusable (box, iter);
+}
- return iter;
+static GSequenceIter *
+egg_flow_box_get_last_focusable (EggFlowBox *box)
+{
+ EggFlowBoxPrivate *priv = box->priv;
+ GSequenceIter *iter;
+
+ iter = g_sequence_get_end_iter (priv->children);
+ return egg_flow_box_get_previous_focusable (box, iter);
}
+
static GSequenceIter *
-egg_flow_box_get_above_visible (EggFlowBox *box,
- GSequenceIter *iter)
+egg_flow_box_get_above_focusable (EggFlowBox *box,
+ GSequenceIter *iter)
{
- EggFlowBoxChild *child;
- GSequenceIter *ret = NULL;
+ EggFlowBoxChild *child = NULL;
gint i;
- if (g_sequence_iter_is_begin (iter))
- return NULL;
-
- i = 0;
- do
+ while (TRUE)
{
- iter = g_sequence_iter_prev (iter);
- child = g_sequence_get (iter);
- if (child_is_visible (GTK_WIDGET (child)))
- i++;
+ i = 0;
+ while (i < box->priv->cur_children_per_line)
+ {
+ if (g_sequence_iter_is_begin (iter))
+ return NULL;
+ iter = g_sequence_iter_prev (iter);
+ child = g_sequence_get (iter);
+ if (child_is_visible (GTK_WIDGET (child)))
+ i++;
+ }
+ if (child && gtk_widget_get_sensitive (GTK_WIDGET (child)))
+ return iter;
}
- while (!g_sequence_iter_is_begin (iter)
- && i < box->priv->cur_children_per_line);
-
- if (i == box->priv->cur_children_per_line)
- ret = iter;
- return ret;
+ return NULL;
}
static GSequenceIter *
-egg_flow_box_get_below_visible (EggFlowBox *box,
- GSequenceIter *iter)
+egg_flow_box_get_below_focusable (EggFlowBox *box,
+ GSequenceIter *iter)
{
EggFlowBoxChild *child;
- GSequenceIter *ret = NULL;
gint i;
- if (g_sequence_iter_is_end (iter))
- return iter;
-
- i = 0;
- do
+ while (TRUE)
{
- iter = g_sequence_iter_next (iter);
- if (!g_sequence_iter_is_end (iter))
+ i = 0;
+ while (i < box->priv->cur_children_per_line)
{
+ iter = g_sequence_iter_next (iter);
+ if (g_sequence_iter_is_end (iter))
+ return iter;
child = g_sequence_get (iter);
if (child_is_visible (GTK_WIDGET (child)))
i++;
}
+ if (child && gtk_widget_get_sensitive (GTK_WIDGET (child)))
+ return iter;
}
- while (!g_sequence_iter_is_end (iter)
- && i < box->priv->cur_children_per_line);
-
- if (i == box->priv->cur_children_per_line)
- ret = iter;
- return ret;
+ return NULL;
}
static gboolean
@@ -2918,6 +2889,10 @@ egg_flow_box_focus (GtkWidget *widget,
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
EggFlowBoxPrivate *priv = box->priv;
+ GtkWidget *focus_child;
+ GSequenceIter *iter;
+ EggFlowBoxChildPrivate *child_priv;
+
gboolean had_focus = FALSE;
GtkWidget *recurse_into;
EggFlowBoxChild *current_focus_child;
@@ -2925,95 +2900,51 @@ egg_flow_box_focus (GtkWidget *widget,
gboolean modify_selection_pressed;
gboolean extend_selection_pressed;
GdkModifierType state = 0;
- EggFlowBoxChildPrivate *child_priv;
- recurse_into = NULL;
- current_focus_child = NULL;
+ focus_child = gtk_container_get_focus_child (GTK_CONTAINER (box));
next_focus_child = NULL;
- if (gtk_container_get_focus_child ((GtkContainer *) box) != NULL)
+ if (focus_child != NULL)
{
- /* There is a focus child, always navigate inside it first */
- recurse_into = gtk_container_get_focus_child ((GtkContainer *) box);
- current_focus_child = EGG_FLOW_BOX_CHILD (recurse_into);
-
- /* If exiting child container to the left, select row or out */
- if (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD)
- next_focus_child = current_focus_child;
- }
- else
- {
- /* If coming from the left, enter into possible container */
- if (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD)
- {
- if (priv->selected_child != NULL)
- recurse_into = gtk_bin_get_child (GTK_BIN (priv->selected_child));
- }
- }
-
- if (recurse_into != NULL)
- {
- if (gtk_widget_child_focus (recurse_into, direction))
+ if (gtk_widget_child_focus (focus_child, direction))
return TRUE;
- }
- if (next_focus_child == NULL)
- {
- if (current_focus_child != NULL)
- {
- GSequenceIter *iter;
+ child_priv = egg_flow_box_child_get_instance_private (EGG_FLOW_BOX_CHILD (focus_child));
- child_priv = egg_flow_box_child_get_instance_private (current_focus_child);
+ if (direction == GTK_DIR_LEFT ||
+ direction == GTK_DIR_TAB_BACKWARD)
+ iter = egg_flow_box_get_previous_focusable (box, child_priv->iter);
+ else if (direction == GTK_DIR_RIGHT ||
+ direction == GTK_DIR_TAB_FORWARD)
+ iter = egg_flow_box_get_next_focusable (box, child_priv->iter);
+ else if (direction == GTK_DIR_UP)
+ iter = egg_flow_box_get_above_focusable (box, child_priv->iter);
+ else if (direction == GTK_DIR_DOWN)
+ iter = egg_flow_box_get_below_focusable (box, child_priv->iter);
- if (direction == GTK_DIR_LEFT)
- {
- iter = egg_flow_box_get_previous_visible (box, child_priv->iter);
- if (iter != NULL)
- next_focus_child = g_sequence_get (iter);
- }
- else if (direction == GTK_DIR_RIGHT)
- {
- iter = egg_flow_box_get_next_visible (box, child_priv->iter);
- if (iter != NULL && !g_sequence_iter_is_end (iter))
- next_focus_child = g_sequence_get (iter);
- }
- else if (direction == GTK_DIR_UP)
- {
- iter = egg_flow_box_get_above_visible (box, child_priv->iter);
- if (iter != NULL && !g_sequence_iter_is_end (iter))
- next_focus_child = g_sequence_get (iter);
- }
- else if (direction == GTK_DIR_DOWN)
- {
- iter = egg_flow_box_get_below_visible (box, child_priv->iter);
- if (iter != NULL && !g_sequence_iter_is_end (iter))
- next_focus_child = g_sequence_get (iter);
- }
- }
+ if (iter != NULL && !g_sequence_iter_is_end (iter))
+ next_focus_child = g_sequence_get (iter);
+ }
+ else
+ {
+ if (priv->selected_child)
+ next_focus_child = priv->selected_child;
else
{
- switch (direction)
- {
- case GTK_DIR_UP:
- case GTK_DIR_TAB_BACKWARD:
- next_focus_child = priv->selected_child;
- if (next_focus_child == NULL)
- next_focus_child = egg_flow_box_get_last_visible (box);
- break;
- default:
- next_focus_child = priv->selected_child;
- if (next_focus_child == NULL)
- next_focus_child =
- egg_flow_box_get_first_visible (box);
- break;
- }
+ if (direction == GTK_DIR_UP || direction == GTK_DIR_TAB_BACKWARD)
+ iter = egg_flow_box_get_last_focusable (box);
+ else
+ iter = egg_flow_box_get_first_focusable (box);
+
+ if (iter != NULL && !g_sequence_iter_is_end (iter))
+ next_focus_child = g_sequence_get (iter);
}
}
if (next_focus_child == NULL)
{
- if (direction == GTK_DIR_UP || direction == GTK_DIR_DOWN
- || direction == GTK_DIR_LEFT || direction == GTK_DIR_RIGHT)
+ if (direction == GTK_DIR_UP || direction == GTK_DIR_DOWN ||
+ direction == GTK_DIR_LEFT || direction == GTK_DIR_RIGHT)
{
if (gtk_widget_keynav_failed (GTK_WIDGET (box), direction))
return TRUE;
@@ -3022,27 +2953,8 @@ egg_flow_box_focus (GtkWidget *widget,
return FALSE;
}
- modify_selection_pressed = FALSE;
- extend_selection_pressed = FALSE;
- if (gtk_get_current_event_state (&state))
- {
- GdkModifierType extend_mod_mask;
- GdkModifierType modify_mod_mask;
-
- extend_mod_mask = gtk_widget_get_modifier_mask (GTK_WIDGET (box),
- GDK_MODIFIER_INTENT_EXTEND_SELECTION);
- if ((state & extend_mod_mask) == extend_mod_mask)
- extend_selection_pressed = TRUE;
-
- modify_mod_mask = gtk_widget_get_modifier_mask (GTK_WIDGET (box),
- GDK_MODIFIER_INTENT_MODIFY_SELECTION);
- if ((state & modify_mod_mask) == modify_mod_mask)
- modify_selection_pressed = TRUE;
- }
-
- egg_flow_box_update_cursor (box, next_focus_child);
- if (!modify_selection_pressed)
- egg_flow_box_update_selection (box, next_focus_child, FALSE, extend_selection_pressed);
+ if (gtk_widget_child_focus (GTK_WIDGET (next_focus_child), direction))
+ return TRUE;
return TRUE;
}
@@ -3180,12 +3092,12 @@ egg_flow_box_move_cursor (EggFlowBox *box,
while (count < 0 && iter != NULL)
{
- iter = egg_flow_box_get_previous_visible (box, iter);
+ iter = egg_flow_box_get_previous_focusable (box, iter);
count = count + 1;
}
- while (count > 0 && iter != NULL)
+ while (count > 0 && iter != NULL)
{
- iter = egg_flow_box_get_next_visible (box, iter);
+ iter = egg_flow_box_get_next_focusable (box, iter);
count = count - 1;
}
@@ -3195,9 +3107,11 @@ egg_flow_box_move_cursor (EggFlowBox *box,
break;
case GTK_MOVEMENT_BUFFER_ENDS:
if (count < 0)
- child = egg_flow_box_get_first_visible (box);
+ iter = egg_flow_box_get_first_focusable (box);
else
- child = egg_flow_box_get_last_visible (box);
+ iter = egg_flow_box_get_last_focusable (box);
+ if (iter != NULL && !g_sequence_iter_is_end (iter))
+ child = g_sequence_get (iter);
break;
case GTK_MOVEMENT_DISPLAY_LINES:
if (priv->cursor_child != NULL)
@@ -3205,14 +3119,14 @@ egg_flow_box_move_cursor (EggFlowBox *box,
child_priv = egg_flow_box_child_get_instance_private (priv->cursor_child);
iter = child_priv->iter;
- while (count < 0 && iter != NULL)
+ while (count < 0 && iter != NULL)
{
- iter = egg_flow_box_get_above_visible (box, iter);
+ iter = egg_flow_box_get_above_focusable (box, iter);
count = count + 1;
}
- while (count > 0 && iter != NULL)
+ while (count > 0 && iter != NULL)
{
- iter = egg_flow_box_get_below_visible (box, iter);
+ iter = egg_flow_box_get_below_focusable (box, iter);
count = count - 1;
}
@@ -3238,9 +3152,9 @@ egg_flow_box_move_cursor (EggFlowBox *box,
gint i = 0;
/* Up */
- while (iter != NULL && !g_sequence_iter_is_begin (iter))
+ while (iter != NULL)
{
- iter = egg_flow_box_get_previous_visible (box, iter);
+ iter = egg_flow_box_get_previous_focusable (box, iter);
if (iter == NULL)
break;
@@ -3261,9 +3175,9 @@ egg_flow_box_move_cursor (EggFlowBox *box,
gint i = 0;
/* Down */
- while (iter != NULL && !g_sequence_iter_is_end (iter))
+ while (!g_sequence_iter_is_end (iter))
{
- iter = egg_flow_box_get_next_visible (box, iter);
+ iter = egg_flow_box_get_next_focusable (box, iter);
if (g_sequence_iter_is_end (iter))
break;
@@ -3733,7 +3647,7 @@ egg_flow_box_new (void)
GList *
egg_flow_box_get_selected_children (EggFlowBox *box)
{
- EggFlowBoxChild *child_info;
+ EggFlowBoxChild *child;
EggFlowBoxChildPrivate *child_priv;
GSequenceIter *iter;
GList *selected = NULL;
@@ -3744,10 +3658,10 @@ egg_flow_box_get_selected_children (EggFlowBox *box)
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
- child_info = g_sequence_get (iter);
- child_priv = egg_flow_box_child_get_instance_private (child_info);
+ child = g_sequence_get (iter);
+ child_priv = egg_flow_box_child_get_instance_private (child);
if (child_priv->selected)
- selected = g_list_prepend (selected, child_info);
+ selected = g_list_prepend (selected, child);
}
return g_list_reverse (selected);
@@ -3767,8 +3681,6 @@ void
egg_flow_box_unselect_child (EggFlowBox *box,
EggFlowBoxChild *child)
{
- EggFlowBoxChild *child_info;
-
g_return_if_fail (EGG_IS_FLOW_BOX (box));
g_return_if_fail (EGG_IS_FLOW_BOX_CHILD (child));
@@ -3801,7 +3713,7 @@ egg_flow_box_selected_foreach (EggFlowBox *box,
EggFlowBoxForeachFunc func,
gpointer data)
{
- EggFlowBoxChild *child_info;
+ EggFlowBoxChild *child;
EggFlowBoxChildPrivate *priv;
GSequenceIter *iter;
@@ -3811,10 +3723,10 @@ egg_flow_box_selected_foreach (EggFlowBox *box,
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
- child_info = g_sequence_get (iter);
- priv = egg_flow_box_child_get_instance_private (child_info);
+ child = g_sequence_get (iter);
+ priv = egg_flow_box_child_get_instance_private (child);
if (priv->selected)
- (* func) (box, child_info, data);
+ (* func) (box, child, data);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]