widget array
- From: Ariel Flashner <flashner 012 net il>
- To: gtk-list gnome org
- Subject: widget array
- Date: Thu, 13 May 2004 17:24:05 +0300
Hi,
I would like to load a few widgets and then be able to run some code
when a "enter_notify_event" occurs...
I've done it this way:
1. (i defined a structure)
struct satellite {
GtkWidget *sat_menu_items;
gchar *ip;
};
(i created the widgets inside a certain function)
struct sat_map *sat;
GtkWidget *fixed;
fixed = lookup_widget (frmMain, "fixed");
sat = g_malloc( sizeof( *sat ) );
sat->img = create_pixmap (fixed, "sat.jpg");
gtk_widget_set_size_request (sat->img, 16, 16);
sat->evnt = gtk_event_box_new();
sat->frmInfo = gtk_button_new_with_label ("bla");
gtk_container_add (GTK_CONTAINER (sat->evnt), sat->img);
gtk_fixed_put (GTK_FIXED(fixed), sat->evnt, gps_x, gps_y);
gtk_fixed_put (GTK_FIXED(fixed), sat->frmInfo, gps_x, gps_y + 16);
gtk_widget_show (sat->evnt);
gtk_widget_show (sat->img);
g_signal_connect_swapped (G_OBJECT (sat->evnt), "enter_notify_event",
G_CALLBACK (on_SatEnter), (gpointer) sat);
g_signal_connect_swapped (G_OBJECT (sat->evnt), "leave_notify_event",
G_CALLBACK (on_SatLeave), (gpointer) sat);
g_free (sat);
(then, in the call back functions)
void on_SatEnter (gpointer user_data)
{
struct sat_map *sat;
sat = user_data;
gtk_widget_show (GTK_WIDGET(sat->frmInfo));
}
void on_SatLeave (gpointer user_data)
{
struct sat_map *sat;
sat = user_data;
gtk_widget_destroy (GTK_WIDGET(sat->frmInfo));
}
The program compiles with now errors/warninngs but when i run it, it
gives me an error and terminates the program.
the error is (when i debug it with gdb):
"Program received signal SIGSEGV, Segmentation fault.
0x4041db12 in g_type_check_instance_cast () from
/usr/lib/libgobject-2.0.so.0"
What am I doing wrong here?
Is there another easy way to do what I want to accomplish?
Thanks.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]