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
|
//structure a faire passer en parametre
typedef struct{
GtkObject *Small;
GtkObject *Medium;
GtkObject *Large;
GtkWidget *sLabel;
}SAdjust;
//definition de la structure et intialisation dans la fonction main.
SAdjust Adjust;
Adjust.Large=gtk_adjustment_new(0, 0, 50, 5, 0, 0);
Adjust.Medium=gtk_adjustment_new(0, 0, 500, 50, 50, 0);
Adjust.Small=gtk_adjustment_new(0, 0, 27000, 500, 500, 0);
Adjust.sLabel=gtk_label_new("");
//connection des signaux a la fonction callback
gtk_signal_connect(GTK_OBJECT(Adjust.Large),"value-changed",G_CALLBACK(weight),&Adjust);
gtk_signal_connect(GTK_OBJECT(Adjust.Medium),"value-changed",G_CALLBACK(weight),&Adjust);
gtk_signal_connect(GTK_OBJECT(Adjust.Small),"value-changed",G_CALLBACK(weight),&Adjust);
//fonction callback, je lutte surtout avec les deux premiers parametres
void weight(GtkWidget*widget,GdkEventScroll *event,SAdjust *Adjust)
{
gchar* sLabel;
gint iValue;
iValue=gtk_adjustment_get_value(GTK_ADJUSTMENT(Adjust->Small));
sLabel = g_strdup_printf("%d", iValue);
gtk_label_set_text(GTK_LABEL(Adjust->sLabel), sLabel);
g_free(sLabel);
} |
Partager