mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Forgotten files again + autosave-file fixes and small other fixes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@961 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bfabea1a25
commit
67191fe11f
15
ChangeLog
15
ChangeLog
@ -1,5 +1,20 @@
|
||||
2000-08-08 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* src/lyx_cb.C (AutoSave): autosave for unnamed files enabled!
|
||||
|
||||
* src/bufferlist.C (close):
|
||||
* src/bufferlist.C (QwriteAll): remove Autosave-files for Unnamed()
|
||||
documents if exiting without saving.
|
||||
|
||||
* src/buffer.C (save): use removeAutosaveFile()
|
||||
|
||||
* src/support/filetools.C (removeAutosaveFile): new function.
|
||||
|
||||
* src/lyx_cb.C (MenuWrite): returns a bool now.
|
||||
(MenuWriteAs): check if file could really be saved and revert to the
|
||||
old name if not.
|
||||
(MenuWriteAs): removing old autosavefile if existant.
|
||||
|
||||
* src/frontends/xforms/FormRef.h: puting FD_form_ref declaration
|
||||
before Goto toggle declaration, because of compiler warning.
|
||||
|
||||
|
14
src/buffer.C
14
src/buffer.C
@ -1203,19 +1203,7 @@ bool Buffer::save() const
|
||||
|
||||
if (writeFile(fileName(), false)) {
|
||||
markLyxClean();
|
||||
|
||||
// now delete the autosavefile
|
||||
string a = OnlyPath(fileName());
|
||||
a += '#';
|
||||
a += OnlyFilename(fileName());
|
||||
a += '#';
|
||||
FileInfo fileinfo(a);
|
||||
if (fileinfo.exist()) {
|
||||
if (::remove(a.c_str()) != 0) {
|
||||
WriteFSAlert(_("Could not delete "
|
||||
"auto-save file!"), a);
|
||||
}
|
||||
}
|
||||
removeAutosaveFile(fileName());
|
||||
} else {
|
||||
// Saving failed, so backup is not backup
|
||||
if (lyxrc.make_backup) {
|
||||
|
@ -88,7 +88,7 @@ bool BufferList::empty() const
|
||||
}
|
||||
|
||||
|
||||
extern void MenuWrite(Buffer *);
|
||||
extern bool MenuWrite(Buffer *);
|
||||
extern bool MenuWriteAs(Buffer *);
|
||||
|
||||
bool BufferList::QwriteAll()
|
||||
@ -112,11 +112,16 @@ bool BufferList::QwriteAll()
|
||||
if ((*it)->isUnnamed())
|
||||
reask = !MenuWriteAs((*it));
|
||||
else {
|
||||
MenuWrite((*it));
|
||||
reask = false;
|
||||
reask = !MenuWrite((*it));
|
||||
}
|
||||
break;
|
||||
case 2: // No
|
||||
// if we crash after this we could
|
||||
// have no autosave file but I guess
|
||||
// this is really inprobable (Jug)
|
||||
if ((*it)->isUnnamed()) {
|
||||
removeAutosaveFile((*it)->fileName());
|
||||
}
|
||||
askMoreConfirmation = true;
|
||||
unsaved += MakeDisplayPath(fname, 50);
|
||||
unsaved += "\n";
|
||||
@ -194,6 +199,9 @@ bool BufferList::close(Buffer * buf)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (buf->isUnnamed()) {
|
||||
removeAutosaveFile(buf->fileName());
|
||||
}
|
||||
reask = false;
|
||||
break;
|
||||
case 3: // Cancel
|
||||
|
389
src/frontends/xforms/FormRef.C
Normal file
389
src/frontends/xforms/FormRef.C
Normal file
@ -0,0 +1,389 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000 The LyX Team.
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
|
||||
#include "gettext.h"
|
||||
#include "Dialogs.h"
|
||||
#include "FormRef.h"
|
||||
#include "LyXView.h"
|
||||
#include "buffer.h"
|
||||
#include "form_ref.h"
|
||||
#include "lyxfunc.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using std::sort;
|
||||
using std::vector;
|
||||
|
||||
static int formw;
|
||||
static int formh;
|
||||
|
||||
FormRef::FormRef(LyXView * lv, Dialogs * d)
|
||||
: FormCommand(lv, d, _("Reference")), dialog_(0),
|
||||
toggle(GOBACK)
|
||||
{
|
||||
// let the dialog be shown
|
||||
// These are permanent connections so we won't bother
|
||||
// storing a copy because we won't be disconnecting.
|
||||
d->showRef.connect(slot(this, &FormRef::showInset));
|
||||
d->createRef.connect(slot(this, &FormRef::createInset));
|
||||
}
|
||||
|
||||
|
||||
FormRef::~FormRef()
|
||||
{
|
||||
free();
|
||||
delete dialog_;
|
||||
}
|
||||
|
||||
|
||||
void FormRef::clearStore()
|
||||
{
|
||||
refs.clear();
|
||||
}
|
||||
|
||||
|
||||
void FormRef::build()
|
||||
{
|
||||
dialog_ = build_ref();
|
||||
|
||||
fl_addto_choice(dialog_->type,
|
||||
_(" Ref | Page | TextRef | TextPage | PrettyRef "));
|
||||
|
||||
// XFORMS bug workaround
|
||||
// Define the min/max dimensions. Actually applied in update()
|
||||
formw = form()->w, formh = form()->h;
|
||||
|
||||
// Name is irrelevant to LaTeX documents
|
||||
if( lv_->buffer()->isLatex() ) {
|
||||
fl_deactivate_object( dialog_->name );
|
||||
fl_set_object_lcol( dialog_->name, FL_INACTIVE );
|
||||
}
|
||||
|
||||
// Can change reference only through browser
|
||||
fl_deactivate_object( dialog_->ref );
|
||||
|
||||
if( lv_->buffer()->isReadonly() ) {
|
||||
fl_deactivate_object( dialog_->type );
|
||||
fl_deactivate_object( dialog_->ok );
|
||||
fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
|
||||
} else {
|
||||
fl_activate_object( dialog_->type );
|
||||
fl_activate_object( dialog_->ok );
|
||||
fl_set_object_lcol( dialog_->ok, FL_BLACK );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FL_FORM * const FormRef::form() const
|
||||
{
|
||||
if( dialog_ ) // no need to test for dialog_->form_ref
|
||||
return dialog_->form_ref;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void FormRef::update()
|
||||
{
|
||||
fl_set_input(dialog_->ref, params.getContents().c_str());
|
||||
fl_set_input(dialog_->name, params.getOptions().c_str());
|
||||
|
||||
Type type = getType();
|
||||
fl_set_choice( dialog_->type, type+1 );
|
||||
|
||||
toggle = GOBACK;
|
||||
fl_set_object_label(dialog_->go, _("Goto reference"));
|
||||
|
||||
refs.clear();
|
||||
if( inset_ == 0 ) {
|
||||
refs = lv_->buffer()->getLabelList();
|
||||
updateBrowser( refs );
|
||||
showBrowser();
|
||||
} else
|
||||
hideBrowser();
|
||||
}
|
||||
|
||||
|
||||
void FormRef::updateBrowser( vector<string> keys ) const
|
||||
{
|
||||
if( fl_get_button( dialog_->sort ) )
|
||||
sort( keys.begin(), keys.end() );
|
||||
|
||||
fl_clear_browser( dialog_->browser );
|
||||
for( vector<string>::const_iterator it = keys.begin();
|
||||
it != keys.end(); ++it )
|
||||
fl_add_browser_line( dialog_->browser, (*it).c_str());
|
||||
|
||||
if( keys.empty() ) {
|
||||
fl_add_browser_line( dialog_->browser,
|
||||
_("*** No labels found in document ***"));
|
||||
|
||||
fl_deactivate_object( dialog_->browser );
|
||||
fl_deactivate_object( dialog_->update );
|
||||
fl_deactivate_object( dialog_->sort );
|
||||
fl_set_object_lcol( dialog_->browser, FL_INACTIVE );
|
||||
fl_set_object_lcol( dialog_->update, FL_INACTIVE );
|
||||
fl_set_object_lcol( dialog_->sort, FL_INACTIVE );
|
||||
} else {
|
||||
fl_set_browser_topline( dialog_->browser, 1 );
|
||||
fl_activate_object( dialog_->browser );
|
||||
fl_set_object_lcol( dialog_->browser, FL_BLACK );
|
||||
fl_activate_object( dialog_->update );
|
||||
fl_set_object_lcol( dialog_->update, FL_BLACK );
|
||||
fl_activate_object( dialog_->sort );
|
||||
fl_set_object_lcol( dialog_->sort, FL_BLACK );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormRef::showBrowser() const
|
||||
{
|
||||
fl_show_object( dialog_->browser );
|
||||
fl_show_object( dialog_->update );
|
||||
fl_show_object( dialog_->sort );
|
||||
|
||||
setSize( formw, formh, 0 );
|
||||
|
||||
fl_deactivate_object( dialog_->type );
|
||||
fl_set_object_lcol( dialog_->type, FL_INACTIVE );
|
||||
fl_deactivate_object( dialog_->go );
|
||||
fl_set_object_lcol( dialog_->go, FL_INACTIVE );
|
||||
fl_deactivate_object( dialog_->ok );
|
||||
fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
|
||||
fl_set_object_lcol( dialog_->ref, FL_INACTIVE );
|
||||
}
|
||||
|
||||
|
||||
void FormRef::hideBrowser() const
|
||||
{
|
||||
fl_hide_object( dialog_->browser );
|
||||
fl_hide_object( dialog_->update );
|
||||
fl_hide_object( dialog_->sort );
|
||||
|
||||
setSize( 250, formh, 280 );
|
||||
|
||||
fl_activate_object( dialog_->type );
|
||||
fl_set_object_lcol( dialog_->type, FL_BLACK );
|
||||
fl_activate_object( dialog_->go );
|
||||
fl_set_object_lcol( dialog_->go, FL_BLACK );
|
||||
fl_deactivate_object( dialog_->ok );
|
||||
fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
|
||||
fl_set_object_lcol( dialog_->ref, FL_BLACK );
|
||||
}
|
||||
|
||||
|
||||
void FormRef::setSize( int w, int h, int dx ) const
|
||||
{
|
||||
static int x1 = dialog_->name->x;
|
||||
static int y1 = dialog_->name->y;
|
||||
static int x2 = dialog_->ref->x;
|
||||
static int y2 = dialog_->ref->y;
|
||||
static int x3 = dialog_->type->x;
|
||||
static int y3 = dialog_->type->y;
|
||||
static int x4 = dialog_->go->x;
|
||||
static int y4 = dialog_->go->y;
|
||||
static int x5 = dialog_->ok->x;
|
||||
static int y5 = dialog_->ok->y;
|
||||
static int x6 = dialog_->cancel->x;
|
||||
static int y6 = dialog_->cancel->y;
|
||||
|
||||
if( form()->w != w )
|
||||
fl_set_form_size( form(), w, h );
|
||||
|
||||
fl_set_form_minsize( form(), w, h );
|
||||
fl_set_form_maxsize( form(), 2*w, h );
|
||||
|
||||
if( form()->w == w ) return;
|
||||
|
||||
fl_set_object_position( dialog_->name, x1-dx, y1 );
|
||||
fl_set_object_position( dialog_->ref, x2-dx, y2 );
|
||||
fl_set_object_position( dialog_->type, x3-dx, y3 );
|
||||
fl_set_object_position( dialog_->go, x4-dx, y4 );
|
||||
fl_set_object_position( dialog_->ok, x5-dx, y5 );
|
||||
fl_set_object_position( dialog_->cancel, x6-dx, y6 );
|
||||
|
||||
// These two must be reset apparently
|
||||
// Name is irrelevant to LaTeX documents
|
||||
if( lv_->buffer()->isLatex() ) {
|
||||
fl_deactivate_object( dialog_->name );
|
||||
fl_set_object_lcol( dialog_->name, FL_INACTIVE );
|
||||
}
|
||||
|
||||
// Can change reference only through browser
|
||||
fl_deactivate_object( dialog_->ref );
|
||||
}
|
||||
|
||||
|
||||
void FormRef::apply()
|
||||
{
|
||||
if (!lv_->view()->available())
|
||||
return;
|
||||
|
||||
Type type = static_cast<Type>( fl_get_choice(dialog_->type)-1 );
|
||||
params.setCmdName( getName( type ) );
|
||||
|
||||
params.setOptions( fl_get_input(dialog_->name) );
|
||||
|
||||
if( inset_ != 0 )
|
||||
{
|
||||
// Only update if contents have changed
|
||||
if( params != inset_->params() ) {
|
||||
inset_->setParams( params );
|
||||
lv_->view()->updateInset( inset_, true );
|
||||
}
|
||||
} else {
|
||||
lv_->getLyXFunc()->Dispatch( LFUN_REF_INSERT,
|
||||
params.getAsString().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormRef::input( long data )
|
||||
{
|
||||
switch( data ) {
|
||||
// goto reference / go back
|
||||
case 1:
|
||||
{
|
||||
toggle = static_cast<Goto>(toggle + 1);
|
||||
if( toggle == GOFIRST ) toggle = GOREF;
|
||||
|
||||
switch( toggle ) {
|
||||
case GOREF:
|
||||
{
|
||||
lv_->getLyXFunc()->
|
||||
Dispatch(LFUN_REF_GOTO,
|
||||
params.getContents().c_str());
|
||||
fl_set_object_label(dialog_->go, _("Go back"));
|
||||
}
|
||||
break;
|
||||
|
||||
case GOBACK:
|
||||
{
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK);
|
||||
fl_set_object_label(dialog_->go, _("Goto reference"));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// choose browser key
|
||||
case 2:
|
||||
{
|
||||
unsigned int sel = fl_get_browser( dialog_->browser );
|
||||
if( sel < 1 || sel > refs.size() ) break;
|
||||
|
||||
string s = fl_get_browser_line( dialog_->browser, sel );
|
||||
fl_set_input( dialog_->ref, s.c_str());
|
||||
params.setContents( s );
|
||||
|
||||
toggle = GOBACK;
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK);
|
||||
fl_set_object_label(dialog_->go, _("Goto reference"));
|
||||
|
||||
fl_activate_object( dialog_->type );
|
||||
fl_set_object_lcol( dialog_->type, FL_BLACK );
|
||||
fl_activate_object( dialog_->go );
|
||||
fl_set_object_lcol( dialog_->go, FL_BLACK );
|
||||
fl_activate_object( dialog_->ok );
|
||||
fl_set_object_lcol( dialog_->ok, FL_BLACK );
|
||||
fl_set_object_lcol( dialog_->ref, FL_BLACK );
|
||||
}
|
||||
break;
|
||||
|
||||
// update or sort
|
||||
case 3:
|
||||
{
|
||||
fl_freeze_form( form() );
|
||||
updateBrowser( refs );
|
||||
fl_unfreeze_form( form() );
|
||||
}
|
||||
break;
|
||||
|
||||
// changed reference type
|
||||
case 4:
|
||||
{
|
||||
Type type = static_cast<Type>( fl_get_choice(dialog_->type)-1 );
|
||||
if( params.getCmdName() != getName( type ) ) {
|
||||
fl_activate_object( dialog_->ok );
|
||||
fl_set_object_lcol( dialog_->ok, FL_BLACK );
|
||||
} else if( inset_ != 0 ) {
|
||||
fl_deactivate_object( dialog_->ok );
|
||||
fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FormRef::Type FormRef::getType() const
|
||||
{
|
||||
Type type;
|
||||
|
||||
if( params.getCmdName() == "ref" )
|
||||
type = REF;
|
||||
|
||||
else if( params.getCmdName() == "pageref" )
|
||||
type = PAGEREF;
|
||||
|
||||
else if( params.getCmdName() == "vref" )
|
||||
type = VREF;
|
||||
|
||||
else if( params.getCmdName() == "vpageref" )
|
||||
type = VPAGEREF;
|
||||
|
||||
else
|
||||
type = PRETTYREF;
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
string FormRef::getName( Type type ) const
|
||||
{
|
||||
string name;
|
||||
|
||||
switch( type ) {
|
||||
case REF:
|
||||
name = "ref";
|
||||
break;
|
||||
case PAGEREF:
|
||||
name = "pageref";
|
||||
break;
|
||||
case VREF:
|
||||
name = "vref";
|
||||
break;
|
||||
case VPAGEREF:
|
||||
name = "vpageref";
|
||||
break;
|
||||
case PRETTYREF:
|
||||
name = "prettyref";
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
77
src/frontends/xforms/FormRef.h
Normal file
77
src/frontends/xforms/FormRef.h
Normal file
@ -0,0 +1,77 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000 The LyX Team.
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#ifndef FORMREF_H
|
||||
#define FORMREF_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "FormCommand.h"
|
||||
struct FD_form_ref;
|
||||
|
||||
/** This class provides an XForms implementation of the FormRef Dialog.
|
||||
*/
|
||||
class FormRef : public FormCommand {
|
||||
public:
|
||||
/**@name Constructors and Destructors */
|
||||
//@{
|
||||
///
|
||||
FormRef(LyXView *, Dialogs *);
|
||||
///
|
||||
~FormRef();
|
||||
//@}
|
||||
|
||||
private:
|
||||
///
|
||||
enum Type{ REF=0, PAGEREF, VREF, VPAGEREF, PRETTYREF };
|
||||
///
|
||||
enum Goto{ GOREF=0, GOBACK, GOFIRST };
|
||||
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Filter the input
|
||||
virtual void input( long );
|
||||
/// Update dialog before showing it
|
||||
virtual void update();
|
||||
/// Not used but must be instantiated
|
||||
virtual void apply();
|
||||
/// delete derived class variables from hide()
|
||||
virtual void clearStore();
|
||||
/// Pointer to the actual instantiation of the xform's form
|
||||
virtual FL_FORM * const form() const;
|
||||
|
||||
///
|
||||
void updateBrowser( std::vector<string> ) const;
|
||||
///
|
||||
void showBrowser() const;
|
||||
///
|
||||
void hideBrowser() const;
|
||||
///
|
||||
void setSize( int, int, int ) const;
|
||||
///
|
||||
FD_form_ref * build_ref();
|
||||
///
|
||||
Type getType() const;
|
||||
///
|
||||
string getName( Type type ) const;
|
||||
|
||||
/// Real GUI implementation.
|
||||
FD_form_ref * dialog_;
|
||||
|
||||
///
|
||||
Goto toggle;
|
||||
///
|
||||
std::vector<string> refs;
|
||||
};
|
||||
|
||||
#endif
|
60
src/frontends/xforms/form_ref.C
Normal file
60
src/frontends/xforms/form_ref.C
Normal file
@ -0,0 +1,60 @@
|
||||
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
|
||||
#include <config.h>
|
||||
#include "lyx_gui_misc.h"
|
||||
#include "gettext.h"
|
||||
|
||||
/* Form definition file generated with fdesign. */
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
#include <stdlib.h>
|
||||
#include "form_ref.h"
|
||||
#include "FormRef.h"
|
||||
|
||||
FD_form_ref * FormRef::build_ref()
|
||||
{
|
||||
FL_OBJECT *obj;
|
||||
FD_form_ref *fdui = new FD_form_ref;
|
||||
|
||||
fdui->form_ref = fl_bgn_form(FL_NO_BOX, 530, 340);
|
||||
fdui->form_ref->u_vdata = this;
|
||||
obj = fl_add_box(FL_UP_BOX, 0, 0, 530, 340, "");
|
||||
fdui->browser = obj = fl_add_browser(FL_HOLD_BROWSER, 10, 10, 270, 280, "");
|
||||
fl_set_object_gravity(obj, FL_NorthWest, FL_NoGravity);
|
||||
fl_set_object_resize(obj, FL_RESIZE_X);
|
||||
fl_set_object_callback(obj, C_FormCommandInputCB, 2);
|
||||
fdui->update = obj = fl_add_button(FL_NORMAL_BUTTON, 40, 300, 90, 30, _("Update"));
|
||||
fl_set_button_shortcut(obj, scex(_("Update|#U#u")), 1);
|
||||
fl_set_object_resize(obj, FL_RESIZE_NONE);
|
||||
fl_set_object_callback(obj, C_FormCommandInputCB, 3);
|
||||
fdui->sort = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 170, 300, 30, 30, _("Sort"));
|
||||
fl_set_object_lalign(obj, FL_ALIGN_RIGHT);
|
||||
fl_set_object_resize(obj, FL_RESIZE_NONE);
|
||||
fl_set_object_callback(obj, C_FormCommandInputCB, 3);
|
||||
fdui->name = obj = fl_add_input(FL_NORMAL_INPUT, 370, 10, 150, 40, _("Name:"));
|
||||
fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
|
||||
fdui->ref = obj = fl_add_input(FL_NORMAL_INPUT, 370, 60, 150, 40, _("Reference:"));
|
||||
fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
|
||||
fdui->type = obj = fl_add_choice(FL_NORMAL_CHOICE, 340, 140, 140, 40, _("Reference type"));
|
||||
fl_set_object_shortcut(obj, scex(_("Reference type|#t")), 1);
|
||||
fl_set_object_boxtype(obj, FL_FRAME_BOX);
|
||||
fl_set_object_lalign(obj, FL_ALIGN_TOP);
|
||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
||||
fl_set_object_callback(obj, C_FormCommandInputCB, 4);
|
||||
fdui->go = obj = fl_add_button(FL_NORMAL_BUTTON, 340, 200, 140, 40, _("Goto reference"));
|
||||
fl_set_button_shortcut(obj, scex(_("Goto reference|#G")), 1);
|
||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
||||
fl_set_object_callback(obj, C_FormCommandInputCB, 1);
|
||||
fdui->ok = obj = fl_add_button(FL_RETURN_BUTTON, 330, 300, 90, 30, _("OK"));
|
||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
||||
fl_set_object_callback(obj, C_FormCommandOKCB, 0);
|
||||
fdui->cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 430, 300, 90, 30, _("Cancel"));
|
||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
||||
fl_set_object_callback(obj, C_FormCommandCancelCB, 0);
|
||||
fl_end_form();
|
||||
|
||||
fdui->form_ref->fdui = fdui;
|
||||
|
||||
return fdui;
|
||||
}
|
||||
/*---------------------------------------*/
|
||||
|
27
src/frontends/xforms/form_ref.h
Normal file
27
src/frontends/xforms/form_ref.h
Normal file
@ -0,0 +1,27 @@
|
||||
/** Header file generated with fdesign on Mon Aug 7 17:11:47 2000.**/
|
||||
|
||||
#ifndef FD_form_ref_h_
|
||||
#define FD_form_ref_h_
|
||||
|
||||
/** Callbacks, globals and object handlers **/
|
||||
extern "C" void C_FormCommandInputCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormCommandOKCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormCommandCancelCB(FL_OBJECT *, long);
|
||||
|
||||
|
||||
/**** Forms and Objects ****/
|
||||
struct FD_form_ref {
|
||||
|
||||
FL_FORM *form_ref;
|
||||
FL_OBJECT *browser;
|
||||
FL_OBJECT *update;
|
||||
FL_OBJECT *sort;
|
||||
FL_OBJECT *name;
|
||||
FL_OBJECT *ref;
|
||||
FL_OBJECT *type;
|
||||
FL_OBJECT *go;
|
||||
FL_OBJECT *ok;
|
||||
FL_OBJECT *cancel;
|
||||
};
|
||||
|
||||
#endif /* FD_form_ref_h_ */
|
196
src/frontends/xforms/forms/form_ref.fd
Normal file
196
src/frontends/xforms/forms/form_ref.fd
Normal file
@ -0,0 +1,196 @@
|
||||
Magic: 13000
|
||||
|
||||
Internal Form Definition File
|
||||
(do not change)
|
||||
|
||||
Number of forms: 1
|
||||
Unit of measure: FL_COORD_PIXEL
|
||||
|
||||
=============== FORM ===============
|
||||
Name: form_ref
|
||||
Width: 530
|
||||
Height: 340
|
||||
Number of Objects: 10
|
||||
|
||||
--------------------
|
||||
class: FL_BOX
|
||||
type: UP_BOX
|
||||
box: 0 0 530 340
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label:
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BROWSER
|
||||
type: HOLD_BROWSER
|
||||
box: 10 10 270 280
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_YELLOW
|
||||
alignment: FL_ALIGN_BOTTOM
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label:
|
||||
shortcut:
|
||||
resize: FL_RESIZE_X
|
||||
gravity: FL_NorthWest FL_NoGravity
|
||||
name: browser
|
||||
callback: C_FormCommandInputCB
|
||||
argument: 2
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: NORMAL_BUTTON
|
||||
box: 40 300 90 30
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Update
|
||||
shortcut: Update|#U#u
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: update
|
||||
callback: C_FormCommandInputCB
|
||||
argument: 3
|
||||
|
||||
--------------------
|
||||
class: FL_CHECKBUTTON
|
||||
type: PUSH_BUTTON
|
||||
box: 170 300 30 30
|
||||
boxtype: FL_NO_BOX
|
||||
colors: FL_COL1 FL_YELLOW
|
||||
alignment: FL_ALIGN_RIGHT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Sort
|
||||
shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: sort
|
||||
callback: C_FormCommandInputCB
|
||||
argument: 3
|
||||
|
||||
--------------------
|
||||
class: FL_INPUT
|
||||
type: NORMAL_INPUT
|
||||
box: 370 10 150 40
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_MCOL
|
||||
alignment: FL_ALIGN_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Name:
|
||||
shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_NorthEast FL_NorthEast
|
||||
name: name
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_INPUT
|
||||
type: NORMAL_INPUT
|
||||
box: 370 60 150 40
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_MCOL
|
||||
alignment: FL_ALIGN_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Reference:
|
||||
shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_NorthEast FL_NorthEast
|
||||
name: ref
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_CHOICE
|
||||
type: NORMAL_CHOICE
|
||||
box: 340 140 140 40
|
||||
boxtype: FL_FRAME_BOX
|
||||
colors: FL_COL1 FL_BLACK
|
||||
alignment: FL_ALIGN_TOP
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Reference type
|
||||
shortcut: Reference type|#t
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: type
|
||||
callback: C_FormCommandInputCB
|
||||
argument: 4
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: NORMAL_BUTTON
|
||||
box: 340 200 140 40
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Goto reference
|
||||
shortcut: Goto reference|#G
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: go
|
||||
callback: C_FormCommandInputCB
|
||||
argument: 1
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: RETURN_BUTTON
|
||||
box: 330 300 90 30
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: OK
|
||||
shortcut: ^M
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: ok
|
||||
callback: C_FormCommandOKCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: NORMAL_BUTTON
|
||||
box: 430 300 90 30
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Cancel
|
||||
shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: cancel
|
||||
callback: C_FormCommandCancelCB
|
||||
argument: 0
|
||||
|
||||
==============================
|
||||
create_the_forms
|
25
src/lyx_cb.C
25
src/lyx_cb.C
@ -157,7 +157,7 @@ void ToggleLockedInsetCursor(long x, long y, int asc, int desc);
|
||||
|
||||
int RunLinuxDoc(BufferView *, int, string const &);
|
||||
int RunDocBook(int, string const &);
|
||||
void MenuWrite(Buffer * buf);
|
||||
bool MenuWrite(Buffer * buf);
|
||||
bool MenuWriteAs(Buffer * buffer);
|
||||
void MenuReload(Buffer * buf);
|
||||
void MenuLayoutSave();
|
||||
@ -187,7 +187,7 @@ void ShowMessage(Buffer * buf,
|
||||
//
|
||||
|
||||
// should be moved to lyxfunc.C
|
||||
void MenuWrite(Buffer * buffer)
|
||||
bool MenuWrite(Buffer * buffer)
|
||||
{
|
||||
XFlush(fl_display);
|
||||
if (!buffer->save()) {
|
||||
@ -196,11 +196,13 @@ void MenuWrite(Buffer * buffer)
|
||||
if (AskQuestion(_("Save failed. Rename and try again?"),
|
||||
MakeDisplayPath(s, 50),
|
||||
_("(If not, document is not saved.)"))) {
|
||||
MenuWriteAs(buffer);
|
||||
return MenuWriteAs(buffer);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
lastfiles->newFile(buffer->fileName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -280,13 +282,23 @@ bool MenuWriteAs(Buffer * buffer)
|
||||
// Ok, change the name of the buffer
|
||||
buffer->fileName(s);
|
||||
buffer->markDirty();
|
||||
bool unnamed = buffer->isUnnamed();
|
||||
buffer->setUnnamed(false);
|
||||
// And save
|
||||
// Small bug: If the save fails, we have irreversible changed the name
|
||||
// of the document.
|
||||
MenuWrite(buffer);
|
||||
// Hope this is fixed this way! (Jug)
|
||||
if (!MenuWrite(buffer)) {
|
||||
buffer->fileName(oldname);
|
||||
buffer->setUnnamed(unnamed);
|
||||
ShowMessage(buffer, _("Document could not be saved!"),
|
||||
_("Holding the old name."), MakeDisplayPath(oldname));
|
||||
return false;
|
||||
}
|
||||
// now remove the oldname autosave file if existant!
|
||||
removeAutosaveFile(oldname);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int MenuRunLaTeX(Buffer * buffer)
|
||||
@ -978,8 +990,7 @@ void AutoSave(BufferView * bv)
|
||||
if (!bv->available())
|
||||
return;
|
||||
|
||||
if (bv->buffer()->isBakClean() ||
|
||||
bv->buffer()->isReadonly() || bv->buffer()->isUnnamed()) {
|
||||
if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) {
|
||||
// We don't save now, but we'll try again later
|
||||
bv->owner()->resetAutosaveTimer();
|
||||
return;
|
||||
|
@ -108,7 +108,7 @@ extern bool selection_possible;
|
||||
|
||||
extern kb_keymap * toplevel_keymap;
|
||||
|
||||
extern void MenuWrite(Buffer *);
|
||||
extern bool MenuWrite(Buffer *);
|
||||
extern bool MenuWriteAs(Buffer *);
|
||||
extern int MenuRunLaTeX(Buffer *);
|
||||
extern int MenuBuildProg(Buffer *);
|
||||
|
@ -1089,3 +1089,17 @@ findtexfile(string const & fil, string const & /*format*/)
|
||||
<< "'" << endl;
|
||||
return c.first != -1 ? strip(c.second, '\n') : string();
|
||||
}
|
||||
|
||||
void removeAutosaveFile(string const & filename)
|
||||
{
|
||||
string a = OnlyPath(filename);
|
||||
a += '#';
|
||||
a += OnlyFilename(filename);
|
||||
a += '#';
|
||||
FileInfo fileinfo(a);
|
||||
if (fileinfo.exist()) {
|
||||
if (::remove(a.c_str()) != 0) {
|
||||
WriteFSAlert(_("Could not delete auto-save file!"), a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,4 +199,7 @@ bool LyXReadLink(string const & file, string & Link);
|
||||
/* Uses kpsewhich to find tex files */
|
||||
string const findtexfile(string const & fil, string const & format);
|
||||
|
||||
/* remove the autosave-file and give a Message if it can't be done */
|
||||
void removeAutosaveFile(string const & filename);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user