popupmen item callback



hi, i write a button which pops up a popupmenu after clicked,
and when i select an item of the popupmen such warring appeared, and why? 

(taskmanager:4638): Gtk-CRITICAL **: gtk_widget_get_display: assertion `GTK_IS_WIDGET (widget)' failed

(taskmanager:4638): Gdk-CRITICAL **: gdk_display_sync: assertion `GDK_IS_DISPLAY (display)' failed

(taskmanager:4638): Gtk-CRITICAL **: gtk_widget_activate: assertion `GTK_IS_WIDGET (widget)' failed

my functions:

static void
om_kill_task_cb(GtkMenuItem *item, gpointer *user_data)
{
 g_debug ("call kill task function");
}

void
om_init_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
{
  GtkWidget *menu;
  GtkMenuItem *item;
  int button, event_time;

  menu = gtk_menu_new ();
  gtk_widget_show (menu);
  g_signal_connect (menu, "deactivate", G_CALLBACK (gtk_widget_destroy), NULL);

  /* ... add menu items ... */
  item = gtk_menu_item_new_with_label ("Close and switch");
  gtk_widget_show (item);
  gtk_menu_prepend (menu, item);
  g_signal_connect (item, "activate", G_CALLBACK (om_kill_task_cb), NULL);

  item = gtk_menu_item_new_with_label ("Kill the Application");
  gtk_widget_show (item);
  gtk_menu_prepend (menu, item);
  g_signal_connect (item, "activate", G_CALLBACK (om_kill_task_cb), NULL);

  
  if (event)
    {
      button = event->button;
      event_time = event->time;
    }
  else
    {
      button = 0;
      event_time = gtk_get_current_event_time ();
    }

  gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 
                  button, event_time);
}

sun zhiyong
2006-11-29
sunzyjszri gmail com



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