]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/FileDialogPrivate.C
Display accelerator (binding) labels in menus.
[lyx.git] / src / frontends / gtk / FileDialogPrivate.C
1 /**
2  * \file FileDialogPrivate.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Huang Ying
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "FileDialogPrivate.h"
14
15 using std::string;
16
17
18 FileDialog::Private::Private(string const & title,
19                              kb_action action,
20                              FileDialog::Button /*b1*/,
21                              FileDialog::Button /*b2*/) :
22         action_(action)
23 {
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('|');
35                 button1_.set_label(
36                         Glib::locale_to_utf8(b1.first.substr(0, pos)));
37                 dir1_ = b1.second;
38                 button1_.show();
39         }
40         if (!b2.first.empty() && !b2.second.empty()) {
41                 string::size_type pos = b2.first.find('|');
42                 button2_.set_label(
43                         Glib::locale_to_utf8(b2.first.substr(0, pos)));
44                 dir2_ = b2.second;
45                 button2_.show();
46         }*/
47 }
48
49
50 void FileDialog::Private::onButton1Clicked()
51 {
52         fileSelection_.set_filename(dir1_);
53 }
54
55
56 void FileDialog::Private::onButton2Clicked()
57 {
58         fileSelection_.set_filename(dir2_);
59 }
60
61
62 FileDialog::Result const
63 FileDialog::Private::open(string const & path,
64                           lyx::support::FileFilterList const & /*filters*/,
65                           string const & /*suggested*/)
66 {
67         fileSelection_.set_filename(path);
68         fileSelection_.get_file_list()->get_parent()->show();
69         Result result;
70         result.first = FileDialog::Chosen;
71         if (fileSelection_.run() == Gtk::RESPONSE_OK)
72                 result.second = fileSelection_.get_filename();
73         else
74                 result.second = string();
75         return result;
76 }
77
78
79 FileDialog::Result const FileDialog::Private::opendir(string const & path,
80                                                       string const & /*suggested*/)
81 {
82         fileSelection_.set_filename(path);
83         fileSelection_.get_file_list()->get_parent()->hide();
84         Result result;
85         result.first = FileDialog::Chosen;
86         if (fileSelection_.run() == Gtk::RESPONSE_OK)
87                 result.second = fileSelection_.get_filename();
88         else
89                 result.second = string();
90         return result;
91 }
92
93
94 FileDialog::Result const FileDialog::Private::save(string const & path,
95                                                    lyx::support::FileFilterList const & filters,
96                                                    string const & suggested)
97 {
98         return open(path, filters, suggested);
99 }