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
|
/*******************************
* INCLUSION DES LIBRAIRIES.
********************************/
#include<stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <glib/gprintf.h>
#include <string.h>
#include "copy_data.h"
#include "Verification.h"
/************************************
* DECLARATION DES WIDGETS EN GLOBALE.
*************************************/
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
////////////////////////////// INTERFACE /////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
int main(int argc,char **argv)
{
struct MainWindow
{
GtkWidget *Fenetre ;
GtkWidget *Table ;
GtkWidget *Label1, *Label2, *Label3, *Label4, *Label5, *Label6, *Label7, *Label8, *Label9 ;
GtkWidget *Bouton ;
GtkWidget *Combo, *Combo1, *Combo2 ;;
GtkWidget *Spin1, *Spin2, *Spin3, *Spin4, *Spin5 ;
GtkWidget *cocher1, *cocher2, *cocher3, *cocher4, *cocher5, *cocher6 ;
GtkWidget *Image ;
GtkWidget *Frame1, *Frame2, *Frame3 ;
GList *list ;
};
typedef struct MainWindow MainWindow; // On fait un alias de la structure
MainWindow *papp; // Pointeur sur la structure. On recupere l'@ de la structure
GdkColor color;
FILE *fichier = NULL;
/************************
* INITIALISATION DE GTK.
************************/
gtk_init(&argc, &argv);
papp=g_malloc(sizeof(MainWindow)); // On alloue de la memoire dynamiquement
/**************************************************
* CREATION ET PARAMETRAGE DE LA FENETRE PRINCIPALE.
***************************************************/
papp->Fenetre = gtk_window_new(GTK_WINDOW_TOPLEVEL); // Définition de la fenêtre
gtk_window_set_title(GTK_WINDOW(papp->Fenetre), "Chaine MIMO"); // Titre de la fenêtre
gtk_window_set_default_size(GTK_WINDOW(papp->Fenetre), 350, 300); // Taille de la fenêtre
gtk_container_set_border_width(GTK_CONTAINER(papp->Fenetre),5); // Espace sur les bords de la fenetre
gtk_window_set_position(GTK_WINDOW(papp->Fenetre),GTK_WIN_POS_CENTER); // Fenêtre centrée à l'écran
g_signal_connect(G_OBJECT(papp->Fenetre),"destroy",G_CALLBACK(gtk_main_quit), NULL); // Destruction de l'application
/*=== Couleur de l'interface ====*/
color.pixel = 32;
color.red = 65535;
color.green = 55530;
color.blue = 30530;
gtk_widget_modify_bg (papp->Fenetre, GTK_STATE_NORMAL, &color); // Change la couleur
/*****************
* CREATION TABLE.
*****************/
papp->Table= gtk_table_new(10,15,FALSE); // Cree une table de 10 lignes et 10 colonnes
gtk_container_add(GTK_CONTAINER(papp->Fenetre),papp->Table); // On place la table dans la fenetre
/**************************
* REMPLISSAGE DE LA TABLE.
**************************/
/*===================== Creation des Labels et des Frames ====================*/
papp->Frame1=gtk_frame_new(" "); // Ajouts des contours
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Frame1, 0,10, 0, 5 ); // On place la widget sur la table
papp->Label1=gtk_label_new(" <b>PARAMETRES </b> ");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Label1, 0, 1, 0, 1 );
gtk_label_set_use_markup(GTK_LABEL(papp->Label1), TRUE); // On dit que l'on utilise les balises pango
papp->Label2=gtk_label_new(" Frequence(Mhz) : ");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Label2, 0, 1, 1, 2 );
papp->Label3=gtk_label_new(" Frequence carte d'acquisition(Mhz) : ");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Label3, 0, 1, 2, 3 );
papp->Label4=gtk_label_new(" Nombre de voies : ");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Label4, 0, 1, 3, 4 );
papp->Label5=gtk_label_new(" Attenuation(dB) : ");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Label5, 0, 1, 4, 5 );
papp->Label8=gtk_label_new ("RF");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Label8, 1, 2, 4, 5 );
papp->Label9=gtk_label_new ("FI");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Label9, 8, 9, 4, 5 );
papp->Frame2=gtk_frame_new(" ");
papp->Label6=gtk_label_new("<b>MESURES </b>");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Label6, 0, 1, 6, 7 );
gtk_label_set_use_markup(GTK_LABEL(papp->Label6), TRUE);
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Frame2, 0,10, 6, 8 );
papp->Frame3=gtk_frame_new(" ");
papp->Label7=gtk_label_new("<b>MODES </b>");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Label7, 0, 1, 9, 10 );
gtk_label_set_use_markup(GTK_LABEL(papp->Label7), TRUE);
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Frame3, 0,10, 8, 11 );
/*============================================================================*/
/*======================= Creation du bouton valider =========================*/
papp->Bouton = gtk_button_new_with_label("Valider");
gtk_table_attach_defaults(GTK_TABLE(papp->Table),papp->Bouton,6,10,14,15);
gtk_widget_show(papp->Bouton);
color.pixel = 32;
color.red = 45535;
color.green = 58530;
color.blue = 40530;
gtk_widget_modify_bg (papp->Bouton, GTK_STATE_NORMAL, &color); // Change la couleur
/*============================================================================*/
fichier = fopen("fichier_data.txt","w+"); // Suppresion du contenu du fichier au prealable
fclose(fichier);
/*=========================== Creation des Spin ==============================*/
papp->Spin1 = gtk_spin_button_new_with_range(20,3000,20);
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Spin1, 5, 8, 1, 2 );
papp->Spin2 = gtk_spin_button_new_with_range(0,100,10);
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Spin2, 5, 8, 2, 3 );
papp->Spin3=gtk_spin_button_new_with_range(0,4,1);
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Spin3, 5, 8, 3, 4 );
papp->Spin4=gtk_spin_button_new_with_range(0,50,1);
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Spin4, 6, 7, 4, 5 );
papp->Spin5=gtk_spin_button_new_with_range(0,50,1);
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->Spin5, 9, 10, 4, 5 );
/*============================================================================*/
/*====================== Creation des listes déroulantes =====================*/
papp->list = g_list_append(papp->list, "Analyseur de Spectre"); // ajoute une chaine a la liste
papp->list = g_list_append(papp->list, "Mesure de champs");
papp->Combo = gtk_combo_new(); // creation d'une boite combo
gtk_combo_set_popdown_strings( GTK_COMBO(papp->Combo), papp->list) ; // met la liste dans la combo box
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(papp->Combo)->entry), ""); // definit le texte initial de la combo box
gtk_table_attach(GTK_TABLE(papp->Table), papp->Combo, 0, 4, 7, 8, GTK_EXPAND, GTK_EXPAND, 0, 0 );
gtk_widget_show(papp->Combo);
/*============================================================================*/
printf("on est ici\n");
/*======================== Creation des cases à cocher =======================*/
papp->cocher1 = gtk_check_button_new_with_label("Affichage");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->cocher1, 0, 2, 10, 11 );
papp->cocher2 = gtk_check_button_new_with_label("Sauvegarde");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->cocher2, 9, 10, 10, 11 );
papp->cocher3 = gtk_check_button_new_with_label("Activation de l'ampli de tete");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->cocher3, 0, 2, 11, 12 );
papp->cocher4 = gtk_check_button_new_with_label("Activation du filtre FM");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->cocher4, 0, 2, 12, 13 );
papp->cocher5 = gtk_check_button_new_with_label("Activation du breaking");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->cocher5, 9, 10, 11, 12);
papp->cocher6 = gtk_check_button_new_with_label("Allumage de la led");
gtk_table_attach_defaults(GTK_TABLE(papp->Table), papp->cocher6, 9, 10, 12, 13);
/*===============================================================================*/
g_signal_connect(G_OBJECT(papp->Bouton),"clicked",G_CALLBACK(Verification),NULL); // Permet de faire la verification avant le click sur le bouton
g_signal_connect(G_OBJECT(papp->Bouton),"clicked",G_CALLBACK(copy_data),(gpointer)papp); // Appel de la fct copy_data apres le click
/*****************************
* CONSTRUCTION DE LA FENETRE.
*****************************/
gtk_widget_show_all(papp->Fenetre); // On affiche 'Fenetre' et tout ce qu'il contient
gtk_main(); //Rend la main a l'application
g_free(papp); // On libere la memoire
return EXIT_SUCCESS;
} |
Partager