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.
13 #include "FileDialogPrivate.h"
18 FileDialog::Private::Private(string const & title,
20 FileDialog::Button /*b1*/,
21 FileDialog::Button /*b2*/) :
24 fileSelection_.set_title(title);
25 /* fileSelection_.get_button_area()->children().push_back(
26 Gtk::Box_Helpers::Element(button1_));
27 fileSelection_.get_button_area()->children().push_back(
28 Gtk::Box_Helpers::Element(button2_));
29 button1_.signal_clicked().connect(
30 sigc::mem_fun(*this, &FileDialog::Private::onButton1Clicked));
31 button2_.signal_clicked().connect(
32 sigc::mem_fun(*this, &FileDialog::Private::onButton2Clicked));
33 if (!b1.first.empty() && !b1.second.empty()) {
34 string::size_type pos = b1.first.find('|');
36 Glib::locale_to_utf8(b1.first.substr(0, pos)));
40 if (!b2.first.empty() && !b2.second.empty()) {
41 string::size_type pos = b2.first.find('|');
43 Glib::locale_to_utf8(b2.first.substr(0, pos)));
50 void FileDialog::Private::onButton1Clicked()
52 fileSelection_.set_filename(dir1_);
56 void FileDialog::Private::onButton2Clicked()
58 fileSelection_.set_filename(dir2_);
62 FileDialog::Result const
63 FileDialog::Private::open(string const & path,
64 lyx::support::FileFilterList const & /*filters*/,
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,
95 lyx::support::FileFilterList const & filters,
96 string const & suggested)
98 return open(path, filters, suggested);