]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GnomeBase.C
ws cleanup
[lyx.git] / src / frontends / gnome / GnomeBase.C
1 /* This file is part of
2  * =================================================
3  *
4  *          LyX, The Document Processor
5  *          Copyright 1995 Matthias Ettrich.
6  *          Copyright 1995-2000 The LyX Team.
7  *
8  * ================================================= */
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include <config.h>
15 #include "GnomeBase.h"
16 #include "support/LAssert.h"
17 #include "debug.h"
18 #include "support/filetools.h"
19 #include <glib.h>
20
21 #include <gnome--/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
30 GnomeBase::~GnomeBase()
31 {
32         if (xml_)
33                 gtk_object_unref(GTK_OBJECT(xml_));
34 }
35
36
37 void GnomeBase::loadXML() const
38 {
39 #ifdef WITH_WARNINGS
40 #warning Change this before declaring it production code! (be 20010325)
41 #endif
42         string const path("src/frontends/gnome/dialogs/;frontends/gnome/dialogs/;/home/baruch/prog/lyx/graphics/src/frontends/gnome/dialogs/");
43         string const file = FileOpenSearch(path, file_, "glade");
44
45         if (file.empty()) {
46                 lyxerr << "Cannot find glade file. Aborting." << std::endl;
47                 lyx::Assert(true);
48         }
49
50         lyxerr[Debug::GUI] << "Glade file to open is " << file << '\n';
51
52         xml_ = glade_xml_new(file.c_str(), widget_name_.c_str());
53 }
54
55
56 void GnomeBase::show()
57 {
58         if (!dialog_) {
59                 dialog_ = dialog();
60                 build();
61         }
62
63         update();
64         dialog_->show();
65 }
66
67
68 void GnomeBase::hide()
69 {
70         if (dialog_)
71                 dialog_->hide();
72 }
73
74 bool GnomeBase::validate()
75 {
76         return true;
77 }
78
79 void GnomeBase::OKClicked()
80 {
81         lyxerr[Debug::GUI] << "OKClicked()\n";
82         OKButton();
83 }
84
85 void GnomeBase::CancelClicked()
86 {
87         CancelButton();
88 }
89
90 void GnomeBase::ApplyClicked()
91 {
92         ApplyButton();
93 }
94
95 void GnomeBase::RestoreClicked()
96 {
97         RestoreButton();
98 }
99
100 void GnomeBase::InputChanged()
101 {
102         bc().valid(validate());
103 }
104
105 Gnome::Dialog * GnomeBase::dialog()
106 {
107         if (!dialog_)
108                 dialog_ = getWidget<Gnome::Dialog>(widget_name_.c_str());
109
110         return dialog_;
111 }