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 :

Mon programme ne fonctionne plus après mise à jour de linux


Sujet :

GTK+ avec C & C++

  1. #1
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut Mon programme ne fonctionne plus après mise à jour de linux
    Bonjour,
    J'ai un problème avec un programme que j'ai conçu il fonctionne très bien sous Fedora 2, je suis passé à Fedora 5, j'ai vu que Gtk est passé à Gtk 2.
    Et c'est peut être le problème car maintenant mon programme affiche au lancement make: *** [all] Erreur de segmentation.

    Mon ancien MAKEFILE:
    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
    # vd Makefile
     
    all: vd
     
    clean:
    	$(RM) *.o *~
     
    # General
     
    CC      = gcc
    CFLAGS  = -pipe
    LDFLAGS = -lm
     
    # Warnings
     
    CFLAGS  += -Wall -Winline # -ansi -pedantic
     
    # Optimize
     
    CFLAGS  += -O3 -fforce-mem -funroll-loops -fomit-frame-pointer
    LDFLAGS += -s
     
    # Debug
     
    # CFLAGS += -g -DDEBUG
     
    # Profile
     
    # CFLAGS  += -pg
    # LDFLAGS += -pg
     
    # GTK
     
    CFLAGS  += `gtk-config --cflags`
    LDFLAGS += `gtk-config --libs`
     
    # Dependencies
     
    OBJS = bitboard.o board.o clock.o eboard.o eindex.o emove.o endgame.o eval.o \
           gboard.o hash.o mboard.o mmove.o move.o search.o sort.o vd.o
     
    vd: $(OBJS)
    	$(CC) $(LDFLAGS) -o vd $(OBJS)
     
    *.o: Makefile
     
    bitboard.o: bitboard.c bitboard.h types.h board.h
    board.o: board.c board.h types.h eval.h mboard.h bitboard.h
    clock.o: clock.c clock.h types.h
    eboard.o: eboard.c eboard.h types.h board.h mboard.h bitboard.h
    eindex.o: eindex.c eindex.h types.h eboard.h board.h mboard.h \
     bitboard.h emove.h move.h endgame.h
    emove.o: emove.c emove.h eboard.h types.h board.h mboard.h bitboard.h \
     move.h
    endgame.o: endgame.c endgame.h eindex.h types.h eboard.h board.h \
     mboard.h bitboard.h clock.h emove.h move.h
    eval.o: eval.c eval.h mboard.h types.h bitboard.h board.h endgame.h \
     eindex.h eboard.h search.h move.h
    gboard.o: gboard.c gboard.h board.h types.h vd.h
    hash.o: hash.c hash.h types.h mboard.h bitboard.h board.h
    mboard.o: mboard.c mboard.h types.h bitboard.h board.h eval.h hash.h
    mmove.o: mmove.c mmove.h types.h mboard.h bitboard.h board.h move.h \
     eval.h hash.h sort.h
    move.o: move.c move.h board.h types.h eval.h mboard.h bitboard.h
    search.o: search.c search.h board.h types.h move.h clock.h endgame.h \
     eindex.h eboard.h mboard.h bitboard.h eval.h hash.h mmove.h sort.h
    sort.o: sort.c sort.h mboard.h types.h bitboard.h board.h mmove.h \
     move.h eval.h search.h
    vd.o: vd.c vd.h types.h bitboard.h board.h clock.h endgame.h \
     eindex.h eboard.h mboard.h eval.h gboard.h hash.h move.h search.h
    Mon nouveau MAKEFILE:

    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
    # vd Makefile
     
    all: vd
     
    clean:
    	$(RM) *.o *~
     
    # General
     
    CC      = gcc
    CFLAGS  = -pipe
    LDFLAGS = -lm
     
    # Warnings
     
    CFLAGS  += -Wall -Wextra -Werror -Winline # -ansi -pedantic
     
    # Optimize
     
    CFLAGS  = $$(pkg-config --cflags gtk+-2.0)
    LDFLAGS = $$(pkg-config --libs gtk+-2.0)
     
     
    # Debug
     
    # CFLAGS += -g -DDEBUG
     
    # Profile
     
    # CFLAGS  += -pg
    # LDFLAGS += -pg
     
    # GTK
     
    CFLAGS  += -O3 -funroll-loops -fomit-frame-pointer
    LDFLAGS += -s
     
    # Dependencies
     
    OBJS = bitboard.o board.o clock.o eboard.o eindex.o emove.o endgame.o eval.o \
           gboard.o hash.o mboard.o mmove.o move.o search.o sort.o vd.o
     
    vd: $(OBJS)
    	$(CC) $(LDFLAGS) -o vd $(OBJS)
     
    *.o: Makefile
     
    bitboard.o: bitboard.c bitboard.h types.h board.h
    board.o: board.c board.h types.h eval.h mboard.h bitboard.h
    clock.o: clock.c clock.h types.h
    eboard.o: eboard.c eboard.h types.h board.h mboard.h bitboard.h
    eindex.o: eindex.c eindex.h types.h eboard.h board.h mboard.h \
     bitboard.h emove.h move.h endgame.h
    emove.o: emove.c emove.h eboard.h types.h board.h mboard.h bitboard.h \
     move.h
    endgame.o: endgame.c endgame.h eindex.h types.h eboard.h board.h \
     mboard.h bitboard.h clock.h emove.h move.h
    eval.o: eval.c eval.h mboard.h types.h bitboard.h board.h endgame.h \
     eindex.h eboard.h search.h move.h
    gboard.o: gboard.c gboard.h board.h types.h vd.h
    hash.o: hash.c hash.h types.h mboard.h bitboard.h board.h
    mboard.o: mboard.c mboard.h types.h bitboard.h board.h eval.h hash.h
    mmove.o: mmove.c mmove.h types.h mboard.h bitboard.h board.h move.h \
     eval.h hash.h sort.h
    move.o: move.c move.h board.h types.h eval.h mboard.h bitboard.h
    search.o: search.c search.h board.h types.h move.h clock.h endgame.h \
     eindex.h eboard.h mboard.h bitboard.h eval.h hash.h mmove.h sort.h
    sort.o: sort.c sort.h mboard.h types.h bitboard.h board.h mmove.h \
     move.h eval.h search.h
    vd.o: vd.c vd.h types.h bitboard.h board.h clock.h endgame.h \
     eindex.h eboard.h mboard.h eval.h gboard.h hash.h move.h search.h

    Merci d'avance pour vos réponse

  2. #2
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Bin dit moi, il serait temps que tu passe à la version 2 de GTK+, ca fait depuis mars 2002 qu'il y est passé, aujourd'hui on en est à la version 2.10.11 tout de même. A mon humble avis le problème se situe avant tout dans le code source de ton programme, surtout s'il utilise encore la version 1.2 de GTK+ ou plus vieux encore !

    Peut-être peux-tu mettre à jour ton programme ce qui ne serait pas une mauvaise chose tu peux me croire mais sinon, tu peux encore installer l'ancienne version de GTK+ (1.2 entre autre) et tenter une compilation !

    Je ne vois pas non plus pour quelle raison tu précises tous ces header à la fin de ton Makefile, je n'ai jamais eu à le faire ! Ceci est mon Makefile de base:

    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
    #
    # Variables:
    #
    CC = gcc
    BIN = bin_name
    SRC = main.c
    OBJ = main.o
     
     
    #
    # Flags d'erreurs:
    #
    ERROR_CFLAGS = -Wall -W -pedantic
     
     
    #
    # Flags pour le compilateur:
    #
    GTK_CFLAGS := $$(pkg-config --cflags gtk+-2.0)
    CFLAGS = $(ERROR_FLAGS) $(GTK_CFLAGS)
     
     
    #
    # Flags pour l'editeur de liens:
    #
    GTK_LDFLAGS = $$(pkg-config --libs gtk+-2.0)
    LDFLAGS = $(ERROR_FLAGS) $(GTK_LDFLAGS)
     
     
    #
    # Construction du programme:
    #
    all: $(BIN)
     
    $(BIN): $(SRC)
    	$(CC) $(CFLAGS) -c $(SRC)
    	$(CC) $(LDFLAGS) -o $(BIN) $(OBJ)
     
     
    #
    # Nettoyage:
    #
    clean:
    	rm -f *.o *~ core $(BIN)
    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

  3. #3
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut message attention peut être le problème ?
    Voici le seul message d'alerte pouvant peut être poser problème :

    endgame.c: In function ‘GetValue’:
    endgame.c:2182: attention : passing argument 1 of ‘OpenBaseFile’ discards qualif iers from pointer target type
    endgame.c:2186: attention : passing argument 1 of ‘CloseBaseFile’ discards quali fiers from pointer target type.

  4. #4
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Je ne pense pas, ici ce sont simplement deux petits warnings car tu passe en argument à la fonction OpenBaseFile un pointeur de type:
    alors que la fonction en attend un de type:
    Ceci n'empêche pas la compilation, c'est une simple mise en garde ici !
    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

  5. #5
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut Voici les sources si quelqu'un a une idée.
    Voici les sources si quelqu'un a une idée.
    Il fonctionne très bien sur Fedora core 2 et Aurox 9.2.
    Mais il ne fonctionne plus sur les nouvelles version Linux Fedora Core 5 et 6.
    Ni sur Suse 10 et Mandriva 2006 et 2007.
    Surement du a un changement dans Gtk.

  6. #6
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Bin si tu était sur une version inférieur à GTK+ 2.0 oui c'est un changement majeur Je pense que le mieux pour ton programme c'est de l'adapter à la nouvelle version de GTK+ mais c'est une masse de travail non négligeable. A moins que tu installes la version 1.2 de GTK+, c'est solution envisageable et de compiler spécifiquement avec cette version
    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

  7. #7
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut fichier Gboard
    Je pense qu'il y a que le fichier Gboard.c qui pose problème:

    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
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    /* GBoard.C */
     
    #include <stdlib.h>
    #include <math.h>
     
    #include <gtk/gtk.h>
    #include <gdk/gdk.h>
     
    #include "gboard.h"
    #include "types.h"
    #include "vd.h"
     
    /* Variables */
     
    gboard GBoard[1];
     
    static GtkWidget   *DrawArea;
    static GdkPixmap   *Pixmap   = NULL;
    static GdkColormap *Colormap = NULL;
    static GdkGC       *LightGC, *DarkGC, *RedGC, *GreenGC;
     
    static double PropWidth     = 0.9;
    static double PropHeight    = 0.65;
    static double PropThickness = 0.09;
    static double PropKingSpace = 0.16;
     
    static int    SquareWidth   = 39; /* 39/46/52 */
    static int    SquareHeight  = 39; /* 39/46/52 */
    static int    BoardWidth;
    static int    BoardHeight;
     
    /* Prototypes */
     
    static void InitDraw      (void);
    static void Draw          (void);
    static void DrawPixmap    (void);
    static void DrawSquare    (int X, int Y, const gsquare *Square);
     
    static void AllocColour   (GdkColor *Colour, int Red, int Green, int Blue);
    static int  Round         (double X);
     
    static void Destroy       (GtkWidget *Widget, gpointer *Data);
    static gint Expose        (GtkWidget *Widget, GdkEventExpose *Event, gpointer *Data);
    static gint Configure     (GtkWidget *Widget, GdkEventConfigure *Event, gpointer *Data);
    static gint ButtonPress   (GtkWidget *Widget, GdkEventButton *Event, gpointer *Data);
    static gint ButtonRelease (GtkWidget *Widget, GdkEventButton *Event, gpointer *Data);
    static gint KeyPress      (GtkWidget *Widget, GdkEventKey *Event, gpointer *Data);
    static gint KeyRelease    (GtkWidget *Widget, GdkEventKey *Event, gpointer *Data);
     
    /* Functions */
     
    /* InitGBoard() */
     
    void InitGBoard(int *argc, char ***argv) {
     
       gtk_init(argc,argv);
    }
     
    /* OpenGBoard() */
     
    void OpenGBoard(void) {
     
       GtkWidget *Window;
       GdkGeometry Geometry[1];
     
       BoardWidth  = 10 * SquareWidth;
       BoardHeight = 10 * SquareHeight;
     
       Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
       gtk_widget_set_events(Window,GDK_KEY_PRESS_MASK);
       gtk_signal_connect(GTK_OBJECT(Window),"destroy",GTK_SIGNAL_FUNC(Destroy),(gpointer)"Destroy()");
       gtk_signal_connect(GTK_OBJECT(Window),"key_press_event",GTK_SIGNAL_FUNC(KeyPress),(gpointer)"KeyPress()");
       gtk_window_set_title(GTK_WINDOW(Window),vd_NAME);
     
       DrawArea = gtk_drawing_area_new();
       gtk_widget_set_events(DrawArea,GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK);
       gtk_signal_connect(GTK_OBJECT(DrawArea),"expose_event",GTK_SIGNAL_FUNC(Expose),(gpointer)"Expose()");
       gtk_signal_connect(GTK_OBJECT(DrawArea),"configure_event",GTK_SIGNAL_FUNC(Configure),(gpointer)"Configure()");
       gtk_signal_connect(GTK_OBJECT(DrawArea),"button_press_event",GTK_SIGNAL_FUNC(ButtonPress),(gpointer)"ButtonPress()");
       gtk_signal_connect(GTK_OBJECT(DrawArea),"button_release_event",GTK_SIGNAL_FUNC(ButtonRelease),(gpointer)"ButtonRelease()");
       gtk_drawing_area_size(GTK_DRAWING_AREA(DrawArea),BoardWidth,BoardHeight);
       gtk_container_add(GTK_CONTAINER(Window),DrawArea);
     
       gtk_widget_show(DrawArea);
     
       Geometry->min_width   = 60;
       Geometry->min_height  = 60;
       Geometry->base_width  = 0;
       Geometry->base_height = 0;
       Geometry->width_inc   = 10;
       Geometry->height_inc  = 10;
       Geometry->min_aspect  = 1.0;
       Geometry->max_aspect  = 1.0;
     
       gtk_window_set_geometry_hints(GTK_WINDOW(Window),DrawArea,Geometry,GDK_HINT_MIN_SIZE|GDK_HINT_BASE_SIZE|GDK_HINT_ASPECT|GDK_HINT_RESIZE_INC);
     
       gtk_widget_show(Window);
     
       Draw();
    }
     
    /* CloseGBoard() */
     
    void CloseGBoard(void) {
     
    }
     
    /* DrawGBoard() */
     
    void DrawGBoard(void) {
     
       GdkRectangle Rectangle[1];
     
       DrawPixmap();
     
       Rectangle->x      = 0;
       Rectangle->y      = 0;
       Rectangle->width  = BoardWidth;
       Rectangle->height = BoardHeight;
     
       gtk_widget_draw(DrawArea,Rectangle);
       gdk_flush();
    }
     
    /* UpdateGBoard() */
     
    void UpdateGBoard(void) {
     
       DrawGBoard();
    }
     
    /* InitDraw() */
     
    static void InitDraw(void) {
     
       GdkColor Colour[1];
     
       Colormap = gdk_colormap_get_system();
     
       LightGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,252,254,132); /* 200,192,96 | 252,254,132 */
       gdk_gc_set_foreground(LightGC,Colour);
     
       DarkGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,164,98,68); /* 112,160,104 | 164,98,68 */
       gdk_gc_set_foreground(DarkGC,Colour);
     
       RedGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,132,2,4); /* 255,0,0 | 132,2,4 */
       gdk_gc_set_foreground(RedGC,Colour);
     
       GreenGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,2,132,4); /* 0,255,0 | 2,132,4 */
       gdk_gc_set_foreground(GreenGC,Colour);
    }
     
    /* Draw() */
     
    static void Draw(void) {
     
       int S;
     
       for (S = 1; S <= 20; S++) {
          GBoard->Square[S].Piece  = BLACK_MAN;
          GBoard->Square[S].Colour = DARK;
       }
     
       for (S = 21; S <= 30; S++) {
          GBoard->Square[S].Piece  = NO_PIECE;
          GBoard->Square[S].Colour = DARK;
       }
     
       for (S = 31; S <= 50; S++) {
          GBoard->Square[S].Piece  = WHITE_MAN;
          GBoard->Square[S].Colour = DARK;
       }
     
       DrawGBoard();
    }
     
    /* DrawPixmap() */
     
    static void DrawPixmap(void) {
     
       int S, X, Y;
       gsquare Light[1];
     
       if (Colormap == NULL) InitDraw();
     
       Light->Piece  = NO_PIECE;
       Light->Colour = LIGHT;
     
       S = 1;
     
       for (Y = 0; Y < 10; Y++) {
          for (X = 0; X < 10; X++) {
             if ((X + Y) % 2 == 1) {
                DrawSquare(X,Y,&GBoard->Square[S]);
                S++;
             } else {
                DrawSquare(X,Y,Light);
             }
          }
       }
     
       gdk_flush();
    }
     
    /* DrawSquare() */
     
    static void DrawSquare(int X, int Y, const gsquare *Square) {
     
       int Sx, Sy, Width, Height, Thickness, KingSpace;
       GdkRectangle Rectangle[1];
     
       Width     = Round(PropWidth*SquareWidth);
       Height    = Round(PropHeight*SquareHeight);
       Thickness = Round(PropThickness*SquareHeight);
       KingSpace = Round(PropKingSpace*SquareHeight);
     
       Sx = SquareWidth  * X;
       Sy = SquareHeight * Y;
     
       Rectangle->x      = Sx;
       Rectangle->y      = Sy;
       Rectangle->width  = SquareWidth;
       Rectangle->height = SquareHeight;
     
       switch (Square->Colour) {
       case LIGHT :
          gdk_draw_rectangle(Pixmap,LightGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       case DARK :
          gdk_draw_rectangle(Pixmap,DarkGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       case RED :
          gdk_draw_rectangle(Pixmap,RedGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       case GREEN :
          gdk_draw_rectangle(Pixmap,GreenGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       }
       gdk_draw_rectangle(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy,SquareWidth,SquareHeight);
     
       Sx += (SquareWidth  - Width)  / 2;
       Sy += (SquareHeight - Height) / 2;
     
       switch (Square->Piece) {
       case WHITE_MAN :
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          break;
       case BLACK_MAN :
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          break;
       case WHITE_KING :
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          break;
       case BLACK_KING :
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          break;
       }
     
    /*
       gdk_draw_pixmap(DrawArea->window,DrawArea->style->black_gc,Pixmap,Rectangle->x,Rectangle->y,Rectangle->x,Rectangle->y,Rectangle->width,Rectangle->height);
       gtk_widget_draw(DrawArea,Rectangle);
    */
    }
     
    /* AllocColour() */
     
    static void AllocColour(GdkColor *Colour, int Red, int Green, int Blue) {
     
       Colour->red   = 0x101 * Red;
       Colour->green = 0x101 * Green;
       Colour->blue  = 0x101 * Blue;
     
       if (! gdk_color_alloc(Colormap,Colour)) g_error("couldn't allocate colour");
    }
     
    /* Round() */
     
    static int Round(double X) {
     
       return (int) floor(X+0.5);
    }
     
    /* Destroy() */
     
    static void Destroy(GtkWidget *Widget, gpointer *Data) {
     
    }
     
    /* Expose() */
     
    static gint Expose(GtkWidget *Widget, GdkEventExpose *Event, gpointer *Data) {
     
       gdk_draw_pixmap(Widget->window,Widget->style->fg_gc[GTK_WIDGET_STATE(Widget)],Pixmap,Event->area.x,Event->area.y,Event->area.x,Event->area.y,Event->area.width,Event->area.height);
     
       return TRUE;
    }
     
    /* Configure() */
     
    static gint Configure(GtkWidget *Widget, GdkEventConfigure *Event, gpointer *Data) {
     
       if (Pixmap != NULL) gdk_pixmap_unref(Pixmap);
     
       BoardWidth  = Widget->allocation.width;
       BoardHeight = Widget->allocation.height;
     
       SquareWidth  = BoardWidth  / 10;
       SquareHeight = BoardHeight / 10;
     
       Pixmap = gdk_pixmap_new(DrawArea->window,BoardWidth,BoardHeight,-1);
       gdk_draw_rectangle(Pixmap,DrawArea->style->white_gc,TRUE,0,0,BoardWidth,BoardHeight);
     
       DrawPixmap();
     
       return TRUE;
    }
     
    /* ButtonPress() */
     
    static gint ButtonPress(GtkWidget *Widget, GdkEventButton *Event, gpointer *Data) {
     
       int X, Y, S;
     
       S = 0;
     
       if (Event->button == 1) {
          X = (int) Event->x / SquareWidth;
          Y = (int) Event->y / SquareHeight;
          if ((X + Y) % 2 == 1) {
             S = Y * 5 + X / 2 + 1;
             SquareClick(+S);
          }
       }
     
       return TRUE;
    }
     
    /* ButtonRelease() */
     
    static gint ButtonRelease(GtkWidget *Widget, GdkEventButton *Event, gpointer *Data) {
     
       int X, Y, S;
     
       S = 0;
     
       if (Event->button == 1) {
          X = (int) Event->x / SquareWidth;
          Y = (int) Event->y / SquareHeight;
          if ((X + Y) % 2 == 1) {
             S = Y * 5 + X / 2 + 1;
             SquareClick(-S);
          }
       }
     
       return TRUE;
    }
     
    /* KeyPress() */
     
    static gint KeyPress(GtkWidget *Widget, GdkEventKey *Event, gpointer *Data) {
     
       /* Event->keyval : GDK_Escape, GDK_Tab, GDK_Up, GDK_Down, GDK_Page_Up, GDK_Page_Down, GDK_Home, GDK_End */
     
       StringInput(Event->string);
     
       return TRUE;
    }
     
    /* KeyRelease() */
     
    static gint KeyRelease(GtkWidget *Widget, GdkEventKey *Event, gpointer *Data) {
     
       /* Event->keyval : GDK_Escape, GDK_Tab, GDK_Up, GDK_Down, GDK_Page_Up, GDK_Page_Down, GDK_Home, GDK_End */
     
       return TRUE;
    }
     
    /* End of GBoard.C */
    Il y a cette partie du code je pense que je dois changer :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gtk_container_add(GTK_CONTAINER(Window),DrawArea);
    Par gtk_container_class ?

  8. #8
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Bin non, pourquoi tu voudrais changer ca !
    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

  9. #9
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut
    Je ne vois pas ce qui cloche entre Gtk 1.2 et Gtk 2.
    Il n'y a pas de doc précise pour pouvoir faire la transposition entre les 2 ?

  10. #10
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut
    Voilà j'ai fais des changements sur ce que j'ai trouvé à savoir :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gtk_signal_connect changé en g_signal_connect
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gdk_pixmap_unref changé en gdk_drawable_unref
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gdk_draw_pixmap changé en gdk_draw_drawable

  11. #11
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut
    voilà les dernières modif mais j'ai toujours le message d'erreur :
    Erreur de segmentation

    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
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
     
    /* GBoard.C */
     
    #include <stdlib.h>
    #include <math.h>
     
    #include <gtk/gtk.h>
    #include <gdk/gdk.h>
     
    #include "gboard.h"
    #include "types.h"
    #include "vd.h"
     
    /* Variables */
     
    gboard GBoard[1];
     
    static GtkWidget   *DrawArea;
    static GdkPixmap   *Pixmap   = NULL;
    static GdkColormap *Colormap = NULL;
    static GdkGC       *LightGC, *DarkGC, *RedGC, *GreenGC;
     
    static double PropWidth     = 0.9;
    static double PropHeight    = 0.65;
    static double PropThickness = 0.09;
    static double PropKingSpace = 0.16;
     
    static int    SquareWidth   = 39; /* 39/46/52 */
    static int    SquareHeight  = 39; /* 39/46/52 */
    static int    BoardWidth;
    static int    BoardHeight;
     
    /* Prototypes */
     
    static void InitDraw      (void);
    static void Draw          (void);
    static void DrawPixmap    (void);
    static void DrawSquare    (int X, int Y, const gsquare *Square);
     
    static void AllocColour   (GdkColor *Colour, int Red, int Green, int Blue);
    static int  Round         (double X);
     
    static void Destroy       (GtkWidget *Widget, gpointer *Data);
    static gint Expose        (GtkWidget *Widget, GdkEventExpose *Event, gpointer *Data);
    static gint Configure     (GtkWidget *Widget, GdkEventConfigure *Event, gpointer *Data);
    static gint ButtonPress   (GtkWidget *Widget, GdkEventButton *Event, gpointer *Data);
    static gint ButtonRelease (GtkWidget *Widget, GdkEventButton *Event, gpointer *Data);
    static gint KeyPress      (GtkWidget *Widget, GdkEventKey *Event, gpointer *Data);
    static gint KeyRelease    (GtkWidget *Widget, GdkEventKey *Event, gpointer *Data);
     
    /* Functions */
     
    /* InitGBoard() */
     
    void InitGBoard(int *argc, char ***argv) {
     
       gtk_init(argc,argv);
    }
     
    /* OpenGBoard() */
     
    void OpenGBoard(void) {
     
       GtkWidget *Window;
       GdkGeometry Geometry[1];
     
       BoardWidth  = 10 * SquareWidth;
       BoardHeight = 10 * SquareHeight;
     
       Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
       gtk_widget_set_events(Window,GDK_KEY_PRESS_MASK);
       g_signal_connect(GTK_OBJECT(Window),"destroy",GTK_SIGNAL_FUNC(Destroy),(gpointer)"Destroy()");
       g_signal_connect(GTK_OBJECT(Window),"key_press_event",GTK_SIGNAL_FUNC(KeyPress),(gpointer)"KeyPress()");
       gtk_window_set_title(GTK_WINDOW(Window),vd_NAME);
     
       DrawArea = gtk_drawing_area_new();
       gtk_widget_set_events(DrawArea,GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK);
       g_signal_connect(GTK_OBJECT(DrawArea),"expose_event",GTK_SIGNAL_FUNC(Expose),(gpointer)"Expose()");
       g_signal_connect(GTK_OBJECT(DrawArea),"configure_event",GTK_SIGNAL_FUNC(Configure),(gpointer)"Configure()");
       g_signal_connect(GTK_OBJECT(DrawArea),"button_press_event",GTK_SIGNAL_FUNC(ButtonPress),(gpointer)"ButtonPress()");
       g_signal_connect(GTK_OBJECT(DrawArea),"button_release_event",GTK_SIGNAL_FUNC(ButtonRelease),(gpointer)"ButtonRelease()");
       gtk_widget_set_size_request(DrawArea,BoardWidth,BoardHeight);
       gtk_container_add(GTK_CONTAINER(Window),DrawArea);
     
       gtk_widget_show(DrawArea);
     
       Geometry->min_width   = 60;
       Geometry->min_height  = 60;
       Geometry->base_width  = 0;
       Geometry->base_height = 0;
       Geometry->width_inc   = 10;
       Geometry->height_inc  = 10;
       Geometry->min_aspect  = 1.0;
       Geometry->max_aspect  = 1.0;
     
       gtk_window_set_geometry_hints(GTK_WINDOW(Window),DrawArea,Geometry,GDK_HINT_MIN_SIZE|GDK_HINT_BASE_SIZE|GDK_HINT_ASPECT|GDK_HINT_RESIZE_INC);
     
       gtk_widget_show(Window);
     
       Draw();
    }
     
    /* CloseGBoard() */
     
    void CloseGBoard(void) {
     
    }
     
    /* DrawGBoard() */
     
    void DrawGBoard(void) {
     
       DrawPixmap();
     
    	 gtk_widget_queue_draw_area(DrawArea, 0, 0, BoardWidth, BoardHeight);
       gdk_flush();
    }
     
    /* UpdateGBoard() */
     
    void UpdateGBoard(void) {
     
       DrawGBoard();
    }
     
    /* InitDraw() */
     
    static void InitDraw(void) {
     
       GdkColor Colour[1];
     
       Colormap = gdk_colormap_get_system();
     
       LightGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,252,254,132); /* 200,192,96 | 252,254,132 */
       gdk_gc_set_foreground(LightGC,Colour);
     
       DarkGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,164,98,68); /* 112,160,104 | 164,98,68 */
       gdk_gc_set_foreground(DarkGC,Colour);
     
       RedGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,132,2,4); /* 255,0,0 | 132,2,4 */
       gdk_gc_set_foreground(RedGC,Colour);
     
       GreenGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,2,132,4); /* 0,255,0 | 2,132,4 */
       gdk_gc_set_foreground(GreenGC,Colour);
    }
     
    /* Draw() */
     
    static void Draw(void) {
     
       int S;
     
       for (S = 1; S <= 20; S++) {
          GBoard->Square[S].Piece  = BLACK_MAN;
          GBoard->Square[S].Colour = DARK;
       }
     
       for (S = 21; S <= 30; S++) {
          GBoard->Square[S].Piece  = NO_PIECE;
          GBoard->Square[S].Colour = DARK;
       }
     
       for (S = 31; S <= 50; S++) {
          GBoard->Square[S].Piece  = WHITE_MAN;
          GBoard->Square[S].Colour = DARK;
       }
     
       DrawGBoard();
    }
     
    /* DrawPixmap() */
     
    static void DrawPixmap(void) {
     
       int S, X, Y;
       gsquare Light[1];
     
       if (Colormap == NULL) InitDraw();
     
       Light->Piece  = NO_PIECE;
       Light->Colour = LIGHT;
     
       S = 1;
     
       for (Y = 0; Y < 10; Y++) {
          for (X = 0; X < 10; X++) {
             if ((X + Y) % 2 == 1) {
                DrawSquare(X,Y,&GBoard->Square[S]);
                S++;
             } else {
                DrawSquare(X,Y,Light);
             }
          }
       }
     
       gdk_flush();
    }
     
    /* DrawSquare() */
     
    static void DrawSquare(int X, int Y, const gsquare *Square) {
     
       int Sx, Sy, Width, Height, Thickness, KingSpace;
       GdkRectangle Rectangle[1];
     
       Width     = Round(PropWidth*SquareWidth);
       Height    = Round(PropHeight*SquareHeight);
       Thickness = Round(PropThickness*SquareHeight);
       KingSpace = Round(PropKingSpace*SquareHeight);
     
       Sx = SquareWidth  * X;
       Sy = SquareHeight * Y;
     
       Rectangle->x      = Sx;
       Rectangle->y      = Sy;
       Rectangle->width  = SquareWidth;
       Rectangle->height = SquareHeight;
     
       switch (Square->Colour) {
       case LIGHT :
          gdk_draw_rectangle(Pixmap,LightGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       case DARK :
          gdk_draw_rectangle(Pixmap,DarkGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       case RED :
          gdk_draw_rectangle(Pixmap,RedGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       case GREEN :
          gdk_draw_rectangle(Pixmap,GreenGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       }
       gdk_draw_rectangle(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy,SquareWidth,SquareHeight);
     
       Sx += (SquareWidth  - Width)  / 2;
       Sy += (SquareHeight - Height) / 2;
     
       switch (Square->Piece) {
       case WHITE_MAN :
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          break;
       case BLACK_MAN :
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          break;
       case WHITE_KING :
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          break;
       case BLACK_KING :
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          break;
       }
     
    /*
       gdk_draw_pixmap(DrawArea->window,DrawArea->style->black_gc,Pixmap,Rectangle->x,Rectangle->y,Rectangle->x,Rectangle->y,Rectangle->width,Rectangle->height);
       gtk_widget_draw(DrawArea,Rectangle);
    */
    }
     
    /* AllocColour() */
     
    static void AllocColour(GdkColor *Colour, int Red, int Green, int Blue) {
     
       Colour->red   = 0x101 * Red;
       Colour->green = 0x101 * Green;
       Colour->blue  = 0x101 * Blue;
     
       if (! gdk_colormap_alloc_color(Colormap,Colour,FALSE,FALSE)) g_error("couldn't allocate colour");
    }
     
    /* Round() */
     
    static int Round(double X) {
     
       return (int) floor(X+0.5);
    }
     
    /* Destroy() */
     
    static void Destroy(GtkWidget *Widget, gpointer *Data) {
     
    }
     
    /* Expose() */
     
    static gint Expose(GtkWidget *Widget, GdkEventExpose *Event, gpointer *Data) {
     
       gdk_draw_drawable(Widget->window,Widget->style->fg_gc[GTK_WIDGET_STATE(Widget)],Pixmap,Event->area.x,Event->area.y,Event->area.x,Event->area.y,Event->area.width,Event->area.height);
     
       return TRUE;
    }
     
    /* Configure() */
     
    static gint Configure(GtkWidget *Widget, GdkEventConfigure *Event, gpointer *Data) {
     
       if (Pixmap != NULL) g_object_unref(Pixmap);
     
       BoardWidth  = Widget->allocation.width;
       BoardHeight = Widget->allocation.height;
     
       SquareWidth  = BoardWidth  / 10;
       SquareHeight = BoardHeight / 10;
     
       Pixmap = gdk_pixmap_new(DrawArea->window,BoardWidth,BoardHeight,-1);
       gdk_draw_rectangle(Pixmap,DrawArea->style->white_gc,TRUE,0,0,BoardWidth,BoardHeight);
     
       DrawPixmap();
     
       return TRUE;
    }
     
    /* ButtonPress() */
     
    static gint ButtonPress(GtkWidget *Widget, GdkEventButton *Event, gpointer *Data) {
     
       int X, Y, S;
     
       S = 0;
     
       if (Event->button == 1) {
          X = (int) Event->x / SquareWidth;
          Y = (int) Event->y / SquareHeight;
          if ((X + Y) % 2 == 1) {
             S = Y * 5 + X / 2 + 1;
             SquareClick(+S);
          }
       }
     
       return TRUE;
    }
     
    /* ButtonRelease() */
     
    static gint ButtonRelease(GtkWidget *Widget, GdkEventButton *Event, gpointer *Data) {
     
       int X, Y, S;
     
       S = 0;
     
       if (Event->button == 1) {
          X = (int) Event->x / SquareWidth;
          Y = (int) Event->y / SquareHeight;
          if ((X + Y) % 2 == 1) {
             S = Y * 5 + X / 2 + 1;
             SquareClick(-S);
          }
       }
     
       return TRUE;
    }
     
    /* KeyPress() */
     
    static gint KeyPress(GtkWidget *Widget, GdkEventKey *Event, gpointer *Data) {
     
       /* Event->keyval : GDK_Escape, GDK_Tab, GDK_Up, GDK_Down, GDK_Page_Up, GDK_Page_Down, GDK_Home, GDK_End */
     
       StringInput(Event->string);
     
       return TRUE;
    }
     
    /* KeyRelease() */
     
    static gint KeyRelease(GtkWidget *Widget, GdkEventKey *Event, gpointer *Data) {
     
       /* Event->keyval : GDK_Escape, GDK_Tab, GDK_Up, GDK_Down, GDK_Page_Up, GDK_Page_Down, GDK_Home, GDK_End */
     
       return TRUE;
    }
     
    /* End of GBoard.C */
    Est-ce que quelqu'un a une idée ?

  12. #12
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Si tu as une erreur de segmentation, ca peut être n'importe où dans ton programme et vu qu'il n'est pas si petit que ca, le mieux serait de la compiler avec les informations de débogage (-g) puis de le passer à la moulinette qui s'appel gdb mais là ca dépasse le cadre de mes compétences
    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

  13. #13
    Expert éminent sénior

    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    10 603
    Détails du profil
    Informations personnelles :
    Âge : 66
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 10 603
    Points : 17 913
    Points
    17 913
    Billets dans le blog
    2
    Par défaut
    moi je préfère ddd comme debugger. ça utilise gdb, mais l'interface utilisateur est.... nettement plus conviviale
    "Un homme sage ne croit que la moitié de ce qu’il lit. Plus sage encore, il sait laquelle".

    Consultant indépendant.
    Architecture systèmes complexes. Programmation grosses applications critiques. Ergonomie.
    C, Fortran, XWindow/Motif, Java

    Je ne réponds pas aux MP techniques

  14. #14
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Citation Envoyé par souviron34
    moi je préfère ddd comme debugger. ça utilise gdb, mais l'interface utilisateur est.... nettement plus conviviale
    Ouais c'est vrai, m'empêche le jour où un vrai tutoriel existe en français sur l'utilisation correcte de se débogueur, je veux bien le lien
    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

  15. #15
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut
    J'ai repris et passé les fonctions gtk 1.2 vers gtk 2.x du fichier Gboard.
    le voici modifié:
    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
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
     
    /* GBoard.C */
     
    #include <stdlib.h>
    #include <math.h>
     
    #include <gtk/gtk.h>
    #include <gdk/gdk.h>
     
    #include "gboard.h"
    #include "types.h"
    #include "vd.h"
     
    /* Variables */
     
    gboard GBoard[1];
     
    static GtkWidget   *DrawArea;
    static GdkPixmap   *Pixmap   = NULL;
    static GdkColormap *Colormap = NULL;
    static GdkGC       *LightGC, *DarkGC, *RedGC, *GreenGC;
     
    static double PropWidth     = 0.9;
    static double PropHeight    = 0.65;
    static double PropThickness = 0.09;
    static double PropKingSpace = 0.16;
     
    static int    SquareWidth   = 39; /* 39/46/52 */
    static int    SquareHeight  = 39; /* 39/46/52 */
    static int    BoardWidth;
    static int    BoardHeight;
     
    /* Prototypes */
     
    static void InitDraw      (void);
    static void Draw          (void);
    static void DrawPixmap    (void);
    static void DrawSquare    (int X, int Y, const gsquare *Square);
     
    static void AllocColour   (GdkColor *Colour, int Red, int Green, int Blue);
    static int  Round         (double X);
     
    static void Destroy       (GtkWidget *Widget, gpointer *Data);
    static gint Expose        (GtkWidget *Widget, GdkEventExpose *Event, gpointer *Data);
    static gint Configure     (GtkWidget *Widget, GdkEventConfigure *Event, gpointer *Data);
    static gint ButtonPress   (GtkWidget *Widget, GdkEventButton *Event, gpointer *Data);
    static gint ButtonRelease (GtkWidget *Widget, GdkEventButton *Event, gpointer *Data);
    static gint KeyPress      (GtkWidget *Widget, GdkEventKey *Event, gpointer *Data);
    static gint KeyRelease    (GtkWidget *Widget, GdkEventKey *Event, gpointer *Data);
     
    /* Functions */
     
    /* InitGBoard() */
     
    void InitGBoard(int *argc, char ***argv) {
     
       gtk_init(argc,argv);
    }
     
    /* OpenGBoard() */
     
    void OpenGBoard(void) {
     
       GtkWidget *Window;
       GdkGeometry Geometry[1];
     
       BoardWidth  = 10 * SquareWidth;
       BoardHeight = 10 * SquareHeight;
     
       Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
       gtk_widget_set_events(Window,GDK_KEY_PRESS_MASK);
       g_signal_connect(GTK_OBJECT(Window),"destroy",GTK_SIGNAL_FUNC(Destroy),(gpointer)"Destroy()");
       g_signal_connect(GTK_OBJECT(Window),"key_press_event",GTK_SIGNAL_FUNC(KeyPress),(gpointer)"KeyPress()");
       gtk_window_set_title(GTK_WINDOW(Window),vd_NAME);
     
       DrawArea = gtk_drawing_area_new();
       gtk_widget_set_events(DrawArea,GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK);
       g_signal_connect(GTK_OBJECT(DrawArea),"expose_event",GTK_SIGNAL_FUNC(Expose),(gpointer)"Expose()");
       g_signal_connect(GTK_OBJECT(DrawArea),"configure_event",GTK_SIGNAL_FUNC(Configure),(gpointer)"Configure()");
       g_signal_connect(GTK_OBJECT(DrawArea),"button_press_event",GTK_SIGNAL_FUNC(ButtonPress),(gpointer)"ButtonPress()");
       g_signal_connect(GTK_OBJECT(DrawArea),"button_release_event",GTK_SIGNAL_FUNC(ButtonRelease),(gpointer)"ButtonRelease()");
       gtk_widget_set_size_request(DrawArea,BoardWidth,BoardHeight);
       gtk_container_add(GTK_CONTAINER(Window),DrawArea);
     
       gtk_widget_show(DrawArea);
     
       Geometry->min_width   = 60;
       Geometry->min_height  = 60;
       Geometry->base_width  = 0;
       Geometry->base_height = 0;
       Geometry->width_inc   = 10;
       Geometry->height_inc  = 10;
       Geometry->min_aspect  = 1.0;
       Geometry->max_aspect  = 1.0;
     
       gtk_window_set_geometry_hints(GTK_WINDOW(Window),DrawArea,Geometry,GDK_HINT_MIN_SIZE|GDK_HINT_BASE_SIZE|GDK_HINT_ASPECT|GDK_HINT_RESIZE_INC);
     
       gtk_widget_show(Window);
     
       Draw();
    }
     
    /* CloseGBoard() */
     
    void CloseGBoard(void) {
     
    }
     
    /* DrawGBoard() */
     
    void DrawGBoard(void) {
     
       DrawPixmap();
     
    	 gtk_widget_queue_draw_area(DrawArea, 0, 0, BoardWidth, BoardHeight);
       gdk_flush();
    }
     
    /* UpdateGBoard() */
     
    void UpdateGBoard(void) {
     
       DrawGBoard();
    }
     
    /* InitDraw() */
     
    static void InitDraw(void) {
     
       GdkColor Colour[1];
     
       Colormap = gdk_colormap_get_system();
     
       LightGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,252,254,132); /* 200,192,96 | 252,254,132 */
       gdk_gc_set_foreground(LightGC,Colour);
     
       DarkGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,164,98,68); /* 112,160,104 | 164,98,68 */
       gdk_gc_set_foreground(DarkGC,Colour);
     
       RedGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,132,2,4); /* 255,0,0 | 132,2,4 */
       gdk_gc_set_foreground(RedGC,Colour);
     
       GreenGC = gdk_gc_new(DrawArea->window);
       AllocColour(Colour,2,132,4); /* 0,255,0 | 2,132,4 */
       gdk_gc_set_foreground(GreenGC,Colour);
    }
     
    /* Draw() */
     
    static void Draw(void) {
     
       int S;
     
       for (S = 1; S <= 20; S++) {
          GBoard->Square[S].Piece  = BLACK_MAN;
          GBoard->Square[S].Colour = DARK;
       }
     
       for (S = 21; S <= 30; S++) {
          GBoard->Square[S].Piece  = NO_PIECE;
          GBoard->Square[S].Colour = DARK;
       }
     
       for (S = 31; S <= 50; S++) {
          GBoard->Square[S].Piece  = WHITE_MAN;
          GBoard->Square[S].Colour = DARK;
       }
     
       DrawGBoard();
    }
     
    /* DrawPixmap() */
     
    static void DrawPixmap(void) {
     
       int S, X, Y;
       gsquare Light[1];
     
       if (Colormap == NULL) InitDraw();
     
       Light->Piece  = NO_PIECE;
       Light->Colour = LIGHT;
     
       S = 1;
     
       for (Y = 0; Y < 10; Y++) {
          for (X = 0; X < 10; X++) {
             if ((X + Y) % 2 == 1) {
                DrawSquare(X,Y,&GBoard->Square[S]);
                S++;
             } else {
                DrawSquare(X,Y,Light);
             }
          }
       }
     
       gdk_flush();
    }
     
    /* DrawSquare() */
     
    static void DrawSquare(int X, int Y, const gsquare *Square) {
     
       int Sx, Sy, Width, Height, Thickness, KingSpace;
       GdkRectangle Rectangle[1];
     
       Width     = Round(PropWidth*SquareWidth);
       Height    = Round(PropHeight*SquareHeight);
       Thickness = Round(PropThickness*SquareHeight);
       KingSpace = Round(PropKingSpace*SquareHeight);
     
       Sx = SquareWidth  * X;
       Sy = SquareHeight * Y;
     
       Rectangle->x      = Sx;
       Rectangle->y      = Sy;
       Rectangle->width  = SquareWidth;
       Rectangle->height = SquareHeight;
     
       switch (Square->Colour) {
       case LIGHT :
          gdk_draw_rectangle(Pixmap,LightGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       case DARK :
          gdk_draw_rectangle(Pixmap,DarkGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       case RED :
          gdk_draw_rectangle(Pixmap,RedGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       case GREEN :
          gdk_draw_rectangle(Pixmap,GreenGC,TRUE,Sx,Sy,SquareWidth,SquareHeight);
          break;
       }
       gdk_draw_rectangle(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy,SquareWidth,SquareHeight);
     
       Sx += (SquareWidth  - Width)  / 2;
       Sy += (SquareHeight - Height) / 2;
     
       switch (Square->Piece) {
       case WHITE_MAN :
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          break;
       case BLACK_MAN :
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-Thickness/2,Width,Height,0,360*64);
          break;
       case WHITE_KING :
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          break;
       case BLACK_KING :
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy+KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->white_gc,TRUE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2+Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,TRUE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          gdk_draw_arc(Pixmap,DrawArea->style->black_gc,FALSE,Sx,Sy-KingSpace/2-Thickness/2,Width,Height,0,360*64);
          break;
       }
     
    /*
       gdk_draw_pixmap(DrawArea->window,DrawArea->style->black_gc,Pixmap,Rectangle->x,Rectangle->y,Rectangle->x,Rectangle->y,Rectangle->width,Rectangle->height);
       gtk_widget_draw(DrawArea,Rectangle);
    */
    }
     
    /* AllocColour() */
     
    static void AllocColour(GdkColor *Colour, int Red, int Green, int Blue) {
     
       Colour->red   = 0x101 * Red;
       Colour->green = 0x101 * Green;
       Colour->blue  = 0x101 * Blue;
     
       if (! gdk_colormap_alloc_color(Colormap,Colour,FALSE,FALSE)) g_error("couldn't allocate colour");
    }
     
    /* Round() */
     
    static int Round(double X) {
     
       return (int) floor(X+0.5);
    }
     
    /* Destroy() */
     
    static void Destroy(GtkWidget *Widget, gpointer *Data) {
     
    }
     
    /* Expose() */
     
    static gint Expose(GtkWidget *Widget, GdkEventExpose *Event, gpointer *Data) {
     
       gdk_draw_drawable(Widget->window,Widget->style->fg_gc[GTK_WIDGET_STATE(Widget)],Pixmap,Event->area.x,Event->area.y,Event->area.x,Event->area.y,Event->area.width,Event->area.height);
     
       return TRUE;
    }
     
    /* Configure() */
     
    static gint Configure(GtkWidget *Widget, GdkEventConfigure *Event, gpointer *Data) {
     
       if (Pixmap != NULL) g_object_unref(Pixmap);
     
       BoardWidth  = Widget->allocation.width;
       BoardHeight = Widget->allocation.height;
     
       SquareWidth  = BoardWidth  / 10;
       SquareHeight = BoardHeight / 10;
     
       Pixmap = gdk_pixmap_new(DrawArea->window,BoardWidth,BoardHeight,-1);
       gdk_draw_rectangle(Pixmap,DrawArea->style->white_gc,TRUE,0,0,BoardWidth,BoardHeight);
     
       DrawPixmap();
     
       return TRUE;
    }
     
    /* ButtonPress() */
     
    static gint ButtonPress(GtkWidget *Widget, GdkEventButton *Event, gpointer *Data) {
     
       int X, Y, S;
     
       S = 0;
     
       if (Event->button == 1) {
          X = (int) Event->x / SquareWidth;
          Y = (int) Event->y / SquareHeight;
          if ((X + Y) % 2 == 1) {
             S = Y * 5 + X / 2 + 1;
             SquareClick(+S);
          }
       }
     
       return TRUE;
    }
     
    /* ButtonRelease() */
     
    static gint ButtonRelease(GtkWidget *Widget, GdkEventButton *Event, gpointer *Data) {
     
       int X, Y, S;
     
       S = 0;
     
       if (Event->button == 1) {
          X = (int) Event->x / SquareWidth;
          Y = (int) Event->y / SquareHeight;
          if ((X + Y) % 2 == 1) {
             S = Y * 5 + X / 2 + 1;
             SquareClick(-S);
          }
       }
     
       return TRUE;
    }
     
    /* KeyPress() */
     
    static gint KeyPress(GtkWidget *Widget, GdkEventKey *Event, gpointer *Data) {
     
       /* Event->keyval : GDK_Escape, GDK_Tab, GDK_Up, GDK_Down, GDK_Page_Up, GDK_Page_Down, GDK_Home, GDK_End */
     
       StringInput(Event->string);
     
       return TRUE;
    }
     
    /* KeyRelease() */
     
    static gint KeyRelease(GtkWidget *Widget, GdkEventKey *Event, gpointer *Data) {
     
       /* Event->keyval : GDK_Escape, GDK_Tab, GDK_Up, GDK_Down, GDK_Page_Up, GDK_Page_Down, GDK_Home, GDK_End */
     
       return TRUE;
    }
     
    /* End of GBoard.C */
    Mais j'ai maintenant ciblé le problème proviens de ce bout de 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
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    /* RootMove() */
     
    void RootMove(const board *Board, int DepthMax, double TimeMax, search *Search) {
     
       int I, Event;
       int MoveNb, BestValue, Alpha, Beta, Value;
       int *NewPV;
       double Elapsed;
       mboard NewBoard[1];
       mmovelist MoveList[1];
       mmove *Move;
       mundo Undo[1];
     
       SearchStart = CurrentTime();
       TimerOn     = FALSE;
     
       Search->Move[0] = 0;
       Search->Move[1] = 0;
       Search->Move[2] = 0;
       Search->Depth   = 0;
       Search->Value   = 0.0;
       Search->Time    = 0.0;
       for (I = 0; I < 64*3+20; I++) Search->PV[I] = 0;
     
       InitSort();
     
       ElapsedMax = TimeMax;
     
       MCopyBoard(Board,NewBoard);
     
       MGenMoves(NewBoard,MoveList);
       MoveNb = MoveList->MoveNb;
     
       if (MoveNb == 0) {
          Search->Value = -INF / 100.0;
          return;
       } else if (MoveNb == 1) {
          MCopyMove(MoveList->Move[0].Move,Search->Move);
          return;
       }
     
       UpdateHash();
     
       NS = NodeNb;
       ES = EvalNb;
       HS = ReadHashTotal;
       RS = ReadHashTrue;
       DS = DbEvalNb;
     
       Event = setjmp(Return);
     
       if (Event != 0) {
     
          Output("%s *TIME OUT*\n",InfoString(Search));
          Output("\n");
     
          return;
       }
     
       Depth = ShortDepth;
     
       for (I = 0; I < MoveNb; I++) {
     
          Move = MoveList->Move[I].Move;
     
          MDoMove(NewBoard,Move,Undo);
          Value = -PVS(NewBoard,-INF,+INF,Depth-1,1,NULL);
          MUndoMove(NewBoard,Move,Undo);
     
          MoveList->Move[I].Value = Value;
       }
     
       Elapsed = Duration(SearchStart,CurrentTime());
       if (Elapsed <= 0.0) Elapsed = 1.0;
     
       Search->Time = Elapsed;
     
       SortMoveList(MoveList);
     
       Move = MoveList->Move[0].Move;
     
       MCopyMove(Move,Search->Move);
       Search->Depth = Depth;
       Search->Value = MoveList->Move[0].Value / 100.0;
     
       NewPV = Search->PV;
       NewPV = MCopyMove(Move,NewPV);
       *NewPV = 0;
     
       if (Elapsed >= EARLY * ElapsedMax
        || MoveList->Move[0].Value >= +INF - (Depth+1)
        || MoveList->Move[0].Value <= -INF + (Depth+1)) {
          Output("%s *EARLY*\n",InfoString(Search));
          Output("\n");
          return;
       }
     
       TimerOn = TRUE;
     
       for (Depth = ShortDepth+1; Depth <= DepthMax; Depth++) {
     
          BestValue = -INF-1;
          Alpha     = -INF;
          Beta      = +INF;
     
          for (I = 0; I < MoveNb; I++) {
     
             Move = MoveList->Move[I].Move;
     
             Output("%s %2d %2d/%2d %-5.5s",InfoString(Search),Depth,I+1,MoveNb,MMoveString(Move));
     
             MDoMove(NewBoard,Move,Undo);
             if (I == 0) {
                NewPV = Search->PV;
                if (NewPV != NULL) {
                   NewPV = MCopyMove(Move,NewPV);
                   *NewPV = 0;
                }
                Value = -PVS(NewBoard,-Beta,-Alpha,Depth-1,1,NewPV);
             } else {
                if (UseScout) {
                   Value = -PVS(NewBoard,-Alpha-1,-Alpha,Depth-1,1,NULL);
                   if (Value > Alpha && Value < Beta) {
                      Output("%s\n",InfoString(Search));
                      MCopyMove(Move,Search->Move);
                      Search->Depth = Depth;
                      Search->Value = Value / 100.0;
                      Output("%s %2d %2d/%2d %-5.5s",InfoString(Search),Depth,I+1,MoveNb,MMoveString(Move));
                      NewPV = Search->PV;
                      if (NewPV != NULL) {
                         NewPV = MCopyMove(Move,NewPV);
                         *NewPV = 0;
                      }
                      Value = -PVS(NewBoard,-Beta,-Value,Depth-1,1,NewPV);
                   }
                } else {
                   Value = -PVS(NewBoard,-Beta,-Alpha,Depth-1,1,NULL);
                }
             }
             MUndoMove(NewBoard,Move,Undo);
     
             Elapsed = Duration(SearchStart,CurrentTime());
             if (Elapsed <= 0.0) Elapsed = 1.0;
             Search->Time = Elapsed;
     
             MoveList->Move[I].Value = Value;
             if (Value > BestValue) {
                BestValue = Value;
                if (Value > Alpha) {
                   Alpha = Value;
                   MCopyMove(MoveList->Move[I].Move,Search->Move);
                   Search->Depth = Depth;
                   Search->Value = Value / 100.0;
                   MoveToFront(MoveList,I);
                   if (Value >= Beta) break;
                }
             }
          }
     
          if (Search->Time >= EARLY * ElapsedMax
           || MoveList->Move[0].Value >= +INF - (Depth+1)
           || MoveList->Move[0].Value <= -INF + (Depth+1)) {
             break;
          }
       }
     
       Output("%s *EARLY*\n",InfoString(Search));
       Output("\n");
    }
    Est-ce que quelqu'un trouve quelque chose qui pourrait fonctionner sur GTK 1.2 mais pas sur GTK 2.x.

    Merci pour votre aide

  16. #16
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Mais dans cette fonction il n'y même rien en rapport avec cette bibliothèque
    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

  17. #17
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut
    Il y a bien eu une modif qui fait que sur GTK 1.2 le programme tourne sans aucun problème, et que sur l'autre GTK 2.X le programme plante tout le temps.

  18. #18
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Points : 12 462
    Points
    12 462
    Par défaut
    Les différences en GTK+ lui même, voici la liste des widgets dépréciés: http://developer.gnome.org/doc/API/2...edObjects.html mais ca s'étend également dans les fonction de la GLib, Pango, GDK, etc... avec 5 ans d'évolution tu penses bien que la bibliothèque à plus que sensiblement changée

    La meilleure chose à faire reste encore de lire des tutoriels traitant de GTK+ 2.x pour voir de toi même les changements
    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

  19. #19
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut
    Je trouve vraiment pas ce qui pose problème

  20. #20
    Membre régulier
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2003
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2003
    Messages : 132
    Points : 89
    Points
    89
    Par défaut
    Toujours pas trouvé.

    Est-ce qu'il existe un moyen de faire cohabiter GTK 1.2 et GTK 2.x.
    en installant une librairie pas exemple ?

    Pour pouvoir faire tourner mon prog sous Fedora 6 comme s'il était sur la Fedora 2.

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. [CS3] Mon programme ne fonctionne plus après une copie
    Par Jeffreyshep dans le forum Flash
    Réponses: 1
    Dernier message: 05/09/2014, 10h24
  2. Réponses: 2
    Dernier message: 18/03/2013, 17h39
  3. Réponses: 3
    Dernier message: 12/08/2012, 15h45
  4. Wifi ne fonctionne plus après mise en veille
    Par mikael2235 dans le forum Windows 7
    Réponses: 2
    Dernier message: 17/01/2012, 21h37
  5. [Support]Mon ordi ne repond plus apres mise en veille
    Par Nip dans le forum Ordinateurs
    Réponses: 11
    Dernier message: 22/03/2007, 14h22

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