Here is one way I use it. The caption depends on
the state of a radio button, and the selected file name is inserted
into a Gtk::Edit called filename. void Fiscrypt::get_file(void) { Glib::ustring str; if(rbs[0]->get_active()) str = "Choose a file to encrypt"; else str = "Choose a file to de-crypt"; Gtk::FileChooserDialog dialog(str, Gtk::FILE_CHOOSER_ACTION_OPEN); dialog.set_transient_for(*window); //Add response buttons the the dialog: dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); //Add filters, so that only certain file types can be selected: if(rbs[0]->get_active()) { Gtk::FileFilter filter_any; filter_any.set_name("Any files"); filter_any.add_pattern("*"); dialog.add_filter(filter_any); Gtk::FileFilter filter_text; filter_text.set_name("Encrypted files"); filter_text.add_pattern("*.fcr"); dialog.add_filter(filter_text); } else { Gtk::FileFilter filter_text; filter_text.set_name("Encrypted files"); filter_text.add_pattern("*.fcr"); dialog.add_filter(filter_text); Gtk::FileFilter filter_any; filter_any.set_name("Any files"); filter_any.add_pattern("*"); dialog.add_filter(filter_any); } //Show the dialog and wait for a user response: int result = dialog.run(); //Handle the response: switch(result) { case(Gtk::RESPONSE_OK): file_name = dialog.get_filename(); filename->set_text(file_name); filename->grab_focus(); break; case(Gtk::RESPONSE_CANCEL): filename->grab_focus(); break; } } Hope this helps Grizzly(Francis Smit) wrote: Grizzly(Francis Smit) wrote:Hi List I'm looking for example code for using dialog in particular a Gtk::FileChooserDialog I'm using anjuta/glade3 but any example should help. I need to know how to use one as a SaveAS dialogOh and I'm working in C++/Gtkmm/libGlademm --
Robert L. Caryl Jr. Fiscal Systems, Inc. 102 Commerce Circle Madison, AL 35758-2706 USA 256-772-8922 ext. 108 This e-mail message may contain privileged or confidential information. If you are not the intended recipient, you may not disclose, use, disseminate, distribute, copy or relay this message or attachment in any way. If you received this e-mail message in error, please return by forwarding the message and it's attachment to the sender and then delete the message and it's attachment from your computer. Neither Fiscal Systems, Inc., nor its affiliates, accept any liability for any errors, omissions, corruption or viruses in the contents of this message or any attachments that arise as a result of e-mail transmission.
|