Problem with message window management...



Hello, 

I have a problem with message window management. My prog is develpped using 
Glade and once my prog launched, user can open a file using a standard 'open 
file' window.
I would like to make an error message appear when file is wrong. 

The message window is called by :

int show_message(GtkWidget *widget, gchar *message)
{
/* CAUTION should be called with widget = wn_dialog */
        GtkWidget *dialog_lbl;
        
        dialog_lbl = lookup_widget(GTK_WIDGET(widget), "dialog_lbl");
        gtk_label_set_text(GTK_LABEL(dialog_lbl), message);
        gtk_widget_show(widget);

        return 0;
}

This function should be called from an 'open file window' callback (on OK 
button clicked) :

void on_open_file_ok_btn_clicked (GtkButton *button,
                                                        gpointer user_data)
{
  GtkWidget *wn_file_open;
  GtkWidget *wn_dialog;
  GtkWidget *wn_main;
  
  wn_file_open = lookup_widget(GTK_WIDGET(button), "wn_file_open");
  wn_main = lookup_widget(GTK_WIDGET(wn_file_open), "wn_main");

  if(!load_scene(wn_file_open)){
        gtk_widget_hide(wn_file_open);
        wn_dialog = gtk_object_get_data(GTK_OBJECT(wn_main), "wn_dialog");
              g_print("Can't lad model... \n");
        show_message(wn_dialog, "Error...");
  }
}

But when calling show_message function frm here, I have a segfault on 
gtk_label_set_text() function.

To test, I've created a special button used to call message window. The 
corresponding callback is here :
void on_start_btn_clicked (GtkButton *button,
                                           gpointer user_data)
{
  GtkWidget *wn_dialog;
  GtkWidget *wn_main;

  wn_main = lookup_widget(GTK_WIDGET(button), "wn_main");
  wn_dialog = gtk_object_get_data(GTK_OBJECT(wn_main), "wn_dialog");
  show_message(wn_dialog, "My message");
  g_print("Start btn clicked \n");

  gtk_widget_show (wn_dialog);
}

This way all is working fine. 

So my question is why the message window works when called from a main window 
callback and doesn't work when called from a open file window callback.

Any help would be very appreciated.

Thanks

-- 
______________________________________________________________________________
Jean-Max Redonnet                             mailto:redonnet lgmt ups-tlse fr
Mechanical Engineering Laboratory of Toulouse
University Paul Sabatier - Toulouse (France)



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