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