forked from AuroraMiddleware/gtk
Gail: use accessor functions to access GtkWidget
This commit is contained in:
parent
c8afa3f000
commit
104fdae2bf
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user