]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GnomeBase.C
A lean, clean and working start to the new, improved gnome frontend.
[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/;");
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         update();
59         dialog()->show();
60 }
61
62
63 void GnomeBase::hide()
64 {
65         dialog()->hide();
66 }
67
68 bool GnomeBase::validate()
69 {
70         return true;
71 }
72
73 void GnomeBase::OKClicked()
74 {
75         lyxerr[Debug::GUI] << "GnomeBase::OKClicked()\n";
76         OKButton();
77 }
78
79 void GnomeBase::CancelClicked() 
80
81         lyxerr[Debug::GUI] << "GnomeBase::CancelClicked()\n";
82         CancelButton(); 
83 }
84
85 void GnomeBase::ApplyClicked() 
86
87         lyxerr[Debug::GUI] << "GnomeBase::ApplyClicked()\n";
88         ApplyButton(); 
89 }
90
91 void GnomeBase::RestoreClicked() 
92
93         lyxerr[Debug::GUI] << "GnomeBase::RestoreClicked()\n";
94         RestoreButton(); 
95 }
96
97 void GnomeBase::InputChanged()
98 {
99         bc().valid(validate());
100 }
101
102 Gnome::Dialog * GnomeBase::dialog()
103 {
104         if (!dialog_)
105                 dialog_ = getWidget<Gnome::Dialog>(widget_name_.c_str());
106
107         return dialog_;
108 }