Re: Help with g_signal_connect()



2009/2/10 Victor Vladimir Chavez Gallardo <vivlachaga gmail com>
Hi, guys

i have the next code
====================================================================
mainIcon = gtk_status_icon_new_from_file(icon_filename);

GtkWidget *menu_popup;
menu_popup = glade_xml_get_widget(xml, "main_menu");
gtk_menu_popup(GTK_MENU(menu_popup) , NULL, NULL, NULL, NULL, 0,0);
====================================================================

my GtkMenu is showed, but, if i send the widget via data in
g_signal_connect i get an segfault, with gdb i see a problem with
g_type_check_instance_cast ()

wrong code via g_signal_connect()
=====================================================================
void tray_icon_button_press (GtkWidget *widget, GtkWidget *menu)
{
   gtk_menu_popup( GTK_MENU (menu) , NULL, NULL, NULL, NULL, 0, 0);
}

mainIcon = gtk_status_icon_new_from_file(icon_filename);

GtkWidget *menu_popup;
menu_popup = glade_xml_get_widget(xml, "main_menu");
g_signal_connect(G_OBJECT(mainIcon), "popup-menu",
G_CALLBACK(tray_icon_button_press), menu_popup );
====================================================================================================


The documentation for GtkStatusIcon[1] says that the signature of the callback for "popup-menu" is:

void  user_function  (GtkStatusIcon *status_icon, guint button,  guint activate_time, gpointer user_data)

So it looks like you are casting a guint to a GtkMenu right there. In the future questions like this are better off on the gtk-app-devel-list[2].

[1]: http://library.gnome.org/devel/gtk/2.14/GtkStatusIcon.html#GtkStatusIcon-popup-menu
[2]: http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Good luck with your application! Cheers,
Mikkel



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