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