xboard-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XBoard-devel] Opening pgn files in xboard


From: Byrial Jensen
Subject: Re: [XBoard-devel] Opening pgn files in xboard
Date: Fri, 30 Dec 2011 17:41:00 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111109 Thunderbird/3.1.16

Den 30-12-2011 12:58, h.g. muller wrote:

Hi,

I will try to answer all this question by question.

For starters, the mime type application/x-chess-pgn was already defined,
but it was associated with some primitive chess-viewer application.

You cannot do anything about that. If several programs handle the same MIME type, it is up to the user to choose by some system dependent means.

And
as I noticed that the .xml mime-type file also specifies the icon, and I
did not like the text-x-generic icon for PGN files, I tried to change
that first. But icons seem to be scattered all over the place. I looked
in /usr/share/icons/hicolor/*/mimetypes, but I could not find the
text-x-generic there. Finally I found something in
/usr/share/icons/gnome, and copied our xboard.svg to the
'scalable/mimetypes' subdirectory, and specified that for the
x-chess-pgn mimetype, but it did not alter the icons displayed for PGN
files in the file explorer.

Well, I did not treat icons in the winboard forum, because it was not asked for.

Icons must be png, xpm or svg files, although support for svg is optional. Png is the recommended file type.

Common sizes are 16x16, 22x22, 32x32, 48x48, 64x64, 128,128

If a required size isn't available, the icons can be resized, but the result will not always be pleasant. We should at least have 48x48 icons. 32x32 + scaleable svg icons would also be fine.

/usr/share/icons/hicolor/*/mimetypes would be the right directories for a system wide installation, however you normally don't install directly into these, but install with the xdg-icon-resource program. It is more likely to get it right, and it will make sure to update whatever indexes/caches there are.

Then the naming. The xml-file for a mimetype doesn't specify the filepath(s) to an icon, but names. The default icon name for a mimetype is based on the type ("application-x-chess-pgn" for application/x-chess-pgn). The icon file will then be sought for based on the icon name, the current icon theme, and the required size. If nothing is found, the generic icon name will be used instead.

So my first question is: how can I install new icons, and associate
those to mime types?

In the xml-file for a mimetype you specify for instance <icon name="chess"/>, and then install an icon with the name "chess" with:

$ xdg-icon-resource install --context mimetypes --size 48 /path/to/icon/file/xboard.png chess

Run xdg-icon-resource once for each iconfile you want installed.

Now I don't only want to do this for PGN files, but also for FEN an TRN.
Can I do that in a single xboard.xml file, by multiplying the
<mime-type> block?

Yes.

> I did find an xml file for the x-chess-pgn type on my
system (I think it was in /usr/share/mime), and it roughly looked like
you described, except that there were zillions of internationalized
versions of the 'Comment' line, and that the <mime-info> and <mime-type>
tags seemed to be combined into one. I guess if we create an xboard.xml
for distribution with xboard, we best copy all those messages into it as
well.

We could do that. We can also move the comment field to our pot-file, and move translations back from the po-files. GNU gettext doesn't support XML files and desktop files, but GNU intltool does.

Now there seems to exist an application/x-chess-fen mime type, although
I got only a single hit for it with Google (and the actual page to which
it brought me did not contain is...). But I am pretty sure there is
nothing for TRN, as this extension I cooked up myself. So the question
is, do these mime-types referred to from the xml file have to be
officially existing, or can I take an arbitrary identifier for them (say
application/x-game-tourney)?

All subtypes (the subtype is the part after the slash) starting with x- are unofficial and may be made by everyone.

The XBoard tourney files are easily
recognized by content, which always starts with '-participants {'. I
could not think of a pattern to recognize FENs, so I guess that we
should simply drop this <magic> block for the x-chess-fen mime type?

It is not required to have any magic tags.

But does any other programs use FEN-files and are they really needed? I mean isn't it better to put a FEN position into a PGN-file where you do have metadata to tell which game the position is taken from?

As to the desktop file. We seem to already have an xboard.desktop file
in our source tree, but it is for a bare "xboard" command (i.e. it
starts up in engine mode, with fairymax). Do I understand correctly that
we would have to create several .desktop files of different names, like
pgnviewer.desktop, fenviewer.desktop, chesstourney.desktop, only
differing in the Exec line, MimeType and Comment?

Yes. The desktop files for mimetype association should also have a "NoDisplay=true" line which means that no menu entry will be made from the desktop file.

(And what exactly is
the function of the name field?)

It is the name of program. It may be translated to the user's language, like also the GenericName and Comment lines. The content of these 3 lines should not be redundant. It could for example be:

Name=XBoard
GenericName=Chess Board
Comment=Play against an engine or on an internet server, or view PGN. Many chess variants are supported.

- Byrial



reply via email to

[Prev in Thread] Current Thread [Next in Thread]