|
|
| Author |
Message |
|
|
DennisH Familiar Face
Joined: 21 Jun 2007 Posts: 5
|
Posted: Thu Jun 21, 2007 2:41 pm Post subject: Problem with File Selection |
|
|
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 |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Thu Jun 21, 2007 3:09 pm Post subject: |
|
|
| Could we see some code? |
|
| Back to top |
|
 |
DennisH Familiar Face
Joined: 21 Jun 2007 Posts: 5
|
Posted: Thu Jun 21, 2007 3:25 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Thu Jun 21, 2007 3:56 pm Post subject: |
|
|
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/gtk/GtkFileChooserDialog.html#id3408809
(That example won't have the problem you are talking about ... |
|
| Back to top |
|
 |
DennisH Familiar Face
Joined: 21 Jun 2007 Posts: 5
|
Posted: Thu Jun 21, 2007 4:17 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
|
| Back to top |
|
 |
DennisH Familiar Face
Joined: 21 Jun 2007 Posts: 5
|
Posted: Tue Jun 26, 2007 10:19 am Post subject: |
|
|
Cant try the example cause it is for gtk 2.x I use 1.2.10
maybe anybody know why these messages come
Dennis |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
|
| Back to top |
|
 |
DennisH Familiar Face
Joined: 21 Jun 2007 Posts: 5
|
Posted: Tue Jun 26, 2007 11:01 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|