Commit 1ebe3b51 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Add a utility function to translate coordinates relative to one widget's

Tue Oct 16 15:50:03 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Add
	a utility function to translate coordinates relative to
	one widget's allocation to coordinates relative to another
	widget's allocation.

	* gtk/gtkradiobutton.c: Add a special ->focus() implementation
	that:
	 - only accepts external focus if there is no active
   	   member of the group or the button is active.
	 - makes arrow keys move the active button as well
	   as the focus
	 - make tab tab out directly.
	This makes a radio button group act as a single focus location.
	(#53577).

	* gtk/gtkcontainer.c (gtk_container_focus): Remove prefiltering -
	it was only a small optimization that didn't matter and made
	things more complicated.

	* gtk/gtkcontainer.c (gtk_container_focus_tab): Get rid of custom
	sorter for FOCUS_TAB as we did for the other focus directions,
	sort by center of widgets, not upper-left corner. (Shouldn't
	matter in general.)

	* gtk/gtkcontainer.c: Restructure code to remove duplicate code
	from the different types of focusing: encapsulate sorting the
	widgets for the focus direction into one routine
	(gtk_container_focus_sort()) and then share the work of moving the
	focus between the different focus directions.

	* gtk/gtkcontainer.c: Fix bug where arrow navigation might not
	work correctly with focus chains containing non-immediate
	children. Sorting was being done using allocation coordinates for
	each widget in the focus chain, and if there were intermediate
	window-widgets, these allocations would not be in the same
	coordinate system.
parent 3612439d
Tue Oct 16 15:50:03 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Add
a utility function to translate coordinates relative to
one widget's allocation to coordinates relative to another
widget's allocation.
* gtk/gtkradiobutton.c: Add a special ->focus() implementation
that:
- only accepts external focus if there is no active
member of the group or the button is active.
- makes arrow keys move the active button as well
as the focus
- make tab tab out directly.
This makes a radio button group act as a single focus location.
(#53577).
* gtk/gtkcontainer.c (gtk_container_focus): Remove prefiltering -
it was only a small optimization that didn't matter and made
things more complicated.
* gtk/gtkcontainer.c (gtk_container_focus_tab): Get rid of custom
sorter for FOCUS_TAB as we did for the other focus directions,
sort by center of widgets, not upper-left corner. (Shouldn't
matter in general.)
* gtk/gtkcontainer.c: Restructure code to remove duplicate code
from the different types of focusing: encapsulate sorting the
widgets for the focus direction into one routine
(gtk_container_focus_sort()) and then share the work of moving the
focus between the different focus directions.
* gtk/gtkcontainer.c: Fix bug where arrow navigation might not
work correctly with focus chains containing non-immediate
children. Sorting was being done using allocation coordinates for
each widget in the focus chain, and if there were intermediate
window-widgets, these allocations would not be in the same
coordinate system.
Tue Oct 16 15:12:26 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_mnemonic_activate): add a
mnemonic_activate function to option menu.
2001-10-15 Murray Cumming <murrayc@usa.net
2001-10-15 Murray Cumming <murrayc@usa.net>
* gtk/gtkinputdialog.c, gtk/gtktoolbar.c, gtk/gtkwidget.c:
Corrected the type names used in some calls to g_signal_new().
......
Tue Oct 16 15:50:03 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Add
a utility function to translate coordinates relative to
one widget's allocation to coordinates relative to another
widget's allocation.
* gtk/gtkradiobutton.c: Add a special ->focus() implementation
that:
- only accepts external focus if there is no active
member of the group or the button is active.
- makes arrow keys move the active button as well
as the focus
- make tab tab out directly.
This makes a radio button group act as a single focus location.
(#53577).
* gtk/gtkcontainer.c (gtk_container_focus): Remove prefiltering -
it was only a small optimization that didn't matter and made
things more complicated.
* gtk/gtkcontainer.c (gtk_container_focus_tab): Get rid of custom
sorter for FOCUS_TAB as we did for the other focus directions,
sort by center of widgets, not upper-left corner. (Shouldn't
matter in general.)
* gtk/gtkcontainer.c: Restructure code to remove duplicate code
from the different types of focusing: encapsulate sorting the
widgets for the focus direction into one routine
(gtk_container_focus_sort()) and then share the work of moving the
focus between the different focus directions.
* gtk/gtkcontainer.c: Fix bug where arrow navigation might not
work correctly with focus chains containing non-immediate
children. Sorting was being done using allocation coordinates for
each widget in the focus chain, and if there were intermediate
window-widgets, these allocations would not be in the same
coordinate system.
Tue Oct 16 15:12:26 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_mnemonic_activate): add a
mnemonic_activate function to option menu.
2001-10-15 Murray Cumming <murrayc@usa.net
2001-10-15 Murray Cumming <murrayc@usa.net>
* gtk/gtkinputdialog.c, gtk/gtktoolbar.c, gtk/gtkwidget.c:
Corrected the type names used in some calls to g_signal_new().
......
Tue Oct 16 15:50:03 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Add
a utility function to translate coordinates relative to
one widget's allocation to coordinates relative to another
widget's allocation.
* gtk/gtkradiobutton.c: Add a special ->focus() implementation
that:
- only accepts external focus if there is no active
member of the group or the button is active.
- makes arrow keys move the active button as well
as the focus
- make tab tab out directly.
This makes a radio button group act as a single focus location.
(#53577).
* gtk/gtkcontainer.c (gtk_container_focus): Remove prefiltering -
it was only a small optimization that didn't matter and made
things more complicated.
* gtk/gtkcontainer.c (gtk_container_focus_tab): Get rid of custom
sorter for FOCUS_TAB as we did for the other focus directions,
sort by center of widgets, not upper-left corner. (Shouldn't
matter in general.)
* gtk/gtkcontainer.c: Restructure code to remove duplicate code
from the different types of focusing: encapsulate sorting the
widgets for the focus direction into one routine
(gtk_container_focus_sort()) and then share the work of moving the
focus between the different focus directions.
* gtk/gtkcontainer.c: Fix bug where arrow navigation might not
work correctly with focus chains containing non-immediate
children. Sorting was being done using allocation coordinates for
each widget in the focus chain, and if there were intermediate
window-widgets, these allocations would not be in the same
coordinate system.
Tue Oct 16 15:12:26 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_mnemonic_activate): add a
mnemonic_activate function to option menu.
2001-10-15 Murray Cumming <murrayc@usa.net
2001-10-15 Murray Cumming <murrayc@usa.net>
* gtk/gtkinputdialog.c, gtk/gtktoolbar.c, gtk/gtkwidget.c:
Corrected the type names used in some calls to g_signal_new().
......
Tue Oct 16 15:50:03 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Add
a utility function to translate coordinates relative to
one widget's allocation to coordinates relative to another
widget's allocation.
* gtk/gtkradiobutton.c: Add a special ->focus() implementation
that:
- only accepts external focus if there is no active
member of the group or the button is active.
- makes arrow keys move the active button as well
as the focus
- make tab tab out directly.
This makes a radio button group act as a single focus location.
(#53577).
* gtk/gtkcontainer.c (gtk_container_focus): Remove prefiltering -
it was only a small optimization that didn't matter and made
things more complicated.
* gtk/gtkcontainer.c (gtk_container_focus_tab): Get rid of custom
sorter for FOCUS_TAB as we did for the other focus directions,
sort by center of widgets, not upper-left corner. (Shouldn't
matter in general.)
* gtk/gtkcontainer.c: Restructure code to remove duplicate code
from the different types of focusing: encapsulate sorting the
widgets for the focus direction into one routine
(gtk_container_focus_sort()) and then share the work of moving the
focus between the different focus directions.
* gtk/gtkcontainer.c: Fix bug where arrow navigation might not
work correctly with focus chains containing non-immediate
children. Sorting was being done using allocation coordinates for
each widget in the focus chain, and if there were intermediate
window-widgets, these allocations would not be in the same
coordinate system.
Tue Oct 16 15:12:26 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_mnemonic_activate): add a
mnemonic_activate function to option menu.
2001-10-15 Murray Cumming <murrayc@usa.net
2001-10-15 Murray Cumming <murrayc@usa.net>
* gtk/gtkinputdialog.c, gtk/gtktoolbar.c, gtk/gtkwidget.c:
Corrected the type names used in some calls to g_signal_new().
......
Tue Oct 16 15:50:03 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Add
a utility function to translate coordinates relative to
one widget's allocation to coordinates relative to another
widget's allocation.
* gtk/gtkradiobutton.c: Add a special ->focus() implementation
that:
- only accepts external focus if there is no active
member of the group or the button is active.
- makes arrow keys move the active button as well
as the focus
- make tab tab out directly.
This makes a radio button group act as a single focus location.
(#53577).
* gtk/gtkcontainer.c (gtk_container_focus): Remove prefiltering -
it was only a small optimization that didn't matter and made
things more complicated.
* gtk/gtkcontainer.c (gtk_container_focus_tab): Get rid of custom
sorter for FOCUS_TAB as we did for the other focus directions,
sort by center of widgets, not upper-left corner. (Shouldn't
matter in general.)
* gtk/gtkcontainer.c: Restructure code to remove duplicate code
from the different types of focusing: encapsulate sorting the
widgets for the focus direction into one routine
(gtk_container_focus_sort()) and then share the work of moving the
focus between the different focus directions.
* gtk/gtkcontainer.c: Fix bug where arrow navigation might not
work correctly with focus chains containing non-immediate
children. Sorting was being done using allocation coordinates for
each widget in the focus chain, and if there were intermediate
window-widgets, these allocations would not be in the same
coordinate system.
Tue Oct 16 15:12:26 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_mnemonic_activate): add a
mnemonic_activate function to option menu.
2001-10-15 Murray Cumming <murrayc@usa.net
2001-10-15 Murray Cumming <murrayc@usa.net>
* gtk/gtkinputdialog.c, gtk/gtktoolbar.c, gtk/gtkwidget.c:
Corrected the type names used in some calls to g_signal_new().
......
Tue Oct 16 15:50:03 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Add
a utility function to translate coordinates relative to
one widget's allocation to coordinates relative to another
widget's allocation.
* gtk/gtkradiobutton.c: Add a special ->focus() implementation
that:
- only accepts external focus if there is no active
member of the group or the button is active.
- makes arrow keys move the active button as well
as the focus
- make tab tab out directly.
This makes a radio button group act as a single focus location.
(#53577).
* gtk/gtkcontainer.c (gtk_container_focus): Remove prefiltering -
it was only a small optimization that didn't matter and made
things more complicated.
* gtk/gtkcontainer.c (gtk_container_focus_tab): Get rid of custom
sorter for FOCUS_TAB as we did for the other focus directions,
sort by center of widgets, not upper-left corner. (Shouldn't
matter in general.)
* gtk/gtkcontainer.c: Restructure code to remove duplicate code
from the different types of focusing: encapsulate sorting the
widgets for the focus direction into one routine
(gtk_container_focus_sort()) and then share the work of moving the
focus between the different focus directions.
* gtk/gtkcontainer.c: Fix bug where arrow navigation might not
work correctly with focus chains containing non-immediate
children. Sorting was being done using allocation coordinates for
each widget in the focus chain, and if there were intermediate
window-widgets, these allocations would not be in the same
coordinate system.
Tue Oct 16 15:12:26 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_mnemonic_activate): add a
mnemonic_activate function to option menu.
2001-10-15 Murray Cumming <murrayc@usa.net
2001-10-15 Murray Cumming <murrayc@usa.net>
* gtk/gtkinputdialog.c, gtk/gtktoolbar.c, gtk/gtkwidget.c:
Corrected the type names used in some calls to g_signal_new().
......
Tue Oct 16 15:50:03 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Add
a utility function to translate coordinates relative to
one widget's allocation to coordinates relative to another
widget's allocation.
* gtk/gtkradiobutton.c: Add a special ->focus() implementation
that:
- only accepts external focus if there is no active
member of the group or the button is active.
- makes arrow keys move the active button as well
as the focus
- make tab tab out directly.
This makes a radio button group act as a single focus location.
(#53577).
* gtk/gtkcontainer.c (gtk_container_focus): Remove prefiltering -
it was only a small optimization that didn't matter and made
things more complicated.
* gtk/gtkcontainer.c (gtk_container_focus_tab): Get rid of custom
sorter for FOCUS_TAB as we did for the other focus directions,
sort by center of widgets, not upper-left corner. (Shouldn't
matter in general.)
* gtk/gtkcontainer.c: Restructure code to remove duplicate code
from the different types of focusing: encapsulate sorting the
widgets for the focus direction into one routine
(gtk_container_focus_sort()) and then share the work of moving the
focus between the different focus directions.
* gtk/gtkcontainer.c: Fix bug where arrow navigation might not
work correctly with focus chains containing non-immediate
children. Sorting was being done using allocation coordinates for
each widget in the focus chain, and if there were intermediate
window-widgets, these allocations would not be in the same
coordinate system.
Tue Oct 16 15:12:26 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_mnemonic_activate): add a
mnemonic_activate function to option menu.
2001-10-15 Murray Cumming <murrayc@usa.net
2001-10-15 Murray Cumming <murrayc@usa.net>
* gtk/gtkinputdialog.c, gtk/gtktoolbar.c, gtk/gtkwidget.c:
Corrected the type names used in some calls to g_signal_new().
......
This diff is collapsed.
......@@ -35,19 +35,20 @@ enum {
};
static void gtk_radio_button_class_init (GtkRadioButtonClass *klass);
static void gtk_radio_button_init (GtkRadioButton *radio_button);
static void gtk_radio_button_destroy (GtkObject *object);
static void gtk_radio_button_clicked (GtkButton *button);
static void gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
GdkRectangle *area);
static void gtk_radio_button_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_radio_button_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_radio_button_class_init (GtkRadioButtonClass *klass);
static void gtk_radio_button_init (GtkRadioButton *radio_button);
static void gtk_radio_button_destroy (GtkObject *object);
static gboolean gtk_radio_button_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_radio_button_clicked (GtkButton *button);
static void gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
GdkRectangle *area);
static void gtk_radio_button_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_radio_button_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static GtkCheckButtonClass *parent_class = NULL;
......@@ -83,8 +84,10 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
GtkObjectClass *object_class;
GtkButtonClass *button_class;
GtkCheckButtonClass *check_button_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
button_class = (GtkButtonClass*) class;
check_button_class = (GtkCheckButtonClass*) class;
......@@ -96,6 +99,8 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
object_class->get_arg = gtk_radio_button_get_arg;
object_class->destroy = gtk_radio_button_destroy;
widget_class->focus = gtk_radio_button_focus;
button_class->clicked = gtk_radio_button_clicked;
check_button_class->draw_indicator = gtk_radio_button_draw_indicator;
......@@ -330,6 +335,156 @@ gtk_radio_button_destroy (GtkObject *object)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
get_coordinates (GtkWidget *widget,
GtkWidget *reference,
gint *x,
gint *y)
{
*x = widget->allocation.x + widget->allocation.width / 2;
*y = widget->allocation.y + widget->allocation.height / 2;
gtk_widget_translate_coordinates (widget, reference, *x, *y, x, y);
}
static gint
left_right_compare (gconstpointer a,
gconstpointer b,
gpointer data)
{
gint x1, y1, x2, y2;
get_coordinates ((GtkWidget *)a, data, &x1, &y1);
get_coordinates ((GtkWidget *)b, data, &x2, &y2);
if (y1 == y2)
return (x1 < x2) ? -1 : ((x1 == x2) ? 0 : 1);
else
return (y1 < y2) ? -1 : 1;
}
static gint
up_down_compare (gconstpointer a,
gconstpointer b,
gpointer data)
{
gint x1, y1, x2, y2;
get_coordinates ((GtkWidget *)a, data, &x1, &y1);
get_coordinates ((GtkWidget *)b, data, &x2, &y2);
if (x1 == x2)
return (y1 < y2) ? -1 : ((y1 == y2) ? 0 : 1);
else
return (x1 < x2) ? -1 : 1;
}
static gboolean
gtk_radio_button_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkRadioButton *radio_button = GTK_RADIO_BUTTON (widget);
GSList *tmp_slist;
if (gtk_widget_is_focus (widget))
{
GSList *focus_list, *tmp_list;
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
GtkWidget *new_focus = NULL;
focus_list = g_slist_copy (radio_button->group);
switch (direction)
{
case GTK_DIR_TAB_FORWARD:
case GTK_DIR_TAB_BACKWARD:
return FALSE;
case GTK_DIR_LEFT:
case GTK_DIR_RIGHT:
focus_list = g_slist_sort_with_data (focus_list, left_right_compare, toplevel);
break;
case GTK_DIR_UP:
case GTK_DIR_DOWN:
focus_list = g_slist_sort_with_data (focus_list, up_down_compare, toplevel);
break;
}
if (direction == GTK_DIR_LEFT || direction == GTK_DIR_UP)
focus_list = g_slist_reverse (focus_list);
tmp_list = g_slist_find (focus_list, widget);
if (tmp_list)
{
tmp_list = tmp_list->next;
while (tmp_list)
{
GtkWidget *child = tmp_list->data;
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_IS_SENSITIVE (child))
{
new_focus = child;
break;
}
tmp_list = tmp_list->next;
}
}
if (!new_focus)
{
tmp_list = focus_list;
while (tmp_list)
{
GtkWidget *child = tmp_list->data;
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_IS_SENSITIVE (child))
{
new_focus = child;
break;
}
tmp_list = tmp_list->next;
}
}
g_slist_free (focus_list);
if (new_focus)
{
gtk_widget_grab_focus (new_focus);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (new_focus), TRUE);
}
return TRUE;
}
else
{
GtkRadioButton *selected_button = NULL;
/* We accept the focus if, we don't have the focus and
* - we are the currently active button in the group
* - there is no currently active radio button.
*/
tmp_slist = radio_button->group;
while (tmp_slist)
{
if (GTK_TOGGLE_BUTTON (tmp_slist->data)->active)
selected_button = tmp_slist->data;
tmp_slist = tmp_slist->next;
}
if (selected_button && selected_button != radio_button)
return FALSE;
gtk_widget_grab_focus (widget);
return TRUE;
}
}
static void
gtk_radio_button_clicked (GtkButton *button)
{
......
......@@ -2317,6 +2317,167 @@ gtk_widget_size_allocate (GtkWidget *widget,
}
}
/**
* gtk_widget_common_ancestor:
* @widget_a: a #GtkWidget
* @widget_b: a #GtkWidget
*
* Find the common ancestor of @widget_a and @widget_b that
* is closest to the two widgets.
*
* Return value: the closest common ancestor of @widget_a and
* @widget_b or %NULL if @widget_a and @widget_b do not
* share a common ancestor.
**/
static GtkWidget *
gtk_widget_common_ancestor (GtkWidget *widget_a,
GtkWidget *widget_b)
{
GtkWidget *parent_a;
GtkWidget *parent_b;
gint depth_a = 0;
gint depth_b = 0;
parent_a = widget_a;
while (parent_a->parent)
{
parent_a = parent_a->parent;
depth_a++;
}
parent_b = widget_b;
while (parent_b->parent)
{
parent_b = parent_b->parent;
depth_b++;
}
if (parent_a != parent_b)
return NULL;
while (depth_a > depth_b)
{
widget_a = widget_a->parent;
depth_a--;
}
while (depth_b > depth_a)
{
widget_b = widget_b->parent;
depth_b--;
}
while (widget_a != widget_b)
{
widget_a = widget_a->parent;
widget_b = widget_b->parent;
}
return widget_a;
}
/**
* gtk_widget_translate_coordinates:
* @src_widget: a #GtkWidget
* @dest_widget: a #GtkWidget
* @src_x: X position relative to @src_widget
* @src_y: Y position relative to @src_widget
* @dest_x: location to store X position relative to @dest_widget
* @dest_y: location to store Y position relative to @dest_widget
*
* Translate coordinates relative to @src_widget's allocation to coordinates
* relative to @dest_widget's allocations. In order to perform this
* operation, both widgets must be realized, and must share a common
* toplevel.
*
* Return value: %FALSE if either widget was not realized, or there
* was no common ancestor. In this case, nothing is stored in
* *@dest_x and *@dest_y. Otherwise %TRUE.
**/
gboolean
gtk_widget_translate_coordinates (GtkWidget *src_widget,
GtkWidget *dest_widget,
gint src_x,
gint src_y,
gint *dest_x,
gint *dest_y)
{
GtkWidget *ancestor;
GdkWindow *window;
g_return_if_fail (GTK_IS_WIDGET (src_widget));
g_return_if_fail (GTK_IS_WIDGET (dest_widget));
ancestor = gtk_widget_common_ancestor (src_widget, dest_widget);
if (!ancestor || !GTK_WIDGET_REALIZED (src_widget) || !GTK_WIDGET_REALIZED (dest_widget))
return FALSE;
/* Translate from allocation relative to window relative */
if (!GTK_WIDGET_NO_WINDOW (src_widget) && src_widget->parent)
{
gint wx, wy;
gdk_window_get_position (src_widget->window, &wx, &wy);
src_x -= wx - src_widget->allocation.x;
src_y -= wy - src_widget->allocation.y;
}
else
{
src_x += src_widget->allocation.x;
src_y += src_widget->allocation.y;
}
/* Translate to the common ancestor */
window = src_widget->window;
while (window != ancestor->window)
{
gint dx, dy;
gdk_window_get_position (window, &dx, &dy);
src_x += dx;
src_y += dy;
window = gdk_window_get_parent (window);
}
/* And back */
window = dest_widget->window;
while (window != ancestor->window)
{
gint dx, dy;
gdk_window_get_position (window, &dx, &dy);
src_x -= dx;
src_y -= dy;
window = gdk_window_get_parent (window);
}
/* Translate from window relative to allocation relative */
if (!GTK_WIDGET_NO_WINDOW (dest_widget) && dest_widget->parent)
{
gint wx, wy;
gdk_window_get_position (dest_widget->window, &wx, &wy);
src_x += wx - dest_widget->allocation.x;
src_y += wy - dest_widget->allocation.y;
}
else
{
src_x -= dest_widget->allocation.x;
src_y -= dest_widget->allocation.y;
}
if (dest_x)
*dest_x = src_x;
if (dest_y)
*dest_y = src_y;
return TRUE;
}
static void
gtk_widget_real_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
......
......@@ -621,6 +621,13 @@ void gtk_widget_get_pointer (GtkWidget *widget,
gboolean gtk_widget_is_ancestor (GtkWidget *widget,
GtkWidget *ancestor);
gboolean gtk_widget_translate_coordinates (GtkWidget *src_widget,
GtkWidget *dest_widget,
gint src_x,
gint src_y,
gint *dest_x,
gint *dest_y);
/* Hide widget and return TRUE.
*/
gboolean gtk_widget_hide_on_delete (GtkWidget *widget);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment