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+ Discussion :

Identification (ID + MDP) : Pb récupération saisie avec une GList


Sujet :

GTK+

  1. #1
    Candidat au Club
    Femme Profil pro
    Lycéen
    Inscrit en
    Février 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Lycéen

    Informations forums :
    Inscription : Février 2014
    Messages : 2
    Points : 2
    Points
    2
    Par défaut Identification (ID + MDP) : Pb récupération saisie avec une GList
    Bonjour tout le monde

    J'ai un problème au niveau de la récupération de saisie avec GTK+ : je souhaite faire une fenêtre d'identification sauf que j'ai du mal a récupérer 2 saisie dans une fenêtre... Je ne sais pas si j'ai été assez clair mais dans tout les cas je vous mets le code (tout du moins le contenu du fichier idetification.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
     
    #include <stdlib.h>
    #include <string.h>
    #include <gtk/gtk.h>
    #include "initializing.h"
    #include "error.h"
    #include "defines.h"
    #include "identification.h"
     
    int identification()
    {
        GtkWidget *id_window;                                                                                                         printf("identification\n");
        GtkWidget *table;
        GtkWidget *win_label;
        GtkWidget *ID_label;
        GtkWidget *PWD_label;
        GtkWidget *id_entry;
        GtkWidget *pwd_entry;
        GtkWidget *ok_button;
        gchar *id_win_icon;
     
    /* Identification window initialization */                                                                                        printf("\tIdentification window initialization\n");
        id_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_position(GTK_WINDOW(id_window), GTK_WIN_POS_CENTER_ON_PARENT);
        gtk_window_set_title(GTK_WINDOW(id_window), "Identification");
        id_win_icon = "img/id_win_icon.png";
        if(!gtk_window_set_icon_from_file(GTK_WINDOW(id_window), id_win_icon, NULL))
            error_returned(id_win_icon, TRIVIAL, id_window);
    /* Text initialization */                                                                                                         printf("\tText initialization\n");
        win_label = gtk_label_new("Please log in :");
        ID_label = gtk_label_new("ID :");
        PWD_label = gtk_label_new("Password :");
    /* Identification entries initialization */                                                                                         printf("\tIdentification entry initialization\n");
        id_entry = gtk_entry_new_with_max_length(7);
        pwd_entry = gtk_entry_new_with_max_length(10);
        gtk_entry_set_visibility(GTK_ENTRY(pwd_entry), FALSE);
        gtk_entry_set_invisible_char(GTK_ENTRY(pwd_entry), '$');
    /* Ok button initialization */                                                                                                    printf("\tOk button initialization\n");
        ok_button = gtk_button_new_with_label("Ok");
    /* Table initialization */                                                                                                        printf("\tTable initialization\n");
        table = gtk_table_new(4, 10, TRUE);
        gtk_container_add(GTK_CONTAINER(id_window), table);
    /* Widgets arranging */                                                                                                           printf("\tWidgets arranging\n");
        gtk_table_attach(GTK_TABLE(table), win_label, 3, 7, 0, 1, 0, 0, 0, 0);
        gtk_table_attach(GTK_TABLE(table), ID_label, 0, 1, 1, 2, 0, 0, 2, 0);
        gtk_table_attach(GTK_TABLE(table), PWD_label, 0, 1, 2, 3, 0, 0, 3, 0);
        gtk_table_attach(GTK_TABLE(table), id_entry, 1, 10, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 0);
        gtk_table_attach(GTK_TABLE(table), pwd_entry, 1, 10, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 0);
        gtk_table_attach(GTK_TABLE(table), ok_button, 4, 6, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 0);
    /*/ Widgets displaying */                                                                                                         printf("\tWidgets displaying\n");
        gtk_widget_show_all(id_window);
    /*  Verifications */
        g_signal_connect(G_OBJECT(id_entry), "activate", G_CALLBACK(verification_on_activate_id_entry), G_OBJECT((GtkWidget*) table));
        g_signal_connect(G_OBJECT(pwd_entry), "activate", G_CALLBACK(verification_on_activate_pwd_entry), G_OBJECT((GtkWidget*) table));
        g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(verification_on_ok_button), G_OBJECT((GtkWidget*) table));
        gtk_main();
        gtk_widget_destroy(id_window);
        return 1;
    }
     
    void verification_on_activate_id_entry(GtkWidget *id_entry, gpointer data)
    {
        GtkWidget *pwd_entry;                                                                                                          printf("verification_on_activate_id_entry\n");
        GList *list;
        const gchar *id_entered;
        const gchar *pwd_entered;
        gchar *ID_0;
        gchar *PWD_0;
     
        list = gtk_container_get_children(GTK_CONTAINER((GtkWidget*) data));
        list = g_list_next(list);
        list = g_list_next(list);
        list = g_list_next(list);
        list = g_list_next(list);
        list = g_list_next(list);
        pwd_entry = GTK_WIDGET(list->data);
     
        id_entered = gtk_entry_get_text(GTK_ENTRY(id_entry));
        pwd_entered = gtk_entry_get_text(GTK_ENTRY(pwd_entry));
     
        ID_0 = "admin";
        PWD_0 = "admin";
        if(!strcmp(id_entered, ID_0))
        {
            printf("\t%s -> correct ID\n", id_entered);
            if(!strcmp(pwd_entered, PWD_0))
            {
                printf("\t%s -> correct PWD\n", id_entered);
                gtk_main_quit();
            }
            else
            {
                printf("\t%s -> erroneous PWD\n", id_entered);
            }
        }
        else
        {
            printf("\t%s -> erroneous ID\n", id_entered);
        }
    }
     
    void verification_on_activate_pwd_entry(GtkWidget *pwd_entry, gpointer data)
    {
        GtkWidget *id_entry;                                                                                                          printf("verification_on_activate_pwd_entry\n");
        GList *list;
        const gchar *id_entered;
        const gchar *pwd_entered;
        gchar *ID_0;
        gchar *PWD_0;
     
        list = gtk_container_get_children(GTK_CONTAINER((GtkWidget*) data));
        list = g_list_next(list);
        list = g_list_next(list);
        list = g_list_next(list);
        list = g_list_next(list);
        id_entry = GTK_WIDGET(list->data);
     
        id_entered = gtk_entry_get_text(GTK_ENTRY(id_entry));
        pwd_entered = gtk_entry_get_text(GTK_ENTRY(pwd_entry));
     
        ID_0 = "admin";
        PWD_0 = "admin";
        if(!strcmp(id_entered, ID_0))
        {
            printf("\t%s -> correct ID\n", id_entered);
            if(!strcmp(pwd_entered, PWD_0))
            {
                printf("\t%s -> correct PWD\n", id_entered);
                gtk_main_quit();
            }
            else
            {
                printf("\t%s -> erroneous PWD\n", id_entered);
            }
        }
        else
        {
            printf("\t%s -> erroneous ID\n", id_entered);
        }
    }
     
    void verification_on_ok_button(GtkWidget *ok_button, gpointer data)
    {
        GtkWidget *id_entry;                                                                                                         printf("verification_on_ok_button\n");
        GtkWidget *pwd_entry;
        GList *list;
        const gchar *id_entered;
        const gchar *pwd_entered;
        gchar *ID_0;
        gchar *PWD_0;
     
        list = gtk_container_get_children(GTK_CONTAINER((GtkWidget*) data));
        list = g_list_next(list);
        list = g_list_next(list);
        list = g_list_next(list);
        list = g_list_next(list);
        id_entry = GTK_WIDGET(list->data);
        id_entered = gtk_entry_get_text(GTK_ENTRY(id_entry));
     
        list = g_list_next(list);
        pwd_entry = GTK_WIDGET(list->data);
        pwd_entered = gtk_entry_get_text(GTK_ENTRY(pwd_entry));
     
        ID_0 = "admin";
        PWD_0 = "admin";
        if(!strcmp(id_entered, ID_0))
        {
            printf("\t%s -> correct ID\n", id_entered);
            if(!strcmp(pwd_entered, PWD_0))
            {
                printf("\t%s -> correct PWD\n", id_entered);
                gtk_main_quit();
            }
            printf("\t%s -> erroneous PWD\n", id_entered);
        }
        else
        {
            printf("\t%s -> erroneous ID\n", id_entered);
        }
    }
    Voili voilou et dans les trois cas je n'obtiens pas d'erreur dans le build log ou le build message (je travaille avec Code::Blocks). Le programme cesse simplement de fonctionner après que j'ai appuyer sur Entrée ou clicker sur le bouton Ok. Je vais aussi faire une petite vidéo YT pour vous montrer explicitement le problème. Le lien va suivre

    www.youtube.com/watch?v=0FlDvJkBUs0

    Merci pour votre aide future qui j'espère va m'aider à résoudre ce problème ^^

    Coordialement, Mona Lisa ;-P

  2. #2
    Candidat au Club
    Femme Profil pro
    Lycéen
    Inscrit en
    Février 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Lycéen

    Informations forums :
    Inscription : Février 2014
    Messages : 2
    Points : 2
    Points
    2
    Par défaut
    Résolu.

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

Discussions similaires

  1. récupération multiple avec une seule requète
    Par rebel29270 dans le forum Requêtes
    Réponses: 7
    Dernier message: 04/12/2011, 19h01
  2. Réponses: 2
    Dernier message: 29/05/2008, 10h13
  3. Problème pour lier un valeur saisie avec une requête.
    Par jejeapollo dans le forum Requêtes et SQL.
    Réponses: 2
    Dernier message: 10/08/2007, 12h56
  4. Lier une zone de saisie avec une Checkbox
    Par Marconico dans le forum ASP
    Réponses: 3
    Dernier message: 25/04/2006, 14h41

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