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 :

probleme (click bouton)


Sujet :

GTK+ avec C & C++

  1. #1
    Membre du Club
    Inscrit en
    Mai 2008
    Messages
    55
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 55
    Points : 40
    Points
    40
    Par défaut probleme (click bouton)
    Salut,
    J'ai réalisé une interface graphique simple dans la quelle je récupère le nom et le prénom saisis que je mes dans un label . J'ai du modifier mon code afin de savoir d'ou provenait l'erreur, à l'origine je voulais recuperer le nom ,le prénom et dautres info que je devais enrégistrer dans une base de données.J'ai enlevé tout ce qui concerne la base de données. Mais le problème persiste.
    Problème: Chaque fois que je clique sur le bouton valider l'interface se ferme et je recoit ce message " Gtk-CRITICAL **: gtk_container_foreach: assertion `GTK_IS_CONTAINER (container)' failed
    Erreur de segmentation (core dumped)"

    Quelqu'un a t'il une idée? Merci

    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
     
    #include <stdlib.h>
    #include <gtk/gtk.h>
    #include <mysql/mysql.h>
    #include <sql.h>
     
    void Action(GtkWidget *pWidget, gpointer pData);
     
    int main(int argc, char **argv)
    {
        GtkWidget *Window;
        GtkWidget *ComboBox,*ComboBoxcanal;
        GtkWidget *HBoxp,*HBoxn,*VBox,*HBoxtitre,*HBoxadresse,*HBoxtel,*HBoxrv,*HBoxhd,*HBoxdate,*HBoxheure,*HBoxdh,*HBoxj,*HBoxm,*HBoxa,*HBoxh,*HBoxmin,
                   *HBox1,*HBox2,*HBox3,*HBox4,*HBoxvide,*HBoxcanal,*HBoxbouton;
        GtkWidget *Bouton;
        GtkWidget *Labeltitre,*Labelp,*Labeladresse,*Labeltel,*Labeln,*Labelrv,*Labeldate,*Labelj,*Labelm,*Labela,*Labelheure,*Labelh,
                  *Labelmin,*Labelcanal,*Labelc;
        GtkWidget *Entryn,*Entryp,*Entryadresse,*Entrytel,*Entryj,*Entrym,*Entrya,*Entryh,*Entrymin;
        GtkWidget *Label;
     
     
        gtk_init(&argc,&argv);
     
        Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(Window), "CALLBACK");
        gtk_window_set_default_size(GTK_WINDOW(Window), 500, 400);
        gtk_window_set_position(GTK_WINDOW(Window), GTK_WIN_POS_CENTER);
        g_signal_connect(G_OBJECT(Window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
     
        /* Creation de la GtkBox verticale  */
        VBox = gtk_vbox_new(FALSE, 10);
     
        /* Ajout de la GtkVBox dans la fenetre */
        gtk_container_add(GTK_CONTAINER(Window), VBox);
     
         /* Creation des box horizontaux */
        HBoxtitre = gtk_hbox_new(TRUE, 0);     
        HBoxn = gtk_hbox_new(TRUE, 0);         
        HBoxp = gtk_hbox_new(TRUE, 0);        
        HBoxbouton = gtk_hbox_new(TRUE, 0);
     
        /* Ajout des GtkHBox dans la GtkVBox */
        gtk_box_pack_start(GTK_BOX(VBox), HBoxtitre, FALSE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(VBox), HBoxn, FALSE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(VBox), HBoxp, FALSE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(VBox), HBoxbouton, FALSE, TRUE, 0);
     
         /* Creation du label */
        Labeln=gtk_label_new("Nom :");                              
        Labelp=gtk_label_new("Prenom :");                                                   
        Labeltitre=gtk_label_new("COORDONNEES DU CLIENT");           
        Label = gtk_label_new(NULL);              
     
         /* Creation des GtkEntry */
        Entryn = gtk_entry_new();         
        Entryp = gtk_entry_new();         
     
        /* On ajoute des labels aux box horizontaux */
        gtk_box_pack_start(GTK_BOX(HBoxtitre), Labeltitre, TRUE, TRUE, 0);       
        gtk_box_pack_start(GTK_BOX(HBoxn), Labeln, TRUE, TRUE, 0);               
        gtk_box_pack_start(GTK_BOX(HBoxp), Labelp, TRUE, TRUE, 0); 
     
        gtk_box_pack_start(GTK_BOX(VBox), Label, TRUE, FALSE, 0);
     
        /* On ajoute des zones de saisie aux box horizontaux */
        gtk_box_pack_start(GTK_BOX(HBoxn), Entryn, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(HBoxp), Entryp, TRUE, TRUE, 0); 
     
        /* Initialisation du bouton Valider */
         Bouton = gtk_button_new_with_label("Valider"); 
     
        /* Ajout de Bouton dans la GtkHBox */
        gtk_box_pack_start(GTK_BOX(HBoxbouton), Bouton, TRUE, FALSE, 0);  
     
        /* Connexion du signal "clicked" du bouton */
        g_signal_connect(G_OBJECT(Bouton), "clicked", G_CALLBACK(Action), NULL);
     
        //gtk_container_foreach(GTK_CONTAINER(Window),(GtkCallback)Action,""); 
     
     
        gtk_widget_show_all(Window);
     
        gtk_main();
     
        return EXIT_SUCCESS;
    }
     
     
    void Action(GtkWidget *pWidget, gpointer data)
    {
        GtkWidget *Tempn;
        GtkWidget *Tempp;
        GtkWidget *TempLabel;
        GList *pList;
        const gchar *Textnom,*Textprenom;
        FILE *fichier; 
     
     
        /* Recuperation de la liste des elements que contient la GtkVBox */
        pList = gtk_container_get_children(GTK_CONTAINER((GtkWidget*)data));
     
        /* Le nom */
        Tempn = GTK_WIDGET(pList->data);
     
        /* Passage a l element suivant*/
        pList = g_list_next(pList);
     
        /* Le prenom */
        Tempp = GTK_WIDGET(pList->data);
     
        /* Passage a l element suivant*/
        pList = g_list_next(pList);
     
         /* Passage a l element suivant*/
        pList = g_list_next(pList);
     
        TempLabel = GTK_WIDGET(pList->data);
     
        /* Recuperation du texte contenu dans les GtkEntry  */
        Textnom = gtk_entry_get_text(GTK_ENTRY(Tempn));
        //Textprenom = gtk_entry_get_text(GTK_ENTRY(Tempp)); 
     
         /* Modification du texte contenu dans le GtkLabel */
        gtk_label_set_text(GTK_LABEL(TempLabel), Textnom);
     
        /* Liberation de la memoire utilisee par la liste */
        g_list_free(pList);  
    }

  2. #2
    Membre expérimenté
    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
    Points : 1 633
    Points
    1 633
    Par défaut
    Pourquoi est-ce que dans ton callback tu t'attends à ce que l'argument 'data' soit un GtkContainer ?

  3. #3
    Membre régulier
    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
    Points : 117
    Points
    117
    Par défaut
    Surtout que dans g_signal_connect tu passes NULL comme argument à ta callback...
    Un peu normal que ça t'fasse un seg fault

  4. #4
    Membre du Club
    Inscrit en
    Mai 2008
    Messages
    55
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 55
    Points : 40
    Points
    40
    Par défaut
    Merci pour vos reponses,
    J'ai finis par trouver la solution et kicker tu as raison c'etait çà le probleme. j'ai ajouter " (GtkWidget*) VBox "
    /* Connexion du signal "clicked" du bouton */
    g_signal_connect(G_OBJECT(Bouton), "clicked", G_CALLBACK(Action), (GtkWidget*) VBox);
    .
    Au fait a fait seulement une semaine que je me suis mis sur le GTK et comme ca ressemble au java je me retrouve un peu.
    Par rapport à ta question teuf franchement je ne sais pas trop.Le premier argument je comprends mais le 2eme "" j'ai toujours pensé que c'est truc standard.Peux tu me donner une explication par rapport à çà? merci.

    Maintenant mon probleme est que je n'arrive pas à récuperer les info saisies. Dans les tutos que j'ai trouvé (sur ce site); on a utilisé in Glist pour recuperer les widgets du contenaire.Et selon ce que j'ai vu la recuperation a été faite par rapport à l'ordre d'insertion en plus l'interface lui même n'etait pas compliqué.
    Dans le Gtkvbox on a place un Gtkentry ensuite un bouton puis un label.
    Par contre dans mon interface, dans le GtkVBox j'ai d'abord place un GtkHBox dans lequel j'ai mis un label puis une zone de saisie. Puis un autre GtkHbox dans lequel j'ai aussi mis un label et une zone.Et deux autres GtkHBox dans lesquels j'ai mis respectivement un bouton et un label vide.

    Donc si je ne me trompe pas et qu'on doit ajouter les widgets à la Glist selon l'ordre d'insertion alors la ca devient tres complique.Comment pourrais je recuperer les champs saisis?Si on a une vingtaine voir plus ou qu'on a des imbrications , je suppose qu'on ne va se mettre à ajouter les widgets un par un.
    Il n'y a t'il pas un moyen d'indiquer directement le champs qu'on veut recuperer?

    Merci

  5. #5
    Membre du Club
    Inscrit en
    Mai 2008
    Messages
    55
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 55
    Points : 40
    Points
    40
    Par défaut
    Le code modifié
    Et les erreurs produites: "
    (test7:19770): GLib-GObject-WARNING **: invalid cast from `GtkHBox' to `GtkEntry'

    (test7:19770): Gtk-CRITICAL **: gtk_entry_get_text: assertion `GTK_IS_ENTRY (entry)' failed

    (test7:19770): GLib-GObject-WARNING **: invalid cast from `GtkHBox' to `GtkEntry'

    (test7:19770): Gtk-CRITICAL **: gtk_entry_get_text: assertion `GTK_IS_ENTRY (entry)' failed
    "


    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
     
     
    #include <stdlib.h>
    #include <gtk/gtk.h>
    #include <mysql/mysql.h>
    #include <sql.h>
     
    void Action(GtkWidget *Bouton, gpointer data);
     
    int main(int argc, char **argv)
    {
        GtkWidget *Window;
        GtkWidget *ComboBox,*ComboBoxcanal;
        GtkWidget *HBoxp,*HBoxn,*VBox,*HBoxtitre,*HBoxadresse,*HBoxtel,*HBoxrv,*HBoxhd,*HBoxdate,*HBoxheure,*HBoxdh,*HBoxj,*HBoxm,*HBoxa,*HBoxh,*HBoxmin,
                   *HBox1,*HBox2,*HBox3,*HBox4,*HBoxvide,*HBoxcanal,*HBoxbouton;
        GtkWidget *Bouton;
        GtkWidget *Labeltitre,*Labelp,*Labeladresse,*Labeltel,*Labeln,*Labelrv,*Labeldate,*Labelj,*Labelm,*Labela,*Labelheure,*Labelh,
                  *Labelmin,*Labelcanal,*Labelc;
        GtkWidget *Entryn,*Entryp,*Entryadresse,*Entrytel,*Entryj,*Entrym,*Entrya,*Entryh,*Entrymin;
        GtkWidget *Label;
     
     
        gtk_init(&argc,&argv);
     
        Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(Window), "CALLBACK");
        gtk_window_set_default_size(GTK_WINDOW(Window), 500, 400);
        gtk_window_set_position(GTK_WINDOW(Window), GTK_WIN_POS_CENTER);
        g_signal_connect(G_OBJECT(Window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
     
        /* Creation de la GtkBox verticale  */
        VBox = gtk_vbox_new(FALSE, 10);
     
        /* Ajout de la GtkVBox dans la fenetre */
        gtk_container_add(GTK_CONTAINER(Window), VBox);
     
         /* Creation des box horizontaux */
        HBoxtitre = gtk_hbox_new(TRUE, 0);     
        HBoxn = gtk_hbox_new(TRUE, 0);         
        HBoxp = gtk_hbox_new(TRUE, 0);        
        HBoxbouton = gtk_hbox_new(TRUE, 0);
     
        /* Ajout des GtkHBox dans la GtkVBox */
        gtk_box_pack_start(GTK_BOX(VBox), HBoxtitre, FALSE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(VBox), HBoxn, FALSE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(VBox), HBoxp, FALSE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(VBox), HBoxbouton, FALSE, TRUE, 0);
     
         /* Creation du label */
        Labeln=gtk_label_new("Nom :");                              
        Labelp=gtk_label_new("Prenom :");                                                   
        Labeltitre=gtk_label_new("COORDONNEES DU CLIENT");           
        Label = gtk_label_new(NULL);              
     
         /* Creation des GtkEntry */
        Entryn = gtk_entry_new();         
        Entryp = gtk_entry_new();         
     
        /* On ajoute des labels aux box horizontaux */
        gtk_box_pack_start(GTK_BOX(HBoxtitre), Labeltitre, TRUE, TRUE, 0);       
        gtk_box_pack_start(GTK_BOX(HBoxn), Labeln, TRUE, TRUE, 0);               
        gtk_box_pack_start(GTK_BOX(HBoxp), Labelp, TRUE, TRUE, 0); 
     
        gtk_box_pack_start(GTK_BOX(VBox), Label, TRUE, FALSE, 0);
     
        /* On ajoute des zones de saisie aux box horizontaux */
        gtk_box_pack_start(GTK_BOX(HBoxn), Entryn, TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(HBoxp), Entryp, TRUE, TRUE, 0); 
     
        /* Initialisation du bouton Valider */
         Bouton = gtk_button_new_with_label("Valider"); 
     
        /* Ajout de Bouton dans la GtkHBox */
        gtk_box_pack_start(GTK_BOX(HBoxbouton), Bouton, TRUE, FALSE, 0);  
     
        /* Connexion du signal "clicked" du bouton */
        g_signal_connect(G_OBJECT(Bouton), "clicked", G_CALLBACK(Action), (GtkWidget*) VBox);
     
        //gtk_container_foreach(GTK_CONTAINER(Window),(GtkCallback)Action,""); 
     
     
        gtk_widget_show_all(Window);
     
        gtk_main();
        return EXIT_SUCCESS;
    }
     
     
    void Action(GtkWidget *Bouton, gpointer data)
    {
        GtkWidget *Tempn;
        GtkWidget *Tempp;
        GtkWidget *TempLabel;
        GList *pList=NULL;
        const gchar *Textnom,*Textprenom;
        FILE *fichier; 
     
     
        /* Recuperation de la liste des elements que contient la GtkVBox */
        pList = gtk_container_get_children(GTK_CONTAINER((GtkWidget*)data));
     
        /* Passage a l element suivant*/
        pList = g_list_next(pList);
     
        /* Le nom */
        Tempn = GTK_WIDGET(pList->data);
     
        /* Passage a l element suivant*/
        pList = g_list_next(pList);
     
        /* Le prenom */
        Tempp = GTK_WIDGET(pList->data);
     
        /* Passage a l element suivant*/
        pList = g_list_next(pList);
     
         /* Passage a l element suivant*/
        pList = g_list_next(pList);
     
        TempLabel = GTK_WIDGET(pList->data);
     
        /* Recuperation du texte contenu dans les GtkEntry  */
        Textnom = gtk_entry_get_text(GTK_ENTRY(Tempn));
        Textprenom = gtk_entry_get_text(GTK_ENTRY(Tempp)); 
     
         /* Modification du texte contenu dans le GtkLabel */
        gtk_label_set_text(GTK_LABEL(TempLabel), Textnom);
     
        /* Liberation de la memoire utilisee par la liste */
        //g_list_free(pList);  
    }

  6. #6
    Membre expérimenté
    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
    Points : 1 633
    Points
    1 633
    Par défaut
    J'ai l'impression que quand tu parcours ta liste de widgets, tu recuperes des GtkHBox contenant des GtkEntry, pas unne GtkEntry directement.

  7. #7
    Membre du Club
    Inscrit en
    Mai 2008
    Messages
    55
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 55
    Points : 40
    Points
    40
    Par défaut
    Tu as raison teuf13.
    Dans ce tuto par exemple (http://gtk.developpez.com/cours/gtk2....de.saisie.php) le GtkEntry est directement inserer sur le GtkVBox ce qui fait qu'on le recuperer facilement.Dans mon cas mes GtkEntry sur des GtkHBox qui sont eux meme sur la GtkVBox.
    Comment dire que le champs "nom "(Entrynom) que je veux recuperer se trouve sur un widget precis?

  8. #8
    Membre régulier
    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
    Points : 117
    Points
    117
    Par défaut
    bah tu fais la même chose que pour la VBox avec la HBox...

  9. #9
    Membre du Club
    Inscrit en
    Mai 2008
    Messages
    55
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 55
    Points : 40
    Points
    40
    Par défaut
    Merci a tous le probleme est resolu voici le code:
    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
     
    #include <stdlib.h>
    #include <gtk/gtk.h>
    #include <mysql/mysql.h>
    #include <sql.h>
     
    void Action(GtkWidget *Bouton, gpointer data);
    void on_activate_entry(GtkWidget *Entryn, gpointer data);
     
    int main(int argc, char **argv)
    {
        GtkWidget *Window;
        GtkWidget *ComboBox,*ComboBoxcanal;
        GtkWidget *HBoxp,*HBoxn,*VBox,*HBoxtitre,*HBoxadresse,*HBoxtel,*HBoxrv,*HBoxhd,*HBoxdate,*HBoxheure,*HBoxdh,*HBoxj,*HBoxm,*HBoxa,*HBoxh,*HBoxmin,
                   *HBox1,*HBox2,*HBox3,*HBox4,*HBoxvide,*HBoxcanal,*HBoxbouton;
        GtkWidget *Bouton;
        GtkWidget *Labeltitre,*Labelp,*Labeladresse,*Labeltel,*Labeln,*Labelrv,*Labeldate,*Labelj,*Labelm,*Labela,*Labelheure,*Labelh,
                  *Labelmin,*Labelcanal,*Labelc,*Labelln;
        GtkWidget *Entryn,*Entryp,*Entryadresse,*Entrytel,*Entryj,*Entrym,*Entrya,*Entryh,*Entrymin;
        GtkWidget *Label;
     
        const gchar *Textnom;
     
     
        gtk_init(&argc,&argv);
     
        Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(Window), "CALLBACK");
        gtk_window_set_default_size(GTK_WINDOW(Window), 500, 400);
        gtk_window_set_position(GTK_WINDOW(Window), GTK_WIN_POS_CENTER);
        g_signal_connect(G_OBJECT(Window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
     
        /* Creation de la GtkBox verticale  */
        VBox = gtk_vbox_new(FALSE, 10);
     
        /* Ajout de la GtkVBox dans la fenetre */
        gtk_container_add(GTK_CONTAINER(Window), VBox);
     
         /* Creation des box horizontaux */
        HBoxtitre = gtk_hbox_new(TRUE, 0);     
        HBoxn = gtk_hbox_new(TRUE, 0);         
        //HBoxp = gtk_hbox_new(TRUE, 0);        
        HBoxbouton = gtk_hbox_new(TRUE, 0);
     
        /* Ajout des GtkHBox dans la GtkVBox */
        gtk_box_pack_start(GTK_BOX(VBox), HBoxtitre, FALSE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(VBox), HBoxn, FALSE, TRUE, 0);
        //gtk_box_pack_start(GTK_BOX(VBox), HBoxp, FALSE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(VBox), HBoxbouton, FALSE, TRUE, 0);
     
         /* Creation du label */
        Labeln=gtk_label_new("Nom :");                              
        Labelp=gtk_label_new("Prenom :");                                                   
        //Labeltitre=gtk_label_new("COORDONNEES DU CLIENT");           
        Label = gtk_label_new(NULL); 
        Labelln = gtk_label_new(NULL);              
     
         /* Creation des GtkEntry */
        Entryn = gtk_entry_new();         
        //Entryp = gtk_entry_new();         
     
        /* On ajoute des labels aux box horizontaux */
        //gtk_box_pack_start(GTK_BOX(HBoxtitre), Labeltitre, TRUE, TRUE, 0);       
        gtk_box_pack_start(GTK_BOX(HBoxn), Labeln, TRUE, TRUE, 0);               
        //gtk_box_pack_start(GTK_BOX(HBoxp), Labelp, TRUE, TRUE, 0); 
     
        gtk_box_pack_start(GTK_BOX(VBox), Label, TRUE, FALSE, 0);
     
        /* On ajoute des zones de saisie aux box horizontaux */
        gtk_box_pack_start(GTK_BOX(HBoxn), Entryn, TRUE, TRUE, 0);
        //gtk_box_pack_start(GTK_BOX(HBoxp), Entryp, TRUE, TRUE, 0); 
     
        gtk_box_pack_start(GTK_BOX(HBoxn), Labelln, TRUE, TRUE, 0); 
     
        /* Initialisation du bouton Valider */
         Bouton = gtk_button_new_with_label("Valider"); 
     
        /* Ajout de Bouton dans la GtkHBox */
        gtk_box_pack_start(GTK_BOX(HBoxbouton), Bouton, TRUE, FALSE, 0);  
     
        /* Connexion du signal "clicked" du bouton */
        g_signal_connect(G_OBJECT(Bouton), "clicked", G_CALLBACK(Action), (GtkWidget*) HBoxn);
     
        /* Connexion du signal "activate" du GtkEntry */
        g_signal_connect(G_OBJECT(Entryn), "activate", G_CALLBACK(on_activate_entry), (GtkWidget*) Label);
     
        //gtk_container_foreach(GTK_CONTAINER(Window),(GtkCallback)Action,""); 
     
     
        gtk_widget_show_all(Window);
     
        gtk_main();
        return EXIT_SUCCESS;
    }
     
     
     
    void on_activate_entry(GtkWidget *pEntry, gpointer data)
    {
        const gchar *sText;
     
        /* Recuperation du texte contenu dans le GtkEntry */
        sText = gtk_entry_get_text(GTK_ENTRY(pEntry));
     
        /* Modification du texte contenu dans le GtkLabel */
        gtk_label_set_text(GTK_LABEL((GtkWidget*)data), sText);
    }
     
     
    void Action(GtkWidget *Bouton, gpointer data)
    {
        GtkWidget *Tempn;
        GtkWidget *nom,*entry;
        GtkWidget *Label; 
        GList *pList=NULL;
        GList *pListn=NULL;
        const gchar *Textnom;
        const gchar *Txtnom;
        FILE *fichier; 
     
        MYSQL *mysql;
        MYSQL *conn;                     
        char *query;
        int t,r;
     
     
        /* Recuperation de la liste des elements que contient la GtkHBox HBoxn */
        pListn = gtk_container_get_children(GTK_CONTAINER((GtkWidget*)data));
     
        /* Premier element labeln*/
        nom = GTK_WIDGET(pListn->data);
     
        /* Passage a l element suivant le gtkentry*/
        pListn = g_list_next(pListn);
        entry = GTK_WIDGET(pListn->data);
     
         /* Passage a l element suivant le label*/
        pListn = g_list_next(pListn);
        Label = GTK_WIDGET(pListn->data);
     
        /* Recuperation du texte contenu dans les GtkEntry  */
        Textnom = gtk_entry_get_text(GTK_ENTRY(entry));
     
         /* Modification du texte contenu dans le GtkLabel */
        gtk_label_set_text(GTK_LABEL(Label), Textnom);
     
        /* Liberation de la memoire utilisee par la liste */
        //g_list_free(pList); 
    }

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

Discussions similaires

  1. probleme de bouton radio
    Par jeanfrancois dans le forum Langage
    Réponses: 4
    Dernier message: 23/02/2006, 13h44
  2. Simuler un click bouton?
    Par mickael.be dans le forum Composants VCL
    Réponses: 3
    Dernier message: 26/12/2005, 21h56
  3. [VBA excel] Probleme sur bouton commande
    Par RedBurn dans le forum Macros et VBA Excel
    Réponses: 21
    Dernier message: 22/11/2005, 10h10
  4. [FLASH MX2004] Probleme liens boutons
    Par pierpo dans le forum Flash
    Réponses: 2
    Dernier message: 16/11/2005, 23h31
  5. [Struts]probleme de bouton
    Par stanilas dans le forum Struts 1
    Réponses: 3
    Dernier message: 18/08/2005, 22h29

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