when and where to destroy "popup menu"?
- From: Zhang Yang <marship 126 com>
- To: gtk-app-devel-list gnome org
- Subject: when and where to destroy "popup menu"?
- Date: Thu, 08 Feb 2007 14:30:13 +0800
Hello.
I have created a popup menu in my function(list below). But I have a
question "when and where to destroy it?".
I tried connect its selection-done handler to gtk_widget_destroy.But it
seems nothing happened. I run the program and monitor it through
"system monitor". The program continuing eat memory when I right click
the treeview to popup menu.
Thanks for any help.
Best regards.
[CODE]
gboolean jmView_OnButtonPressed(GtkWidget *tv,GdkEventButton
*event,gpointer userdata){
if(GDK_BUTTON_PRESS == event->type && event->button == 1){
g_print("left click on treeview\n");
}else if(GDK_BUTTON_PRESS == event->type && 3 == event->button){
GtkTreeSelection *treeSel = NULL;
GtkTreePath *treePath = NULL;
GladeXML *xml = NULL;
GtkWidget *popupMenu = NULL,*jmPopupMenu_open=NULL,*jmPopupMenu_add =
NULL;
treeSel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
if(gtk_tree_selection_count_selected_rows(treeSel) < 1){
return TRUE;
}
if(FALSE ==
gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv),(gint)event->x,(gint)event->y,&treePath,NULL,NULL,NULL)){
return TRUE;
}
//here create the menu
popupMenu = libcore_get_widget(&xml,"menuCategory");
jmPopupMenu_open = libcore_get_widget(&xml,"menuitemCategoryOpen");
jmPopupMenu_add = libcore_get_widget(&xml,"menuitemCategoryAdd");
g_signal_connect(GTK_MENU_ITEM(jmPopupMenu_open),"activate",(GCallback)jmPopupMenu_open_onActivate,treePath);
g_signal_connect(GTK_MENU_ITEM(jmPopupMenu_add),"activate",(GCallback)jmPopupMenu_add_onActivate,treePath);
g_signal_connect(GTK_MENU_SHELL(popupMenu),"selection-done",gtk_widget_destroy,popupMenu);
gtk_menu_popup(GTK_MENU(popupMenu),NULL,NULL,NULL,NULL,event->button,event->time);
g_print("right click on treeview\n");
// gtk_widget_destroy(popupMenu);
return TRUE;
}
return FALSE;
}
[/CODE]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]