gtk sendto dialog

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9283 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Spray 2004-11-21 13:14:39 +00:00
parent 82d82f7a11
commit 9b3cfb9363
6 changed files with 383 additions and 3 deletions

View 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

View 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()));

112
src/frontends/gtk/GSendto.C Normal file
View File

@ -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

View File

@ -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

View 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 \

View File

@ -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>