kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #24725
[PATCH] Cleanup and fixes in the Linux desktop integration files
Patch 1: Fix resources/linux/mime/mime/packages/kicad.xml by changing
the extension to .kicad_pcb (was set to .brd which is the old one),
the mimetype name itself is corrected to "application/x-kicad-pcb" to
agree with the .application files. It also renames the package to
kicad-kicad.xml to conform to the XDG convention that calls for a
vendor-product.xml format [1]
Patch 2: Remove the resources/linux/mime/mimelnk folder. mimelnk
hasn't been used since KDE 3, If someone is still using bleeding edge
KiCad and KDE3 together they are used to patching things, so
maintaining those files themselves shouldn't be too much to ask.
Patch 3: Clean up the applications/*.destop files. Put all keys in
consistent order and remove/fix bogus mime types, some assigned to
programs that don't even open files. Those files could use some TLC
from translators and people better at words than me to improve the
wording and provide translated names and tooltips, i preserved some of
the french that was already in the files.
Patch 4: Fix hicolor icons. This renames (well, actually regenerates
from the originals) all the icons installed on Linux to match the
correct mime type names, and adds all the missing icons in some sizes.
This is not a diff because it's mostly binaries, I prepared a tarball
with the new contents of the resources/linux/mime/icons folder, to
apply just delete that directory and unzip patch-4.tar.gz in it's
place.
To generate the new icons directory I put together a very hackish
python script called mk_icons.py which must be called from
resources/linux/mime. the script reads the .application files and the
kicad-kicad.xml mime package file, reconciles mime types and
application icons and generates the right icons for the applications
and mimetypes from the originals in bitmaps_png/sources. It also warns
if the xml and .application files go out of sync.
I tested these changes on Debian Testing with Gnome3 and they work
perfectly, I can open kicad files from nautilus directly after doing a
make install and update-mime. If someone could give this a try on
other Linux distros it'd be great. Worst case i don't think it'd work
worse than before.
Thanks!
José
diff --git a/resources/linux/mime/mime/packages/kicad.xml b/resources/linux/mime/mime/packages/kicad-kicad.xml
index 3b945dd..0c3e024 100644
--- a/resources/linux/mime/mime/packages/kicad.xml
+++ b/resources/linux/mime/mime/packages/kicad-kicad.xml
@@ -12,10 +12,10 @@
<comment xml:lang="fr">Schéma électronique KiCad</comment>
<glob pattern="*.sch"/>
</mime-type>
- <mime-type type="application/x-kicad-pcbnew">
+ <mime-type type="application/x-kicad-pcb">
<sub-class-of type="text/plain"/>
- <comment>KiCad PCB</comment>
+ <comment>KiCad Printed Circuit Board</comment>
<comment xml:lang="fr">Circuit imprimé KiCad</comment>
- <glob pattern="*.brd"/>
+ <glob pattern="*.kicad_pcb"/>
</mime-type>
</mime-info>
diff --git a/resources/linux/mime/mimelnk/application/x-kicad-pcb.desktop /dev/null
old mode 100644
new mode 0
index 7a5afb8..0000000 0
--- a/resources/linux/mime/mimelnk/application/x-kicad-pcb.desktop
+++ /dev/null
@@ -1,8 +1,0 @@
-[Desktop Entry]
-Type=MimeType
-MimeType=application/x-kicad-pcb
-Icon=pcbnew
-Patterns=*.kicad_pcb
-
-Comment=KiCad Printed Circuit Board
-#Comment[fr]=Schéma électronique KiCad
diff --git a/resources/linux/mime/mimelnk/application/x-kicad-project.desktop /dev/null
old mode 100644
new mode 0
index bdae413..0000000 0
--- a/resources/linux/mime/mimelnk/application/x-kicad-project.desktop
+++ /dev/null
@@ -1,7 +1,0 @@
-[Desktop Entry]
-Type=MimeType
-MimeType=application/x-kicad-project
-Icon=kicad
-Patterns=*.pro
-Comment=KiCad Project
-Comment[fr]=Projet KiCad
diff --git a/resources/linux/mime/mimelnk/application/x-kicad-schematic.desktop /dev/null
old mode 100644
new mode 0
index f34abc3..0000000 0
--- a/resources/linux/mime/mimelnk/application/x-kicad-schematic.desktop
+++ /dev/null
@@ -1,7 +1,0 @@
-[Desktop Entry]
-Type=MimeType
-MimeType=application/x-kicad-schematic
-Icon=eeschema
-Patterns=*.sch
-Comment=KiCad Schematic
-Comment[fr]=Schéma électronique KiCad
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f077de3..7ff5219 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -721,16 +721,9 @@
# Set paths
set( UNIX_MIME_DIR resources/linux/mime )
- set( UNIX_MIMELNK_FILES ${UNIX_MIME_DIR}/mimelnk )
set( UNIX_MIME_FILES ${UNIX_MIME_DIR}/mime )
set( UNIX_ICON_FILES ${UNIX_MIME_DIR}/icons )
set( UNIX_APPLICATIONS_FILES ${UNIX_MIME_DIR}/applications )
-
- # Install Mimelnk directory
- install( DIRECTORY ${UNIX_MIMELNK_FILES}
- DESTINATION ${CMAKE_INSTALL_PREFIX}/share
- COMPONENT resources
- )
# Install Mime directory
install( DIRECTORY ${UNIX_ICON_FILES}
diff --git a/resources/linux/mime/applications/bitmap2component.desktop b/resources/linux/mime/applications/bitmap2component.desktop
index f2ff024..9426fde 100644
--- a/resources/linux/mime/applications/bitmap2component.desktop
+++ b/resources/linux/mime/applications/bitmap2component.desktop
@@ -1,10 +1,10 @@
[Desktop Entry]
+Version=1.0
+Terminal=false
+Icon=bitmap2component
+Type=Application
Categories=Development;Electronics;
+Exec=bitmap2component
+Name=Bitmap to Component Converter
+GenericName=Bitmap to Component Converter
Comment=Create a component from a bitmap for use with KiCad
-Exec=bitmap2component
-GenericName=EDA Suite
-Icon=bitmap2component
-MimeType=application/x-bitmap2component-project;
-Name=Bitmap to Component Converter
-Type=Application
-Name[en_US]=Bitmap to Component Converter
diff --git a/resources/linux/mime/applications/eeschema.desktop b/resources/linux/mime/applications/eeschema.desktop
index 41b1ba3..b0d0c14 100644
--- a/resources/linux/mime/applications/eeschema.desktop
+++ b/resources/linux/mime/applications/eeschema.desktop
@@ -1,11 +1,13 @@
[Desktop Entry]
+Version=1.0
+Terminal=false
+Icon=eeschema
+Type=Application
Categories=Development;Electronics;
-Comment=Design an electronic schematic
-Comment[fr]=Dessiner des schémas électroniques
Exec=eeschema %f
-GenericName=Electronic schematic design
+MimeType=application/x-kicad-schematic;
+Name=Eeschema (Standalone)
+GenericName=Electronic schematic capture
GenericName[fr]=Saisie de schéma électronique
-Icon=eeschema
-MimeType=application/x-eeschema-schematic;
-Name=Eeschema
-Type=Application
+Comment=Design an electronic schematic (Standalone)
+Comment[fr]=Dessiner des schémas électroniques (Standalone)
diff --git a/resources/linux/mime/applications/gerbview.desktop b/resources/linux/mime/applications/gerbview.desktop
index 42e3a83..289915c 100644
--- a/resources/linux/mime/applications/gerbview.desktop
+++ b/resources/linux/mime/applications/gerbview.desktop
@@ -1,10 +1,11 @@
[Desktop Entry]
+Version=1.0
+Terminal=false
+Icon=gerbview
+Type=Application
Categories=Development;Electronics;
+Exec=gerbview
+# MimeType= # XXX: association to gerber files?
+Name=GerbView
+GenericName=Gerber File Viewer
Comment=View gerber files
-Exec=gerbview
-GenericName=EDA Suite
-Icon=gerbview
-MimeType=application/x-gerbview-project;
-Name=GerbView
-Type=Application
-Name[en_US]=GerbView
diff --git a/resources/linux/mime/applications/kicad.desktop b/resources/linux/mime/applications/kicad.desktop
index e9df0f0..a38b534 100644
--- a/resources/linux/mime/applications/kicad.desktop
+++ b/resources/linux/mime/applications/kicad.desktop
@@ -1,11 +1,13 @@
[Desktop Entry]
+Version=1.0
+Terminal=false
+Icon=kicad
+Type=Application
Categories=Development;Electronics;
-Comment=Design a printed circuit board
-Comment[fr]=Concevoir un circuit imprimé
Exec=kicad %f
-GenericName=EDA Suite
-GenericName[fr]=Suite logicielle de conception électronique
-Icon=kicad
MimeType=application/x-kicad-project;
Name=KiCad
-Type=Application
+GenericName=EDA Suite
+Comment=Electronic Design Automation Suite
+Comment[fr]=Suite logicielle de conception électronique
+X-Desktop-File-Install-Version=0.22
diff --git a/resources/linux/mime/applications/pcbcalculator.desktop b/resources/linux/mime/applications/pcbcalculator.desktop
index ce37e64..af352d2 100644
--- a/resources/linux/mime/applications/pcbcalculator.desktop
+++ b/resources/linux/mime/applications/pcbcalculator.desktop
@@ -1,10 +1,10 @@
[Desktop Entry]
+Version=1.0
+Terminal=false
+Icon=pcbcalculator
+Type=Application
Categories=Development;Electronics;
+Exec=pcb_calculator
+Name=PCB Calculator
+GenericName=PCB Calculator
Comment=Calculator for various electronics related computations
-Exec=pcb_calculator
-GenericName=EDA Suite
-Icon=pcbcalculator
-MimeType=application/x-pcbcalculator-project;
-Name=Pcb Calculator
-Type=Application
-Name[en_US]=Pcb Calculator
diff --git a/resources/linux/mime/applications/pcbnew.desktop b/resources/linux/mime/applications/pcbnew.desktop
index 120231e..2253675 100644
--- a/resources/linux/mime/applications/pcbnew.desktop
+++ b/resources/linux/mime/applications/pcbnew.desktop
@@ -1,10 +1,11 @@
[Desktop Entry]
+Version=1.0
+Terminal=false
+Icon=pcbnew
+Type=Application
Categories=Development;Electronics;
-Comment=Layout a printed circuit board
Exec=pcbnew %f
-GenericName=EDA Suite
-Icon=pcbnew
-MimeType=application/x-pcbnew-pcb;
-Name=Pcbnew
-Type=Application
-Name[en_US]=Pcbnew
+MimeType=application/x-kicad-pcb;
+Name=Pcbnew (Standalone)
+GenericName=PCB Layout Program
+Comment=KiCADs Printed Circuit Board Layout Program (Standalone)
Attachment:
patch-4.tar.gz
Description: GNU Zip compressed data
#!/usr/bin/env python
import os, glob
import xml.etree.ElementTree as ET
from shutil import copyfile, rmtree
from subprocess import call
ICON_SOURCES = "../../../bitmaps_png/sources/"
def icon_sourcename(icon):
return ICON_SOURCES+"/icon_%s.svg" % icon
# Get a list of the applications we will install, their icons and mimes
app_icons = {}
for desktopfile in glob.glob("./applications/*.desktop"):
icon = None
mimes = []
for line in open(desktopfile):
keypair = map(str.strip, line.split("="))
if len(keypair) != 2: continue
key, value = keypair
if key == "Icon":
icon = value
elif key == "MimeType":
mimes = [x.strip() for x in value.split(";") if str.strip(x)]
if icon is None:
print "WARNING: file '", desktopfile, "' contains no Icon entry, corrupted?"
continue
else:
app_icons[icon] = mimes;
# Obtain the mime types we provide from the mime package XML
MIME_PACKAGE = "./mime/packages/kicad-kicad.xml"
mimepkg_root = ET.parse(MIME_PACKAGE).getroot()
mimepkg_mimetypes = [n.attrib['type'] for n in mimepkg_root]
# Reconcile mime types
mime_icons = {}
for mime in mimepkg_mimetypes:
for icon, mimes in app_icons.iteritems():
if mime in mimes:
mime_icons[mime.replace('/','-')] = icon
break
else:
print "WARNING: mimetype'", mime,"' is provided in the package, but no app is associated with it."
RESOLUTIONS = [16,22,24,32,48,64,128]
rmtree('./icons')
os.makedirs('./icons/hicolor/scalable/apps')
os.makedirs('./icons/hicolor/scalable/mimetypes')
for r in RESOLUTIONS:
os.makedirs('./icons/hicolor/%ix%i/apps' % (r,r))
os.makedirs('./icons/hicolor/%ix%i/mimetypes' % (r,r))
for icon in app_icons.keys():
copyfile(icon_sourcename(icon),
"./icons/hicolor/scalable/apps/%s.svg" % icon)
for r in RESOLUTIONS:
call(['inkscape', '-f', icon_sourcename(icon),
'-e', './icons/hicolor/%ix%i/apps/%s.png' % (r, r, icon),
'-w', str(r), '-h', str(r), '--export-area-snap'])
for mime, icon in mime_icons.iteritems():
copyfile(icon_sourcename(icon),
"./icons/hicolor/scalable/mimetypes/%s.svg" % mime)
for r in RESOLUTIONS:
call(['inkscape', '-f', icon_sourcename(icon),
'-e', './icons/hicolor/%ix%i/mimetypes/%s.png' % (r, r, mime),
'-w', str(r), '-h', str(r), '--export-area-snap'])
Follow ups