]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GChanges.C
some tabular fixes for the problems reported by Helge
[lyx.git] / src / frontends / gtk / GChanges.C
1 /**
2  * \file GChanges.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 // Too hard to make concept checks work with this file
12 #ifdef _GLIBCXX_CONCEPT_CHECKS
13 #undef _GLIBCXX_CONCEPT_CHECKS
14 #endif
15
16 #include "GChanges.h"
17 #include "ControlChanges.h"
18
19 #include "ghelpers.h"
20
21 using std::string;
22
23 namespace lyx {
24 namespace frontend {
25
26
27 GChanges::GChanges(Dialog & parent)
28         : GViewCB<ControlChanges, GViewGladeB>(parent, _("Merge Changes"), false)
29 {}
30
31
32 void GChanges::doBuild()
33 {
34         string const gladeName = findGladeFile("changes");
35         xml_ = Gnome::Glade::Xml::create(gladeName);
36
37         xml_->get_widget("Message", messagelabel_);
38
39         Gtk::Button * closebutton;
40         xml_->get_widget("Close", closebutton);
41         setCancel(closebutton);
42
43         xml_->get_widget("Accept", acceptbutton_);
44         bcview().addReadOnly(acceptbutton_);
45         acceptbutton_->signal_clicked().connect(
46                 sigc::mem_fun(*this, &GChanges::onAccept));
47
48         xml_->get_widget("Reject", rejectbutton_);
49         bcview().addReadOnly(rejectbutton_);
50         rejectbutton_->signal_clicked().connect(
51                 sigc::mem_fun(*this, &GChanges::onReject));
52
53         xml_->get_widget("Next", nextbutton_);
54         nextbutton_->signal_clicked().connect(
55                 sigc::mem_fun(*this, &GChanges::onNext));
56 }
57
58
59 void GChanges::update()
60 {
61         onNext();
62 }
63
64
65 void GChanges::onAccept()
66 {
67         if (controller().accept()) {
68                 promptChange();
69         } else {
70                 promptDismiss();
71         }
72 }
73
74
75 void GChanges::onReject()
76 {
77         if (controller().reject()) {
78                 promptChange();
79         } else {
80                 promptDismiss();
81         }
82 }
83
84
85 void GChanges::onNext()
86 {
87         if (controller().find()) {
88                 promptChange();
89         } else {
90                 promptDismiss();
91         }
92 }
93
94
95 void GChanges::promptChange()
96 {
97         string const header = _("Accept highlighted change?");
98         string author = controller().getChangeAuthor();
99         string date = controller().getChangeDate();
100         if(author.empty())
101                 author = _("unknown author");
102         if(date.empty())
103                 date = _("unknown date");
104
105         messagelabel_->set_markup("<big><b>" + header +
106                                 "</b></big>\n\nChanged by <b>" + author
107                                 + "</b> on <b>" + date + "</b>");
108
109         acceptbutton_->set_sensitive(true && !readOnly());
110         rejectbutton_->set_sensitive(true && !readOnly());
111         nextbutton_->set_sensitive(true);
112 }
113
114
115 void GChanges::promptDismiss()
116 {
117         string const header = _("Done merging changes");
118
119         messagelabel_->set_markup("<big><b>" + header +
120                                 "</b></big>");
121
122         // Disable all buttons but close.
123         acceptbutton_->set_sensitive(false);
124         rejectbutton_->set_sensitive(false);
125         nextbutton_->set_sensitive(false);
126 }
127
128
129 } // namespace frontend
130 } // namespace lyx