The sequence of signals...
- From: Andre Lerche <a lerche gmx net>
- To: gtk-app-devel-list gnome org
- Subject: The sequence of signals...
- Date: Wed, 29 Oct 2003 22:10:54 +0100
Hi List!
sorry, it's me again, but I think it should be one of my last newbie questions:
Let's say I've a popup menu with several items. I've connected menu's hide
signal to destroy the menu and the activate signal of some items to execute
special functions. Now to the problem:
If I activate on of the items, first the menu get's the hide signal and will
be destroyed. After that the activate signal for the item is thrown, but
cause it has been destroyed, I get some errormessages. How can I change this?
I am using GTK 2.2.1-4 on RedHat 9.
Thanks,
Andre
The sample code...
#include <gtk/gtk.h>
int ActivateEvent (GtkWidget *widget, GdkEventCrossing *event, gpointer data) {
g_message ("Item: activate");
}
int DeactivateEvent (GtkWidget *widget, GdkEventCrossing *event, gpointer data) {
g_message ("Menu: deactivate");
gtk_widget_destroy (widget);
}
int BuildMenu (GtkWidget *widget, GdkEventCrossing *event, gpointer data) {
GtkWidget *item, *menu;
menu = gtk_menu_new ();
item = gtk_menu_item_new_with_label ("Test");
gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
g_signal_connect (GTK_WIDGET(menu), "deactivate", G_CALLBACK(DeactivateEvent), menu);
// it's the same for the hide-signal
// g_signal_connect (GTK_WIDGET(menu), "hide", G_CALLBACK(DeactivateEvent), menu);
g_signal_connect (GTK_WIDGET(item), "activate", G_CALLBACK(ActivateEvent), NULL);
gtk_widget_show_all (GTK_WIDGET(menu));
gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
}
int main (int argc, char *argv[]) {
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_widget_set_size_request (window, 100, 100);
gtk_widget_add_events (window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
g_signal_connect (window, "button-release-event", G_CALLBACK(BuildMenu), NULL);
gtk_main ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]