]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GUrl.C
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / gtk / GUrl.C
1 /**
2  * \file GUrl.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 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCPP_CONCEPT_CHECKS
15 #undef _GLIBCPP_CONCEPT_CHECKS
16 #endif
17
18 #include "ControlCommand.h"
19 #include "GUrl.h"
20 #include "ghelpers.h"
21
22 #include "support/lstrings.h"
23
24 #include <gtkmm.h>
25 #include <libglademm.h>
26
27 using std::string;
28
29 namespace lyx {
30 namespace frontend {
31
32
33 GUrl::GUrl(Dialog & parent)
34         : GViewCB<ControlCommand, GViewGladeB>(parent, _("URL"))
35 {
36 }
37
38
39 void GUrl::doBuild()
40 {
41         string const gladeName = findGladeFile("url");
42         xml_ = Gnome::Glade::Xml::create(gladeName);
43         Gtk::Button * restore;
44         Gtk::Button * ok;
45         Gtk::Button * apply;
46         Gtk::Button * cancel;
47         xml_->get_widget("Url", url_);
48         xml_->get_widget("Name", name_);
49         xml_->get_widget("Html", htmlType_);
50         xml_->get_widget("Restore", restore);
51         xml_->get_widget("Ok", ok);
52         xml_->get_widget("Apply", apply);
53         xml_->get_widget("Cancel", cancel);
54         setOK(ok);
55         setCancel(cancel);
56         setApply(apply);
57         setRestore(restore);
58         bcview().addReadOnly(name_);
59         bcview().addReadOnly(url_);
60         bcview().addReadOnly(htmlType_);
61
62         url_->signal_changed().connect(
63                 sigc::mem_fun(*this, &GUrl::onEntryChanged));
64         name_->signal_changed().connect(
65                 sigc::mem_fun(*this, &GUrl::onEntryChanged));
66 }
67
68
69 void GUrl::onEntryChanged()
70 {
71         bc().valid(!url_->get_text().empty() || !name_->get_text().empty());
72 }
73
74
75 void GUrl::update()
76 {
77         url_->set_text(Glib::locale_to_utf8(
78                                controller().params().getContents()));
79         name_->set_text(Glib::locale_to_utf8(
80                                 controller().params().getOptions()));
81         if (controller().params().getCmdName() == "url")
82                 htmlType_->set_active(false);
83         else
84                 htmlType_->set_active();
85 }
86
87
88 void GUrl::apply()
89 {
90         controller().params().setContents(
91                 Glib::locale_to_utf8(url_->get_text()));
92         controller().params().setOptions(
93                 Glib::locale_to_utf8(name_->get_text()));
94         if (htmlType_->get_active())
95                 controller().params().setCmdName("htmlurl");
96         else
97                 controller().params().setCmdName("url");
98 }
99
100 } // namespace frontend
101 } // namespace lyx