2 * \file FileDialogPrivate.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
16 #include "FileDialogPrivate.h"
19 FileDialog::Private::Private(string const & title,
21 FileDialog::Button b1,
22 FileDialog::Button b2) :
25 fileSelection_.set_title(title);
26 fileSelection_.get_button_area()->children().push_back(
27 Gtk::Box_Helpers::Element(button1_));
28 fileSelection_.get_button_area()->children().push_back(
29 Gtk::Box_Helpers::Element(button2_));
30 button1_.signal_clicked().connect(
31 SigC::slot(*this, &FileDialog::Private::onButton1Clicked));
32 button2_.signal_clicked().connect(
33 SigC::slot(*this, &FileDialog::Private::onButton2Clicked));
34 if (!b1.first.empty() && !b1.second.empty()) {
35 string::size_type pos = b1.first.find('|');
37 Glib::locale_to_utf8(b1.first.substr(0, pos)));
41 if (!b2.first.empty() && !b2.second.empty()) {
42 string::size_type pos = b2.first.find('|');
44 Glib::locale_to_utf8(b2.first.substr(0, pos)));
51 void FileDialog::Private::onButton1Clicked()
53 fileSelection_.set_filename(dir1_);
57 void FileDialog::Private::onButton2Clicked()
59 fileSelection_.set_filename(dir2_);
63 FileDialog::Result const FileDialog::Private::open(string const & path,
64 string const & /*mask*/,
65 string const & /*suggested*/)
67 fileSelection_.set_filename(path);
68 fileSelection_.get_file_list()->get_parent()->show();
70 result.first = FileDialog::Chosen;
71 if (fileSelection_.run() == Gtk::RESPONSE_OK)
72 result.second = fileSelection_.get_filename();
74 result.second = string();
79 FileDialog::Result const FileDialog::Private::opendir(string const & path,
80 string const & /*suggested*/)
82 fileSelection_.set_filename(path);
83 fileSelection_.get_file_list()->get_parent()->hide();
85 result.first = FileDialog::Chosen;
86 if (fileSelection_.run() == Gtk::RESPONSE_OK)
87 result.second = fileSelection_.get_filename();
89 result.second = string();
94 FileDialog::Result const FileDialog::Private::save(string const & path,
96 string const & suggested)
98 return open(path, mask, suggested);