1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
/* create our main window */
void create_main_window(void);
/* callback to display a window with label displaying results calculated */
void calc_and_show_window(GtkWidget *widget, gpointer data);
struct car_data {
gfloat horsepower;
gfloat time;
gfloat weight;
};
...
...
...
void create_main_window(void)
{
...
...
...
/* calculate button */
button = gtk_button_new_with_mnemonic("_Calculate");
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(calc_and_show_window), (gpointer)entry_weight); /* two arguments here maybe? */
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(calc_and_show_window), (gpointer)entry_horsepower);
...
...
...
}
/* this is the function I haven't completed yet because I don't understand how to do it */
void calc_and_show_window(GtkWidget *widget, gpointer callback_data)
{
const gchar * horsepower =
gtk_entry_get_text(GTK_ENTRY(callback_data));
g_print("%s INCOMPLETE, FINISH ME!\n", horsepower);
}
|