[gtk+/refactor: 108/145] Gail: use accessor functions to access GtkWidget



commit 915d3b74961400142140126a5ad0e401d716d55e
Author: Javier Jardón <jjardon gnome org>
Date:   Sun Aug 15 19:45:13 2010 +0200

    Gail: use accessor functions to access GtkWidget

 modules/other/gail/gail.c                  |    2 +-
 modules/other/gail/gailbutton.c            |    9 +++-
 modules/other/gail/gailmenu.c              |    2 +-
 modules/other/gail/gailscrollbar.c         |    6 ++-
 modules/other/gail/gailtoplevel.c          |    4 +-
 modules/other/gail/gailtreeview.c          |    3 +-
 modules/other/gail/gailutil.c              |   14 ++++---
 modules/other/gail/gailwidget.c            |   61 ++++++++++++++++-----------
 modules/other/gail/gailwindow.c            |   16 +++++---
 modules/other/gail/libgail-util/gailmisc.c |    5 +-
 10 files changed, 73 insertions(+), 49 deletions(-)
---
diff --git a/modules/other/gail/gail.c b/modules/other/gail/gail.c
index e72b564..6e97505 100644
--- a/modules/other/gail/gail.c
+++ b/modules/other/gail/gail.c
@@ -161,7 +161,7 @@ gail_get_accessible_for_widget (GtkWidget *widget,
     }
   else if (GTK_IS_TOGGLE_BUTTON (widget))
     {
-      GtkWidget *other_widget = widget->parent;
+      GtkWidget *other_widget = gtk_widget_get_parent (widget);
       if (GTK_IS_COMBO_BOX (other_widget))
         {
           gail_set_focus_widget (other_widget, widget);
diff --git a/modules/other/gail/gailbutton.c b/modules/other/gail/gailbutton.c
index ec22818..b49a129 100644
--- a/modules/other/gail/gailbutton.c
+++ b/modules/other/gail/gailbutton.c
@@ -498,12 +498,15 @@ idle_do_action (gpointer data)
   GtkWidget *widget;
   GailButton *gail_button;
   GdkEvent tmp_event;
+  GdkWindow *window;
 
   gail_button = GAIL_BUTTON (data);
   gail_button->action_idle_handler = 0;
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (gail_button));
+  window = gtk_widget_get_window (widget);
+
   tmp_event.button.type = GDK_BUTTON_RELEASE;
-  tmp_event.button.window = widget->window;
+  tmp_event.button.window = window;
   tmp_event.button.button = 1;
   tmp_event.button.send_event = TRUE;
   tmp_event.button.time = GDK_CURRENT_TIME;
@@ -543,7 +546,7 @@ idle_do_action (gpointer data)
 	   * not get the job done for a GtkOptionMenu.  
 	   */
 	  tmp_event.button.type = GDK_BUTTON_PRESS;
-	  tmp_event.button.window = widget->window;
+	  tmp_event.button.window = window;
 	  tmp_event.button.button = 1;
 	  tmp_event.button.send_event = TRUE;
 	  tmp_event.button.time = GDK_CURRENT_TIME;
@@ -565,7 +568,7 @@ idle_do_action (gpointer data)
 	   * not get the job done for a GtkOptionMenu.  
 	   */
 	  tmp_event.button.type = GDK_BUTTON_PRESS;
-	  tmp_event.button.window = widget->window;
+	  tmp_event.button.window = window;
 	  tmp_event.button.button = 1;
 	  tmp_event.button.send_event = TRUE;
 	  tmp_event.button.time = GDK_CURRENT_TIME;
diff --git a/modules/other/gail/gailmenu.c b/modules/other/gail/gailmenu.c
index 5cdb1e6..b744d0c 100644
--- a/modules/other/gail/gailmenu.c
+++ b/modules/other/gail/gailmenu.c
@@ -91,7 +91,7 @@ gail_menu_get_parent (AtkObject *accessible)
       parent_widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
 
       if (!GTK_IS_MENU_ITEM (parent_widget) && !GTK_IS_BUTTON (parent_widget) && !GTK_IS_COMBO_BOX (parent_widget))
-        parent_widget = widget->parent;
+        parent_widget = gtk_widget_get_parent (widget);
 
       if (parent_widget == NULL)
         return NULL;
diff --git a/modules/other/gail/gailscrollbar.c b/modules/other/gail/gailscrollbar.c
index 35774db..d6ddb45 100644
--- a/modules/other/gail/gailscrollbar.c
+++ b/modules/other/gail/gailscrollbar.c
@@ -58,6 +58,7 @@ static gint
 gail_scrollbar_get_index_in_parent (AtkObject *accessible)
 {
   GtkWidget *widget;
+  GtkWidget *parent;
   GtkScrolledWindow *scrolled_window;
   gint n_children;
   GList *children;
@@ -73,10 +74,11 @@ gail_scrollbar_get_index_in_parent (AtkObject *accessible)
   }
   g_return_val_if_fail (GTK_IS_SCROLLBAR (widget), -1);
 
-  if (!GTK_IS_SCROLLED_WINDOW(widget->parent))
+  parent = gtk_widget_get_parent (widget);
+  if (!GTK_IS_SCROLLED_WINDOW (parent))
     return ATK_OBJECT_CLASS (gail_scrollbar_parent_class)->get_index_in_parent (accessible);
 
-  scrolled_window = GTK_SCROLLED_WINDOW (widget->parent);
+  scrolled_window = GTK_SCROLLED_WINDOW (parent);
   children = gtk_container_get_children (GTK_CONTAINER (scrolled_window));
   n_children = g_list_length (children);
   g_list_free (children);
diff --git a/modules/other/gail/gailtoplevel.c b/modules/other/gail/gailtoplevel.c
index 8d01105..6205a42 100644
--- a/modules/other/gail/gailtoplevel.c
+++ b/modules/other/gail/gailtoplevel.c
@@ -94,7 +94,7 @@ gail_toplevel_init (GailToplevel *toplevel)
       if (!window || 
           !gtk_widget_get_visible (widget) ||
           is_attached_menu_window (widget) ||
-          GTK_WIDGET (window)->parent ||
+          gtk_widget_get_parent (GTK_WIDGET (window)) ||
           GTK_IS_PLUG (window))
         {
           GList *temp_l  = l->next;
@@ -213,7 +213,7 @@ gail_toplevel_show_event_watcher (GSignalInvocationHint *ihint,
     return TRUE;
 
   widget = GTK_WIDGET (object);
-  if (widget->parent || 
+  if (gtk_widget_get_parent (widget) ||
       is_attached_menu_window (widget) ||
       is_combo_window (widget) ||
       GTK_IS_PLUG (widget))
diff --git a/modules/other/gail/gailtreeview.c b/modules/other/gail/gailtreeview.c
index 695987e..b957028 100644
--- a/modules/other/gail/gailtreeview.c
+++ b/modules/other/gail/gailtreeview.c
@@ -2206,7 +2206,8 @@ gail_tree_view_grab_cell_focus  (GailCellParent *parent,
       if (gtk_widget_is_toplevel (toplevel))
 	{
 #ifdef GDK_WINDOWING_X11
-	  gtk_window_present_with_time (GTK_WINDOW (toplevel), gdk_x11_get_server_time (widget->window));
+	  gtk_window_present_with_time (GTK_WINDOW (toplevel),
+                                        gdk_x11_get_server_time (gtk_widget_get_window (widget)));
 #else
 	  gtk_window_present (GTK_WINDOW (toplevel));
 #endif
diff --git a/modules/other/gail/gailutil.c b/modules/other/gail/gailutil.c
index 8d1c5fd..f784538 100644
--- a/modules/other/gail/gailutil.c
+++ b/modules/other/gail/gailutil.c
@@ -537,6 +537,7 @@ configure_event_watcher (GSignalInvocationHint  *hint,
                          const GValue           *param_values,
                          gpointer               data)
 {
+  GtkAllocation allocation;
   GObject *object;
   GtkWidget *widget;
   AtkObject *atk_obj;
@@ -561,14 +562,15 @@ configure_event_watcher (GSignalInvocationHint  *hint,
      */
     return TRUE;
   widget = GTK_WIDGET (object);
-  if (widget->allocation.x == ((GdkEventConfigure *)event)->x &&
-      widget->allocation.y == ((GdkEventConfigure *)event)->y &&
-      widget->allocation.width == ((GdkEventConfigure *)event)->width &&
-      widget->allocation.height == ((GdkEventConfigure *)event)->height)
+  gtk_widget_get_allocation (widget, &allocation);
+  if (allocation.x == ((GdkEventConfigure *)event)->x &&
+      allocation.y == ((GdkEventConfigure *)event)->y &&
+      allocation.width == ((GdkEventConfigure *)event)->width &&
+      allocation.height == ((GdkEventConfigure *)event)->height)
     return TRUE;
 
-  if (widget->allocation.width != ((GdkEventConfigure *)event)->width ||
-      widget->allocation.height != ((GdkEventConfigure *)event)->height)
+  if (allocation.width != ((GdkEventConfigure *)event)->width ||
+      allocation.height != ((GdkEventConfigure *)event)->height)
     {
       signal_name = "resize";
     }
diff --git a/modules/other/gail/gailwidget.c b/modules/other/gail/gailwidget.c
index 6c320b5..30a7153 100644
--- a/modules/other/gail/gailwidget.c
+++ b/modules/other/gail/gailwidget.c
@@ -277,7 +277,7 @@ gail_widget_get_parent (AtkObject *accessible)
         return NULL;
       gail_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 
-      parent_widget = widget->parent;
+      parent_widget = gtk_widget_get_parent (widget);
       if (parent_widget == NULL)
         return NULL;
 
@@ -564,7 +564,7 @@ gail_widget_get_index_in_parent (AtkObject *accessible)
     }
 
   gail_return_val_if_fail (GTK_IS_WIDGET (widget), -1);
-  parent_widget = widget->parent;
+  parent_widget = gtk_widget_get_parent (widget);
   if (parent_widget == NULL)
     return -1;
   gail_return_val_if_fail (GTK_IS_CONTAINER (parent_widget), -1);
@@ -629,6 +629,7 @@ gail_widget_get_extents (AtkComponent   *component,
                          gint           *height,
                          AtkCoordType   coord_type)
 {
+  GtkAllocation allocation;
   GdkWindow *window;
   gint x_window, y_window;
   gint x_toplevel, y_toplevel;
@@ -642,8 +643,9 @@ gail_widget_get_extents (AtkComponent   *component,
 
   gail_return_if_fail (GTK_IS_WIDGET (widget));
 
-  *width = widget->allocation.width;
-  *height = widget->allocation.height;
+  gtk_widget_get_allocation (widget, &allocation);
+  *width = allocation.width;
+  *height = allocation.height;
   if (!gail_widget_on_screen (widget) || (!gtk_widget_is_drawable (widget)))
     {
       *x = G_MININT;
@@ -651,17 +653,17 @@ gail_widget_get_extents (AtkComponent   *component,
       return;
     }
 
-  if (widget->parent)
+  if (gtk_widget_get_parent (widget))
     {
-      *x = widget->allocation.x;
-      *y = widget->allocation.y;
+      *x = allocation.x;
+      *y = allocation.y;
       window = gtk_widget_get_parent_window (widget);
     }
   else
     {
       *x = 0;
       *y = 0;
-      window = widget->window;
+      window = gtk_widget_get_window (widget);
     }
   gdk_window_get_origin (window, &x_window, &y_window);
   *x += x_window;
@@ -670,7 +672,7 @@ gail_widget_get_extents (AtkComponent   *component,
  
  if (coord_type == ATK_XY_WINDOW) 
     { 
-      window = gdk_window_get_toplevel (widget->window);
+      window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
       gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
 
       *x -= x_toplevel;
@@ -683,6 +685,7 @@ gail_widget_get_size (AtkComponent   *component,
                       gint           *width,
                       gint           *height)
 {
+  GtkAllocation allocation;
   GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
 
   if (widget == NULL)
@@ -693,8 +696,9 @@ gail_widget_get_size (AtkComponent   *component,
 
   gail_return_if_fail (GTK_IS_WIDGET (widget));
 
-  *width = widget->allocation.width;
-  *height = widget->allocation.height;
+  gtk_widget_get_allocation (widget, &allocation);
+  *width = allocation.width;
+  *height = allocation.height;
 }
 
 static AtkLayer
@@ -720,7 +724,8 @@ gail_widget_grab_focus (AtkComponent   *component)
       if (gtk_widget_is_toplevel (toplevel))
 	{
 #ifdef GDK_WINDOWING_X11
-	  gtk_window_present_with_time (GTK_WINDOW (toplevel), gdk_x11_get_server_time (widget->window));
+          gtk_window_present_with_time (GTK_WINDOW (toplevel),
+          gdk_x11_get_server_time (gtk_widget_get_window (widget)));
 #else
 	  gtk_window_present (GTK_WINDOW (toplevel));
 #endif
@@ -760,7 +765,7 @@ gail_widget_set_extents (AtkComponent   *component,
       if (coord_type == ATK_XY_WINDOW)
         {
           gint x_current, y_current;
-          GdkWindow *window = widget->window;
+          GdkWindow *window = gtk_widget_get_window (widget);
 
           gdk_window_get_origin (window, &x_current, &y_current);
           x_current += x;
@@ -804,7 +809,7 @@ gail_widget_set_position (AtkComponent   *component,
       if (coord_type == ATK_XY_WINDOW)
         {
           gint x_current, y_current;
-          GdkWindow *window = widget->window;
+          GdkWindow *window = gtk_widget_get_window (widget);
 
           gdk_window_get_origin (window, &x_current, &y_current);
           x_current += x;
@@ -1000,12 +1005,12 @@ gail_widget_find_viewport (GtkWidget *widget)
    */
   GtkWidget *parent;
 
-  parent = widget->parent;
+  parent = gtk_widget_get_parent (widget);
   while (parent != NULL)
     {
       if (GTK_IS_VIEWPORT (parent))
         break;
-      parent = parent->parent;
+      parent = gtk_widget_get_parent (parent);
     }
   return parent;
 }
@@ -1017,26 +1022,32 @@ gail_widget_find_viewport (GtkWidget *widget)
  */ 
 static gboolean gail_widget_on_screen (GtkWidget *widget)
 {
+  GtkAllocation allocation;
   GtkWidget *viewport;
   gboolean return_value;
 
+  gtk_widget_get_allocation (widget, &allocation);
+
   viewport = gail_widget_find_viewport (widget);
   if (viewport)
     {
+      GtkAllocation viewport_allocation;
       GtkAdjustment *adjustment;
       GdkRectangle visible_rect;
 
+      gtk_widget_get_allocation (viewport, &viewport_allocation);
+
       adjustment = gtk_viewport_get_vadjustment (GTK_VIEWPORT (viewport));
       visible_rect.y = adjustment->value;
       adjustment = gtk_viewport_get_hadjustment (GTK_VIEWPORT (viewport));
       visible_rect.x = adjustment->value;
-      visible_rect.width = viewport->allocation.width;
-      visible_rect.height = viewport->allocation.height;
-             
-      if (((widget->allocation.x + widget->allocation.width) < visible_rect.x) ||
-         ((widget->allocation.y + widget->allocation.height) < visible_rect.y) ||
-         (widget->allocation.x > (visible_rect.x + visible_rect.width)) ||
-         (widget->allocation.y > (visible_rect.y + visible_rect.height)))
+      visible_rect.width = viewport_allocation.width;
+      visible_rect.height = viewport_allocation.height;
+
+      if (((allocation.x + allocation.width) < visible_rect.x) ||
+         ((allocation.y + allocation.height) < visible_rect.y) ||
+         (allocation.x > (visible_rect.x + visible_rect.width)) ||
+         (allocation.y > (visible_rect.y + visible_rect.height)))
         return_value = FALSE;
       else
         return_value = TRUE;
@@ -1047,8 +1058,8 @@ static gboolean gail_widget_on_screen (GtkWidget *widget)
        * Check whether the widget has been placed of the screen. The
        * widget may be MAPPED as when toolbar items do not fit on the toolbar.
        */
-      if (widget->allocation.x + widget->allocation.width <= 0 &&
-          widget->allocation.y + widget->allocation.height <= 0)
+      if (allocation.x + allocation.width <= 0 &&
+          allocation.y + allocation.height <= 0)
         return_value = FALSE;
       else 
         return_value = TRUE;
diff --git a/modules/other/gail/gailwindow.c b/modules/other/gail/gailwindow.c
index 9b62acb..88f47a0 100644
--- a/modules/other/gail/gailwindow.c
+++ b/modules/other/gail/gailwindow.c
@@ -434,6 +434,7 @@ gail_window_ref_state_set (AtkObject *accessible)
   AtkStateSet *state_set;
   GtkWidget *widget;
   GtkWindow *window;
+  GdkWindow *gdk_window;
   GdkWindowState state;
 
   state_set = ATK_OBJECT_CLASS (gail_window_parent_class)->ref_state_set (accessible);
@@ -447,9 +448,10 @@ gail_window_ref_state_set (AtkObject *accessible)
   if (window->has_focus)
     atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
 
-  if (widget->window)
+  gdk_window = gtk_widget_get_window (widget);
+  if (window)
     {
-      state = gdk_window_get_state (widget->window);
+      state = gdk_window_get_state (gdk_window);
       if (state & GDK_WINDOW_STATE_ICONIFIED)
         atk_state_set_add_state (state_set, ATK_STATE_ICONIFIED);
     } 
@@ -570,7 +572,8 @@ gail_window_get_extents (AtkComponent  *component,
       return;
     }
 
-  gdk_window_get_frame_extents (widget->window, &rect);
+  gdk_window_get_frame_extents (gtk_widget_get_window (widget),
+                                &rect);
 
   *width = rect.width;
   *height = rect.height;
@@ -584,7 +587,8 @@ gail_window_get_extents (AtkComponent  *component,
   *y = rect.y;
   if (coord_type == ATK_XY_WINDOW)
     {
-      gdk_window_get_origin (widget->window, &x_toplevel, &y_toplevel);
+      gdk_window_get_origin (gtk_widget_get_window (widget),
+                             &x_toplevel, &y_toplevel);
       *x -= x_toplevel;
       *y -= y_toplevel;
     }
@@ -614,7 +618,7 @@ gail_window_get_size (AtkComponent *component,
       parent_iface->get_size (component, width, height);
       return;
     }
-  gdk_window_get_frame_extents (widget->window, &rect);
+  gdk_window_get_frame_extents (gtk_widget_get_window (widget), &rect);
 
   *width = rect.width;
   *height = rect.height;
@@ -1010,7 +1014,7 @@ gail_window_get_mdi_zorder (AtkComponent *component)
 
   gail_return_val_if_fail (GTK_IS_WINDOW (widget), -1);
 
-  return get_window_zorder (widget->window);
+  return get_window_zorder (gtk_widget_get_window (widget));
 }
 
 #elif defined (GDK_WINDOWING_WIN32)
diff --git a/modules/other/gail/libgail-util/gailmisc.c b/modules/other/gail/libgail-util/gailmisc.c
index 57320d2..a70a4f0 100644
--- a/modules/other/gail/libgail-util/gailmisc.c
+++ b/modules/other/gail/libgail-util/gailmisc.c
@@ -549,9 +549,10 @@ gail_misc_get_origins (GtkWidget *widget,
   if (GTK_IS_TREE_VIEW (widget))
     window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
   else
-    window = widget->window;
+    window = gtk_widget_get_window (widget);
+
   gdk_window_get_origin (window, x_window, y_window);
-  window = gdk_window_get_toplevel (widget->window);
+  window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
   gdk_window_get_origin (window, x_toplevel, y_toplevel);
 }
 



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