Re: problem finding the position of a button in the gtk dialog ( sample code inside )



On Wed, 2008-05-07 at 11:33 +0530, chirag juneja wrote:

approach i am using is :
i will find the distance of the button from its parent, and then its
parent's distance form its parent .. and so on, till i get toplevel
window.
then i am adding the decoration's height, border's width and distance
of top level window from origin of root window(0,0).

That's a lot of overkill :)  You can simply do

void 
get_absolute_position (GtkWidget *widget, int *ret_x, int *ret_y)
{
  GdkWindow *parent;
  int parent_x, parent_y;

  parent = gtk_widget_get_parent_window (widget);
  gdk_window_get_origin (parent, &parent_x, &parent_y);

  *ret_x = parent_x + widget->allocation.x;
  *ret_y = parent_y + widget->allocation.y;
}

  Federico





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