[Glade-users] How to use FileChooserButton to get a filename (C language)
- From: oliveiratiano at gmail.com (Cristiano Oliveira Gonçalves)
- Subject: [Glade-users] How to use FileChooserButton to get a filename (C language)
- Date: Thu, 3 Jan 2013 12:09:07 -0300
Hello!
Im new to this glade thing (and also to this mailing list), and would like
to know if any of you guys could help me out:
I have to get the filename the user selects from the chooserbutton and send
it as a string to a function. Unfortunatelly, i've been receiving this
annoying error: Gtk-CRITICAL **: IA__gtk_file_chooser_get_uri: assertion
`GTK_IS_FILE_CHOOSER (chooser)' failed
I thought it was due to the wrong use of the widget. Could somebody help me
to figure this out? The source code is below, and as you can see, it's from
a Glade-GTK tutorial found at https://live.gnome.org/Glade/Tutorials.
The program is a simple 2 button window: first button is the
filechooserbutton, and the second is the standard button that calls the
"clica" function when clicked.
Thanks a lot, and sorry for my bad english!
Test source (just to figure out how to use the widget):
#include <gtk/gtk.h>
int
main( int argc,
char **argv )
{
GtkBuilder *builder;
GtkWidget *window;
GError *error = NULL;
/* Init GTK+ */
gtk_init( &argc, &argv );
/* Create new GtkBuilder object */
builder = gtk_builder_new();
/* Load UI from file. If error occurs, report it and quit application.
* Replace "tut.glade" with your saved project. */
if( ! gtk_builder_add_from_file( builder, "tut.glade", &error ) )
{
g_warning( "%s", error->message );
g_free( error );
return( 1 );
}
/* Get main window pointer from UI */
window = GTK_WIDGET( gtk_builder_get_object( builder, "window1" ) );
/* Connect signals */
gtk_builder_connect_signals( builder, NULL );
/* Destroy builder, since we don't need it anymore */
g_object_unref( G_OBJECT( builder ) );
/* Show window. All other widgets are automatically shown by GtkBuilder
*/
gtk_widget_show( window );
/* Start main loop */
gtk_main();
return( 0 );
}
void clica(GtkFileChooser *filechooserbutton1){
char cNome[250];
*cNome =
gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(filechooserbutton1));
printf("\n%s", cNome);
}
--
Cristiano Oliveira Gon?alves
Graduando em Bacharelado em Sistemas de Informa??o
Unesp Bauru.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/glade-users/attachments/20130103/b9a685c7/attachment.html>
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]