Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-18 Thread Guenter Milde
On 2017-01-14, Paul A. Rubin wrote:

...

> Is there any evidence that xdg-mime/xdg-open will ever be safe?

Not bullet-proof but maybe safe enaugh to be used as default.

+1 in a properly configured system, the system-wide user preference will be
   honoured, no need to configure preferences for both, xdg and lyx.
   
-1 the "xdg-preference" may be worse than what LyX currently uses (at least
   for the moment this is a real problem).

> Right now I see two problems with it, one of which can be avoided. The 
> original show-stopper was that it defaulted to opening files in the web
> browser if no default application was set. We can work around that by 
> using xdg-mime to test whether a default is set in the MIME database.
> If yes, we can make xdg-open the file handler; if not, we can do what
> we currently do.

Or we can use the default returned by xdg-mime as first choice and keep
our list of fallbacks.


> The bigger problem, in my mind, is that xdg-mime sometimes finds a 
> default application, but not the one actually used by the system. I 
> mentioned this in an earlier message, after stumbling on it 
> accidentally. I found xdg-open using a "stale" default from 
> ~/.local/share/applications/mimeapps.list when the correct default was 
> set in ~/.config/mimeapps.list.
...
> In any case, unless my laptop is an outlier, there may be users out
> there for whom xdg-utils would select not the browser but some other
> incorrect (and, in one case on my laptop, not even installed)
> application.

This is one of the things that hopefully will settle over time.
Users/distros removing the stale files, maybe xdg-* excluding or
downgrading the stale files if the correct ones are present, 
applications no longer using obsolete paths and properly cleaning up when
de-installed, ...


> Rather than waiting on xdg-utils to be fixed (if in fact Freedesktop 
> even sees this as a bug -- I have no idea about that), should we look at 
> gvfs-mime/gvfs-open (again with the stipulation that we first check 
> whether a default application is set, and if not revert to our current 
> practice)? It works on both my systems, but they're both running recent 
> (albeit different) versions of Linux Mint. If we move in this direction, 
> I think we should first ask devs with other Linux distributions to test 
> it (which can be done with a simple shell script).

I had the impression that gvfs-mime is (or should be) superseded by
xdg-mime, so I would not propose to invest in this direction.

The MINT problem is now fixed with simpler changes.


> Incidentally, for people ill served by the configuration script, one way 
> to reduce the pain would be to add something in the Tools > 
> Preferences... dialogs that would allow the user, in one step, to set a 
> new default viewer or editor for all file formats of a certain ilk (all 
> PDF formats, all text formats, all image formats). Having to change the 
> viewer for PDF (pdflatex) every time I reconfigure is mildly annoying; 
> having to change it for multiple PDF formats after each reconfiguration 
> is serious annoying.

Indeed, GUI support to change the viewer/editor "file-type wise" would be
a real advantage. The different sub-formats (pdf1...5 etc) are just an
internal way to specify the different export routes.

Thanks for the suggestions,

Günter



Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-16 Thread Paul A. Rubin

On 01/16/2017 04:28 AM, Pavel Sanda wrote:


Guenter put X-Apps into configure script, so my understanding is that
MINT should be covered now.

Pavel

Great! Thanks to all.

Paul


Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-16 Thread Pavel Sanda
Paul A. Rubin wrote:
> As far as standing pat, I can testify that this represents a PITA for Mint 
> users once they upgrade to 18.1 (or maybe 18.0), because the X-Apps are not 
> recognized and, depending on what else they have installed, they can end up 
> with no viewers or gimp and notepad (WINE) as viewers. I have no idea 
> whether any other distributions are going to move to X-Apps, so it may only 
> be Mint users that are affected.

Guenter put X-Apps into configure script, so my understanding is that 
MINT should be covered now.

Pavel


Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-14 Thread Paul A. Rubin

On 01/14/2017 06:01 AM, Guenter Milde wrote:

On 2017-01-14, Pavel Sanda wrote:

Guenter Milde wrote:

A more general question to all developers:
When checking for default viewer/editor applications during (re)configure,
should LyX
a) prefer feature rich applications, or
b) prefer small and fast-starting applications.

As I don't see any obvious choice I would prefer
c) don't mess with the order unless something really buggy starts appearing
(not so much because I believe the current order is right, but rather
not to disturb people who are used to the current situation).

Yes, this is my conclusion as well.
We should put this off until xdg-mime is safe to use.

Günter

Is there any evidence that xdg-mime/xdg-open will ever be safe? Right 
now I see two problems with it, one of which can be avoided. The 
original show-stopper was that it defaulted to opening files in the web 
browser if no default application was set. We can work around that by 
using xdg-mime to test whether a default is set in the MIME database. If 
yes, we can make xdg-open the file handler; if not, we can do what we 
currently do.


The bigger problem, in my mind, is that xdg-mime sometimes finds a 
default application, but not the one actually used by the system. I 
mentioned this in an earlier message, after stumbling on it 
accidentally. I found xdg-open using a "stale" default from 
~/.local/share/applications/mimeapps.list when the correct default was 
set in ~/.config/mimeapps.list. I haven't been able to locate any 
official document on the Freedesktop web site specifically naming the 
hierarchy of MIME database files, and I don't know enough to know 
whether ~/.config/mimeapps.list results from some applications not using 
the Freedesktop spec, or whether xdg is supposed to check that first but 
for some reason does not. In any case, unless my laptop is an outlier, 
there may be users out there for whom xdg-utils would select not the 
browser but some other incorrect (and, in one case on my laptop, not 
even installed) application.


Rather than waiting on xdg-utils to be fixed (if in fact Freedesktop 
even sees this as a bug -- I have no idea about that), should we look at 
gvfs-mime/gvfs-open (again with the stipulation that we first check 
whether a default application is set, and if not revert to our current 
practice)? It works on both my systems, but they're both running recent 
(albeit different) versions of Linux Mint. If we move in this direction, 
I think we should first ask devs with other Linux distributions to test 
it (which can be done with a simple shell script).


As far as standing pat, I can testify that this represents a PITA for 
Mint users once they upgrade to 18.1 (or maybe 18.0), because the X-Apps 
are not recognized and, depending on what else they have installed, they 
can end up with no viewers or gimp and notepad (WINE) as viewers. I have 
no idea whether any other distributions are going to move to X-Apps, so 
it may only be Mint users that are affected.


Incidentally, for people ill served by the configuration script, one way 
to reduce the pain would be to add something in the Tools > 
Preferences... dialogs that would allow the user, in one step, to set a 
new default viewer or editor for all file formats of a certain ilk (all 
PDF formats, all text formats, all image formats). Having to change the 
viewer for PDF (pdflatex) every time I reconfigure is mildly annoying; 
having to change it for multiple PDF formats after each reconfiguration 
is serious annoying.


One other thought came to mind: /if/ this is actually only a problem for 
Mint users, we could perhaps stick with the current configuration script 
and provide a separate configuration script that Mint users could 
download and install over the one that comes with the LyX package. 
That's essentially the workaround I'm using now.


Paul



Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-14 Thread Guenter Milde
On 2017-01-14, Pavel Sanda wrote:
> Guenter Milde wrote:
>> A more general question to all developers:

>> When checking for default viewer/editor applications during (re)configure,
>> should LyX

>> a) prefer feature rich applications, or
>> b) prefer small and fast-starting applications.

> As I don't see any obvious choice I would prefer
> c) don't mess with the order unless something really buggy starts appearing
>(not so much because I believe the current order is right, but rather
>not to disturb people who are used to the current situation).

Yes, this is my conclusion as well.
We should put this off until xdg-mime is safe to use.

Günter



Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-13 Thread Pavel Sanda
Paul A. Rubin wrote:
> I don't know why Linux distributions store MIME associations in so many 
> different places, but in any event we apparently can't count on xdg-mime to 
> find the correct associations, and there is no painless way for a user to 
> fix that (at least none that I can find). My laptop has a MIME type editor, 

:) Welcome. I believe the (currently) correct way is to push your distro
to fix MIME config and if xdg works fine on top of that then push
the distro maintainer of lyx to patch lyx with xdg-open in configure.py.
This used to be the case with debian, where mime machinery seemed to work (tm).

Fundamentally you are having much deeper request - to unify how mime and
associations are handled across the desktop managers and distributions.

I will be happy to be proved wrong (haven't actually re-checked that for years)
but all this file extension association business was heterogenous across
different desktop managers and linux distributions as well. 
If that still applies then your original request is very hard to get right,
because after you spend weeks of research of the problems and possible
approaches you end up with code which will do something very similar to
xdg-utils. 

Pavel


Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-13 Thread Pavel Sanda
Guenter Milde wrote:
> A more general question to all developers:
> 
> When checking for default viewer/editor applications during (re)configure,
> should LyX
>   
> a) prefer feature rich applications, or
> b) prefer small and fast-starting applications.

As I don't see any obvious choice I would prefer
c) don't mess with the order unless something really buggy starts appearing
   (not so much because I believe the current order is right, but rather
   not to disturb people who are used to the current situation).

Pavel


Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-13 Thread Paul A. Rubin

On 01/13/2017 09:19 AM, Guenter Milde wrote:

IMV, using xdg-mime query seems the right way but not easy.
Maybe you can open an enhancement ticket.


tl;dr

I'm now having second thoughts about it. I discovered xdg-mime returns 
incorrect information on my laptop (including naming applications that 
are no longer installed). As noted here 
, the problem seems 
to be that xdg-utils programs focus on 
~/.local/share/applications/mimeapps.list and ignore 
~/.config/mimeapps.list (which I think is supposed to take precedence).


I don't know why Linux distributions store MIME associations in so many 
different places, but in any event we apparently can't count on xdg-mime 
to find the correct associations, and there is no painless way for a 
user to fix that (at least none that I can find). My laptop has a MIME 
type editor, but it shows the correct associations (presumably meaning 
those in ~/.config) and has no provision for tracking down and deleting 
associations in other obscure locations.


There's an alternative to xdg-open, namely gvfs-open, that seems to do a 
better job of reading the correct MIME association list. Unfortunately, 
where xdg-open defaults to Firefox (or whatever the default browser is?) 
on an unrecognized file type, gvfs-open on my PC tried to open a binary 
file (proprietary format, no MIME association) with Libre Office, which 
expectedly did not go well. So I'm hesitant to suggest setting gvfs-open 
as the default for unknown MIME types.


A possibility is to have the script run 'gvfs-mime --query ' 
and extract the default program from the first line of the return value 
(or ascertain that no default is set). Given the way xdg-mime blew up in 
my face, though, I'd like to hear from others before making a formal 
recommendation. In particular, since both my systems run Linux Mint, I 
have no idea how ubiquitous gvfs-mime is in other distributions.


Paul


Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-13 Thread Guenter Milde
On 2017-01-13, Paul A. Rubin wrote:
> On 01/13/2017 03:27 AM, Guenter Milde wrote:
>> A more general question to all developers:

>> When checking for default viewer/editor applications during (re)configure,
>> should LyX

>> a) prefer feature rich applications, or
>> b) prefer small and fast-starting applications.
...

> [...] what I would prefer is that my system default choices be used 
> (which circles back to the xdg-open problem). Can a Python script 
> "easily" obtain MIME settings from the environment?

The hard part is to get it in a way everyone is satisfied with.

> Assuming that the xdg-utils package is installed, the shell command 
> 'xdg-mime query default application/pdf' will return the default 
> application (if one is set) for PDF files. On my system, the return 
> value is 'xreader.desktop'. Unfortunately, for 'text/plain' the result 
> is the somewhat less easily interpreted 'userapp-xed-07V7SY.desktop' 
> (where xed is the correct answer -- no idea why it's so unclear). 

Here, I get "wine-extension-txt.desktop" (although better alternatives like
leafpad are installed), which is not what I want.

> For 'image/jpeg' and 'image/png' the default is 'xviewer.desktop'. When
> no default is set (as is the case for 'image/svg' on my system), the 
> xdg-mime query returns nothing.

IMV, using xdg-mime query seems the right way but not easy.
Maybe you can open an enhancement ticket.

Günter



Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-13 Thread Stephan Witt
Am 13.01.2017 um 14:32 schrieb Paul A. Rubin :
> 
> On 01/13/2017 03:27 AM, Guenter Milde wrote:
>> A more general question to all developers:
>> 
>> When checking for default viewer/editor applications during (re)configure,
>> should LyX
>>   a) prefer feature rich applications, or
>> b) prefer small and fast-starting applications.
>> 
>> Current praxis seems to be:
>>   1. KDE/QT applications
>>   2. GNOME/GTK applications
>>   3. Windows
>> and in these categories a) feature rich apps first.
>> 
>> I prefer "small first", but not so much that I would change
>> anything without a broad consensus.
>> 
>> 
> I think I would lean to fast-starting (not necessarily small footprint),

+1

> but really what I would prefer is that my system default choices be used 
> (which circles back to the xdg-open problem).

+1

> Can a Python script "easily" obtain MIME settings from the environment?
> 
> Assuming that the xdg-utils package is installed, the shell command 'xdg-mime 
> query default application/pdf' will return the default application (if one is 
> set) for PDF files. On my system, the return value is 'xreader.desktop'. 
> Unfortunately, for 'text/plain' the result is the somewhat less easily 
> interpreted 'userapp-xed-07V7SY.desktop' (where xed is the correct answer -- 
> no idea why it's so unclear). For 'image/jpeg' and 'image/png' the default is 
> 'xviewer.desktop'. When no default is set (as is the case for 'image/svg' on 
> my system), the xdg-mime query returns nothing.
> 
> If the configuration script started out by checking for default choices, and 
> honoring those it finds, I wouldn't worry too much about the order of the 
> options when it falls back to looking for installed applications for those 
> where no default is set.
> 
> Paul
> 



Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-13 Thread Joel Kulesza
On Fri, Jan 13, 2017 at 1:27 AM, Guenter Milde  wrote:

>
> A more general question to all developers:
>
> When checking for default viewer/editor applications during (re)configure,
> should LyX
>
> a) prefer feature rich applications, or
> b) prefer small and fast-starting applications.
>

I don't regard myself as much of a developer, but my opinion would be for
small/fast.


Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-13 Thread Paul A. Rubin

On 01/13/2017 03:27 AM, Guenter Milde wrote:

A more general question to all developers:

When checking for default viewer/editor applications during (re)configure,
should LyX
   
a) prefer feature rich applications, or

b) prefer small and fast-starting applications.

Current praxis seems to be:
   1. KDE/QT applications
   2. GNOME/GTK applications
   3. Windows
and in these categories a) feature rich apps first.

I prefer "small first", but not so much that I would change
anything without a broad consensus.


I think I would lean to fast-starting (not necessarily small footprint), 
but really what I would prefer is that my system default choices be used 
(which circles back to the xdg-open problem). Can a Python script 
"easily" obtain MIME settings from the environment?


Assuming that the xdg-utils package is installed, the shell command 
'xdg-mime query default application/pdf' will return the default 
application (if one is set) for PDF files. On my system, the return 
value is 'xreader.desktop'. Unfortunately, for 'text/plain' the result 
is the somewhat less easily interpreted 'userapp-xed-07V7SY.desktop' 
(where xed is the correct answer -- no idea why it's so unclear). For 
'image/jpeg' and 'image/png' the default is 'xviewer.desktop'. When no 
default is set (as is the case for 'image/svg' on my system), the 
xdg-mime query returns nothing.


If the configuration script started out by checking for default choices, 
and honoring those it finds, I wouldn't worry too much about the order 
of the options when it falls back to looking for installed applications 
for those where no default is set.


Paul



Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-13 Thread Guenter Milde
On 2017-01-12, Scott Kostyshak wrote:
> On Thu, Jan 12, 2017 at 04:08:18PM +0100, Günter Milde wrote:
>> commit 8e65250110cc0003b370c71e27c5713b8051ac0e
...
>> * Under Linux, notepad comes with the Windows emulator "wine"
>> but it is not a good choice for the default text editor.

> If I remember correctly from long ago, notepad is not even a good choice
> for Windows. It had problems simply with figuring out where linebreaks
> were. I remember wordpad being a better choice.
...

I would leave the organization of Windows default applications to the
Windows-using developers.


A more general question to all developers:

When checking for default viewer/editor applications during (re)configure,
should LyX
  
a) prefer feature rich applications, or
b) prefer small and fast-starting applications.

Current praxis seems to be:
  1. KDE/QT applications
  2. GNOME/GTK applications
  3. Windows
and in these categories a) feature rich apps first.

I prefer "small first", but not so much that I would change
anything without a broad consensus.

Günter



Re: [LyX/master] configure.py: Make 'notepad' last in text editor list

2017-01-12 Thread Scott Kostyshak
On Thu, Jan 12, 2017 at 04:08:18PM +0100, Günter Milde wrote:
> commit 8e65250110cc0003b370c71e27c5713b8051ac0e
> Author: Günter Milde 
> Date:   Thu Jan 12 15:35:24 2017 +0100
> 
> configure.py: Make 'notepad' last in text editor list
> 
> Place "notepad" at the end of the text editor selection list.
> 
> * Under Linux, notepad comes with the Windows emulator "wine"
> but it is not a good choice for the default text editor.

If I remember correctly from long ago, notepad is not even a good choice
for Windows. It had problems simply with figuring out where linebreaks
were. I remember wordpad being a better choice. Has notepad gotten better
with that in the last decade?

(I do recognize that you did not add notepad to the list, you are just
reorganizing, but I didn't want to start a separate topic)

Scott


signature.asc
Description: PGP signature