2001-03-30 09:51:46 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2000-2001 The LyX Team.
|
2001-03-12 12:47:07 +00:00
|
|
|
*
|
2001-03-30 09:51:46 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file FormExternal.C
|
|
|
|
* \author Asger Alstrup
|
2001-03-12 12:47:07 +00:00
|
|
|
* \author John Levon
|
2001-03-30 09:51:46 +00:00
|
|
|
* \author Angus Leeming, a.leeming@ic.ac.uk
|
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"
|
2001-03-15 13:37:04 +00:00
|
|
|
#include "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
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
typedef FormCB<ControlExternal, FormDB<FD_form_external> > base_class;
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
FormExternal::FormExternal(ControlExternal & c)
|
|
|
|
: base_class(c, _("Edit external file"))
|
|
|
|
{}
|
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
|
|
|
{
|
2001-03-30 09:51:46 +00:00
|
|
|
dialog_.reset(build_external());
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
string const choice =
|
|
|
|
" " + getStringFromVector(controller().getTemplates(), " | ") + " ";
|
|
|
|
fl_addto_choice(dialog_->choice_template, choice.c_str());
|
2002-01-19 17:05:24 +00:00
|
|
|
fl_set_input_return (dialog_->input_filename, FL_RETURN_CHANGED);
|
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);
|
2001-03-30 09:51:46 +00:00
|
|
|
bc().setCancel(dialog_->button_cancel);
|
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
|
|
|
}
|