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