questions about selecting file from filechooser dialog



hello
i am new to gtk programming and i use glade for the construction of the
gui i want to select a file from filechooser dialog to open it. I have an
entry box (in case the user want to write down the path ) and a button
that brings in front a file chooser dialog. I create the filechooser
dialog and i have coded the callbacks for the open and cancel keys and for
the double click event. I can see that the
"gtk_file_chooser_get_filename()" returning the path of the selected file
in all of the callbacks( although i don't need that when cancel is pressed
). After I close the dialog window with gtk_widget_destroy. I want now to
send the selected filename to an entry box in another window so the user
can understand that the file he selected from the filechooser dialog is
printed to this box. I have read from manuals that i have to emit a signal
to this specific entry box, but i can't understand how can i do that?What
object i must use in the g_signal_emit function?

this is my code.

void
filechooser_open_button_clicked        (GtkButton       *button,
                                        gpointer         user_data)
{
	extern char *filename;
	GtkWidget *chooser;
	chooser=lookup_widget(GTK_WIDGET(button),"filechooserdialog");
	filename=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
//      g_print("%s\n",filename); i can see the filename in the terminal. //
//i suspect the g_signal_emit should be here
//
	chooser=lookup_widget(GTK_WIDGET(button),"filechooserdialog");
	gtk_widget_destroy(chooser);
//suppose that i have to destroy the dialog window and not just hide it }

void
filechooserdialog_file_activated       (GtkFileChooser  *filechooser,
                                        gpointer         user_data)
{
	extern char *filename;
	filename=gtk_file_chooser_get_filename(filechooser);
	gtk_widget_destroy(GTK_WIDGET(filechooser));
//the same as above.this is for the double-click event
}

i have create 1 callback for the entry box, only for the "activate" event
in case the user wants to type the path of the file himself.
Should i have to create another certain callback for a specific event,
that will be run when the emition from the upper functions take place?

thanks
george







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]