[gtk+] gail: add/remove horizontal/vertical state based on orientation value



commit f130db44ea8c2b85f98d3cc73637dc39c8f96ffe
Author: Szilárd Pfeiffer <mailbox pfeifferszilard hu>
Date:   Tue Jan 4 10:47:54 2011 -0500

    gail: add/remove horizontal/vertical state based on orientation value
    
    Now, these states are depending on the widget class.

 modules/other/gail/gailbox.c       |   22 ----------------------
 modules/other/gail/gailpaned.c     |   24 ------------------------
 modules/other/gail/gailrange.c     |   35 ++---------------------------------
 modules/other/gail/gailseparator.c |   22 ----------------------
 modules/other/gail/gailwidget.c    |   23 +++++++++++++++++++++++
 5 files changed, 25 insertions(+), 101 deletions(-)
---
diff --git a/modules/other/gail/gailbox.c b/modules/other/gail/gailbox.c
index c4a045b..f9d05b1 100644
--- a/modules/other/gail/gailbox.c
+++ b/modules/other/gail/gailbox.c
@@ -26,7 +26,6 @@ static void         gail_box_class_init            (GailBoxClass  *klass);
 static void         gail_box_init                  (GailBox       *box);
 static void         gail_box_initialize            (AtkObject     *accessible,
                                                     gpointer       data);
-static AtkStateSet* gail_box_ref_state_set         (AtkObject     *accessible);
 
 G_DEFINE_TYPE (GailBox, gail_box, GAIL_TYPE_CONTAINER)
 
@@ -36,7 +35,6 @@ gail_box_class_init (GailBoxClass *klass)
   AtkObjectClass  *class = ATK_OBJECT_CLASS (klass);
 
   class->initialize = gail_box_initialize;
-  class->ref_state_set = gail_box_ref_state_set;
 }
 
 static void
@@ -52,23 +50,3 @@ gail_box_initialize (AtkObject *accessible,
 
   accessible->role = ATK_ROLE_FILLER;
 }
-
-static AtkStateSet*
-gail_box_ref_state_set (AtkObject *accessible)
-{
-  AtkStateSet *state_set;
-  GtkWidget *widget;
-
-  state_set = ATK_OBJECT_CLASS (gail_box_parent_class)->ref_state_set (accessible);
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
-
-  if (widget == NULL)
-    return state_set;
-
-  if (GTK_IS_VBOX (widget) || GTK_IS_VBUTTON_BOX (widget))
-    atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
-  else if (GTK_IS_HBOX (widget) || GTK_IS_HBUTTON_BOX (widget))
-    atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
-
-  return state_set;
-}
diff --git a/modules/other/gail/gailpaned.c b/modules/other/gail/gailpaned.c
index 1e1404b..7f91f13 100644
--- a/modules/other/gail/gailpaned.c
+++ b/modules/other/gail/gailpaned.c
@@ -31,9 +31,6 @@ static void         gail_paned_real_initialize     (AtkObject      *obj,
                                                     gpointer       data);
 static void         gail_paned_size_allocate_gtk   (GtkWidget      *widget,
                                                     GtkAllocation  *allocation);
-
-static AtkStateSet* gail_paned_ref_state_set       (AtkObject      *accessible);
-
 static void         atk_value_interface_init       (AtkValueIface  *iface);
 static void         gail_paned_get_current_value   (AtkValue       *obj,
                                                     GValue         *value);
@@ -52,7 +49,6 @@ gail_paned_class_init (GailPanedClass *klass)
 {
   AtkObjectClass  *class = ATK_OBJECT_CLASS (klass);
 
-  class->ref_state_set = gail_paned_ref_state_set;
   class->initialize = gail_paned_real_initialize;
 }
 
@@ -61,26 +57,6 @@ gail_paned_init (GailPaned *paned)
 {
 }
 
-static AtkStateSet*
-gail_paned_ref_state_set (AtkObject *accessible)
-{
-  AtkStateSet *state_set;
-  GtkWidget *widget;
-
-  state_set = ATK_OBJECT_CLASS (gail_paned_parent_class)->ref_state_set (accessible);
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
-
-  if (widget == NULL)
-    return state_set;
-
-  if (GTK_IS_VPANED (widget))
-    atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
-  else if (GTK_IS_HPANED (widget))
-    atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
-
-  return state_set;
-}
-
 static void
 gail_paned_real_initialize (AtkObject *obj,
                             gpointer  data)
diff --git a/modules/other/gail/gailrange.c b/modules/other/gail/gailrange.c
index 07b6d75..d708567 100644
--- a/modules/other/gail/gailrange.c
+++ b/modules/other/gail/gailrange.c
@@ -35,9 +35,6 @@ static void         gail_range_real_initialize   (AtkObject      *obj,
 
 static void         gail_range_finalize          (GObject        *object);
 
-static AtkStateSet* gail_range_ref_state_set     (AtkObject      *obj);
-
-
 static void         gail_range_real_notify_gtk   (GObject        *obj,
                                                   GParamSpec     *pspec);
 
@@ -85,7 +82,6 @@ gail_range_class_init		(GailRangeClass *klass)
 
   widget_class->notify_gtk = gail_range_real_notify_gtk;
 
-  class->ref_state_set = gail_range_ref_state_set;
   class->initialize = gail_range_real_initialize;
 
   gobject_class->finalize = gail_range_finalize;
@@ -130,34 +126,7 @@ gail_range_real_initialize (AtkObject *obj,
   obj->role = ATK_ROLE_SLIDER;
 }
 
-static AtkStateSet*
-gail_range_ref_state_set (AtkObject *obj)
-{
-  AtkStateSet *state_set;
-  GtkWidget *widget;
-  GtkRange *range;
-
-  state_set = ATK_OBJECT_CLASS (gail_range_parent_class)->ref_state_set (obj);
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
-
-  if (widget == NULL)
-    return state_set;
-
-  range = GTK_RANGE (widget);
-
-  /*
-   * We do not generate property change for orientation change as there
-   * is no interface to change the orientation which emits a notification
-   */
-  if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
-    atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
-  else
-    atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
-
-  return state_set;
-}
-
-static void	 
+static void
 atk_value_interface_init (AtkValueIface *iface)
 {
   iface->get_current_value = gail_range_get_current_value;
@@ -167,7 +136,7 @@ atk_value_interface_init (AtkValueIface *iface)
   iface->set_current_value = gail_range_set_current_value;
 }
 
-static void	 
+static void
 gail_range_get_current_value (AtkValue		*obj,
                               GValue		*value)
 {
diff --git a/modules/other/gail/gailseparator.c b/modules/other/gail/gailseparator.c
index 6aaa010..22e9146 100644
--- a/modules/other/gail/gailseparator.c
+++ b/modules/other/gail/gailseparator.c
@@ -26,7 +26,6 @@ static void         gail_separator_class_init            (GailSeparatorClass  *k
 static void         gail_separator_init                  (GailSeparator       *accessible);
 static void         gail_separator_initialize            (AtkObject           *accessible,
                                                           gpointer             data);
-static AtkStateSet* gail_separator_ref_state_set	 (AtkObject	      *accessible);
 
 G_DEFINE_TYPE (GailSeparator, gail_separator, GAIL_TYPE_WIDGET)
 
@@ -36,7 +35,6 @@ gail_separator_class_init (GailSeparatorClass *klass)
   AtkObjectClass  *class = ATK_OBJECT_CLASS (klass);
 
   class->initialize = gail_separator_initialize;
-  class->ref_state_set = gail_separator_ref_state_set;
 }
 
 static void
@@ -52,23 +50,3 @@ gail_separator_initialize (AtkObject *accessible,
 
   accessible->role = ATK_ROLE_SEPARATOR;
 }
-
-static AtkStateSet*
-gail_separator_ref_state_set (AtkObject *accessible)
-{
-  AtkStateSet *state_set;
-  GtkWidget *widget;
-
-  state_set = ATK_OBJECT_CLASS (gail_separator_parent_class)->ref_state_set (accessible);
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
-
-  if (widget == NULL)
-    return state_set;
-
-  if (GTK_IS_VSEPARATOR (widget))
-    atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
-  else if (GTK_IS_HSEPARATOR (widget))
-    atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
-
-  return state_set;
-}
diff --git a/modules/other/gail/gailwidget.c b/modules/other/gail/gailwidget.c
index 89a27db..922673d 100644
--- a/modules/other/gail/gailwidget.c
+++ b/modules/other/gail/gailwidget.c
@@ -511,6 +511,18 @@ gail_widget_ref_state_set (AtkObject *accessible)
         {
           atk_state_set_add_state (state_set, ATK_STATE_DEFAULT);
         }
+
+      if (GTK_IS_ORIENTABLE(widget))
+        switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)))
+          {
+          case GTK_ORIENTATION_HORIZONTAL:
+            atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
+            break;
+
+          case GTK_ORIENTATION_VERTICAL:
+            atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
+            break;
+          }
     }
   return state_set;
 }
@@ -976,6 +988,15 @@ gail_widget_real_notify_gtk (GObject     *obj,
       state = ATK_STATE_SENSITIVE;
       value = gtk_widget_get_sensitive (widget);
     }
+  else if (strcmp (pspec->name, "orientation") == 0)
+    {
+      GtkOrientable *orientable;
+
+      orientable = GTK_ORIENTABLE (widget);
+
+      state = ATK_STATE_HORIZONTAL;
+      value = (gtk_orientable_get_orientation (orientable) == GTK_ORIENTATION_HORIZONTAL);
+    }
   else
     return;
 
@@ -983,6 +1004,8 @@ gail_widget_real_notify_gtk (GObject     *obj,
   if (state == ATK_STATE_SENSITIVE)
     atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, value);
 
+  if (state == ATK_STATE_HORIZONTAL)
+    atk_object_notify_state_change (atk_obj, ATK_STATE_VERTICAL, !value);
 }
 
 static void 



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