Salut j'utilise GTK+ avec dev c++ et je cherche à ouvrir des fichiers situés dans "pEntry" le code passe à la compilition par contre l'exe bug. Peut etre un probleme entre gchar et char???????
merci d'avance
#include <stdlib.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#define largeur 10000
void OnUpdate(GtkWidget *pEntry, gpointer data);
int main(int argc,char **argv)
{
GtkWidget* pWindow;
GtkWidget *pMainVBox;
GtkWidget *pFrame;
GtkWidget *pSpin;
gdouble valeur;
GtkWidget *pButton;
GtkWidget *pEntry;
GtkWidget *pLabel;
gtk_init(&argc,&argv);
pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(pWindow), "GtkSpinButton");
gtk_window_set_default_size(GTK_WINDOW(pWindow), 300, 550);
gtk_container_set_border_width(GTK_CONTAINER(pWindow), 4);
pMainVBox = gtk_vbox_new(TRUE, 0);
gtk_container_add(GTK_CONTAINER(pWindow), pMainVBox);
pFrame = gtk_frame_new("Nombre de fichier");
pSpin = gtk_spin_button_new_with_range(0, 255, 1);
gtk_container_add(GTK_CONTAINER(pFrame), pSpin);
gtk_box_pack_start(GTK_BOX(pMainVBox), pFrame, FALSE, FALSE, 0);
pFrame = gtk_frame_new("Nombre de lignes non numeriques");
pSpin = gtk_spin_button_new_with_range(0, 255, 1);
gtk_container_add(GTK_CONTAINER(pFrame), pSpin);
gtk_box_pack_start(GTK_BOX(pMainVBox), pFrame, FALSE, FALSE, 0);
pLabel = gtk_label_new("Entrez la racine de votre fichier( c:/......fuite.txt:");
gtk_box_pack_start(GTK_BOX(pMainVBox), pLabel, TRUE, FALSE, 0);
/* Creation du GtkEntry */
pEntry = gtk_entry_new();
/* Insertion du GtkEntry dans la GtkVBox */
gtk_box_pack_start(GTK_BOX(pMainVBox),pEntry, TRUE, FALSE, 0);
pButton = gtk_button_new_with_label("Valider");
gtk_box_pack_start(GTK_BOX(pMainVBox),pButton, TRUE, FALSE, 0);
/* Connexion du signal "activate" du GtkEntry */
g_signal_connect(G_OBJECT(pEntry), "activate", G_CALLBACK(OnUpdate), (gpointer)pEntry );
/* Connexion du signal "clicked" du GtkButton */
/* La donnee supplementaire est la GtkVBox pVBox */
g_signal_connect(G_OBJECT(pButton), "clicked", G_CALLBACK(OnUpdate), (gpointer)pEntry);
gtk_widget_show_all(pWindow);
g_signal_connect(G_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_main();
return EXIT_SUCCESS;
}
void OnUpdate(GtkWidget *pEntry, gpointer data)
{
FILE *f_result;
char* tab="123";
const gchar* sText;
sText = gtk_entry_get_text(GTK_ENTRY(pEntry));
f_result = fopen(sText,"r+");
fputs(tab,f_result);
fclose(f_result);
}
Patouane