Gtk-CRITICAL **: file gtkentry.c: line 3717 (gtk_entry_set_text): assertion `text != NULL' failed



Hi,

I am trying to build an application which encrypts/ decrypts files or
directories as required.
I am using Fedora core 3 with kernel version 2.6.9-1.667. I am
developing the GUI using Glade 2.6.0.

I am trying to select a file name using the gtk_file_selection_new
method and display the selected file name in a text box. On clicking
the add file button I am getting a error message

"Gtk-CRITICAL **: file gtkentry.c: line 3717 (gtk_entry_set_text):
assertion `text != NULL' failed".

the file name is not being displayed on the text box at that instant.
If the add file button is clicked again, the text box is being
populated with the previous selsected filename.

The code is like this:

GtkWidget *file_selector;
const gchar *selected_filename;

void
store_filename(GtkFileSelection *selector, gpointer user_data)
{
   selected_filename = gtk_file_selection_get_filename
(GTK_FILE_SELECTION(file_selector));
}

void
on_button3_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
{
  GtkWidget * entry = lookup_widget(GTK_WIDGET(button), "entry1");

 /* Create the selector */
   file_selector = gtk_file_selection_new("Please select a file for editing.");
   gtk_entry_set_text(GTK_ENTRY(entry),selected_filename);
   gtk_signal_connect (GTK_OBJECT
(GTK_FILE_SELECTION(file_selector)->ok_button),
                           "clicked", GTK_SIGNAL_FUNC (store_filename), NULL);

   /* Ensure that the dialog box is destroyed when the user clicks a button. */

   gtk_signal_connect_object (GTK_OBJECT
GTK_FILE_SELECTION(file_selector)->ok_button),
                                          "clicked", GTK_SIGNAL_FUNC
(gtk_widget_destroy),
                                          (gpointer) file_selector);

   gtk_signal_connect_object (GTK_OBJECT
(GTK_FILE_SELECTION(file_selector)->cancel_button),
                                          "clicked", GTK_SIGNAL_FUNC
(gtk_widget_destroy),
                                          (gpointer) file_selector);

   /* Display that dialog */
   gtk_widget_show (file_selector);
}

Please guide me in resolving this error.

-- 
Cheers
Sandy



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