]> git.lyx.org Git - features.git/blob - src/frontends/gtk/GChanges.C
* remove various xforms relicts, in particular:
[features.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         if (controller().changed())
67                 promptChange();
68         else
69                 promptDismiss();
70 }
71
72
73 void GChanges::onAccept()
74 {
75         if (controller().accept()) {
76                 promptChange();
77         } else {
78                 promptDismiss();
79         }
80 }
81
82
83 void GChanges::onReject()
84 {
85         if (controller().reject()) {
86                 promptChange();
87         } else {
88                 promptDismiss();
89         }
90 }
91
92
93 void GChanges::onNext()
94 {
95         if (controller().find()) {
96                 promptChange();
97         } else {
98                 promptDismiss();
99         }
100 }
101
102
103 void GChanges::promptChange()
104 {
105         string const header = _("Accept highlighted change?");
106         string author = controller().getChangeAuthor();
107         string date = controller().getChangeDate();
108         if(author.empty())
109                 author = _("unknown author");
110         if(date.empty())
111                 date = _("unknown date");
112
113         messagelabel_->set_markup("<big><b>" + header +
114                                 "</b></big>\n\nChanged by <b>" + author
115                                 + "</b> on <b>" + date + "</b>");
116
117         acceptbutton_->set_sensitive(true && !readOnly());
118         rejectbutton_->set_sensitive(true && !readOnly());
119         nextbutton_->set_sensitive(true);
120 }
121
122
123 void GChanges::promptDismiss()
124 {
125         string const header = _("Done merging changes");
126
127         messagelabel_->set_markup("<big><b>" + header +
128                                 "</b></big>");
129
130         // Disable all buttons but close.
131         acceptbutton_->set_sensitive(false);
132         rejectbutton_->set_sensitive(false);
133         nextbutton_->set_sensitive(false);
134 }
135
136
137 } // namespace frontend
138 } // namespace lyx