2002-03-07 15:06:57 +00:00
|
|
|
/*
|
|
|
|
* \file FormSendto.C
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
2002-03-11 17:00:41 +00:00
|
|
|
* \author Angus Leeming, a.leeming@ic.ac.uk
|
2002-03-07 15:06:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "FormSendto.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
#include "forms/form_sendto.h"
|
2002-03-07 15:06:57 +00:00
|
|
|
#include "ControlSendto.h"
|
|
|
|
#include "xformsBC.h"
|
2002-03-11 09:54:42 +00:00
|
|
|
#include "Tooltips.h"
|
2002-03-07 15:06:57 +00:00
|
|
|
#include "xforms_helpers.h"
|
|
|
|
#include "converter.h"
|
|
|
|
#include "gettext.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
#include FORMS_H_LOCATION
|
2002-03-07 15:06:57 +00:00
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
typedef FormCB<ControlSendto, FormDB<FD_sendto> > base_class;
|
2002-03-07 15:06:57 +00:00
|
|
|
|
2002-07-02 19:23:10 +00:00
|
|
|
FormSendto::FormSendto(ControlSendto & c, Dialogs & d)
|
|
|
|
: base_class(c, d, _("Send document to command"))
|
2002-03-07 15:06:57 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void FormSendto::build()
|
|
|
|
{
|
2002-06-13 13:43:51 +00:00
|
|
|
dialog_.reset(build_sendto(this));
|
2002-03-07 15:06:57 +00:00
|
|
|
|
|
|
|
fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
|
2002-03-11 18:24:31 +00:00
|
|
|
setPrehandler(dialog_->input_command);
|
2002-03-07 15:06:57 +00:00
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
2002-03-07 15:06:57 +00:00
|
|
|
bc().setOK(dialog_->button_ok);
|
|
|
|
bc().setApply(dialog_->button_apply);
|
2002-03-12 14:11:15 +00:00
|
|
|
bc().setCancel(dialog_->button_close);
|
2002-03-11 09:54:42 +00:00
|
|
|
|
|
|
|
// Set up the tooltip mechanism
|
2002-04-02 17:04:23 +00:00
|
|
|
string str = _("Export the buffer to this format before running the command below on it.");
|
2002-03-18 15:56:00 +00:00
|
|
|
tooltips().init(dialog_->browser_formats, str);
|
2002-03-11 09:54:42 +00:00
|
|
|
|
2002-04-02 17:04:23 +00:00
|
|
|
str = _("Run this command on the buffer exported to the chosen format. $$FName will be replaced by the name of this file.");
|
2002-03-18 15:56:00 +00:00
|
|
|
tooltips().init(dialog_->input_command, str);
|
2002-03-07 15:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormSendto::update()
|
|
|
|
{
|
|
|
|
all_formats_ = controller().allFormats();
|
|
|
|
|
|
|
|
// Check whether the current contents of the browser will be
|
|
|
|
// changed by loading the contents of 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();
|
|
|
|
}
|
2002-03-11 09:54:42 +00:00
|
|
|
|
2002-03-07 15:06:57 +00:00
|
|
|
vector<string> const browser_keys =
|
2002-07-21 15:51:07 +00:00
|
|
|
getVector(dialog_->browser_formats);
|
2002-03-07 15:06:57 +00:00
|
|
|
|
|
|
|
if (browser_keys == keys)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Reload the browser
|
|
|
|
fl_clear_browser(dialog_->browser_formats);
|
|
|
|
|
|
|
|
for (vector<string>::const_iterator it = keys.begin();
|
|
|
|
it < keys.end(); ++it) {
|
|
|
|
fl_add_browser_line(dialog_->browser_formats, it->c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
fl_set_input(dialog_->input_command, controller().getCommand().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-11 09:54:42 +00:00
|
|
|
ButtonPolicy::SMInput FormSendto::input(FL_OBJECT *, long)
|
2002-03-07 15:06:57 +00:00
|
|
|
{
|
|
|
|
int const line = fl_get_browser(dialog_->browser_formats);
|
|
|
|
if (line < 1 || line > fl_get_browser_maxline(dialog_->browser_formats))
|
|
|
|
return ButtonPolicy::SMI_INVALID;
|
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
string cmd = getString(dialog_->input_command);
|
2002-03-07 15:06:57 +00:00
|
|
|
cmd = strip(frontStrip(cmd));
|
|
|
|
if (cmd.empty())
|
|
|
|
return ButtonPolicy::SMI_INVALID;
|
|
|
|
|
|
|
|
return ButtonPolicy::SMI_VALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormSendto::apply()
|
|
|
|
{
|
|
|
|
int const line = fl_get_browser(dialog_->browser_formats);
|
|
|
|
if (line < 1 || line > fl_get_browser_maxline(dialog_->browser_formats))
|
|
|
|
return;
|
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
string const cmd = getString(dialog_->input_command);
|
2002-03-07 15:06:57 +00:00
|
|
|
|
|
|
|
controller().setFormat(all_formats_[line-1]);
|
|
|
|
controller().setCommand(cmd);
|
|
|
|
}
|