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