2002-03-11 17:00:41 +00:00
|
|
|
/**
|
2001-03-30 09:51:46 +00:00
|
|
|
* \file FormExternal.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-11 17:00:41 +00:00
|
|
|
*
|
2001-03-30 09:51:46 +00:00
|
|
|
* \author Asger Alstrup
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author John Levon
|
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-12 12:47:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
#include "xformsBC.h"
|
|
|
|
#include "ControlExternal.h"
|
2001-03-12 12:47:07 +00:00
|
|
|
#include "FormExternal.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
#include "forms/form_external.h"
|
2001-03-30 09:51:46 +00:00
|
|
|
#include "gettext.h"
|
|
|
|
#include "xforms_helpers.h"
|
|
|
|
#include "helper_funcs.h"
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2002-04-15 12:05:07 +00:00
|
|
|
#include "support/lstrings.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
#include FORMS_H_LOCATION
|
2002-04-15 12:05:07 +00:00
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
typedef FormCB<ControlExternal, FormDB<FD_external> > base_class;
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
FormExternal::FormExternal()
|
|
|
|
: base_class(_("Edit external file"))
|
2001-03-30 09:51:46 +00:00
|
|
|
{}
|
2001-03-12 12:47:07 +00:00
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
void FormExternal::apply()
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
2001-03-30 09:51:46 +00:00
|
|
|
controller().params().filename =
|
|
|
|
fl_get_input(dialog_->input_filename);
|
|
|
|
controller().params().parameters =
|
|
|
|
fl_get_input(dialog_->input_parameters);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
int const choice = fl_get_choice(dialog_->choice_template);
|
|
|
|
controller().params().templ = controller().getTemplate(choice);
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
void FormExternal::build()
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
2002-06-13 13:43:51 +00:00
|
|
|
dialog_.reset(build_external(this));
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
string const choice =
|
2002-03-21 16:59:12 +00:00
|
|
|
" " + getStringFromVector(controller().getTemplates(), " | ") + " ";
|
2001-03-30 09:51:46 +00:00
|
|
|
fl_addto_choice(dialog_->choice_template, choice.c_str());
|
2002-03-11 18:24:31 +00:00
|
|
|
|
|
|
|
fl_set_input_return (dialog_->input_filename, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (dialog_->input_parameters, FL_RETURN_CHANGED);
|
|
|
|
|
|
|
|
setPrehandler(dialog_->input_filename);
|
|
|
|
setPrehandler(dialog_->input_parameters);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
bc().setOK(dialog_->button_ok);
|
2001-03-30 13:47:39 +00:00
|
|
|
bc().setApply(dialog_->button_apply);
|
2002-03-12 14:11:15 +00:00
|
|
|
bc().setCancel(dialog_->button_close);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
bc().addReadOnly(dialog_->input_filename);
|
|
|
|
bc().addReadOnly(dialog_->button_filenamebrowse);
|
|
|
|
bc().addReadOnly(dialog_->input_parameters);
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
void FormExternal::update()
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
2001-03-30 09:51:46 +00:00
|
|
|
InsetExternal::Params const & params = controller().params();
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
fl_set_input(dialog_->input_filename, params.filename.c_str());
|
|
|
|
fl_set_input(dialog_->input_parameters, params.parameters.c_str());
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
int const ID = controller().getTemplateNumber(params.templ.lyxName);
|
|
|
|
if (ID >= 0) {
|
|
|
|
setEnabled(dialog_->choice_template, true);
|
|
|
|
fl_set_choice(dialog_->choice_template, ID+1);
|
|
|
|
} else
|
|
|
|
setEnabled(dialog_->choice_template, false);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
updateComboChange();
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
ButtonPolicy::SMInput FormExternal::input(FL_OBJECT * ob, long)
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
2001-03-30 09:51:46 +00:00
|
|
|
if (ob == dialog_->choice_template) {
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
// set to the chosen template
|
|
|
|
int const choice = fl_get_choice(dialog_->choice_template);
|
|
|
|
controller().params().templ = controller().getTemplate(choice);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
updateComboChange();
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
} else if (ob == dialog_->button_filenamebrowse) {
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
string const in_name = fl_get_input(dialog_->input_filename);
|
|
|
|
string const out_name = controller().Browse(in_name);
|
|
|
|
fl_set_input(dialog_->input_filename, out_name.c_str());
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
} else if (ob == dialog_->button_edit) {
|
|
|
|
controller().editExternal();
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
} else if (ob == dialog_->button_view) {
|
|
|
|
controller().viewExternal();
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
} else if (ob == dialog_->button_update) {
|
|
|
|
controller().updateExternal();
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
return ButtonPolicy::SMI_VALID;
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormExternal::updateComboChange()
|
|
|
|
{
|
|
|
|
// Update the help text
|
|
|
|
fl_clear_browser(dialog_->browser_helptext);
|
2001-03-30 09:51:46 +00:00
|
|
|
fl_addto_browser(dialog_->browser_helptext,
|
|
|
|
controller().params().templ.helpText.c_str());
|
2001-03-12 12:47:07 +00:00
|
|
|
fl_set_browser_topline(dialog_->browser_helptext, 0);
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
bool const enabled = (!controller().params().templ.automaticProduction);
|
|
|
|
setEnabled(dialog_->button_update, enabled);
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|