]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GUrl.C
fix math fonts with LyX/Mac
[lyx.git] / src / frontends / gnome / 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 Baruch Even
7  * \author Michael Koziarski
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12
13 #include <config.h>
14
15 #include "gnomeBC.h"
16 #include "GUrl.h"
17
18 #include <gtkmm/entry.h>
19 #include <gtkmm/checkbutton.h>
20 #include <gtkmm/button.h>
21
22 GUrl::GUrl()
23         : GControlledView<ControlUrl>("GUrl")
24 {}
25
26
27 GUrl::~GUrl()
28 {}
29
30
31 void GUrl::build()
32 {
33         // Connect the buttons.
34         ok_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::OKClicked));
35         cancel_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::CancelClicked));
36         apply_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::ApplyClicked));
37         restore_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::RestoreClicked));
38
39         // Manage the buttons state
40         bc().setOK(ok_btn());
41         bc().setCancel(cancel_btn());
42         bc().setApply(apply_btn());
43         bc().setRestore(restore_btn());
44
45         // Manage the read-only aware widgets.
46         bc().addReadOnly(html_cb());
47         bc().addReadOnly(name());
48         bc().addReadOnly(url());
49
50         // Make sure everything is in the correct state.
51         bc().refresh();
52 }
53
54
55 void GUrl::connect_signals()
56 {
57         // Get notifications on input change
58         slot_url_ = url()->signal_changed().connect(SigC::slot(*this, &GUrl::InputChanged));
59         slot_name_ = name()->signal_changed().connect(SigC::slot(*this, &GUrl::InputChanged));
60         slot_html_ = html_cb()->signal_toggled().connect(SigC::slot(*this, &GUrl::InputChanged));
61 }
62
63
64 void GUrl::disconnect_signals()
65 {
66         slot_url_.disconnect();
67         slot_name_.disconnect();
68         slot_html_.disconnect();
69 }
70
71
72 void GUrl::apply()
73 {
74         disconnect_signals();
75         controller().params().setContents(url()->get_text());
76         controller().params().setOptions(name()->get_text());
77
78         string cmdname("url");
79         if (html_cb()->get_active())
80                 cmdname = "htmlurl";
81
82         controller().params().setCmdName(cmdname);
83         connect_signals();
84 }
85
86
87 void GUrl::update()
88 {
89         disconnect_signals();
90
91         url()->set_text(controller().params().getContents());
92         name()->set_text(controller().params().getOptions());
93
94         html_cb()->set_active("url" != controller().params().getCmdName());
95
96         connect_signals();
97 }
98
99
100 bool GUrl::validate() const
101 {
102         return !url()->get_text().empty() && !name()->get_text().empty();
103 }
104
105 Gtk::Button * GUrl::restore_btn() const
106 {
107         return getWidget<Gtk::Button>("r_restore_btn");
108 }
109 Gtk::Button * GUrl::ok_btn() const
110 {
111         return getWidget<Gtk::Button>("r_ok_btn");
112 }
113 Gtk::Button * GUrl::apply_btn() const
114 {
115         return getWidget<Gtk::Button>("r_apply_btn");
116 }
117 Gtk::Button * GUrl::cancel_btn() const
118 {
119         return getWidget<Gtk::Button>("r_cancel_btn");
120 }
121 Gtk::Entry * GUrl::url() const
122 {
123         return getWidget<Gtk::Entry>("r_url");
124 }
125 Gtk::Entry * GUrl::name() const
126 {
127         return getWidget<Gtk::Entry>("r_name");
128 }
129 Gtk::CheckButton * GUrl::html_cb() const
130 {
131         return getWidget<Gtk::CheckButton>("r_html_cb");
132 }