[egg-list-box/flow-box-enhancements] Add egg_flow_box_get_child_at_index
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [egg-list-box/flow-box-enhancements] Add egg_flow_box_get_child_at_index
- Date: Sat, 28 Sep 2013 00:57:44 +0000 (UTC)
commit 218cd413f396014f1ae63b05bd203126be82ea38
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 27 20:57:10 2013 -0400
Add egg_flow_box_get_child_at_index
And use it instead of iterating over all children.
egg-flow-box-accessible.c | 9 +++------
egg-flow-box-child-accessible.c | 2 +-
egg-flow-box.c | 23 ++++++++++++++++++++---
egg-flow-box.h | 5 +++--
4 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/egg-flow-box-accessible.c b/egg-flow-box-accessible.c
index 83e1161..16b81fe 100644
--- a/egg-flow-box-accessible.c
+++ b/egg-flow-box-accessible.c
@@ -210,18 +210,15 @@ egg_flow_box_accessible_is_child_selected (AtkSelection *selection,
gint idx)
{
GtkWidget *box;
- GtkWidget *widget;
- GList *children;
EggFlowBoxChild *child;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
- children = gtk_container_get_children (GTK_CONTAINER (box));
- child = g_list_nth_data (children, idx);
- g_list_free (children);
- return egg_flow_box_is_child_selected (EGG_FLOW_BOX (box), child);
+ child = egg_flow_box_get_child_at_index (EGG_FLOW_BOX (box), idx);
+
+ return egg_flow_box_child_is_selected (child);
}
static void atk_selection_interface_init (AtkSelectionIface *iface)
diff --git a/egg-flow-box-child-accessible.c b/egg-flow-box-child-accessible.c
index 2552db1..7124341 100644
--- a/egg-flow-box-child-accessible.c
+++ b/egg-flow-box-child-accessible.c
@@ -52,7 +52,7 @@ egg_flow_box_child_accessible_ref_state_set (AtkObject *obj)
if (egg_flow_box_get_selection_mode (EGG_FLOW_BOX (parent)) != GTK_SELECTION_NONE)
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
- if (egg_flow_box_is_child_selected (EGG_FLOW_BOX (parent), EGG_FLOW_BOX_CHILD (widget)))
+ if (egg_flow_box_child_is_selected (EGG_FLOW_BOX_CHILD (widget)))
atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
}
diff --git a/egg-flow-box.c b/egg-flow-box.c
index 0e86f16..59a36b6 100644
--- a/egg-flow-box.c
+++ b/egg-flow-box.c
@@ -3839,15 +3839,14 @@ egg_flow_box_unselect_child (EggFlowBox *box,
}
gboolean
-egg_flow_box_is_child_selected (EggFlowBox *box,
- EggFlowBoxChild *child)
+egg_flow_box_child_is_selected (EggFlowBoxChild *child)
{
EggFlowBoxChildPrivate *priv;
- g_return_if_fail (EGG_IS_FLOW_BOX (box));
g_return_if_fail (EGG_IS_FLOW_BOX_CHILD (child));
priv = egg_flow_box_child_get_instance_private (child);
+
return priv->selected;
}
@@ -4089,3 +4088,21 @@ egg_flow_box_insert (EggFlowBox *box,
egg_flow_box_apply_filter (box, info);
}
+EggFlowBoxChild *
+egg_flow_box_get_child_at_index (EggFlowBox *box,
+ gint index_)
+{
+ EggFlowBoxPrivate *priv;
+ GSequenceIter *iter;
+
+ g_return_val_if_fail (EGG_IS_FLOW_BOX (box), NULL);
+
+ priv = egg_flow_box_get_instance_private (box);
+
+ iter = g_sequence_get_iter_at_pos (priv->children, index_);
+ if (iter)
+ return g_sequence_get (iter);
+
+ return NULL;
+}
+
diff --git a/egg-flow-box.h b/egg-flow-box.h
index 2eb10dd..7899085 100644
--- a/egg-flow-box.h
+++ b/egg-flow-box.h
@@ -117,6 +117,7 @@ struct _EggFlowBoxChildClass
GType egg_flow_box_child_get_type (void) G_GNUC_CONST;
GtkWidget* egg_flow_box_child_new (void);
gint egg_flow_box_child_get_index (EggFlowBoxChild *child);
+gboolean egg_flow_box_child_is_selected (EggFlowBoxChild *child);
void egg_flow_box_child_changed (EggFlowBoxChild *child);
@@ -156,6 +157,8 @@ void egg_flow_box_set_activate_on_single_click (EggFlowBox
void egg_flow_box_insert (EggFlowBox *box,
GtkWidget *child,
gint position);
+EggFlowBoxChild *egg_flow_box_get_child_at_index (EggFlowBox *box,
+ gint index_);
GList *egg_flow_box_get_selected_children (EggFlowBox *box);
void egg_flow_box_selected_foreach (EggFlowBox *box,
@@ -167,8 +170,6 @@ void egg_flow_box_unselect_child (EggFlowBox
EggFlowBoxChild *child);
void egg_flow_box_select_all (EggFlowBox *box);
void egg_flow_box_unselect_all (EggFlowBox *box);
-gboolean egg_flow_box_is_child_selected (EggFlowBox *box,
- EggFlowBoxChild *child);
GtkSelectionMode egg_flow_box_get_selection_mode (EggFlowBox *box);
void egg_flow_box_set_selection_mode (EggFlowBox *box,
GtkSelectionMode mode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]