[Glade-users] File Selection Widget
- From: jbrite webdsi com (jbrite)
- Subject: [Glade-users] File Selection Widget
- Date: Mon, 03 Sep 2001 05:10:44 -0500
--------------040008050504080704090009
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
I'm a newbie too, but...
here is some code I use for my program. I tried to cut the parts that
you didn't need.
----
static void
FileDlgOpenBiOK ( GtkButton * button, gpointer data )
{
FILE *fp;
SelectedFile = gtk_file_selection_get_filename ( GTK_FILE_SELECTION
( data ) );
if ( (fp = fopen(SelectedFile, "r+b")) == NULL)
{
fprintf(stderr, "Error opening file %s.", SelectedFile);
exit(1);
}
fread(C.gInfo.characterName, sizeof(C.gInfo.characterName), 1, fp);
fclose(fp);
gtk_widget_destroy ( GTK_WIDGET ( data ) );
}
void
on_open_character_click (GtkMenuItem *menuitem,
gpointer user_data)
{
GtkWidget * filedlg;
/* Load up the file dialog */
filedlg = gtk_file_selection_new("Open character");
gtk_signal_connect ( GTK_OBJECT ( GTK_FILE_SELECTION ( filedlg ) ->
ok_button ),
"clicked",
GTK_SIGNAL_FUNC ( FileDlgOpenBiOK ),
filedlg );
/* Connect the file dialog's CANCEL button up to a handler */
gtk_signal_connect ( GTK_OBJECT ( GTK_FILE_SELECTION ( filedlg ) ->
cancel_button ),
"clicked",
GTK_SIGNAL_FUNC ( FileDlgCancel ),
filedlg );
/* Set the dialog up to only show source files */
gtk_file_selection_complete ( GTK_FILE_SELECTION ( filedlg ), "*" );
/* Show the dialog */
gtk_window_set_modal ( GTK_WINDOW ( filedlg ), TRUE );
gtk_widget_show ( filedlg );
}
If this doesn't help and you are writing this in C and you could send me
a .tar of the project and I'll look at it.
-Jeff
yannis1976 wrote:
Hello,
I'm new in glade and gtk programming, I'm writing a small
program with glade and I need some help..
I have managed to add the file selection widget in the program
and it pops up when I press the open button (using callbacks).
Then I choose a file by double clicking (or pressing OK) and
-of course- nothing happens... Can someone tell me how do I
"catch" the event that a file was selected and which file was it?
I believe this must be something simple, waiting for your
valuable help.
--Yannis
p.s.: is there any tutorial so newbies like me would not bother
the list with such silly questions?
____________________________________________________________________
<cid:part1.00040500.09000008@netscape.com>
--------------040008050504080704090009--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]