To me it seems that this could be a great job for an external launcher utility 
or an operating system service, but not a feature that LyX should be 
responsible for. I guess Nautilus proves this point. Sorry to be so 
conservative about this, but for LyX to start shipping binary template files of 
a myriad other programs seems the wrong approach (not to mention all those 
hard-coded file extensions). 

How about creating a separate launcher application with all those templates and 
the mechanism for recognizing extensions. The user could (optionally) install 
it separately from LyX, and its presence could be detected by LyX at 
reconfigure time. Then at least one would have decoupled updating and 
development of LyX and this launcher application. 

I would imagine the following solution (probably needs corrections):

(a)
In the Graphics Insert dialog, the option to create a new file from a filename 
that doesn't point to an existing file would appear if the launcher application 
is also installed. 

(b)
Then, if the user says "Yes, create a new file", LyX would send that filename 
(including absolute path) to the launcher application.

(c) 
The launcher application receives the filename, decides which external program 
to launch and which template to use. When it gets the result, it moves that to 
the specified filename at the specified absolute path. 

(d)
Finally, the launcher application sends the confirmation back to LyX, through 
the lyxpipe.in mechanism. Upon receiving this, if there was no error, LyX 
inserts the newly created file. 

So LyX only needs to implement the functionality to call the launcher 
application, and to receive the confirmation message in lyxpipe.in
The rest of the "dirty work" is done in the launcher application. This has the 
additional advantage that the launcher application could then potentially be 
re-used in other programs, depending on the creativity of the developer. All 
the customization you speak of could then be done in a directory outside of LyX 
responsibility.

Jens

On Jul 29, 2011, at 7:42 PM, Tommaso Cucinotta wrote:

> Il 29/07/2011 11:04, Pavel Sanda ha scritto:
>> Tommaso Cucinotta wrote:
>>> I'd like to gather comments on this, whether it may be acceptable for the
>> for the technical part i feel uncomfortable the we should ship bunch of
>> empty binaries file and need to manage proper versions of them. if have
>> older version of third party app which doesn't load it well? if the 
>> conversion
>> from older version has glitches? and so on...
> 
> I understand your concerns, that's why I was also proposing to have
> maybe more versions of the same empty file type, corresponding to
> different versions of the file-format (and corresponding application),
> in order to be more compatible with possible old applications installed
> on a system.
> 
> However, even without this addition, this feature would still be useful
> and work most of the times, and perhaps some times fail in creating
> a proper new file. In such a case the user can:
> -) go with the traditional LyX workflow, i.e., launch the external app
>   independently, save the file to the proper place, then include it
>   in the LyX doc
> -) customise LyX so as to have his/her own empty templates in the
>    .lyx/samples/ folder, which are matching the type and version of
>    the application he/she is using and so that would work 100% of
>    the times.
> 
> On a related note, I just checked how it works on Nautilus (Gnome
> [right-click]->[Create Document] feature). There, the user is supposed
> to have a "$HOME/Templates" folder in which he/she places the
> template files to be used, then they show up in the right-click menu
> (so the whole feature relies on the user making an explicit configuration
> option -- that folder is normally empty).
> 
> Also, on KDE, I found this package: "Create-New-OpenOffice.org-Document",
> which "contains templates and context menu entries for KDE and 
> OpenOffice.org3.
> Now you can right click in file manager or desktop and generate a new file."
> 
> So, there seems to be a common need across different applications for
> creating new files from existing templates. Shipping each application distro
> with an empty file in a well-known folder such as /usr/share/templates
> would solve this problem, but unfortunately it doesn't happen.
> 
> Still, the easiest thing to do seems to be shipping a few binary files (e.g.,
> one per supported file-format) with LyX itself.
> 
>    T.
> 

Reply via email to