IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

GTK+ avec C & C++ Discussion :

[GTK+ C] Chronomètre : problème de structure +jouer un son


Sujet :

GTK+ avec C & C++

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé Avatar de acryline
    Profil pro
    Inscrit en
    Août 2006
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 200
    Par défaut [GTK+ C] Chronomètre : problème de structure +jouer un son
    Bonjour,

    j'ai fait un petit programme en GTK+ avec trois fichiers : main.c, fonctions.c et header.h (Source ci-dessous)
    Le programme fonctionne mais j'ai deux soucis :

    - si j'ai le malheur d'ajouter un champs, voire augmenter la taille d'un des tableaux de ma structure GADGET, mon programme ne démarre pas.. je pense à un problème de mémoire mais je n'arrive pas à le résoudre . Est ce du à l'appel périodique d'une fonction. J'ai toujours utilisé cette structure et jusqu'ici je n'ai jamais rencontré ce problème.

    - J'aurais aimé jouer un son quand le chrono arrive à 0. Comment faire ?

    Merci pour vos réponses.

    Exécutable pour Linux (sans runtime) compressé ZIP
    header.h
    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
     
    #ifndef DEF_CHRONO
    #define DEF_CHRONO
     
    #define LARGEUR     150
    #define HAUTEUR     150
     
    //structures
    typedef struct GADGET GADGET;
     struct GADGET
     {
       GtkWidget * fenetre[1];
       GtkWidget * VBox[1];
       GtkWidget * HBox[2];
       GtkWidget * bouton[4];
       GtkWidget * entree[3];
       time_t temps;
       gboolean chrono; //valeur retournée dans la fct° périodique
       guint test; //numéro du processus
     };
     
     //fonctions
     void cadreFenetre(GADGET *);
     void accueil(GADGET *);
     void chrono(GtkWidget *, gpointer);
     void chrono_start(GtkWidget *, gpointer);
     void chrono_stop(GtkWidget *, gpointer);
     void retour_accueil(GtkWidget *, gpointer);
     void quitter(GtkWidget *, gpointer);
     void decompte(GtkWidget *, gpointer);
     gboolean  calcul_temps (gpointer);
     void decompte_start(GtkWidget *, gpointer);
     gboolean  calcul_decompte (gpointer);
     
    #endif
    main.c
    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
    #include <stdlib.h>
    #include <gtk/gtk.h>
    #include <time.h>
    #include "header.h"
     
    int main(int argc,char **argv)
    {
        /* Declaration du widget */
        GADGET gadget;
     
        gtk_init(&argc,&argv);
     
        /* Creation de la fenetre */
        gadget.fenetre[0] = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        cadreFenetre(&gadget);
        accueil(&gadget);
       /* Affichage de la fenetre */
     
        gtk_main();
     
        return EXIT_SUCCESS;
    }
    fonctions.c
    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
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
     
    #include <stdlib.h>
    #include <gtk/gtk.h>
    #include <time.h>
    #include "header.h"
     
    //Dessiner la fenêtre principale
    void cadreFenetre(GADGET *p_gadget)
    {
        /* Definition de la position */
        gtk_window_set_position(GTK_WINDOW(p_gadget->fenetre[0]), GTK_WIN_POS_CENTER);
        /* Taille de la Fenêtre */
        gtk_window_set_default_size  (GTK_WINDOW(p_gadget->fenetre[0]),LARGEUR,HAUTEUR );
        /* barre des titres*/
        gtk_window_set_decorated (GTK_WINDOW(p_gadget->fenetre[0]),TRUE);
        /*Icone*/
        //gtk_window_set_default_icon_from_file(ADRESSE_ICONE,NULL);
        /*espace de 1 autour de la fenêtre*/
        gtk_container_set_border_width(GTK_CONTAINER(p_gadget->fenetre[0]),1 );
    }
     
    //choix chrono ou décompte
    void accueil(GADGET *p_gadget)
    {
      if (p_gadget->VBox[0])
      {
          gtk_widget_destroy(p_gadget->VBox[0]);
      }
      p_gadget->VBox[0]=gtk_vbox_new(TRUE,0);
      gtk_container_add (GTK_CONTAINER(p_gadget->fenetre[0]),p_gadget->VBox[0]);
      p_gadget->bouton[0]=  gtk_button_new_with_label("Chronomètre") ;
      p_gadget->bouton[1]=  gtk_button_new_with_label("Décompte") ;
      gtk_box_pack_start(GTK_BOX(p_gadget->VBox[0]),p_gadget->bouton[0],TRUE,TRUE,0);
      gtk_box_pack_start(GTK_BOX(p_gadget->VBox[0]),p_gadget->bouton[1],TRUE,TRUE,0);
      gtk_widget_show_all(p_gadget->fenetre[0]);
     
      g_signal_connect(G_OBJECT(p_gadget->bouton[0]), "clicked", G_CALLBACK(chrono), (gpointer)p_gadget);
      g_signal_connect(G_OBJECT(p_gadget->bouton[1]), "clicked", G_CALLBACK(decompte), (gpointer)p_gadget);
      g_signal_connect(G_OBJECT(p_gadget->fenetre[0]), "destroy", G_CALLBACK(quitter), NULL);
     
    }
     
    //callback du bouton chronomètre --> affichage des GtkEntry et boutons
    void chrono(GtkWidget *p_Bouton, gpointer data)
    {
        GADGET *p_gadget=NULL;
        p_gadget=(GADGET*)data;
        GtkWidget *label;
        gchar buf[32];
     
        gtk_widget_destroy(p_gadget->VBox[0]);
        p_gadget->VBox[0]=gtk_vbox_new(TRUE,0);
        gtk_container_add (GTK_CONTAINER(p_gadget->fenetre[0]),p_gadget->VBox[0]);
        //les boutons
        p_gadget->bouton[0]=  gtk_button_new_with_label("Lancer") ;
        p_gadget->bouton[1]=   gtk_button_new_with_label("Stop") ;
        p_gadget->bouton[2]=   gtk_button_new_with_label("Accueil") ;
        p_gadget->bouton[3]=   gtk_button_new_with_label("Quitter") ;
     
        //les gtkEntry
        p_gadget->entree[0]=gtk_entry_new();
        gtk_entry_set_width_chars(GTK_ENTRY(p_gadget->entree[0]),3);
        gtk_editable_set_editable(GTK_EDITABLE(p_gadget->entree[0]),FALSE);
        p_gadget->entree[1]=gtk_entry_new();
        gtk_entry_set_width_chars(GTK_ENTRY(p_gadget->entree[1]),3);
        gtk_editable_set_editable(GTK_EDITABLE(p_gadget->entree[1]),FALSE);
        p_gadget->entree[2]=gtk_entry_new();
        gtk_entry_set_width_chars(GTK_ENTRY(p_gadget->entree[2]),3);
        gtk_editable_set_editable(GTK_EDITABLE(p_gadget->entree[2]),FALSE);
     
        p_gadget->HBox[0]=gtk_hbox_new(FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->VBox[0]),p_gadget->HBox[0],FALSE,FALSE,0);
     
        //entrer les widgets
        label=gtk_label_new("              ");
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),label,FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),p_gadget->entree[0],FALSE,FALSE,0);
        label=gtk_label_new(":");
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),label,FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),p_gadget->entree[1],FALSE,FALSE,0);
        label=gtk_label_new(":");
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),label,FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),p_gadget->entree[2],FALSE,FALSE,0);
     
        p_gadget->HBox[1]=gtk_hbox_new(TRUE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->VBox[0]),p_gadget->HBox[1],FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[1]),p_gadget->bouton[0],FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[1]),p_gadget->bouton[1],FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[1]),p_gadget->bouton[2],FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[1]),p_gadget->bouton[3],FALSE,FALSE,0);
        //texte des GtkEntry
         sprintf(buf,"%d",0);
         gtk_entry_set_text(GTK_ENTRY(p_gadget->entree[0]),buf);
         sprintf(buf,"%d",0);
         gtk_entry_set_text(GTK_ENTRY(p_gadget->entree[1]),buf);
         sprintf(buf,"%d",0);
         gtk_entry_set_text(GTK_ENTRY(p_gadget->entree[2]),buf);
     
        g_signal_connect(G_OBJECT(p_gadget->bouton[0]), "clicked", G_CALLBACK(chrono_start), (gpointer)p_gadget);
        g_signal_connect(G_OBJECT(p_gadget->bouton[1]), "clicked", G_CALLBACK(chrono_stop), (gpointer)p_gadget);
        g_signal_connect(G_OBJECT(p_gadget->bouton[2]), "clicked", G_CALLBACK(retour_accueil), (gpointer)p_gadget);
        g_signal_connect(G_OBJECT(p_gadget->bouton[3]), "clicked", G_CALLBACK(quitter), (gpointer)p_gadget);
        gtk_widget_show_all(p_gadget->fenetre[0]);
     
    }
     
    void chrono_start(GtkWidget *p_Bouton, gpointer data)
    {
        GADGET *p_gadget=NULL;
        p_gadget=(GADGET*)data;
        p_gadget->chrono=TRUE; //valeur revoyée dans calcul-temps
        p_gadget->temps=time(NULL);
        p_gadget->test=g_timeout_add(1000,calcul_temps,p_gadget);
    }
     
    void chrono_stop(GtkWidget *p_Bouton, gpointer data)
    {
        GADGET *p_gadget=NULL;
        p_gadget=(GADGET*)data;
     
        p_gadget->chrono=FALSE; //valeur revoyée dans calcul-temps
    }
     
    void retour_accueil(GtkWidget *p_Bouton, gpointer data)
    {
        GADGET *p_gadget=NULL;
        p_gadget=(GADGET*)data;
        g_source_remove(p_gadget->test); //arrêter le chrono
        accueil(p_gadget); //retour au double choix du début
    }
     
    void quitter(GtkWidget *p_Bouton, gpointer data)
    {
        GADGET *p_gadget=NULL;
        p_gadget=(GADGET*)data;
     
        g_source_remove(p_gadget->test); //arrêter le chrono
        gtk_main_quit();
    }
     
    gboolean  calcul_temps (gpointer data)
    {
        gchar buf[32];
        GADGET *p_gadget=NULL;
        p_gadget=(GADGET*)data;
        time_t tA=0;
        int tps=0,jour=0,heure=0,min=0;
     
        if (p_gadget->chrono==FALSE)
        {
        return p_gadget->chrono;
        }
     
         tA=time(NULL);
     
         //définir les textes des trois GtkEntry pour  les heures et les minutes les secondes
         tps=tA-p_gadget->temps;
         jour =tps/(24*60*60);
         tps-= jour*24*60*60;
         heure= tps/(60*60);
         tps-=heure*60*60;
         min =tps/60;
         tps-=min*60;
     
         sprintf(buf,"%d",heure);
         gtk_entry_set_text(GTK_ENTRY(p_gadget->entree[0]),buf);
         sprintf(buf,"%d",min);
         gtk_entry_set_text(GTK_ENTRY(p_gadget->entree[1]),buf);
         sprintf(buf,"%d",tps);
         gtk_entry_set_text(GTK_ENTRY(p_gadget->entree[2]),buf);
         gtk_widget_show_all(p_gadget->fenetre[0]);
     
     return p_gadget->chrono;
    }
     
    //callback du bouton décompte --> GtkENtry et boutons
    void decompte(GtkWidget *p_Bouton, gpointer data)
    {
        GADGET *p_gadget=NULL;
        p_gadget=(GADGET*)data;
        GtkWidget *label;
     
        gtk_widget_destroy(p_gadget->VBox[0]);
        p_gadget->VBox[0]=gtk_vbox_new(TRUE,0);
        gtk_container_add (GTK_CONTAINER(p_gadget->fenetre[0]),p_gadget->VBox[0]);
     
        label=gtk_label_new("Entrer le temps du compte à rebour\n h/m/s :");
        gtk_box_pack_start(GTK_BOX(p_gadget->VBox[0]),label,FALSE,FALSE,0);
     
        //les GtkEntry
        p_gadget->entree[0]=gtk_entry_new();
        gtk_entry_set_width_chars(GTK_ENTRY(p_gadget->entree[0]),3);
        p_gadget->entree[1]=gtk_entry_new();
        gtk_entry_set_width_chars(GTK_ENTRY(p_gadget->entree[1]),3);
        p_gadget->entree[2]=gtk_entry_new();
        gtk_entry_set_width_chars(GTK_ENTRY(p_gadget->entree[2]),3);
     
        p_gadget->HBox[0]=gtk_hbox_new(FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->VBox[0]),p_gadget->HBox[0],FALSE,FALSE,0);
     
        label=gtk_label_new("              ");
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),label,FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),p_gadget->entree[0],FALSE,FALSE,0);
        label=gtk_label_new(":");
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),label,FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),p_gadget->entree[1],FALSE,FALSE,0);
        label=gtk_label_new(":");
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),label,FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[0]),p_gadget->entree[2],FALSE,FALSE,0);
     
        p_gadget->HBox[1]=gtk_hbox_new(TRUE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->VBox[0]),p_gadget->HBox[1],FALSE,FALSE,0);
     
        //les boutons
        p_gadget->bouton[0]=  gtk_button_new_with_label("Lancer") ;
        p_gadget->bouton[1]=   gtk_button_new_with_label("Stop") ;
        p_gadget->bouton[2]=   gtk_button_new_with_label("Accueil") ;
        p_gadget->bouton[3]=   gtk_button_new_with_label("Quitter") ;
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[1]),p_gadget->bouton[0],FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[1]),p_gadget->bouton[1],FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[1]),p_gadget->bouton[2],FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(p_gadget->HBox[1]),p_gadget->bouton[3],FALSE,FALSE,0);
     
        g_signal_connect(G_OBJECT(p_gadget->bouton[0]), "clicked", G_CALLBACK(decompte_start), (gpointer)p_gadget);
        g_signal_connect(G_OBJECT(p_gadget->bouton[1]), "clicked", G_CALLBACK(chrono_stop), (gpointer)p_gadget);
        g_signal_connect(G_OBJECT(p_gadget->bouton[2]), "clicked", G_CALLBACK(retour_accueil), (gpointer)p_gadget);
        g_signal_connect(G_OBJECT(p_gadget->bouton[3]), "clicked", G_CALLBACK(quitter), (gpointer)p_gadget);
     
        gtk_widget_show_all(p_gadget->fenetre[0]);
     
    }
     
    void decompte_start(GtkWidget *p_Bouton, gpointer data)
    {
        GADGET *p_gadget=NULL;
        p_gadget=(GADGET*)data;
        const gchar* buf=NULL;
     
        //Entrer le texte du temps à décompter dans les GtkEntry
        p_gadget->chrono=TRUE;
        buf= gtk_entry_get_text(GTK_ENTRY(p_gadget->entree[0]));
        p_gadget->temps=strtol(buf,NULL,10)*60*60;
        buf= gtk_entry_get_text(GTK_ENTRY(p_gadget->entree[1]));
        p_gadget->temps+=strtol(buf,NULL,10)*60;
        buf= gtk_entry_get_text(GTK_ENTRY(p_gadget->entree[2]));
        p_gadget->temps+=strtol(buf,NULL,10);
     
        p_gadget->test=g_timeout_add(1000,calcul_decompte,p_gadget);
     
    }
     
    gboolean  calcul_decompte (gpointer data)
    {
        gchar buf[32];
        GADGET *p_gadget=NULL;
        p_gadget=(GADGET*)data;
        int tps=0,jour=0,heure=0,min=0;
     
        if (p_gadget->chrono==FALSE)
        {
        return p_gadget->chrono;
        }
         p_gadget->temps--;
     
     
         //texte des GtkEntry pendant le décompte
         tps=p_gadget->temps;
         jour =tps/(24*60*60);
         tps-= jour*24*60*60;
         heure= tps/(60*60);
         tps-=heure*60*60;
         min =tps/60;
         tps-=min*60;
     
         sprintf(buf,"%d",heure);
         gtk_entry_set_text(GTK_ENTRY(p_gadget->entree[0]),buf);
         sprintf(buf,"%d",min);
         gtk_entry_set_text(GTK_ENTRY(p_gadget->entree[1]),buf);
         sprintf(buf,"%d",tps);
         gtk_entry_set_text(GTK_ENTRY(p_gadget->entree[2]),buf);
         gtk_widget_show_all(p_gadget->fenetre[0]);
     
        return p_gadget->chrono;
    }

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 172
    Par défaut
    pour jouer des sons, essayes avec fmod. C'est très puissant et simple d'utilisation

  3. #3
    Membre confirmé Avatar de acryline
    Profil pro
    Inscrit en
    Août 2006
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 200
    Par défaut
    Merci pour ta réponse

    Mais n'y a t-il pas plus simple ? Je n'ai pas vraiment envie d'ajouter une autre bibliothèque et apprendre à l'utiliser pour faire un vulgaire "pouet" ou un "tsoin tsoin" quelconque.
    En revanche j'aimerais mettre autre chose que :
    J'ai toujours mon problème de mémoire aussi... (dans mon programme )

  4. #4
    Rédacteur

    Avatar de gege2061
    Femme Profil pro
    Administrateur de base de données
    Inscrit en
    Juin 2004
    Messages
    5 840
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Administrateur de base de données

    Informations forums :
    Inscription : Juin 2004
    Messages : 5 840

  5. #5
    Membre confirmé Avatar de acryline
    Profil pro
    Inscrit en
    Août 2006
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 200
    Par défaut
    J'aurais aimé pouvoir envoyer un autre son qu'un bip.

    Et j'ai toujours mon p'tit problème de mémoire ...

  6. #6
    Membre Expert
    Homme Profil pro
    Inscrit en
    Janvier 2005
    Messages
    1 259
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 1 259
    Par défaut
    Pour ton problème de mémoire, as-tu tenté de lancer ton programme avec valgrind pour voir si ça te donne une piste ?

  7. #7
    Rédacteur

    Avatar de gege2061
    Femme Profil pro
    Administrateur de base de données
    Inscrit en
    Juin 2004
    Messages
    5 840
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Administrateur de base de données

    Informations forums :
    Inscription : Juin 2004
    Messages : 5 840
    Par défaut
    Citation Envoyé par acryline Voir le message
    J'aurais aimé pouvoir envoyer un autre son qu'un bip.
    Dans ce cas il faut passer par une autre bibliothèque pour lire un fichier audio. Regarde du côté de fmod, je crois qu'elle est spécialisée dans ce domaine

  8. #8
    Membre confirmé Avatar de acryline
    Profil pro
    Inscrit en
    Août 2006
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 200
    Par défaut
    ok merci Gege2061.. je crois que je vais me contenter de mon petit bip pour l'instant.
    Pour la mémoire j'ai testé le programme avec gdb.. c'est ça ?
    Rapelle de la structure :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    typedef struct GADGET GADGET;
     struct GADGET
     {
       GtkWidget * fenetre[1];
       GtkWidget * VBox[1];
       GtkWidget * HBox[2];
       GtkWidget * bouton[4];
       GtkWidget * entree[3];
       time_t temps;
       gboolean chrono; //valeur retournée dans la fct° périodique
       guint test; //numéro du processus
     };
    si par exemple je mets GtkWidget * entree[4]; à la place de GtkWidget * entree[3] j'obtiens : (avec 3 tout va bien)
    (gdb) run
    Starting program: /home/acryline/programmation/ChronoGTK/bin/Debug/ChronoGTK
    [Thread debugging using libthread_db enabled]
    [New Thread 0xb748c720 (LWP 6200)]

    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0xb748c720 (LWP 6200)]
    0xb7e7b0b3 in gtk_widget_destroy () from /usr/lib/libgtk-x11-2.0.so.0
    (gdb)

  9. #9
    Membre Expert
    Homme Profil pro
    Inscrit en
    Janvier 2005
    Messages
    1 259
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 1 259
    Par défaut
    si quand j'écris valgrind, tu lis gdb, va voir un opticien au plus vite ! :-p

  10. #10
    Membre confirmé Avatar de acryline
    Profil pro
    Inscrit en
    Août 2006
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 200
    Par défaut
    rhoooooooo
    Je croyais que c'étais pareil... je connais pas valgrind
    Bon je me renseigne

    Edité : ça m'a l'air bien compliqué. Je n'arrive pas à le faire fonctionner.
    Une petite aide serait la bienvenue

  11. #11
    Membre confirmé Avatar de acryline
    Profil pro
    Inscrit en
    Août 2006
    Messages
    200
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 200
    Par défaut
    J'ai peut être mal cherché mais je n'ai pas trouvé d'explication claire pour installer fmod dans codeblocks sous Linux Debian .. je crois y être arrivée après qq essaies voilà comment je m'y suis prise pour ceux qui cherchent : (Je n'ai pas encore appris à utiliser cette bibliothèque donc je n'ai pas encore pu voir si mon installation est vraiment correcte. En tout cas quand je compile le mini programme je n'ai aucune erreur).

    1. Déjà il faut télécharger la bibliothèque fmod 3 (et pas ex) ici

    2. Vous décompactez le fichier téléchargé où vous voulez (je vais l'appeler "chemin")

    3. Vous créez un dossier FMOD dans /usr/include/ ainsi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    # mkdir /usr/include/FMOD
    4. Vous y copiez les 4 header du dossier /api/inc/ que vous avez téléchargé :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    #cp /chemin/api/inc/fmoddyn.h /usr/include/FMOD/fmoddyn.h
    #cp /chemin/api/inc/fmod_errors.h /usr/include/FMOD/fmod_errors.h
    #cp /chemin/api/inc/fmod.h /usr/include/FMOD/fmod.h
    #cp /chemin/api/inc/wincompat.h /usr/include/FMOD/wincompat.h
    5. Vous renommez le fichier libfmod-3.75.so du dossier "api" en libfmod.so pour qu'il soit reconnu puis vous le copiez dans le dossier /usr/lib/

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    #cp /chemin/libfmod.so  /usr/lib/libfmod.so
    6. Dans codeblocks ouvrir un nouveau projet console que vous pouvez appeler fmod

    7. Inclure fmod avec
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    #include <FMOD/fmod.h>
    8. Dans les options de compilations du projet ( Project/build options/ compiler settings/Other options/) mettre : -lfmod

    9. Vérifier si tout se passe bien en compilant le projet. Vous pouvez utiliser ce fichier main.c
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    #include <stdio.h>
    #include <stdlib.h>
    #include <FMOD/fmod.h>
     
    int main()
    {
        FSOUND_Init(44100, 32, 0);
     
        FSOUND_Close();
        return 0;
    }
    J'obtiens :
    Checking for existence: /home/pseudo/programmation/FMOD/bin/Debug/fmod
    Executing: xterm -T fmod -e /usr/bin/cb_console_runner /home/pseudo/programmation/FMOD/bin/Debug/fmod (in /home/pseudo/programmation/FMOD/.)
    Process terminated with status 0 (0 minutes, 2 seconds)
    10. Enregistrer le projet en tant que template utilisateur (Save project as user-template ) pour pouvoir ouvrir des projets FMOD rapidement.

    Les compléments d'information sont les bienvenus. Merci

  12. #12
    Membre Expert
    Homme Profil pro
    Inscrit en
    Janvier 2005
    Messages
    1 259
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 1 259
    Par défaut
    Citation Envoyé par acryline Voir le message
    Edité : [valgrind] m'a l'air bien compliqué. Je n'arrive pas à le faire fonctionner.
    Une petite aide serait la bienvenue
    il suffit de faire "valgrind ./monprogramme" et d'attendre et ensuite d'analyser le résultat, c'est pas trop compliqué à lancer normalement, c'est l'analyse du résultat qui peut être plus complexe

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème sur Structure Incluant un GTK image
    Par diophantes dans le forum GTK+ avec C & C++
    Réponses: 5
    Dernier message: 02/06/2007, 00h03
  2. Réponses: 16
    Dernier message: 21/08/2006, 14h12
  3. [Structures]Problème sur structures
    Par kendras dans le forum C++
    Réponses: 5
    Dernier message: 07/06/2006, 10h20
  4. Réponses: 2
    Dernier message: 05/06/2006, 13h39
  5. [OCaml] Problème de structure/parser
    Par marv1 dans le forum Caml
    Réponses: 4
    Dernier message: 09/05/2005, 12h16

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo