Bonjour, je suis actuellement en train de m'exercer a coder un lecteur audio avec les lib GTK et SDL_Mixer, le programme avance bien j'ai presque finis ma GUI.Le dernier truc a ajouter est un timer pour voir défiler le timecode du morceaux lu et sa durée totale.
J'ai lu que grâce a la Glib je pouvais créer ce genre de timer, sauf que j'avoue être un peu perdu.

Je vous donne la portion de code qui crée la fenêtre avec tout les boutons et autres décorations, le timer se situera dans cette fonction :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
void CreateWindow(void)
{
    GtkWidget *buttonLast = NULL, *buttonRewind = NULL, *buttonPlay = NULL, *buttonPause = NULL, *buttonStop = NULL, *buttonForeward = NULL, *buttonNext = NULL;
    GtkWidget *deco = NULL;
    GtkWidget *openFile = NULL, *buttonPlaylist = NULL, *buttonRandom = NULL, *buttonRepeat = NULL;
    GtkWidget *progressBar = NULL;
    GtkWidget *image[7];
    GtkWidget *zone = NULL;
    GTimer *timer =  NULL;
 
    /** Window configurations **/
    mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(mainWindow), "Audio Reader");
    gtk_window_set_default_size(GTK_WINDOW(mainWindow), 400, 100);
    gtk_window_set_position(GTK_WINDOW(mainWindow), GTK_WIN_POS_CENTER_ON_PARENT);
 
    zone = gtk_fixed_new();
 
    timer = g_timer_new();
    g_timer_start(timer);
 
    gtk_container_add(GTK_CONTAINER(mainWindow), zone);
 
    /** Create the player's buttons **/
    buttonLast = gtk_button_new();
    buttonRewind = gtk_button_new();
    buttonPlay = gtk_button_new();
    buttonPause = gtk_button_new();
    buttonStop = gtk_button_new();
    buttonForeward = gtk_button_new();
    buttonNext = gtk_button_new();
 
    openFile = gtk_button_new_with_label("Open");
    buttonPlaylist = gtk_button_new_with_label("Playlist");
    buttonRepeat = gtk_button_new_with_label("Repeat");
    buttonRandom = gtk_button_new_with_label("Random");
 
    progressBar = gtk_progress_bar_new();
 
    image[0] = gtk_image_new_from_file("Buttons//Last.png");
    image[1] = gtk_image_new_from_file("Buttons//Rewind.png");
    image[2] = gtk_image_new_from_file("Buttons//Play.png");
    image[3] = gtk_image_new_from_file("Buttons//Pause.png");
    image[4] = gtk_image_new_from_file("Buttons//Foreward.png");
    image[5] = gtk_image_new_from_file("Buttons//Next.png");
    image[6] = gtk_image_new_from_file("Buttons//Stop.png");
 
    /** decorative picture **/
    deco = gtk_image_new_from_file("images//icone.jpg");
 
    gtk_container_add(GTK_CONTAINER(buttonLast), image[0]);
    gtk_container_add(GTK_CONTAINER(buttonRewind), image[1]);
    gtk_container_add(GTK_CONTAINER(buttonPlay), image[2]);
    gtk_container_add(GTK_CONTAINER(buttonPause), image[3]);
    gtk_container_add(GTK_CONTAINER(buttonForeward), image[4]);
    gtk_container_add(GTK_CONTAINER(buttonNext), image[5]);
    gtk_container_add(GTK_CONTAINER(buttonStop), image[6]);
 
 
    gtk_fixed_put(GTK_FIXED(zone), buttonLast, 5, 100);
    gtk_fixed_put(GTK_FIXED(zone), buttonRewind, 50, 100);
    gtk_fixed_put(GTK_FIXED(zone), buttonPlay, 95, 100);
    gtk_fixed_put(GTK_FIXED(zone), buttonPause, 140, 100);
    gtk_fixed_put(GTK_FIXED(zone), buttonStop, 185, 100);
    gtk_fixed_put(GTK_FIXED(zone), buttonForeward, 230, 100);
    gtk_fixed_put(GTK_FIXED(zone), buttonNext, 275, 100);
 
    gtk_fixed_put(GTK_FIXED(zone), openFile, 330, 100);
 
    gtk_fixed_put(GTK_FIXED(zone), buttonPlaylist, 180, 20);
    gtk_fixed_put(GTK_FIXED(zone),buttonRepeat , 250, 20);
    gtk_fixed_put(GTK_FIXED(zone),buttonRandom , 320, 20);
 
    gtk_fixed_put(GTK_FIXED(zone), progressBar, 170, 70);
 
    gtk_fixed_put(GTK_FIXED(zone), deco, 10, 10);
 
 
    g_signal_connect(G_OBJECT(mainWindow), "destroy", G_CALLBACK(Quit), NULL);
 
    g_signal_connect(G_OBJECT(buttonPlaylist), "clicked", G_CALLBACK(Playlist), NULL);
 
    g_signal_connect(G_OBJECT(buttonRepeat), "clicked", G_CALLBACK(Repeat), NULL);
 
    g_signal_connect(G_OBJECT(openFile), "clicked", G_CALLBACK(Open), NULL);
 
    return;
}
Je n'arrive pas a afficher le timer dans ma fenêtre principale, si j'utilise la fonction gtk_container_add j'ai un segment fault, bref je suis un peu perdu là, merci de m'aider a avancer dans mon projet.