Re: How to destroy a GtkMenu?



No need to destroy it. Build the menu, keep a pointer to the built
menu around somewhere, and pop it up when you need it.

If you close the window you built the menu for, you can destroy the
menu in the window's dispose method.

On Thursday, 17 March 2011, Vikram Ambrose <noel ambrose gmail com> wrote:
>
>
>
>
>
>
>
>     After you have run gtk_menu_popup(), whats
>       the proper way of deallocating memory for the menu?
>
>       Currently I'm hooking into the "deactivate" signal, from which I
>       call gdk_threads_add_idle, which in turn calls a GSourceFunc that
>       just does gtk_widget_destroy. Seems kinda convoluted so I'm
>       guessing its probably not the right way.
>
>
>       eg.
>
>       ...
>         g_signal_connect(menu,"deactivate",on_menu_deactivate),NULL);
>       ...
>
>
>       static gboolean destroy_(gpointer widget){
>         gtk_widget_destroy(widget);
>         return FALSE;
>       }
>
>       static void on_menu_deactivate(GtkWidget *menu, gpointer data){
>         gdk_threads_add_idle(destroy_menu,menu);
>       }
>
>
>
>       V.
>
>
>
>


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