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