How to Adjust GtkMenu Popup Under Button Widget.



I have added one GtkMenu popup using following code...

Code: (C++)



// Add popup menu.
gtk_menu_popup( GTK_MENU (widget), NULL, NULL, set_position, NULL,  bevent->button, bevent->time);

and to adjust this popup under my button i have used this function...

Code: (C++)













void set_position (GtkMenu *menu, gint *px, gint *py, gboolean *push_in, gpointer data)
{
    gint w, h;
    GtkBuilder *builder = GetBuilderPointer();
    GtkWidget *button = GTK_WIDGET( gtk_builder_get_object( builder, "button_presence"));

    gdk_window_get_size (button->window, &w, &h);
    gdk_window_get_origin (button->window, px, py);
    *py = h;

    printf("\n\n w[%d] h[%d] px[%d] py[%d]\n\n", w, h, *px, *py );
    *push_in = TRUE;
}


but popup is getting displayed at the end of the whole window not at the end of the button...

Out put of the printf:
w[350] h[400] px[341] py[607]

what is going wrong why it is not giving x, y and height, width of button correctly?

Note: The button widget used in this, is a custom composite widget with (GtkHBox+(GtkImage+GtkLabel)) in it.


Cheers,
Pradeep


The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.

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