Am Montag, 5. April 2004 17:31 schrieb Angus Leeming: > Georg Baum wrote: > >> Ok. 'EditCommand'. I'm happy to kill that... > > > > This is easy. I have added an editor (similar to the viewer) to the > > formats mechanism in my 1.3 source. > > > I can adapt the patch to 1.4 if you like. I always planned to > > propose this, but was busy with other stuff... > > Sounds good also, but there's no rush.
Ok, here it is. Some notes: - I left the graphics inset stuff in for reference (and who knows how long the graphics inset still lives?) - It is not much more than a proof of concept and may need some polishing (although I use it since some months without problems). - The "Edit" button for the graphics inset is not very well placed. - I did not change the external inset, but you probably get the idea if you look at InsetGraphics::editGraphics(). Georg
Index: lib/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/lib/ChangeLog,v retrieving revision 1.579 diff -u -p -r1.579 ChangeLog --- lib/ChangeLog 2004/04/06 21:07:26 1.579 +++ lib/ChangeLog 2004/04/07 19:23:42 @@ -1,3 +1,7 @@ +2004-04-07 Georg Baum <[EMAIL PROTECTED]> + + * configure.m4: check for more viewers and editors + 2004-04-06 Georg Baum <[EMAIL PROTECTED]> * external_templates: use some new variables instead of $$Basename Index: lib/configure.m4 =================================================================== RCS file: /cvs/lyx/lyx-devel/lib/configure.m4,v retrieving revision 1.75 diff -u -p -r1.75 configure.m4 --- lib/configure.m4 2004/03/22 16:22:52 1.75 +++ lib/configure.m4 2004/04/07 19:23:45 @@ -568,6 +619,56 @@ $rc_entries \\font_encoding "$chk_fontenc" EOF +SEARCH_PROG([for a TGIF viewer and editor], TGIF, tgif) +if test "$TGIF" = "tgif"; then +cat >>$outfile <<EOF +\\viewer tgif "tgif" +\\viewer tgif2 "tgif" +\\editor tgif "tgif" +\\editor tgif2 "tgif" +EOF +fi + +SEARCH_PROG([for a FIG viewer and editor], FIG, xfig) +if test "$FIG" = "xfig"; then +cat >>$outfile <<EOF +\\viewer fig "xfig" +\\editor fig "xfig" +EOF +fi + +SEARCH_PROG([for a bitmap graphics viewer], BITMAP, kview xv gimp) +if test "$BITMAP" = "kview" -o "$BITMAP" = "xv" -o "$BITMAP" = "gimp"; then +cat >>$outfile <<EOF +\\viewer bmp "$BITMAP" +\\viewer gif "$BITMAP" +\\viewer jpg "$BITMAP" +\\viewer pbm "$BITMAP" +\\viewer pgm "$BITMAP" +\\viewer ppm "$BITMAP" +\\viewer png "$BITMAP" +\\viewer tiff "$BITMAP" +\\viewer xbm "$BITMAP" +\\viewer xpm "$BITMAP" +EOF +fi + +SEARCH_PROG([for a bitmap graphics editor], BITMAP, gimp) +if test "$BITMAP" = "gimp"; then +cat >>$outfile <<EOF +\\editor bmp "gimp" +\\editor gif "gimp" +\\editor jpg "gimp" +\\editor pbm "gimp" +\\editor pgm "gimp" +\\editor ppm "gimp" +\\editor png "gimp" +\\editor tiff "gimp" +\\editor xbm "gimp" +\\editor xpm "gimp" +EOF +fi + ### the graphic converter part with the predefined ones #### Search for tne nonstandard converting progs # Index: src/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v retrieving revision 1.1885 diff -u -p -r1.1885 ChangeLog --- src/ChangeLog 2004/04/06 13:48:12 1.1885 +++ src/ChangeLog 2004/04/07 19:24:49 @@ -1,3 +1,8 @@ +2004-04-07 Georg Baum <[EMAIL PROTECTED]> + + * format.[Ch], lyxrc.[Ch]: add editor to Format + * LyXAction.C, lfuns.h, lyxfunc.C: add lfun LFUN_GRAPHICS_EDIT + 2004-04-05 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * lengthcommon.C: compilation fix: remove explicit array size from Index: src/LyXAction.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/LyXAction.C,v retrieving revision 1.198 diff -u -p -r1.198 LyXAction.C --- src/LyXAction.C 2004/04/05 18:34:33 1.198 +++ src/LyXAction.C 2004/04/07 19:24:54 @@ -325,6 +325,7 @@ void LyXAction::init() { LFUN_PARAGRAPH_APPLY, "paragraph-params-apply", Noop }, { LFUN_PARAGRAPH_UPDATE, "", Noop }, { LFUN_EXTERNAL_EDIT, "external-edit", Noop }, + { LFUN_GRAPHICS_EDIT, "graphics-edit", Noop }, { LFUN_REPEAT, "repeat", NoBuffer }, { LFUN_WORD_FIND, "word-find", Noop }, { LFUN_WORD_REPLACE, "word-replace", Noop }, Index: src/format.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/format.C,v retrieving revision 1.22 diff -u -p -r1.22 format.C --- src/format.C 2004/02/06 08:23:39 1.22 +++ src/format.C 2004/04/07 19:25:03 @@ -70,8 +70,8 @@ bool operator<(Format const & a, Format } Format::Format(string const & n, string const & e, string const & p, - string const & s, string const & v) - : name_(n), extension_(e), prettyname_(p),shortcut_(s), viewer_(v) + string const & s, string const & v, string const & ed) + : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed) {} @@ -136,10 +136,11 @@ void Formats::add(string const & name, s FormatNamesEqual(name)); if (it == formatlist.end()) formatlist.push_back(Format(name, extension, prettyname, - shortcut, "")); + shortcut, "", "")); else { string viewer = it->viewer(); - *it = Format(name, extension, prettyname, shortcut, viewer); + string editor = it->editor(); + *it = Format(name, extension, prettyname, shortcut, viewer, editor); } } @@ -171,8 +172,19 @@ void Formats::setViewer(string const & n } +void Formats::setEditor(string const & name, string const & command) +{ + add(name); + FormatList::iterator it = + find_if(formatlist.begin(), formatlist.end(), + lyx::compare_memfun(&Format::name, name)); + if (it != formatlist.end()) + it->setEditor(command); +} + + bool Formats::view(Buffer const & buffer, string const & filename, - string const & format_name) const + string const & format_name) const { if (filename.empty()) return false; @@ -183,7 +195,7 @@ bool Formats::view(Buffer const & buffer format = getFormat(format->parentFormat()); if (!format || format->viewer().empty()) { // I believe this is the wrong place to show alerts, it should be done by -// the caller (this should be "utility" code +// the caller (this should be "utility" code) Alert::error(_("Cannot view file"), bformat(_("No information for viewing %1$s"), prettyName(format_name))); @@ -219,6 +231,51 @@ bool Formats::view(Buffer const & buffer if (res) { Alert::error(_("Cannot view file"), + bformat(_("An error occurred whilst running %1$s"), + command.substr(0, 50))); + return false; + } + return true; +} + + +bool Formats::edit(Buffer const & buffer, string const & filename, + string const & format_name) const +{ + if (filename.empty()) + return false; + + Format const * format = getFormat(format_name); + if (format && format->editor().empty() && + format->isChildFormat()) + format = getFormat(format->parentFormat()); + if (!format || format->editor().empty()) { +// I believe this is the wrong place to show alerts, it should be done by +// the caller (this should be "utility" code) + Alert::error(_("Cannot edit file"), + bformat(_("No information for editing %1$s"), + prettyName(format_name))); + return false; + } + + string command = format->editor(); + + if (!contains(command, token_from)) + command += ' ' + token_from; + + command = subst(command, token_from, + QuoteName(OnlyFilename(filename))); + command = subst(command, token_path, QuoteName(OnlyPath(filename))); + command = subst(command, token_socket, QuoteName(lyxsocket->address())); + lyxerr[Debug::FILES] << "Executing command: " << command << std::endl; + buffer.message(_("Executing command: ") + command); + + Path p(OnlyPath(filename)); + Systemcall one; + int const res = one.startscript(Systemcall::DontWait, command); + + if (res) { + Alert::error(_("Cannot edit file"), bformat(_("An error occurred whilst running %1$s"), command.substr(0, 50))); return false; Index: src/format.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/format.h,v retrieving revision 1.7 diff -u -p -r1.7 format.h --- src/format.h 2003/10/06 15:42:15 1.7 +++ src/format.h 2004/04/07 19:25:03 @@ -21,7 +21,7 @@ class Format { public: /// Format(std::string const & n, std::string const & e, std::string const & p, - std::string const & s, std::string const & v); + std::string const & s, std::string const & v, std::string const & ed); /// bool dummy() const; /// @@ -52,6 +52,14 @@ public: void setViewer(std::string const & v) { viewer_ = v; } + /// + std::string const & editor() const { + return editor_; + } + /// + void setEditor(std::string const & e) { + editor_ = e; + } private: std::string name_; /// @@ -62,6 +70,8 @@ private: std::string shortcut_; /// std::string viewer_; + /// + std::string editor_; }; @@ -95,6 +105,11 @@ public: void setViewer(std::string const & name, std::string const & command); /// bool view(Buffer const & buffer, std::string const & filename, + std::string const & format_name) const; + /// + void setEditor(std::string const & name, std::string const & command); + /// + bool edit(Buffer const & buffer, std::string const & filename, std::string const & format_name) const; /// std::string const prettyName(std::string const & name) const; Index: src/lfuns.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lfuns.h,v retrieving revision 1.34 diff -u -p -r1.34 lfuns.h --- src/lfuns.h 2004/03/31 16:50:57 1.34 +++ src/lfuns.h 2004/04/07 19:25:04 @@ -348,6 +348,7 @@ enum kb_action { LFUN_BUFFERPARAMS_APPLY, // 265 LFUN_LYXRC_APPLY, + LFUN_GRAPHICS_EDIT, LFUN_LASTACTION // end of the table }; Index: src/lyxfunc.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxfunc.C,v retrieving revision 1.611 diff -u -p -r1.611 lyxfunc.C --- src/lyxfunc.C 2004/04/07 08:07:20 1.611 +++ src/lyxfunc.C 2004/04/07 19:25:09 @@ -483,6 +483,7 @@ FuncStatus LyXFunc::getStatus(FuncReques case LFUN_SET_COLOR: case LFUN_MESSAGE: case LFUN_EXTERNAL_EDIT: + case LFUN_GRAPHICS_EDIT: case LFUN_ALL_INSETS_TOGGLE: case LFUN_LANGUAGE_BUFFER: case LFUN_TEXTCLASS_APPLY: @@ -1255,6 +1256,12 @@ void LyXFunc::dispatch(FuncRequest const case LFUN_EXTERNAL_EDIT: { FuncRequest fr(action, argument); InsetExternal().dispatch(view()->cursor(), fr); + break; + } + + case LFUN_GRAPHICS_EDIT: { + FuncRequest fr(action, argument); + InsetGraphics().dispatch(view()->cursor(), fr); break; } Index: src/lyxrc.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxrc.C,v retrieving revision 1.169 diff -u -p -r1.169 lyxrc.C --- src/lyxrc.C 2004/04/05 18:21:25 1.169 +++ src/lyxrc.C 2004/04/07 19:25:14 @@ -79,6 +79,7 @@ keyword_item lyxrcTags[] = { { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN }, { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS }, { "\\document_path", LyXRC::RC_DOCUMENTPATH }, + { "\\editor", LyXRC::RC_EDITOR}, { "\\escape_chars", LyXRC::RC_ESC_CHARS }, { "\\font_encoding", LyXRC::RC_FONT_ENCODING }, { "\\format", LyXRC::RC_FORMAT }, @@ -986,6 +987,19 @@ int LyXRC::read(LyXLex & lexrc) formats.setViewer(format, command); break; } + case RC_EDITOR: { + string format, command; + if (lexrc.next()) { + format = lexrc.getString(); + } + if (lexrc.next()) { + command = lexrc.getString(); + if (token(command, ' ', 0) == "none") + command.erase(); + } + formats.setEditor(format, command); + break; + } case RC_FORMAT: { string format, extension, prettyname, shortcut; if (lexrc.next()) { @@ -1827,6 +1841,17 @@ void LyXRC::write(ostream & os, bool ign << cit->viewer() << "\"\n"; } + case RC_EDITOR: + for (Formats::const_iterator cit = formats.begin(); + cit != formats.end(); ++cit) { + Format const * format = + system_formats.getFormat(cit->name()); + if ((!format || format->editor() != cit->editor()) && + (format || !cit->editor().empty())) + os << "\\editor \"" << cit->name() << "\" \"" + << cit->editor() << "\"\n"; + } + os << "\n#\n" << "# CONVERTERS SECTION ##########################\n" << "#\n\n"; @@ -2184,6 +2209,9 @@ string const LyXRC::getDescription(LyXRC break; case RC_VIEWER: + break; + + case RC_EDITOR: break; case RC_FORMAT: Index: src/lyxrc.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxrc.h,v retrieving revision 1.85 diff -u -p -r1.85 lyxrc.h --- src/lyxrc.h 2004/04/05 18:21:25 1.85 +++ src/lyxrc.h 2004/04/07 19:25:15 @@ -131,6 +131,7 @@ enum LyXRCTags { RC_USE_SPELL_LIB, RC_USER_NAME, RC_USER_EMAIL, + RC_EDITOR, RC_LAST }; Index: src/frontends/controllers/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/controllers/ChangeLog,v retrieving revision 1.437 diff -u -p -r1.437 ChangeLog --- src/frontends/controllers/ChangeLog 2004/04/07 05:28:51 1.437 +++ src/frontends/controllers/ChangeLog 2004/04/07 19:25:45 @@ -1,3 +1,7 @@ +2004-04-07 Georg Baum <[EMAIL PROTECTED]> + + * ControlGraphics.[Ch] (editGraphics): new method + 2004-04-07 Martin Vermeer <[EMAIL PROTECTED]> * ControlDocument.C: 'assign' for opening/closing branch insets Index: src/frontends/controllers/ControlGraphics.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/controllers/ControlGraphics.C,v retrieving revision 1.82 diff -u -p -r1.82 ControlGraphics.C --- src/frontends/controllers/ControlGraphics.C 2004/01/08 10:59:49 1.82 +++ src/frontends/controllers/ControlGraphics.C 2004/04/07 19:25:45 @@ -133,6 +133,16 @@ bool ControlGraphics::isFilenameValid(st } +void ControlGraphics::editGraphics() +{ + BOOST_ASSERT(params_.get()); + + dialog().view().apply(); + string const lfun = + InsetGraphicsMailer::params2string(params(), kernel().buffer()); + kernel().dispatch(FuncRequest(LFUN_GRAPHICS_EDIT, lfun)); +} + namespace frnt { namespace { Index: src/frontends/controllers/ControlGraphics.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/controllers/ControlGraphics.h,v retrieving revision 1.24 diff -u -p -r1.24 ControlGraphics.h --- src/frontends/controllers/ControlGraphics.h 2004/01/08 10:59:49 1.24 +++ src/frontends/controllers/ControlGraphics.h 2004/04/07 19:25:46 @@ -51,6 +51,8 @@ public: bool bbChanged; /// test if file exist bool isFilenameValid(std::string const & fname) const; + /// edit file + void editGraphics(); private: /// Index: src/frontends/qt2/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/ChangeLog,v retrieving revision 1.666 diff -u -p -r1.666 ChangeLog --- src/frontends/qt2/ChangeLog 2004/04/05 18:34:35 1.666 +++ src/frontends/qt2/ChangeLog 2004/04/07 19:25:58 @@ -1,3 +1,10 @@ +2004-04-07 Georg Baum <[EMAIL PROTECTED]> + + * QPrefsDialog.C, ui/QPrefFileformatsModule.ui: add editor to format + * QGraphics.[Ch]: add slotEdit() + * QGraphicsDialog.[Ch]: add edit_clicked() + * ui/QGraphicsDialogBase.ui: add Edit button + 2004-04-05 Angus Leeming <[EMAIL PROTECTED]> * Dialogs.C (build): set the preferences dialog button policy to Index: src/frontends/qt2/QGraphics.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QGraphics.C,v retrieving revision 1.43 diff -u -p -r1.43 QGraphics.C --- src/frontends/qt2/QGraphics.C 2004/04/05 14:05:02 1.43 +++ src/frontends/qt2/QGraphics.C 2004/04/07 19:25:59 @@ -414,3 +414,9 @@ bool QGraphics::isValid() { return !dialog_->filename->text().isEmpty(); } + + +void QGraphics::slotEdit() +{ + controller().editGraphics(); +} Index: src/frontends/qt2/QGraphics.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QGraphics.h,v retrieving revision 1.15 diff -u -p -r1.15 QGraphics.h --- src/frontends/qt2/QGraphics.h 2003/10/06 15:42:50 1.15 +++ src/frontends/qt2/QGraphics.h 2004/04/07 19:25:59 @@ -30,6 +30,8 @@ public: friend class QGraphicsDialog; /// QGraphics(Dialog &); +public slots: + void slotEdit(); protected: virtual bool isValid(); private: Index: src/frontends/qt2/QGraphicsDialog.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QGraphicsDialog.C,v retrieving revision 1.23 diff -u -p -r1.23 QGraphicsDialog.C --- src/frontends/qt2/QGraphicsDialog.C 2004/01/08 10:59:49 1.23 +++ src/frontends/qt2/QGraphicsDialog.C 2004/04/07 19:25:59 @@ -39,6 +39,8 @@ QGraphicsDialog::QGraphicsDialog(QGraphi form, SLOT(slotClose())); connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore())); + connect(editPB, SIGNAL(clicked()), + this, SLOT(edit_clicked())); } @@ -92,4 +94,11 @@ void QGraphicsDialog::browse_clicked() void QGraphicsDialog::getBB_clicked() { form_->getBB(); +} + + +void QGraphicsDialog::edit_clicked() +{ + form_->changed(); + form_->controller().editGraphics(); } Index: src/frontends/qt2/QGraphicsDialog.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QGraphicsDialog.h,v retrieving revision 1.11 diff -u -p -r1.11 QGraphicsDialog.h --- src/frontends/qt2/QGraphicsDialog.h 2003/09/07 01:45:38 1.11 +++ src/frontends/qt2/QGraphicsDialog.h 2004/04/07 19:25:59 @@ -30,6 +30,7 @@ protected slots: virtual void change_WUnit(); virtual void browse_clicked(); virtual void getBB_clicked(); + virtual void edit_clicked(); protected: virtual void closeEvent(QCloseEvent * e); private: Index: src/frontends/qt2/QPrefsDialog.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QPrefsDialog.C,v retrieving revision 1.32 diff -u -p -r1.32 QPrefsDialog.C --- src/frontends/qt2/QPrefsDialog.C 2004/03/31 16:50:58 1.32 +++ src/frontends/qt2/QPrefsDialog.C 2004/04/07 19:26:01 @@ -381,6 +381,7 @@ void QPrefsDialog::switch_format(int nr) fileformatsModule->extensionED->setText(toqstr(f.extension())); fileformatsModule->shortcutED->setText(toqstr(f.shortcut())); fileformatsModule->viewerED->setText(toqstr(f.viewer())); + fileformatsModule->editorED->setText(toqstr(f.editor())); fileformatsModule->formatRemovePB->setEnabled( !form_->converters().formatIsUsed(f.name())); } @@ -407,10 +408,12 @@ void QPrefsDialog::modify_format() string const extension = fromqstr(fileformatsModule->extensionED->text()); string const shortcut = fromqstr(fileformatsModule->shortcutED->text()); string const viewer = fromqstr(fileformatsModule->viewerED->text()); + string const editor = fromqstr(fileformatsModule->editorED->text()); form_->formats().add(name, extension, prettyname, shortcut); form_->formats().sort(); form_->formats().setViewer(name, viewer); + form_->formats().setEditor(name, editor); fileformatsModule->formatsLB->setUpdatesEnabled(false); updateFormats(); Index: src/frontends/qt2/ui/QGraphicsDialogBase.ui =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/ui/QGraphicsDialogBase.ui,v retrieving revision 1.5 diff -u -p -r1.5 QGraphicsDialogBase.ui --- src/frontends/qt2/ui/QGraphicsDialogBase.ui 2003/12/30 19:05:42 1.5 +++ src/frontends/qt2/ui/QGraphicsDialogBase.ui 2004/04/07 19:26:03 @@ -1117,6 +1117,25 @@ <bool>false</bool> </property> </widget> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>editPB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Edit</string> + </property> + <property stdset="1"> + <name>autoDefault</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>default</name> + <bool>false</bool> + </property> + </widget> <spacer> <property> <name>name</name> @@ -1455,6 +1474,7 @@ <tabstop>draftCB</tabstop> <tabstop>unzipCB</tabstop> <tabstop>restorePB</tabstop> + <tabstop>editPB</tabstop> <tabstop>okPB</tabstop> <tabstop>applyPB</tabstop> <tabstop>closePB</tabstop> Index: src/frontends/qt2/ui/QPrefFileformatsModule.ui =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/ui/QPrefFileformatsModule.ui,v retrieving revision 1.6 diff -u -p -r1.6 QPrefFileformatsModule.ui --- src/frontends/qt2/ui/QPrefFileformatsModule.ui 2003/03/28 01:21:42 1.6 +++ src/frontends/qt2/ui/QPrefFileformatsModule.ui 2004/04/07 19:26:04 @@ -159,6 +159,13 @@ <cstring>viewerED</cstring> </property> </widget> + <widget row="5" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>editorED</cstring> + </property> + </widget> <widget row="2" column="1" > <class>QLineEdit</class> <property stdset="1"> @@ -218,6 +225,21 @@ <cstring>viewerED</cstring> </property> </widget> + <widget row="5" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>editorLA</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Ed&itor:</string> + </property> + <property> + <name>buddy</name> + <cstring>editorED</cstring> + </property> + </widget> <widget row="0" column="1" > <class>QLineEdit</class> <property stdset="1"> @@ -347,5 +369,6 @@ <tabstop>shortcutED</tabstop> <tabstop>extensionED</tabstop> <tabstop>viewerED</tabstop> + <tabstop>editorED</tabstop> </tabstops> </UI> Index: src/frontends/xforms/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/ChangeLog,v retrieving revision 1.898 diff -u -p -r1.898 ChangeLog --- src/frontends/xforms/ChangeLog 2004/04/05 18:34:35 1.898 +++ src/frontends/xforms/ChangeLog 2004/04/07 19:26:26 @@ -1,3 +1,8 @@ +2004-04-07 Georg Baum <[EMAIL PROTECTED]> + + * FormPreferences.C, forms/form_preferences.fd: add editor to format + * FormGraphics.C, forms/form_graphics.fd: add Edit button + 2004-04-05 Angus Leeming <[EMAIL PROTECTED]> * Dialogs.C (build): set the preferences dialog button policy to Index: src/frontends/xforms/FormGraphics.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/FormGraphics.C,v retrieving revision 1.122 diff -u -p -r1.122 FormGraphics.C --- src/frontends/xforms/FormGraphics.C 2004/04/05 14:05:03 1.122 +++ src/frontends/xforms/FormGraphics.C 2004/04/07 19:26:28 @@ -642,7 +642,10 @@ ButtonPolicy::SMInput FormGraphics::inpu setEnabled(extra_->input_subcaption, fl_get_button(extra_->check_subcaption)); + } else if (ob == dialog_->button_edit) { + controller().editGraphics(); } + return ButtonPolicy::SMI_VALID; } Index: src/frontends/xforms/FormPreferences.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/FormPreferences.C,v retrieving revision 1.185 diff -u -p -r1.185 FormPreferences.C --- src/frontends/xforms/FormPreferences.C 2004/03/31 18:51:10 1.185 +++ src/frontends/xforms/FormPreferences.C 2004/04/07 19:26:33 @@ -996,6 +996,7 @@ void FormPreferences::Formats::build() fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED); + fl_set_input_return(dialog_->input_editor, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED); @@ -1010,6 +1011,7 @@ void FormPreferences::Formats::build() setPrehandler(dialog_->button_add); setPrehandler(dialog_->input_extension); setPrehandler(dialog_->input_viewer); + setPrehandler(dialog_->input_editor); setPrehandler(dialog_->input_shrtcut); } @@ -1036,6 +1038,9 @@ FormPreferences::Formats::feedback(FL_OB if (ob == dialog_->input_viewer) return _("The command used to launch the viewer application."); + if (ob == dialog_->input_editor) + return _("The command used to launch the editor application."); + if (ob == dialog_->button_delete) return _("Remove the current format from the list of available " "formats. Note: you must then \"Apply\" the change."); @@ -1062,7 +1067,8 @@ bool FormPreferences::Formats::input(FL_ || ob == dialog_->input_gui_name || ob == dialog_->input_shrtcut || ob == dialog_->input_extension - || ob == dialog_->input_viewer) + || ob == dialog_->input_viewer + || ob == dialog_->input_editor) return Input(); if (ob == dialog_->button_add) @@ -1109,11 +1115,13 @@ bool FormPreferences::Formats::Add() string const extension = fl_get_input(dialog_->input_extension); string const shortcut = fl_get_input(dialog_->input_shrtcut); string const viewer = fl_get_input(dialog_->input_viewer); + string const editor = fl_get_input(dialog_->input_editor); Format const * old = formats().getFormat(name); string const old_prettyname = old ? old->prettyname() : string(); formats().add(name, extension, prettyname, shortcut); formats().setViewer(name, viewer); + formats().setEditor(name, editor); if (!old || prettyname != old_prettyname) { UpdateBrowser(); if (old) @@ -1140,6 +1148,7 @@ bool FormPreferences::Formats::Browser() fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str()); fl_set_input(dialog_->input_extension, f.extension().c_str()); fl_set_input(dialog_->input_viewer, f.viewer().c_str()); + fl_set_input(dialog_->input_editor, f.editor().c_str()); fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str()); Index: src/frontends/xforms/forms/form_graphics.fd =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/forms/form_graphics.fd,v retrieving revision 1.44 diff -u -p -r1.44 form_graphics.fd --- src/frontends/xforms/forms/form_graphics.fd 2003/09/29 21:40:13 1.44 +++ src/frontends/xforms/forms/form_graphics.fd 2004/04/07 19:26:35 @@ -9,14 +9,14 @@ SnapGrid: 5 =============== FORM =============== Name: form_graphics -Width: 395 +Width: 490 Height: 300 -Number of Objects: 6 +Number of Objects: 7 -------------------- class: FL_BOX type: FLAT_BOX -box: 0 0 395 300 +box: 0 0 490 300 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -34,7 +34,7 @@ argument: -------------------- class: FL_TABFOLDER type: TOP_TABFOLDER -box: 0 5 395 260 +box: 0 5 490 260 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_TOP_LEFT @@ -69,8 +69,26 @@ argument: 0 -------------------- class: FL_BUTTON +type: NORMAL_BUTTON +box: 100 270 90 25 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Edit|#E +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NorthEast FL_NorthEast +name: button_edit +callback: C_FormDialogView_InputCB +argument: 0 + +-------------------- +class: FL_BUTTON type: RETURN_BUTTON -box: 110 270 90 25 +box: 205 270 90 25 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -88,7 +106,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 300 270 90 25 +box: 395 270 90 25 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -106,7 +124,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 205 270 90 25 +box: 300 270 90 25 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -123,14 +141,14 @@ argument: 0 =============== FORM =============== Name: form_graphics_file -Width: 395 +Width: 490 Height: 235 Number of Objects: 15 -------------------- class: FL_BOX type: FLAT_BOX -box: 0 0 395 235 +box: 0 0 490 235 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -148,7 +166,7 @@ argument: -------------------- class: FL_LABELFRAME type: ENGRAVED_FRAME -box: 5 125 385 105 +box: 5 125 480 105 boxtype: FL_NO_BOX colors: FL_BLACK FL_COL1 alignment: FL_ALIGN_TOP_LEFT @@ -166,7 +184,7 @@ argument: -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 60 10 225 25 +box: 60 10 320 25 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT @@ -184,7 +202,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 290 10 100 25 +box: 385 10 100 25 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -202,7 +220,7 @@ argument: 0 -------------------- class: FL_LABELFRAME type: ENGRAVED_FRAME -box: 5 55 385 55 +box: 5 55 480 55 boxtype: FL_NO_BOX colors: FL_BLACK FL_COL1 alignment: FL_ALIGN_TOP_LEFT @@ -399,14 +417,14 @@ argument: 0 =============== FORM =============== Name: form_graphics_bbox -Width: 395 +Width: 490 Height: 235 Number of Objects: 10 -------------------- class: FL_BOX type: FLAT_BOX -box: 0 0 395 235 +box: 0 0 490 235 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -585,14 +603,14 @@ argument: 0 =============== FORM =============== Name: form_graphics_extra -Width: 395 +Width: 490 Height: 235 Number of Objects: 8 -------------------- class: FL_BOX type: FLAT_BOX -box: 0 0 395 235 +box: 0 0 490 235 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER Index: src/frontends/xforms/forms/form_preferences.fd =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/forms/form_preferences.fd,v retrieving revision 1.65 diff -u -p -r1.65 form_preferences.fd --- src/frontends/xforms/forms/form_preferences.fd 2004/03/31 18:51:11 1.65 +++ src/frontends/xforms/forms/form_preferences.fd 2004/04/07 19:26:37 @@ -1705,13 +1705,13 @@ argument: =============== FORM =============== Name: form_preferences_formats Width: 450 -Height: 360 -Number of Objects: 9 +Height: 400 +Number of Objects: 10 -------------------- class: FL_BOX type: FLAT_BOX -box: 0 0 450 360 +box: 0 0 450 400 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -1835,9 +1835,27 @@ callback: C_FormDialogView_InputCB argument: 0 -------------------- +class: FL_INPUT +type: NORMAL_INPUT +box: 280 230 150 30 +boxtype: FL_DOWN_BOX +colors: FL_COL1 FL_MCOL +alignment: FL_ALIGN_LEFT +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Editor:|#i +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: input_editor +callback: C_FormDialogView_InputCB +argument: 0 + +-------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 240 270 90 30 +box: 240 300 90 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -1855,7 +1873,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 340 270 90 30 +box: 340 300 90 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER Index: src/insets/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/ChangeLog,v retrieving revision 1.998 diff -u -p -r1.998 ChangeLog --- src/insets/ChangeLog 2004/04/07 09:25:30 1.998 +++ src/insets/ChangeLog 2004/04/07 19:26:57 @@ -1,3 +1,8 @@ +2004-04-07 Georg Baum <[EMAIL PROTECTED]> + + * insetgraphics.C: handle LFUN_GRAPHICS_EDIT + * insetgraphics.C: add editGraphics() + 2004-04-07 Angus Leeming <[EMAIL PROTECTED]> * insetexternal.C (priv_dispatch): Index: src/insets/insetgraphics.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insetgraphics.C,v retrieving revision 1.241 diff -u -p -r1.241 insetgraphics.C --- src/insets/insetgraphics.C 2004/04/05 11:59:14 1.241 +++ src/insets/insetgraphics.C 2004/04/07 19:27:04 @@ -190,6 +186,14 @@ void InsetGraphics::statusChanged() cons void InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest & cmd) { switch (cmd.action) { + case LFUN_GRAPHICS_EDIT: { + Buffer const & buffer = *cur.bv().buffer(); + InsetGraphicsParams p; + InsetGraphicsMailer::string2params(cmd.argument, buffer, p); + editGraphics(p, buffer); + break; + } + case LFUN_INSET_MODIFY: { Buffer const & buffer = *cur.bv().buffer(); InsetGraphicsParams p; @@ -689,6 +693,13 @@ bool InsetGraphics::setParams(InsetGraph InsetGraphicsParams const & InsetGraphics::params() const { return params_; +} + + +void InsetGraphics::editGraphics(InsetGraphicsParams const & p, Buffer const & buffer) const +{ + string const file_with_path = p.filename.absFilename(); + formats.edit(buffer, file_with_path, getExtFromContents(file_with_path)); } Index: src/insets/insetgraphics.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insetgraphics.h,v retrieving revision 1.96 diff -u -p -r1.96 insetgraphics.h --- src/insets/insetgraphics.h 2004/03/18 12:53:39 1.96 +++ src/insets/insetgraphics.h 2004/04/07 19:27:05 @@ -79,6 +79,8 @@ public: void draw(PainterInfo & pi, int x, int y) const; /// void edit(LCursor & cur, bool left); + /// + void editGraphics(InsetGraphicsParams const &, Buffer const &) const; protected: /// void priv_dispatch(LCursor & cur, FuncRequest & cmd);