glade3, how to get the response of GtkFileChooserDialog somwhere in my code and open a file?



Hi g(tk)uys,

I have a GtkFileChooserDialog with two buttons, one Open and one
Cancel. They have the respective Response ID set to "0" and "1". So
when I select a file and click on "Open" GTK sents the code "0"
somewhere, but I don't know how to get this in my code...

So I tried to get the string of the file choosed, by adding a function
to the button "open" :

// global
Gtk::FileChooserDialog* pOpenDialog = 0;
Gtk::Button* pCancelOpenMyfile = 0;
Gtk::Button* pOpenMyfile = 0;

static
void onButtonOpen()
{
  char *filename;
  GtkFileChooser *chooser = GTK_FILE_CHOOSER (pOpenDialog);
  filename = gtk_file_chooser_get_filename (chooser);
  std::cout << filename << std::endl;
}

int main(int argc, char **argv)
{
...
  refBuilder->get_widget("OpenMyFile", pOpenMyFile);
...
  if(pOpenMyfile)
  {
   pOpenMyFile->signal_clicked().connect( sigc::ptr_fun(onButtonOpen) );
  }
...
}
when I run that code I get an issue :

GLib-GObject-WARNING **: invalid uninstantiatable type '(null)' in cast
to 'GtkFileChooser'
regards,
/nicoo


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