]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GErrorList.C
Change glob() API to accept a dir parameter.
[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 _GLIBCPP_CONCEPT_CHECKS
15 #undef _GLIBCPP_CONCEPT_CHECKS
16 #endif
17
18 #include "GErrorList.h"
19 #include "ControlErrorList.h"
20
21 #include "ghelpers.h"
22
23 using std::string;
24
25 namespace lyx {
26 namespace frontend {
27
28 GErrorList::GErrorList(Dialog & parent)
29         : GViewCB<ControlErrorList, GViewGladeB>(parent, _("Errors"), false)
30 {}
31
32
33 void GErrorList::doBuild()
34 {
35         string const gladeName = findGladeFile("errors");
36         xml_ = Gnome::Glade::Xml::create(gladeName);
37
38         Gtk::Button * closebutton;
39         xml_->get_widget("Close", closebutton);
40         setCancel(closebutton);
41
42         xml_->get_widget("ErrorList", errlistview_);
43         listCols_.add(listCol_);
44         listCols_.add(listColIndex_);
45         errliststore_ = Gtk::ListStore::create(listCols_);
46         errlistview_->set_model(errliststore_);
47         errlistview_->append_column("Error", listCol_);
48         errlistsel_ = errlistview_->get_selection();
49
50         xml_->get_widget("ErrorDescription", errdescview_);
51
52         errlistsel_->signal_changed().connect(
53                 sigc::mem_fun(*this, &GErrorList::onErrListSelection));
54 }
55
56
57 void GErrorList::update()
58 {
59   setTitle(controller().name());
60         updateContents();
61 }
62
63
64 void GErrorList::onErrListSelection()
65 {
66         int const choice =
67                 (*errlistsel_->get_selected())[listColIndex_];
68
69         ErrorList const & errors = controller().errorList();
70         errdescview_->get_buffer()->set_text(errors[choice].description);
71 }
72
73
74 void GErrorList::updateContents()
75 {
76         errliststore_->clear();
77         ErrorList const & errors = controller().errorList();
78         if (errors.empty()) {
79                 (*errliststore_->append())[listCol_] = _("*** No Errors ***");
80                 errlistview_->set_sensitive(false);
81                 return;
82         }
83
84         errlistview_->set_sensitive(true);
85
86         ErrorList::const_iterator cit = errors.begin();
87         ErrorList::const_iterator end = errors.end();
88         for (int rowindex = 0; cit != end; ++cit, ++rowindex) {
89                 Gtk::ListStore::Row row = *errliststore_->append();
90                 if (rowindex == 0)
91                         errlistsel_->select(*row);
92
93                 (*row)[listCol_] = cit->error;
94                 (*row)[listColIndex_] = rowindex;
95         }
96 }
97
98 } // namespace frontend
99 } // namespace lyx