On 6/5/07, Jeffrey Barish <[EMAIL PROTECTED]> wrote:

Are you saying that you wonder whether the problem is in the Python wrapper
for GTK+ (i.e., PyGTK)?  It's a good question.


Looks like it's not in the bindings. The same behavior happens in C.
Attached is small example.

I filed a bug with this test case, you can track it at [1].

[1] - https://bugs.maemo.org/show_bug.cgi?id=1509
--
Lauro ("lmoura" on Freenode)
INdT - Recife
http://lauro.wordpress.com
#include <hildon-widgets/hildon-program.h>
#include <gtk/gtk.h>

void calc_pos(GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
              gpointer *button)
{
    GtkWidget *toplevel;

    toplevel = gtk_widget_get_toplevel(GTK_WIDGET(button));

    gtk_window_get_position(GTK_WINDOW(toplevel), x, y);

    *x += toplevel->allocation.x;
    *y += toplevel->allocation.y;
    *push_in = TRUE;

    return;
}

void on_button_clicked(GtkButton *button, gpointer data)
{
    GtkMenu *menu;
    GdkEventButton *event;

    g_debug("Button clicked");

    menu = GTK_MENU(data);
    event = gtk_get_current_event();
                
    gtk_menu_popup(menu, NULL, NULL, G_CALLBACK(calc_pos), button,
                   event->button, event->time);
}

void on_menu_selection_done(GtkMenuShell *menu, gpointer data)
{
    g_debug("Selection done");

}

int main(int argc, char *argv[])
{
    HildonWindow *window;
	GtkWidget *vbox;
	GtkWidget *button;
	GtkWidget *tv;
    GtkWidget *scroll;
    GtkWidget *menu;
    int i = 0;
    char *labels[] = {"one", "two", "three", "four", NULL};

    gtk_init(&argc, &argv);

    window = hildon_window_new();
    g_signal_connect(G_OBJECT(window), "destroy",
                     G_CALLBACK(gtk_main_quit), NULL);

    vbox = gtk_vbox_new(FALSE, 0);
    
    button = gtk_button_new_with_label("Button");
    tv = gtk_text_view_new();
    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_container_add(GTK_CONTAINER(scroll), tv);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
                                   GTK_POLICY_ALWAYS,
                                   GTK_POLICY_ALWAYS);

    menu = gtk_menu_new();

    for (i = 0; i < 4; i++){
        GtkWidget *item;

        item = gtk_menu_item_new_with_label(labels[i]);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
        gtk_widget_show(item);
    }    
    
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(on_button_clicked), menu);
    g_signal_connect(G_OBJECT(menu), "selection-done",
                     G_CALLBACK(on_menu_selection_done), NULL);
    
    gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
    
    gtk_container_add(GTK_CONTAINER(window), vbox);
    gtk_widget_show_all(GTK_WIDGET(window));
    gtk_main();
	return 0;
}
_______________________________________________
maemo-developers mailing list
[email protected]
https://maemo.org/mailman/listinfo/maemo-developers

Reply via email to