]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GnomeBase.C
Clean-up of the button controller.
[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 & glade_file, string const & name)
25         : ViewBC<gnomeBC>(c)
26         , file_(glade_file), 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
75 Gnome::Dialog * GnomeBase::dialog()
76 {
77         if (!dialog_) 
78                 dialog_ = getWidget<Gnome::Dialog>(widget_name_.c_str());
79                 
80         return dialog_;
81 }