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