From 9ee46b846e5e84ad40ceda4f4af94aeb86cd90a2 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sat, 21 Jan 2006 20:06:38 +0000 Subject: [PATCH] Add GTK bibitem dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10761 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 5 + src/frontends/gtk/Dialogs.C | 6 +- src/frontends/gtk/GBibItem.C | 85 ++++++++++++ src/frontends/gtk/GBibItem.h | 40 ++++++ src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/glade/Makefile.am | 1 + src/frontends/gtk/glade/bibitem.glade | 190 ++++++++++++++++++++++++++ 7 files changed, 326 insertions(+), 4 deletions(-) create mode 100644 src/frontends/gtk/GBibItem.C create mode 100644 src/frontends/gtk/GBibItem.h create mode 100644 src/frontends/gtk/glade/bibitem.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index c7eb0884e8..5a5ecf9f86 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,8 @@ +2006-01-21 John Spray + + * GBibItem.[Ch], glade/bibitem.glade: Add the bibitem dialog + * Dialogs.C, Makefile.am, glade/Makefile.am: Use GBibItem + 2006-01-20 Bernhard Reiter * GCitation.[Ch], glade/citation.glade: Add the citation dialog diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 206f97be85..20c31d7fbd 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -60,7 +60,7 @@ #include "GAboutlyx.h" #include "GText.h" #include "GMathDelim.h" -#include "FormBibitem.h" +#include "GBibItem.h" #include "FormBibtex.h" #include "GBox.h" #include "FormBranch.h" @@ -189,9 +189,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GAboutlyx(*dialog)); dialog->bc().bp(new OkCancelPolicy); } else if (name == "bibitem") { - dialog->bc().view(new xformsBC(dialog->bc())); + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlCommand(*dialog, name)); - dialog->setView(new FormBibitem(*dialog)); + dialog->setView(new GBibItem(*dialog)); dialog->bc().bp(new OkCancelReadOnlyPolicy); } else if (name == "bibtex") { dialog->bc().view(new xformsBC(dialog->bc())); diff --git a/src/frontends/gtk/GBibItem.C b/src/frontends/gtk/GBibItem.C new file mode 100644 index 0000000000..3e6bd32965 --- /dev/null +++ b/src/frontends/gtk/GBibItem.C @@ -0,0 +1,85 @@ +/** + * \file GBibItem.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 + +// Too hard to make concept checks work with this file +#ifdef _GLIBCXX_CONCEPT_CHECKS +#undef _GLIBCXX_CONCEPT_CHECKS +#endif +#ifdef _GLIBCPP_CONCEPT_CHECKS +#undef _GLIBCPP_CONCEPT_CHECKS +#endif + +#include "GBibItem.h" +#include "ControlCommand.h" +#include "ghelpers.h" + +#include + +using std::string; + +namespace lyx { +namespace frontend { + +GBibItem::GBibItem(Dialog & parent) + : GViewCB(parent, _("Bibliography Entry Settings"), false) +{} + + +void GBibItem::doBuild() +{ + string const gladeName = findGladeFile("bibitem"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * button; + xml_->get_widget("Cancel", button); + setCancel(button); + xml_->get_widget("OK", button); + setOK(button); + + xml_->get_widget("Key", keyentry_); + xml_->get_widget("Label", labelentry_); + + keyentry_->signal_changed().connect( + sigc::mem_fun(*this, &GBibItem::changed)); + labelentry_->signal_changed().connect( + sigc::mem_fun(*this, &GBibItem::changed)); + + bcview().addReadOnly(keyentry_); + bcview().addReadOnly(labelentry_); +} + + +void GBibItem::update() +{ + bc().refreshReadOnly(); + + keyentry_->set_text (controller().params().getContents()); + labelentry_->set_text (controller().params().getOptions()); +} + + +void GBibItem::apply() +{ + controller().params().setContents(keyentry_->get_text()); + controller().params().setOptions(labelentry_->get_text()); +} + +void GBibItem::changed() +{ + if (keyentry_->get_text().size() > 0) + bc().valid(TRUE); + else + bc().valid(FALSE); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GBibItem.h b/src/frontends/gtk/GBibItem.h new file mode 100644 index 0000000000..e935424b4b --- /dev/null +++ b/src/frontends/gtk/GBibItem.h @@ -0,0 +1,40 @@ +// -*- C++ -*- +/** + * \file GBibItem.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 GBIBITEM_H +#define GBIBITEM_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlCommand; + +/** This class provides a GTK+ implementation of the BibItem Dialog. + */ +class GBibItem : public GViewCB { +public: + GBibItem(Dialog & parent); +private: + virtual void apply(); + virtual void doBuild(); + virtual void update(); + void changed(); + + Gtk::Entry * keyentry_; + Gtk::Entry * labelentry_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GBIBITEM_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 61acd4ebda..28b540ba79 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -31,6 +31,8 @@ libgtk_la_SOURCES = \ GAboutlyx.h \ GBC.C \ GBC.h \ + GBibItem.C \ + GBibItem.h \ GBox.C \ GBox.h \ GChanges.C \ @@ -135,7 +137,6 @@ xforms_objects = \ ../xforms/Color.lo \ ../xforms/combox.lo \ ../xforms/fdesign_base.lo \ - ../xforms/FormBibitem.lo \ ../xforms/FormBibtex.lo \ ../xforms/FormBranch.lo \ ../xforms/FormBrowser.lo \ diff --git a/src/frontends/gtk/glade/Makefile.am b/src/frontends/gtk/glade/Makefile.am index d5f29c8b23..7ed621a292 100644 --- a/src/frontends/gtk/glade/Makefile.am +++ b/src/frontends/gtk/glade/Makefile.am @@ -6,6 +6,7 @@ gladedir = $(pkgdatadir)/glade dist_glade_DATA = \ aboutlyx.glade \ box.glade \ + bibitem.glade \ changes.glade \ character.glade \ citation.glade \ diff --git a/src/frontends/gtk/glade/bibitem.glade b/src/frontends/gtk/glade/bibitem.glade new file mode 100644 index 0000000000..42a90ed344 --- /dev/null +++ b/src/frontends/gtk/glade/bibitem.glade @@ -0,0 +1,190 @@ + + + + + + + True + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 12 + True + 2 + 2 + False + 6 + 6 + + + + True + _Key: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + Key + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + True + True + True + 0 + + True + * + True + + + 1 + 2 + 0 + 1 + + + + + + + True + True + True + True + 0 + + True + * + True + + + 1 + 2 + 1 + 2 + + + + + + + True + _Label: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + Label + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + 0 + True + True + + + + + + + -- 2.39.2