-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
125 lines (89 loc) · 4.29 KB
/
main.c
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
#include <stdlib.h>
#include "lib/UI_individu_macros.h"
#include "lib/init_env_macro.h"
#include "lib/tool.h"
#include "puzzleGame.c"
int main(int argc, char *argv[]) {
/** Declarations **/
GtkWidget *fenetre_principale = NULL;
GtkWidget *button = NULL;
GtkBuilder *builder = NULL;
GError *error = NULL;
gchar *filename = NULL;
//toolBar btn
GtkWidget *playButton = NULL;
GtkWidget *pauseButton = NULL;
GtkWidget *AboutButton = NULL;
GtkWidget *decButton = NULL;
GtkWidget *incButton = NULL;
GtkWidget *quit = NULL;
GtkWidget *restBtn = NULL;
GtkWidget *msgEntry = NULL;
GtkWidget *toggleButton=NULL;
GtkWidget *saveBtn = NULL;
GtkWidget *openBtn = NULL;
GtkWidget *PuzzleBtn = NULL;
/** Initialisation de la librairie Gtk. */
gtk_init(&argc, &argv);
/**Ouverture du fichier Glade de la fenêtre principale */
builder = getBuilder();
/** Création du chemin complet pour accéder au fichier test.glade. */
/** g_build_filename(); construit le chemin complet en fonction du système */
/** d'exploitation. ( / pour Linux et \ pour Windows) */
filename = g_build_filename("../Interface21.glade", NULL);
/** Chargement du fichier test.glade. */
gtk_builder_add_from_file(builder, filename, &error);
g_free(filename);
if (error) {
gint code = error->code;
g_printerr("%s\n", error->message);
g_error_free(error);
return code;
}
/** init and save stats to builder **/
init_save_Stats(builder);
/** Récupération du pointeur de la fenêtre principale */
fenetre_principale = GTK_WIDGET(gtk_builder_get_object(builder, BUILDER_ID_MAIN_WINDOW));
/** The widget that contains the grid **/
GtkWidget *ViewPort2 = GTK_WIDGET(gtk_builder_get_object(builder, "ViewPort2"));
/** button for signal **/
button = GTK_WIDGET(gtk_builder_get_object(builder, "subutton"));
/** toolbar btn */
playButton = GTK_WIDGET(gtk_builder_get_object(builder, "play"));
pauseButton = GTK_WIDGET(gtk_builder_get_object(builder, "pause"));
decButton = GTK_WIDGET(gtk_builder_get_object(builder, "decreaseVT"));
incButton = GTK_WIDGET(gtk_builder_get_object(builder, "increaseVT"));
AboutButton = GTK_WIDGET(gtk_builder_get_object(builder, "about"));
g_signal_connect (GTK_TOOL_BUTTON(AboutButton), "clicked", (GCallback) about_game, NULL);
restBtn = GTK_WIDGET(gtk_builder_get_object(builder, "restart"));
g_signal_connect (GTK_TOOL_BUTTON(restBtn), "clicked", (GCallback) macro_restartEnv, NULL);
quit = GTK_WIDGET(gtk_builder_get_object(builder, "quit"));
g_signal_connect (GTK_TOOL_BUTTON(quit), "clicked", (GCallback) quit_game, NULL);
mvToolBar(playButton, pauseButton, decButton, incButton);
toggleButton = GTK_WIDGET(gtk_builder_get_object (builder, "toggle"));
g_signal_connect (toggleButton, "toggled",G_CALLBACK (Add_Mode),NULL);
saveBtn = GTK_WIDGET(gtk_builder_get_object(builder, "save"));
g_signal_connect (GTK_TOOL_BUTTON(saveBtn), "clicked", (GCallback) macro_saveButton, NULL);
openBtn= GTK_WIDGET(gtk_builder_get_object(builder, "ouvrir"));
g_signal_connect (GTK_TOOL_BUTTON(openBtn), "clicked", (GCallback) init_envFromFile, NULL);
PuzzleBtn= GTK_WIDGET(gtk_builder_get_object(builder, "Puzzle"));
g_signal_connect (GTK_TOOL_BUTTON(PuzzleBtn), "clicked", (GCallback) openPuzzle, NULL);
set_css(builder);
g_printerr("\nReached me\n");
/** create and add the grid to the ViewPort **/
init_background(ViewPort2, builder);
/** Affectation du signal "destroy" à la fonction gtk_main_quit(); pour la */
/** fermeture de la fenêtre. */
g_signal_connect (G_OBJECT(fenetre_principale), "destroy", (GCallback) gtk_main_quit, NULL);
/** signal to get added virus **/
g_signal_connect (GTK_BUTTON(button), "clicked", (GCallback) enregistrer_virus, builder);
/** Signal destroy virus added message **/
msgEntry = GTK_WIDGET(gtk_builder_get_object(builder, "entryNomVirus"));
g_signal_connect (msgEntry, "button-press-event", (GCallback) destroy_message, builder);
/** Affichage de la fenêtre principale. */
gtk_widget_show_all(fenetre_principale);
/// RUN ENV MOVEMENTS
g_timeout_add(PLAY_SPEED, iterateIndividusList, builder);
gtk_main();
return 0;
}