GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Nov 24, 2014 12:26 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Problem with File Selection
PostPosted: Thu Jun 21, 2007 2:41 pm 
Offline
Familiar Face

Joined: Thu Jun 21, 2007 2:15 pm
Posts: 5
Hi
I'm using GTK 1.2.10 I got a file selection and the ok Button is connected with a function which is getting the file name and then destroy the file selection with gtk_widget_destroy. It works but when I use a double click in file window it prints this messages

Gtk-WARNING **: invalid class type `(unknown)' in cast to `GtkObject'

Gtk-CRITICAL **: file gtkobject.c: line 1034 (gtk_object_set_data): assertion `GTK_IS_OBJECT (object)' failed.
but also works. Because It's a program for my university I dont want to have any messages like this. Does anbody now the reasone of this message or how to desiable the double click in the file window.
greetings Dennis


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 3:09 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Could we see some code?

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 3:25 pm 
Offline
Familiar Face

Joined: Thu Jun 21, 2007 2:15 pm
Posts: 5
all written in c
part from the function that opens the file selection:
widget_list_selection->file_window = gtk_file_selection_new ( "select source file" );
gtk_window_set_position ( GTK_WINDOW ( widget_list_selection->file_window ),GTK_WIN_POS_CENTER );
gtk_file_selection_hide_fileop_buttons ( GTK_FILE_SELECTION ( widget_list_selection->file_window ) );
gtk_file_selection_set_filename ( GTK_FILE_SELECTION ( widget_list_selection->file_window ), "/home/dennis/" );
gtk_file_selection_complete ( GTK_FILE_SELECTION ( widget_list_selection->file_window ),"*.ldc" );

gtk_signal_connect ( GTK_OBJECT ( GTK_FILE_SELECTION ( widget_list_selection->file_window )->ok_button ),"clicked", ( GtkSignalFunc ) file_ok_sel_source, ( gpointer ) widget_list_selection) ;
}
widget_list_selection is a struct with 2 gtk_widgets in it.

the called function:
gint file_ok_sel_source ( GtkWidget *button,widget_list *widget_list_selection )
{
GtkWidget *source_entry;
GList *list;

source_name= gtk_file_selection_get_filename ( GTK_FILE_SELECTION ( widget_list_selection->file_window ) );
list = gtk_container_children ( GTK_CONTAINER ( widget_list_selection->main_window ) );
list = gtk_container_children ( GTK_CONTAINER ( g_list_nth_data ( list,0 ) ) );//children von vbox_main
list = gtk_container_children ( GTK_CONTAINER ( g_list_nth_data ( list,1 ) ) );//children von hbox_main
list = gtk_container_children ( GTK_CONTAINER ( g_list_nth_data ( list,0 ) ) );//children von vbox_source
source_entry = GTK_WIDGET ( g_list_nth_data ( list,1 ) );//2. child von vbox_source
gtk_entry_set_text ( GTK_ENTRY ( source_entry ),source_name );
gtk_widget_show ( GTK_WIDGET ( widget_list_selection->main_window ) );
gtk_widget_destroy ( GTK_WIDGET ( widget_list_selection->file_window ) );
}

Dennis


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 3:56 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Ok, there is a huge problem here. You should never use GtkFileSelection because it is a depreciated widget. Instead, use GtkFileChooserDialog. You can find a nice little example of how to use it for what you want here:

http://developer.gnome.org/doc/API/2.0/ ... #id3408809

(That example won't have the problem you are talking about ...

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 4:17 pm 
Offline
Familiar Face

Joined: Thu Jun 21, 2007 2:15 pm
Posts: 5
ok but the FIle Chooser DIalog is just with GTk 2 or not? I use gtk 1.2 because it was installed with distribution I used. The rest of the program is finished and I dont have the time to change everything. And the problem only comes when I destroy the widget. Do you know any solution to avoid this ?
Dennis


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 7:15 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Well, I'd recommend that you check out this excellent example:

http://developer.gnome.org/doc/API/2.0/ ... #id3376743

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 10:19 am 
Offline
Familiar Face

Joined: Thu Jun 21, 2007 2:15 pm
Posts: 5
Cant try the example cause it is for gtk 2.x I use 1.2.10
maybe anybody know why these messages come
Dennis


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 10:44 am 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
That example _should_ work. It is the same example as the one in the GTK+ 1.2 documentation here:

http://developer.gnome.org/doc/API/gtk/ ... ction.html

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 11:01 am 
Offline
Familiar Face

Joined: Thu Jun 21, 2007 2:15 pm
Posts: 5
the gtk 2 example doesn't work because of the g_signal_connect
I tried the gtk 1.2 example but it has the same problem.
I think the problem makes the function gtk_object_unref cause that is what gtk widget destroy finally makes. I can hide the widget, and then I use free for the struct widget_list_selection is that ok or is it not enough


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group