]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GErrorList.C
some tabular fixes for the problems reported by Helge
[lyx.git] / src / frontends / gtk / GErrorList.C
1 /**
2  * \file GErrorList.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Spray
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
16 #endif
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
19 #endif
20
21 #include "GErrorList.h"
22 #include "ControlErrorList.h"
23
24 #include "ghelpers.h"
25
26 using std::string;
27
28 namespace lyx {
29 namespace frontend {
30
31 GErrorList::GErrorList(Dialog & parent)
32         : GViewCB<ControlErrorList, GViewGladeB>(parent, _("Errors"), false)
33 {}
34
35
36 void GErrorList::doBuild()
37 {
38         string const gladeName = findGladeFile("errors");
39         xml_ = Gnome::Glade::Xml::create(gladeName);
40
41         Gtk::Button * closebutton;
42         xml_->get_widget("Close", closebutton);
43         setCancel(closebutton);
44
45         xml_->get_widget("ErrorList", errlistview_);
46         listCols_.add(listCol_);
47         listCols_.add(listColIndex_);
48         errliststore_ = Gtk::ListStore::create(listCols_);
49         errlistview_->set_model(errliststore_);
50         errlistview_->append_column("Error", listCol_);
51         errlistsel_ = errlistview_->get_selection();
52
53         xml_->get_widget("ErrorDescription", errdescview_);
54
55         errlistsel_->signal_changed().connect(
56                 sigc::mem_fun(*this, &GErrorList::onErrListSelection));
57 }
58
59
60 void GErrorList::update()
61 {
62         setTitle(controller().name());
63         updateContents();
64 }
65
66
67 void GErrorList::onErrListSelection()
68 {
69         int const choice =
70                 (*errlistsel_->get_selected())[listColIndex_];
71
72         ErrorList const & errors = controller().errorList();
73         errdescview_->get_buffer()->set_text(errors[choice].description);
74 }
75
76
77 void GErrorList::updateContents()
78 {
79         errliststore_->clear();
80         ErrorList const & errors = controller().errorList();
81         if (errors.empty()) {
82                 (*errliststore_->append())[listCol_] = _("*** No Errors ***");
83                 errlistview_->set_sensitive(false);
84                 return;
85         }
86
87         errlistview_->set_sensitive(true);
88
89         ErrorList::const_iterator cit = errors.begin();
90         ErrorList::const_iterator end = errors.end();
91         for (int rowindex = 0; cit != end; ++cit, ++rowindex) {
92                 Gtk::ListStore::Row row = *errliststore_->append();
93                 if (rowindex == 0)
94                         errlistsel_->select(*row);
95
96                 (*row)[listCol_] = cit->error;
97                 (*row)[listColIndex_] = rowindex;
98         }
99 }
100
101 } // namespace frontend
102 } // namespace lyx