[gtk+] Add api for setting the layer



commit 2980659ab1c93957b4a8aacedfef8771e8b227a7
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jul 3 15:34:06 2011 -0400

    Add api for setting the layer
    
    Add api for setting the component layer, instead of open-coding
    the object data key, and use it.

 gtk/a11y/gtkmenuaccessible.c     |    3 +--
 gtk/a11y/gtkmenuitemaccessible.c |    2 +-
 gtk/a11y/gtkwidgetaccessible.c   |   14 +++++++++++---
 gtk/a11y/gtkwidgetaccessible.h   |    3 +++
 gtk/a11y/gtkwindowaccessible.c   |    2 +-
 5 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/gtk/a11y/gtkmenuaccessible.c b/gtk/a11y/gtkmenuaccessible.c
index 648b9d3..4f38f6e 100644
--- a/gtk/a11y/gtkmenuaccessible.c
+++ b/gtk/a11y/gtkmenuaccessible.c
@@ -32,8 +32,7 @@ gtk_menu_accessible_initialize (AtkObject *obj,
 
   obj->role = ATK_ROLE_MENU;
 
-  g_object_set_data (G_OBJECT (obj), "atk-component-layer",
-                     GINT_TO_POINTER (ATK_LAYER_POPUP));
+  gtk_widget_accessible_set_layer (GTK_WIDGET_ACCESSIBLE (obj), ATK_LAYER_POPUP);
 }
 
 static AtkObject *
diff --git a/gtk/a11y/gtkmenuitemaccessible.c b/gtk/a11y/gtkmenuitemaccessible.c
index 303dafa..5d83bd4 100644
--- a/gtk/a11y/gtkmenuitemaccessible.c
+++ b/gtk/a11y/gtkmenuitemaccessible.c
@@ -62,7 +62,7 @@ gtk_menu_item_accessible_initialize (AtkObject *obj,
         atk_object_set_parent (obj, gtk_widget_get_accessible (parent_widget));
     }
 
-  g_object_set_data (G_OBJECT (obj), "atk-component-layer", GINT_TO_POINTER (ATK_LAYER_POPUP));
+  gtk_widget_accessible_set_layer (GTK_WIDGET_ACCESSIBLE (obj), ATK_LAYER_POPUP);
 
   if (GTK_IS_TEAROFF_MENU_ITEM (data))
     obj->role = ATK_ROLE_TEAR_OFF_MENU_ITEM;
diff --git a/gtk/a11y/gtkwidgetaccessible.c b/gtk/a11y/gtkwidgetaccessible.c
index c522256..f7c1fd1 100644
--- a/gtk/a11y/gtkwidgetaccessible.c
+++ b/gtk/a11y/gtkwidgetaccessible.c
@@ -133,8 +133,6 @@ gtk_widget_accessible_initialize (AtkObject *obj,
 
   g_signal_connect (accessible, "focus-event", G_CALLBACK (focus_event), NULL);
 
-  g_object_set_data (G_OBJECT (obj), "atk-component-layer", GINT_TO_POINTER (ATK_LAYER_WIDGET));
-
   obj->role = ATK_ROLE_UNKNOWN;
 }
 
@@ -651,7 +649,17 @@ gtk_widget_accessible_get_layer (AtkComponent *component)
 
   layer = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (component), "atk-component-layer"));
 
-  return (AtkLayer) layer;
+  if (layer == 0)
+    return ATK_LAYER_WIDGET;
+  else
+    return (AtkLayer) layer;
+}
+
+void
+gtk_widget_accessible_set_layer (GtkWidgetAccessible *accessible,
+                                 AtkLayer             layer)
+{
+  g_object_set_data (G_OBJECT (accessible), "atk-component-layer", GINT_TO_POINTER (layer));
 }
 
 static gboolean
diff --git a/gtk/a11y/gtkwidgetaccessible.h b/gtk/a11y/gtkwidgetaccessible.h
index f51f3f0..05931ea 100644
--- a/gtk/a11y/gtkwidgetaccessible.h
+++ b/gtk/a11y/gtkwidgetaccessible.h
@@ -58,6 +58,9 @@ struct _GtkWidgetAccessibleClass
 
 GType gtk_widget_accessible_get_type (void);
 
+void  gtk_widget_accessible_set_layer (GtkWidgetAccessible *obj,
+                                       AtkLayer             layer);
+
 G_END_DECLS
 
 #endif /* __GTK_WIDGET_ACCESSIBLE_H__ */
diff --git a/gtk/a11y/gtkwindowaccessible.c b/gtk/a11y/gtkwindowaccessible.c
index 4ca157f..d166e23 100644
--- a/gtk/a11y/gtkwindowaccessible.c
+++ b/gtk/a11y/gtkwindowaccessible.c
@@ -114,7 +114,7 @@ gtk_window_accessible_initialize (AtkObject *obj,
   ATK_OBJECT_CLASS (gtk_window_accessible_parent_class)->initialize (obj, data);
 
   g_signal_connect (data, "window_state_event", G_CALLBACK (window_state_event_cb), NULL);
-  g_object_set_data (G_OBJECT (obj), "atk-component-layer", GINT_TO_POINTER (ATK_LAYER_WINDOW));
+  gtk_widget_accessible_set_layer (GTK_WIDGET_ACCESSIBLE (obj), ATK_LAYER_WINDOW);
 
   if (GTK_IS_FILE_CHOOSER_DIALOG (widget))
     obj->role = ATK_ROLE_FILE_CHOOSER;



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