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