[egg-list-box/flow-box-enhancements] Add an EggFlowBoxChildAccessible



commit e47623780cf01fc17636a8ef87cab73414f788aa
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Sep 27 20:38:21 2013 -0400

    Add an EggFlowBoxChildAccessible
    
    This is an almost 1-1 copy of GtkListBoxRowAccessible.
    It implements the selection interface.

 Makefile.am                     |    3 +-
 egg-flow-box-child-accessible.c |   69 +++++++++++++++++++++++++++++++++++++++
 egg-flow-box-child-accessible.h |   49 +++++++++++++++++++++++++++
 egg-flow-box.c                  |    6 +++
 4 files changed, 126 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 282ff54..af23b8d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,8 @@ libegglistbox_la_LIBADD = $(LISTBOX_LIBS)
 
 libeggflowbox_la_SOURCES = \
        egg-flow-box.c egg-flow-box.h \
-       egg-flow-box-accessible.c egg-flow-box-accessible.h
+       egg-flow-box-accessible.c egg-flow-box-accessible.h \
+       egg-flow-box-child-accessible.c egg-flow-box-child-accessible.h
 
 libeggflowbox_la_LIBADD = $(LISTBOX_LIBS)
 
diff --git a/egg-flow-box-child-accessible.c b/egg-flow-box-child-accessible.c
new file mode 100644
index 0000000..2552db1
--- /dev/null
+++ b/egg-flow-box-child-accessible.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "egg-flow-box-child-accessible.h"
+#include "egg-flow-box.h"
+
+
+G_DEFINE_TYPE (EggFlowBoxChildAccessible, egg_flow_box_child_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE)
+
+static void
+egg_flow_box_child_accessible_init (EggFlowBoxChildAccessible *accessible)
+{
+}
+
+static void
+egg_flow_box_child_accessible_initialize (AtkObject *obj,
+                                          gpointer   data)
+{
+  ATK_OBJECT_CLASS (egg_flow_box_child_accessible_parent_class)->initialize (obj, data);
+
+  obj->role = ATK_ROLE_TABLE_CELL;
+}
+
+static AtkStateSet *
+egg_flow_box_child_accessible_ref_state_set (AtkObject *obj)
+{
+  AtkStateSet *state_set;
+  GtkWidget *widget, *parent;
+
+  state_set = ATK_OBJECT_CLASS (egg_flow_box_child_accessible_parent_class)->ref_state_set (obj);
+
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+  if (widget != NULL)
+    {
+      parent = gtk_widget_get_parent (widget);
+      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)))
+        atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
+    }
+
+  return state_set;
+}
+
+static void
+egg_flow_box_child_accessible_class_init (EggFlowBoxChildAccessibleClass *klass)
+{
+  AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
+
+  object_class->initialize = egg_flow_box_child_accessible_initialize;
+  object_class->ref_state_set = egg_flow_box_child_accessible_ref_state_set;
+}
diff --git a/egg-flow-box-child-accessible.h b/egg-flow-box-child-accessible.h
new file mode 100644
index 0000000..092d6d0
--- /dev/null
+++ b/egg-flow-box-child-accessible.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __EGG_FLOW_BOX_CHILD_ACCESSIBLE_H__
+#define __EGG_FLOW_BOX_CHILD_ACCESSIBLE_H__
+
+#include <gtk/gtk-a11y.h>
+
+G_BEGIN_DECLS
+
+#define EGG_TYPE_FLOW_BOX_CHILD_ACCESSIBLE               (egg_flow_box_child_accessible_get_type ())
+#define EGG_FLOW_BOX_CHILD_ACCESSIBLE(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
EGG_TYPE_FLOW_BOX_CHILD_ACCESSIBLE, EggFlowBoxChildAccessible))
+#define EGG_FLOW_BOX_CHILD_ACCESSIBLE_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), 
EGG_TYPE_FLOW_BOX_CHILD_ACCESSIBLE, EggFlowBoxChildAccessibleClass))
+#define EGG_IS_FLOW_BOX_CHILD_ACCESSIBLE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
EGG_TYPE_FLOW_BOX_CHILD_ACCESSIBLE))
+#define EGG_IS_FLOW_BOX_CHILD_ACCESSIBLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), 
EGG_TYPE_FLOW_BOX_CHILD_ACCESSIBLE))
+#define EGG_FLOW_BOX_CHILD_ACCESSIBLE_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), 
EGG_TYPE_FLOW_BOX_CHILD_ACCESSIBLE, EggFlowBoxChildAccessibleClass))
+
+typedef struct _EggFlowBoxChildAccessible        EggFlowBoxChildAccessible;
+typedef struct _EggFlowBoxChildAccessibleClass   EggFlowBoxChildAccessibleClass;
+
+struct _EggFlowBoxChildAccessible
+{
+  GtkContainerAccessible parent;
+};
+
+struct _EggFlowBoxChildAccessibleClass
+{
+  GtkContainerAccessibleClass parent_class;
+};
+
+GType egg_flow_box_child_accessible_get_type (void);
+
+G_END_DECLS
+
+#endif /* __EGG_FLOW_BOX_CHILD_ACCESSIBLE_H__ */
diff --git a/egg-flow-box.c b/egg-flow-box.c
index eb58f74..0e86f16 100644
--- a/egg-flow-box.c
+++ b/egg-flow-box.c
@@ -48,6 +48,7 @@
 #include <gtk/gtk.h>
 #include "egg-flow-box.h"
 #include "egg-flow-box-accessible.h"
+#include "egg-flow-box-child-accessible.h"
 
 /* This already exists in gtk as _gtk_marshal_VOID__ENUM_INT, inline it here for now
    to avoid separate marshallers file */
@@ -2507,6 +2508,7 @@ static gboolean
 egg_flow_box_child_set_selected (EggFlowBoxChild *child,
                                  gboolean         selected)
 {
+  EggFlowBox *box;
   EggFlowBoxChildPrivate *priv;
 
   priv = egg_flow_box_child_get_instance_private (child);
@@ -2519,6 +2521,10 @@ egg_flow_box_child_set_selected (EggFlowBoxChild *child,
       else
         gtk_widget_unset_state_flags (GTK_WIDGET (child),
                                       GTK_STATE_FLAG_SELECTED);
+
+      box = egg_flow_box_child_get_box (child);
+      _egg_flow_box_accessible_selection_changed (GTK_WIDGET (box));
+
       gtk_widget_queue_draw (GTK_WIDGET (child));
 
       return TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]