]> git.lyx.org Git - features.git/commitdiff
gtk changes dialog
authorJohn Spray <spray@lyx.org>
Mon, 11 Oct 2004 14:29:15 +0000 (14:29 +0000)
committerJohn Spray <spray@lyx.org>
Mon, 11 Oct 2004 14:29:15 +0000 (14:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9079 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ControlChanges.C
src/frontends/controllers/ControlChanges.h
src/frontends/gtk/ChangeLog
src/frontends/gtk/Dialogs.C
src/frontends/gtk/GChanges.C [new file with mode: 0644]
src/frontends/gtk/GChanges.h [new file with mode: 0644]
src/frontends/gtk/Makefile.am
src/frontends/gtk/glade/changes.glade [new file with mode: 0644]

index d25a3fa025e3de0848249bae5c84af3e70801753..d2005a9638135f623d75a9542aebe82225c81686 100644 (file)
@@ -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
index f13398d0be6e3fd47edf003682f726b3da683058..cdd262207515579a09c57fb9952aa118160d1dd0 100644 (file)
@@ -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
index 46a03b456ede78415ea1ba6fed3fe632353c1466..b72dfadc431f11616e392a3455217332193a449a 100644 (file)
@@ -1,3 +1,10 @@
+2004-10-11  John Spray  <spray_john@users.sourceforge.net>
+
+       * 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  <spray_john@users.sourceforge.net>
 
        * The Log dialog
index ee877a93643689c138f26f606526c10711d48058..442795385a7d81394ec1cfe2470c99450a40e506 100644 (file)
@@ -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 (file)
index 0000000..7002d4a
--- /dev/null
@@ -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<ControlChanges, GViewGladeB>(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("<big><b>" + header +
+                               "</b></big>\n\nChanged by <b>" + author
+                               + "</b> on <b>" + date + "</b>");
+
+       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("<big><b>" + header +
+                               "</b></big>");
+
+       // 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 (file)
index 0000000..b39b983
--- /dev/null
@@ -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<ControlChanges, GViewGladeB> {
+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
index 456c586cf6b2b73b2c45a0b23409686fc3929c2b..3b0d85a9c8ef590e08a8b5bdcf94d288b796dafb 100644 (file)
@@ -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 (file)
index 0000000..686d325
--- /dev/null
@@ -0,0 +1,352 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkDialog" id="dialog">
+  <property name="border_width">6</property>
+  <property name="title" translatable="yes">dialog1</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">True</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="has_separator">False</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox1">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+       <widget class="GtkHButtonBox" id="dialog-action_area1">
+         <property name="visible">True</property>
+         <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+         <child>
+           <widget class="GtkButton" id="Close">
+             <property name="visible">True</property>
+             <property name="tooltip" translatable="yes">Abort merge</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-close</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <property name="response_id">-7</property>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="Next">
+             <property name="visible">True</property>
+             <property name="tooltip" translatable="yes">Ignore this change and proceed to the next</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <property name="response_id">0</property>
+
+             <child>
+               <widget class="GtkAlignment" id="alignment8">
+                 <property name="visible">True</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xscale">0</property>
+                 <property name="yscale">0</property>
+                 <property name="top_padding">0</property>
+                 <property name="bottom_padding">0</property>
+                 <property name="left_padding">0</property>
+                 <property name="right_padding">0</property>
+
+                 <child>
+                   <widget class="GtkHBox" id="hbox13">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">2</property>
+
+                     <child>
+                       <widget class="GtkImage" id="image10">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-go-forward</property>
+                         <property name="icon_size">4</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkLabel" id="label14">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">_Next</property>
+                         <property name="use_underline">True</property>
+                         <property name="use_markup">False</property>
+                         <property name="justify">GTK_JUSTIFY_LEFT</property>
+                         <property name="wrap">False</property>
+                         <property name="selectable">False</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="Reject">
+             <property name="visible">True</property>
+             <property name="tooltip" translatable="yes">Reject this change</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <property name="response_id">-6</property>
+
+             <child>
+               <widget class="GtkAlignment" id="alignment4">
+                 <property name="visible">True</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xscale">0</property>
+                 <property name="yscale">0</property>
+                 <property name="top_padding">0</property>
+                 <property name="bottom_padding">0</property>
+                 <property name="left_padding">0</property>
+                 <property name="right_padding">0</property>
+
+                 <child>
+                   <widget class="GtkHBox" id="hbox7">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">2</property>
+
+                     <child>
+                       <widget class="GtkImage" id="image4">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-no</property>
+                         <property name="icon_size">4</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkLabel" id="label8">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">_Reject</property>
+                         <property name="use_underline">True</property>
+                         <property name="use_markup">False</property>
+                         <property name="justify">GTK_JUSTIFY_LEFT</property>
+                         <property name="wrap">False</property>
+                         <property name="selectable">False</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="Accept">
+             <property name="visible">True</property>
+             <property name="tooltip" translatable="yes">Accept the change highlighted in the main window</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <property name="response_id">0</property>
+
+             <child>
+               <widget class="GtkAlignment" id="alignment5">
+                 <property name="visible">True</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xscale">0</property>
+                 <property name="yscale">0</property>
+                 <property name="top_padding">0</property>
+                 <property name="bottom_padding">0</property>
+                 <property name="left_padding">0</property>
+                 <property name="right_padding">0</property>
+
+                 <child>
+                   <widget class="GtkHBox" id="hbox10">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">2</property>
+
+                     <child>
+                       <widget class="GtkImage" id="image7">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-yes</property>
+                         <property name="icon_size">4</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkLabel" id="label11">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">_Accept</property>
+                         <property name="use_underline">True</property>
+                         <property name="use_markup">False</property>
+                         <property name="justify">GTK_JUSTIFY_LEFT</property>
+                         <property name="wrap">False</property>
+                         <property name="selectable">False</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">True</property>
+         <property name="pack_type">GTK_PACK_END</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkHBox" id="hbox9">
+         <property name="visible">True</property>
+         <property name="homogeneous">False</property>
+         <property name="spacing">0</property>
+
+         <child>
+           <widget class="GtkImage" id="image6">
+             <property name="visible">True</property>
+             <property name="stock">gtk-dialog-question</property>
+             <property name="icon_size">6</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">6</property>
+             <property name="ypad">0</property>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">True</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkVBox" id="vbox1">
+             <property name="visible">True</property>
+             <property name="homogeneous">False</property>
+             <property name="spacing">0</property>
+
+             <child>
+               <widget class="GtkVBox" id="vbox2">
+                 <property name="visible">True</property>
+                 <property name="homogeneous">False</property>
+                 <property name="spacing">0</property>
+
+                 <child>
+                   <widget class="GtkLabel" id="Message">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">&lt;b&gt;&lt;big&gt;Accept highlighted change?&lt;/big&gt;&lt;/b&gt;
+
+Changed by &lt;b&gt;A Person&lt;/b&gt; on &lt;b&gt;4th July&lt;/b&gt;</property>
+                     <property name="use_underline">False</property>
+                     <property name="use_markup">True</property>
+                     <property name="justify">GTK_JUSTIFY_LEFT</property>
+                     <property name="wrap">False</property>
+                     <property name="selectable">False</property>
+                     <property name="xalign">0</property>
+                     <property name="yalign">0.5</property>
+                     <property name="xpad">0</property>
+                     <property name="ypad">0</property>
+                   </widget>
+                   <packing>
+                     <property name="padding">4</property>
+                     <property name="expand">False</property>
+                     <property name="fill">False</property>
+                   </packing>
+                 </child>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">True</property>
+                 <property name="fill">True</property>
+               </packing>
+             </child>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">True</property>
+             <property name="fill">True</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
+</glade-interface>