]> git.lyx.org Git - features.git/commitdiff
gtk sendto dialog
authorJohn Spray <spray@lyx.org>
Sun, 21 Nov 2004 13:14:39 +0000 (13:14 +0000)
committerJohn Spray <spray@lyx.org>
Sun, 21 Nov 2004 13:14:39 +0000 (13:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9283 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/gtk/ChangeLog
src/frontends/gtk/Dialogs.C
src/frontends/gtk/GSendto.C [new file with mode: 0644]
src/frontends/gtk/GSendto.h [new file with mode: 0644]
src/frontends/gtk/Makefile.am
src/frontends/gtk/glade/sendto.glade [new file with mode: 0644]

index 9a60027874608006ec8243b0875dbdac4b5abd1f..41b4c53d883d931bb2f081a5543042ef6812ff3c 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-21  John Spray  <spray_john@users.sourceforge.net>
+       
+       * The Sendto Dialog:
+         Dialogs.C, Makefile.am, GSendto.C, GSendto.h
+
 2004-11-17  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * Disable concept checks with the use of ugly preprocessor stuff
index 97e96af5368c8cdc436d7faaa82b3ba1087dbc8e..ffc926049ffc6fea2b76ebedd0439d23526b57e8 100644 (file)
@@ -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 (file)
index 0000000..d686f5b
--- /dev/null
@@ -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 <config.h>
+
+#include "GSendto.h"
+#include "ControlSendto.h"
+#include "ghelpers.h"
+
+#include "format.h"
+
+#include <libglademm.h>
+
+using std::string;
+using std::vector;
+
+namespace lyx {
+namespace frontend {
+
+GSendto::GSendto(Dialog & parent)
+       : GViewCB<ControlSendto, GViewGladeB>(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<Format const *> new_formats;
+       new_formats = controller().allFormats();
+
+       if (new_formats == all_formats_)
+               return;
+
+       all_formats_ = new_formats;
+
+       vector<string> keys;
+       keys.resize(all_formats_.size());
+
+       vector<string>::iterator result = keys.begin();
+       vector<Format const *>::const_iterator it  = all_formats_.begin();
+       vector<Format const *>::const_iterator end = all_formats_.end();
+       for (; it != end; ++it, ++result) {
+               *result = (*it)->prettyname();
+       }
+
+       formatstore_->clear();
+
+       vector<string>::const_iterator keyend = keys.end();
+       vector<string>::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 (file)
index 0000000..73ed42f
--- /dev/null
@@ -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 <vector>
+
+class Format;
+
+namespace lyx {
+namespace frontend {
+
+class ControlSendto;
+
+/** This class provides a GTK+ implementation of the Sendto Dialog.
+ */
+class GSendto : public GViewCB<ControlSendto, GViewGladeB> {
+public:
+       GSendto(Dialog & parent);
+private:
+       virtual void apply();
+       virtual void doBuild();
+       virtual void update();
+
+       Gtk::TreeModelColumn<Glib::ustring> stringcol_;
+       Gtk::TreeModelColumn<unsigned int> indexcol_;
+       Gtk::TreeModel::ColumnRecord cols_;
+       Glib::RefPtr<Gtk::ListStore> formatstore_;
+
+       Gtk::TreeView * formatview_;
+       Gtk::Entry * commandentry_;
+
+       std::vector<Format const *> all_formats_;
+
+       void onCommandEntryChanged();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // GSENDTO_H
index a2342128398b2a137dc76133fa99d385be448fbd..24b16e74789dab2909602d0eaa9736041611051f 100644 (file)
@@ -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 (file)
index 0000000..81aab19
--- /dev/null
@@ -0,0 +1,210 @@
+<?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="visible">True</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">False</property>
+  <property name="default_width">200</property>
+  <property name="default_height">350</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="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>
+             <accelerator key="Escape" modifiers="0" signal="clicked"/>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="Execute">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="has_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-execute</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">-10</property>
+           </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="GtkVBox" id="vbox1">
+         <property name="border_width">12</property>
+         <property name="visible">True</property>
+         <property name="homogeneous">False</property>
+         <property name="spacing">0</property>
+
+         <child>
+           <widget class="GtkLabel" id="label1">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">&lt;b&gt;E_xport Format&lt;/b&gt;</property>
+             <property name="use_underline">True</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>
+             <property name="mnemonic_widget">Format</property>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkAlignment" id="alignment2">
+             <property name="visible">True</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xscale">1</property>
+             <property name="yscale">1</property>
+             <property name="top_padding">6</property>
+             <property name="bottom_padding">14</property>
+             <property name="left_padding">12</property>
+             <property name="right_padding">0</property>
+
+             <child>
+               <widget class="GtkScrolledWindow" id="scrolledwindow1">
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                 <property name="shadow_type">GTK_SHADOW_IN</property>
+                 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+                 <child>
+                   <widget class="GtkTreeView" id="Format">
+                     <property name="visible">True</property>
+                     <property name="tooltip" translatable="yes">Export the buffer to this format before running the command below on it.</property>
+                     <property name="can_focus">True</property>
+                     <property name="has_focus">True</property>
+                     <property name="headers_visible">False</property>
+                     <property name="rules_hint">False</property>
+                     <property name="reorderable">False</property>
+                     <property name="enable_search">True</property>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">True</property>
+             <property name="fill">True</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="label2">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">&lt;b&gt;_Command&lt;/b&gt;</property>
+             <property name="use_underline">True</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>
+             <property name="mnemonic_widget">Command</property>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkAlignment" id="alignment1">
+             <property name="visible">True</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xscale">1</property>
+             <property name="yscale">1</property>
+             <property name="top_padding">7</property>
+             <property name="bottom_padding">0</property>
+             <property name="left_padding">12</property>
+             <property name="right_padding">0</property>
+
+             <child>
+               <widget class="GtkEntry" id="Command">
+                 <property name="visible">True</property>
+                 <property name="tooltip" translatable="yes">Run this command on the buffer exported to the chosen format. $$FName will be replaced by the name of this file.</property>
+                 <property name="can_default">True</property>
+                 <property name="has_default">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="editable">True</property>
+                 <property name="visibility">True</property>
+                 <property name="max_length">0</property>
+                 <property name="text" translatable="yes"></property>
+                 <property name="has_frame">True</property>
+                 <property name="invisible_char" translatable="yes">*</property>
+                 <property name="activates_default">True</property>
+               </widget>
+             </child>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</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>