From: John Spray Date: Mon, 11 Oct 2004 14:29:15 +0000 (+0000) Subject: gtk changes dialog X-Git-Tag: 1.6.10~14949 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b0a20c95ff90484d87648f8f24fa89429fba5e53;p=features.git gtk changes dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9079 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/controllers/ControlChanges.C b/src/frontends/controllers/ControlChanges.C index d25a3fa025..d2005a9638 100644 --- a/src/frontends/controllers/ControlChanges.C +++ b/src/frontends/controllers/ControlChanges.C @@ -72,18 +72,19 @@ string const ControlChanges::getChangeAuthor() } -void ControlChanges::accept() +bool ControlChanges::accept() { kernel().dispatch(FuncRequest(LFUN_ACCEPT_CHANGE)); - find::findNextChange(kernel().bufferview()); + return find::findNextChange(kernel().bufferview()); } -void ControlChanges::reject() +bool ControlChanges::reject() { kernel().dispatch(FuncRequest(LFUN_REJECT_CHANGE)); - find::findNextChange(kernel().bufferview()); + return find::findNextChange(kernel().bufferview()); } + } // namespace frontend } // namespace lyx diff --git a/src/frontends/controllers/ControlChanges.h b/src/frontends/controllers/ControlChanges.h index f13398d0be..cdd2622075 100644 --- a/src/frontends/controllers/ControlChanges.h +++ b/src/frontends/controllers/ControlChanges.h @@ -43,10 +43,10 @@ public: std::string const getChangeAuthor(); /// accept the current merge - void accept(); + bool accept(); /// reject the current merge - void reject(); + bool reject(); }; } // namespace frontend diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 46a03b456e..b72dfadc43 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,10 @@ +2004-10-11 John Spray + + * The Changes dialog + * Dialogs.C, Makefile.am, GChanges.C, GChanges.h + * ControlChanges.[Ch]: make accept() and reject() return bool + from findNextChange + 2004-10-09 John Spray * The Log dialog diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index ee877a9364..442795385a 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -56,7 +56,7 @@ #include "FormBibtex.h" #include "FormBox.h" #include "FormBranch.h" -#include "FormChanges.h" +#include "GChanges.h" #include "GCharacter.h" #include "FormCitation.h" #include "FormDocument.h" @@ -194,8 +194,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new FormBox(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "changes") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlChanges(*dialog)); - dialog->setView(new FormChanges(*dialog)); + dialog->setView(new GChanges(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "character") { dialog->bc().view(new GBC(dialog->bc())); diff --git a/src/frontends/gtk/GChanges.C b/src/frontends/gtk/GChanges.C new file mode 100644 index 0000000000..7002d4a69b --- /dev/null +++ b/src/frontends/gtk/GChanges.C @@ -0,0 +1,125 @@ +/** + * \file GChanges.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#include "GChanges.h" +#include "ControlChanges.h" + +#include "ghelpers.h" + +using std::string; + +namespace lyx { +namespace frontend { + + +GChanges::GChanges(Dialog & parent) + : GViewCB(parent, _("Merge Changes"), false) +{} + + +void GChanges::doBuild() +{ + string const gladeName = findGladeFile("changes"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + xml_->get_widget("Message", messagelabel_); + + Gtk::Button * closebutton; + xml_->get_widget("Close", closebutton); + setCancel(closebutton); + + xml_->get_widget("Accept", acceptbutton_); + bcview().addReadOnly(acceptbutton_); + acceptbutton_->signal_clicked().connect( + sigc::mem_fun(*this, &GChanges::onAccept)); + + xml_->get_widget("Reject", rejectbutton_); + bcview().addReadOnly(rejectbutton_); + rejectbutton_->signal_clicked().connect( + sigc::mem_fun(*this, &GChanges::onReject)); + + xml_->get_widget("Next", nextbutton_); + nextbutton_->signal_clicked().connect( + sigc::mem_fun(*this, &GChanges::onNext)); +} + + +void GChanges::update() +{ + onNext(); +} + + +void GChanges::onAccept() +{ + if (controller().accept()) { + promptChange(); + } else { + promptDismiss(); + } +} + + +void GChanges::onReject() +{ + if (controller().reject()) { + promptChange(); + } else { + promptDismiss(); + } +} + + +void GChanges::onNext() +{ + if (controller().find()) { + promptChange(); + } else { + promptDismiss(); + } +} + + +void GChanges::promptChange() +{ + string const header = _("Accept highlighted change?"); + string const author = controller().getChangeAuthor(); + string const date = controller().getChangeDate(); + if(author.empty()) + author = _("unknown author"); + if(date.empty()) + date = _("unknown date"); + + messagelabel_->set_markup("" + header + + "\n\nChanged by " + author + + " on " + date + ""); + + acceptbutton_->set_sensitive(true && !readOnly()); + rejectbutton_->set_sensitive(true && !readOnly()); + nextbutton_->set_sensitive(true); +} + + +void GChanges::promptDismiss() +{ + string const header = _("Done merging changes"); + + messagelabel_->set_markup("" + header + + ""); + + // Disable all buttons but close. + acceptbutton_->set_sensitive(false); + rejectbutton_->set_sensitive(false); + nextbutton_->set_sensitive(false); +} + + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GChanges.h b/src/frontends/gtk/GChanges.h new file mode 100644 index 0000000000..b39b9833ef --- /dev/null +++ b/src/frontends/gtk/GChanges.h @@ -0,0 +1,54 @@ +// -*- C++ -*- +/** + * \file GChanges.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef GCHANGES_H +#define GCHANGES_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlChanges; + +/** + * This class provides a GTK+ implementation of the Merge Changes Dialog. + */ +class GChanges + : public GViewCB { +public: + GChanges(Dialog &); + +private: + /// not needed. + virtual void apply() {} + /// Build the dialog + virtual void doBuild(); + /// update the dialog + virtual void update(); + + void onAccept(); + void onReject(); + void onNext(); + + void promptChange(); + void promptDismiss(); + + Gtk::Label * messagelabel_; + Gtk::Button * nextbutton_; + Gtk::Button * acceptbutton_; + Gtk::Button * rejectbutton_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GCHANGES_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 456c586cf6..3b0d85a9c8 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -24,6 +24,8 @@ libgtk_la_SOURCES = \ GAboutlyx.h \ GBC.C \ GBC.h \ + GChanges.C \ + GChanges.h \ GCharacter.C \ GCharacter.h \ GErrorList.C \ @@ -107,7 +109,6 @@ xforms_objects = \ ../xforms/FormBox.lo \ ../xforms/FormBranch.lo \ ../xforms/FormBrowser.lo \ - ../xforms/FormChanges.lo \ ../xforms/FormCitation.lo \ ../xforms/FormColorpicker.lo \ ../xforms/FormDialogView.lo \ diff --git a/src/frontends/gtk/glade/changes.glade b/src/frontends/gtk/glade/changes.glade new file mode 100644 index 0000000000..686d325d1a --- /dev/null +++ b/src/frontends/gtk/glade/changes.glade @@ -0,0 +1,352 @@ + + + + + + + 6 + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + True + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + Abort merge + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + + True + Ignore this change and proceed to the next + True + True + GTK_RELIEF_NORMAL + True + 0 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-go-forward + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Next + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + Reject this change + True + True + GTK_RELIEF_NORMAL + True + -6 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-no + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Reject + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + Accept the change highlighted in the main window + True + True + GTK_RELIEF_NORMAL + True + 0 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-yes + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Accept + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + False + 0 + + + + True + gtk-dialog-question + 6 + 0.5 + 0.5 + 6 + 0 + + + 0 + False + True + + + + + + True + False + 0 + + + + True + False + 0 + + + + True + <b><big>Accept highlighted change?</big></b> + +Changed by <b>A Person</b> on <b>4th July</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 4 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + +