]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GnomeBase.C
get rid of broken_header.h and some unneeded tests
[lyx.git] / src / frontends / gnome / GnomeBase.C
1 /**
2  * \file GnomeBase.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  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GnomeBase.h"
14 #include "debug.h"
15 #include "support/filetools.h"
16 #include "ControlButtons.h"
17
18 #include <glib.h>
19 #include <gtkmm/dialog.h>
20
21
22 GnomeBase::GnomeBase(string const & name)
23         : ViewBase(),
24           updating_(false),
25           file_(name + ".glade"),
26           title_(name),
27           widget_name_(name),
28           xml_(0),
29           dialog_(0)
30 {
31         loadXML();
32 }
33
34 GnomeBase::~GnomeBase()
35 {}
36
37 gnomeBC & GnomeBase::bc()
38 {
39         return static_cast<gnomeBC &>(getController().bc());
40 }
41
42 void GnomeBase::loadXML()
43 {
44 #ifdef WITH_WARNINGS
45 #warning Change this before declaring it production code! (be 20010325)
46 #endif
47         string const path("src/frontends/gnome/dialogs/;frontends/gnome/dialogs/;");
48
49         string const file = FileOpenSearch(path, file_, "glade");
50
51         if (file.empty()) {
52                 lyxerr << "Cannot find glade file. Aborting." << std::endl;
53                 BOOST_ASSERT(true);
54         }
55
56         lyxerr[Debug::GUI] << "Glade file to open is " << file << endl;
57
58         xml_ = Gnome::Glade::Xml::create (file, widget_name_);
59 }
60
61
62 void GnomeBase::show()
63 {
64         update();
65         dialog()->show();
66 }
67
68
69 void GnomeBase::hide()
70 {
71         dialog()->hide();
72 }
73
74 bool GnomeBase::isValid()
75 {
76         return true;
77 }
78
79 void GnomeBase::OKClicked()
80 {
81         lyxerr[Debug::GUI] << "GnomeBase::OKClicked()" << endl;
82         getController().OKButton();
83 }
84
85 void GnomeBase::CancelClicked()
86 {
87         lyxerr[Debug::GUI] << "GnomeBase::CancelClicked()" << endl;
88         getController().CancelButton();
89 }
90
91 void GnomeBase::ApplyClicked()
92 {
93         lyxerr[Debug::GUI] << "GnomeBase::ApplyClicked()" << endl;
94         getController().ApplyButton();
95 }
96
97 void GnomeBase::RestoreClicked()
98 {
99         lyxerr[Debug::GUI] << "GnomeBase::RestoreClicked()" << endl;
100         getController().RestoreButton();
101 }
102
103 void GnomeBase::InputChanged()
104 {
105         bc().valid(isValid());
106 }
107
108 Gtk::Dialog * GnomeBase::dialog()
109 {
110         if (!dialog_)
111                 dialog_ = getWidget<Gtk::Dialog>(widget_name_);
112
113         return dialog_;
114 }
115
116 bool GnomeBase::isVisible() const
117 {
118         return dialog_ && dialog_->is_visible();
119 }