From 9b3cfb9363269060555776466a14a71a2dfaa9e7 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sun, 21 Nov 2004 13:14:39 +0000 Subject: [PATCH] gtk sendto dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9283 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 5 + src/frontends/gtk/Dialogs.C | 5 +- src/frontends/gtk/GSendto.C | 112 ++++++++++++++ src/frontends/gtk/GSendto.h | 51 +++++++ src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/glade/sendto.glade | 210 +++++++++++++++++++++++++++ 6 files changed, 383 insertions(+), 3 deletions(-) create mode 100644 src/frontends/gtk/GSendto.C create mode 100644 src/frontends/gtk/GSendto.h create mode 100644 src/frontends/gtk/glade/sendto.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 9a60027874..41b4c53d88 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,8 @@ +2004-11-21 John Spray + + * The Sendto Dialog: + Dialogs.C, Makefile.am, GSendto.C, GSendto.h + 2004-11-17 Lars Gullik Bjonnes * Disable concept checks with the use of ugly preprocessor stuff diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 97e96af536..ffc926049f 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -84,7 +84,7 @@ #include "GPrint.h" #include "FormRef.h" #include "GSearch.h" -#include "FormSendto.h" +#include "GSendto.h" #include "FormTabular.h" #include "GTexinfo.h" #include "GShowFile.h" @@ -489,8 +489,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new FormRef(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "sendto") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlSendto(*dialog)); - dialog->setView(new FormSendto(*dialog)); + dialog->setView(new GSendto(*dialog)); dialog->bc().bp(new OkApplyCancelPolicy); } else if (name == "spellchecker") { dialog->bc().view(new GBC(dialog->bc())); diff --git a/src/frontends/gtk/GSendto.C b/src/frontends/gtk/GSendto.C new file mode 100644 index 0000000000..d686f5b25a --- /dev/null +++ b/src/frontends/gtk/GSendto.C @@ -0,0 +1,112 @@ +/** + * \file GSendto.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 + +#include "GSendto.h" +#include "ControlSendto.h" +#include "ghelpers.h" + +#include "format.h" + +#include + +using std::string; +using std::vector; + +namespace lyx { +namespace frontend { + +GSendto::GSendto(Dialog & parent) + : GViewCB(parent, _("Send document to command"), false) +{} + + +void GSendto::doBuild() +{ + string const gladeName = findGladeFile("sendto"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * button; + xml_->get_widget("Close", button); + setCancel(button); + xml_->get_widget("Execute", button); + setOK(button); + + xml_->get_widget("Format", formatview_); + xml_->get_widget("Command", commandentry_); + + cols_.add(stringcol_); + cols_.add(indexcol_); + + formatstore_ = Gtk::ListStore::create(cols_); + formatview_->set_model(formatstore_); + formatview_->append_column("Format", stringcol_); + formatview_->get_selection()->set_mode(Gtk::SELECTION_BROWSE); + + commandentry_->signal_changed().connect( + sigc::mem_fun(*this, &GSendto::onCommandEntryChanged)); +} + + +void GSendto::onCommandEntryChanged() +{ + bc().valid(!commandentry_->get_text().empty()); +} + + +void GSendto::update() +{ + vector new_formats; + new_formats = controller().allFormats(); + + if (new_formats == all_formats_) + return; + + all_formats_ = new_formats; + + vector keys; + keys.resize(all_formats_.size()); + + vector::iterator result = keys.begin(); + vector::const_iterator it = all_formats_.begin(); + vector::const_iterator end = all_formats_.end(); + for (; it != end; ++it, ++result) { + *result = (*it)->prettyname(); + } + + formatstore_->clear(); + + vector::const_iterator keyend = keys.end(); + vector::const_iterator keyit = keys.begin(); + for (int rowindex = 0; + keyit < keyend; ++keyit, ++rowindex) { + Gtk::TreeModel::iterator row = formatstore_->append(); + (*row)[stringcol_] = *keyit; + (*row)[indexcol_] = rowindex; + } + + commandentry_->set_text(controller().getCommand()); +} + + +void GSendto::apply() +{ + int const line = + (*formatview_->get_selection()->get_selected())[indexcol_]; + + string const cmd = commandentry_->get_text(); + + controller().setFormat(all_formats_[line]); + controller().setCommand(cmd); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GSendto.h b/src/frontends/gtk/GSendto.h new file mode 100644 index 0000000000..73ed42fa6c --- /dev/null +++ b/src/frontends/gtk/GSendto.h @@ -0,0 +1,51 @@ +// -*- C++ -*- +/** + * \file GSendto.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 GSENDTO_H +#define GSENDTO_H + +#include "GViewBase.h" +#include + +class Format; + +namespace lyx { +namespace frontend { + +class ControlSendto; + +/** This class provides a GTK+ implementation of the Sendto Dialog. + */ +class GSendto : public GViewCB { +public: + GSendto(Dialog & parent); +private: + virtual void apply(); + virtual void doBuild(); + virtual void update(); + + Gtk::TreeModelColumn stringcol_; + Gtk::TreeModelColumn indexcol_; + Gtk::TreeModel::ColumnRecord cols_; + Glib::RefPtr formatstore_; + + Gtk::TreeView * formatview_; + Gtk::Entry * commandentry_; + + std::vector all_formats_; + + void onCommandEntryChanged(); +}; + +} // namespace frontend +} // namespace lyx + +#endif // GSENDTO_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index a234212839..24b16e7478 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -64,6 +64,8 @@ libgtk_la_SOURCES = \ GScreen.h \ GSearch.C \ GSearch.h \ + GSendto.C \ + GSendto.h \ GShowFile.C \ GShowFile.h \ GSpellchecker.C \ @@ -133,7 +135,6 @@ xforms_objects = \ ../xforms/FormPreamble.lo \ ../xforms/FormPreferences.lo \ ../xforms/FormRef.lo \ - ../xforms/FormSendto.lo \ ../xforms/forms_gettext.lo \ ../xforms/FormTabular.lo \ ../xforms/FormText.lo \ diff --git a/src/frontends/gtk/glade/sendto.glade b/src/frontends/gtk/glade/sendto.glade new file mode 100644 index 0000000000..81aab19d1a --- /dev/null +++ b/src/frontends/gtk/glade/sendto.glade @@ -0,0 +1,210 @@ + + + + + + + True + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 200 + 350 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + + + True + True + True + True + gtk-execute + True + GTK_RELIEF_NORMAL + True + -10 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 12 + True + False + 0 + + + + True + <b>E_xport Format</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + Format + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 14 + 12 + 0 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + Export the buffer to this format before running the command below on it. + True + True + False + False + False + True + + + + + + + 0 + True + True + + + + + + True + <b>_Command</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + Command + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 7 + 0 + 12 + 0 + + + + True + Run this command on the buffer exported to the chosen format. $$FName will be replaced by the name of this file. + True + True + True + True + True + 0 + + True + * + True + + + + + 0 + False + True + + + + + 0 + True + True + + + + + + + -- 2.39.2