[aseprite] 02/128: add linux thumbnailers for Gnome & KDE/Qt

Tobias Hansen thansen at moszumanska.debian.org
Mon May 9 21:24:16 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 75445d0b6782016c5d04d9f13117963e3e6c113b
Author: Gabriel Rauter <rauter.gabriel at gmail.com>
Date:   Fri Apr 1 16:05:15 2016 +0200

    add linux thumbnailers for Gnome & KDE/Qt
    
    This adds thumbnailer support both for Gnome and KDE5/Qt5. The gnome
    thumbnailer is installed by default on linux systems, as it does not add
    any additional dependencies at build time and can be used by
    GnomeThumbnailFactory. The KDE/Qt thumbnailer need the whole Qt and Kio
    stack to build, as well as the distribution dependend variables set.
    Because of that it is not build by default. For the thumnailers to work
    for all of aseprites supported file formats and additonal mime type file
    is installed. Packagers in addition need to call update-mime-database
    path-to-mime-database (/usr/share/mime for example) as post install
    command.
---
 CMakeLists.txt                      |  7 +++++++
 desk/CMakeLists.txt                 | 11 +++++++++++
 desk/aseprite-thumbnailer           | 13 +++++++++++++
 desk/gnome/aseprite.thumbnailer     |  4 ++++
 desk/kde/CMakeLists.txt             | 18 ++++++++++++++++++
 desk/kde/aseprite_thumb_creator.cpp | 33 +++++++++++++++++++++++++++++++++
 desk/kde/aseprite_thumb_creator.h   | 16 ++++++++++++++++
 desk/kde/asepritethumbnail.desktop  |  8 ++++++++
 desk/mime/aseprite.xml              | 12 ++++++++++++
 9 files changed, 122 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 35e96c8..aa563b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,9 @@ option(WITH_WEBP_SUPPORT  "Enable support to load/save .webp files" off)
 option(WITH_GTK_FILE_DIALOG_SUPPORT "Enable support for the experimental native GTK File Dialog" off)
 option(WITH_DEPRECATED_GLIB_SUPPORT "Enable support for older glib versions" off)
 
+option(WITH_DESKTOP_INTEGRATION "Enable desktop integration modules" on)
+option(WITH_QT_THUMBNAILER "Enable kde5/qt5 thumnailer" off)
+
 option(USE_STATIC_LIBC    "Use static version of C and C++ runtimes" off)
 option(USE_SHARED_CURL    "Use your installed copy of curl" off)
 option(USE_SHARED_GIFLIB  "Use your installed copy of giflib" off)
@@ -396,6 +399,10 @@ if(APPLE)
     endif(COMPILER_GCC)
 endif(APPLE)
 
+if(WITH_DESKTOP_INTEGRATION)
+  add_subdirectory(desk)
+endif()
+
 ######################################################################
 # Main ASE targets
 
diff --git a/desk/CMakeLists.txt b/desk/CMakeLists.txt
new file mode 100644
index 0000000..d533a8d
--- /dev/null
+++ b/desk/CMakeLists.txt
@@ -0,0 +1,11 @@
+if(UNIX AND NOT APPLE)
+  install(FILES mime/aseprite.xml
+          DESTINATION share/mime/packages)
+  install(PROGRAMS aseprite-thumbnailer
+          DESTINATION bin)
+  install(FILES gnome/aseprite.thumbnailer
+          DESTINATION share/thumbnailers)
+  if(WITH_QT_THUMBNAILER)
+    add_subdirectory(kde)
+  endif()
+endif()
diff --git a/desk/aseprite-thumbnailer b/desk/aseprite-thumbnailer
new file mode 100755
index 0000000..76e9124
--- /dev/null
+++ b/desk/aseprite-thumbnailer
@@ -0,0 +1,13 @@
+#!/usr/bin/sh
+if [ $# -ge 2 -a $# -lt 4 ]; then
+  mkdir -p /tmp/Aseprite
+  filename=${1//\//.}$RANDOM
+  if [ $# -eq 2 ]; then
+    aseprite -b --frame-range "0,0" $1 --sheet /tmp/Aseprite/$filename.png
+  elif [ $# -eq 3 ]; then
+    aseprite -b --frame-range "0,0" $1 --shrink-to "$3,$3" --sheet /tmp/Aseprite/$filename.png
+  fi
+  mkdir -p $(dirname "$2"); mv /tmp/Aseprite/$filename.png $2; 
+else
+echo "Parameters for aseprite thumbnailer are: inputfile outputfile [size]"
+fi
diff --git a/desk/gnome/aseprite.thumbnailer b/desk/gnome/aseprite.thumbnailer
new file mode 100644
index 0000000..f991c34
--- /dev/null
+++ b/desk/gnome/aseprite.thumbnailer
@@ -0,0 +1,4 @@
+[Thumbnailer Entry]
+TryExec=aseprite-thumbnailer
+Exec=aseprite-thumbnailer %i %o %s
+MimeType=image/bmp;image/gif;image/jpeg;image/png;image/x-pcx;image/x-tga;image/vnd.microsoft.icon;video/x-flic;image/webp;image/x-aseprite;
diff --git a/desk/kde/CMakeLists.txt b/desk/kde/CMakeLists.txt
new file mode 100644
index 0000000..8639223
--- /dev/null
+++ b/desk/kde/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 2.8.12)
+set(QT_MIN_VERSION "5.2.0")
+project(asepritethumbnail)
+find_package(ECM REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
+set(KDE_INSTALL_DIRS_NO_DEPRECATED, TRUE)
+include(FeatureSummary)
+include(WriteBasicConfigVersionFile)
+include(KDEInstallDirs)
+include(KDECMakeSettings)
+include(KDECompilerSettings)
+find_package(KF5 REQUIRED COMPONENTS KIO)
+add_definitions(${QT_DEFINITIONS} -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
+set(KDE_INSTALL_USE_QT_SYS_PATHS)
+add_library(asepritethumbnail MODULE aseprite_thumb_creator.cpp)
+target_link_libraries(asepritethumbnail KF5::KIOWidgets)
+install(TARGETS asepritethumbnail DESTINATION ${PLUGIN_INSTALL_DIR})
+install(FILES asepritethumbnail.desktop DESTINATION ${SERVICES_INSTALL_DIR})
\ No newline at end of file
diff --git a/desk/kde/aseprite_thumb_creator.cpp b/desk/kde/aseprite_thumb_creator.cpp
new file mode 100644
index 0000000..1385dbd
--- /dev/null
+++ b/desk/kde/aseprite_thumb_creator.cpp
@@ -0,0 +1,33 @@
+#include "aseprite_thumb_creator.h"
+
+#include <QImage>
+#include <QProcess>
+#include <QStringList>
+#include <QFile>
+#include <QCryptographicHash>
+#include <cstdio>
+
+extern "C"
+{
+  Q_DECL_EXPORT ThumbCreator *new_creator()
+  {
+    return new AsepriteThumbCreator();
+  }
+};
+
+bool AsepriteThumbCreator::create(const QString& path, int width, int height, QImage& img ) {
+  QProcess process;
+  QStringList list;
+  QString tmpFile = QString(QCryptographicHash::hash(path.toLocal8Bit(),QCryptographicHash::Md5).toHex());
+  list << path << tmpFile;
+  process.start(QString("aseprite-thumbnailer"), list);
+  if (!process.waitForFinished()) return false;
+  img.load(tmpFile);
+  QFile::remove(tmpFile);
+  return true;
+}
+
+AsepriteThumbCreator::Flags AsepriteThumbCreator::flags() const
+{
+  return DrawFrame;
+}
diff --git a/desk/kde/aseprite_thumb_creator.h b/desk/kde/aseprite_thumb_creator.h
new file mode 100644
index 0000000..399b6ae
--- /dev/null
+++ b/desk/kde/aseprite_thumb_creator.h
@@ -0,0 +1,16 @@
+#ifndef _ASEPRITE_THUMBCREATOR_H_
+#define _ASEPRITE_THUMBCREATOR_H_
+#pragma once
+
+#include <QLoggingCategory>
+Q_DECLARE_LOGGING_CATEGORY(LOG_ASEPRITE_THUMBCREATOR)
+
+#include <kio/thumbcreator.h>
+
+class AsepriteThumbCreator : public ThumbCreator {
+  public:
+    virtual bool create(const QString& path, int width, int height, QImage& img);
+    virtual Flags flags() const;
+};
+
+#endif
diff --git a/desk/kde/asepritethumbnail.desktop b/desk/kde/asepritethumbnail.desktop
new file mode 100644
index 0000000..e7c7a00
--- /dev/null
+++ b/desk/kde/asepritethumbnail.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Service
+Name=Aseprite Pixel Art
+MimeType=image/bmp;image/gif;image/jpeg;image/png;image/x-pcx;image/x-tga;image/vnd.microsoft.icon;video/x-flic;image/webp;image/x-aseprite;
+X-KDE-ServiceTypes=ThumbCreator
+X-KDE-Library=asepritethumbnail
+CacheThumbnail=true
+ThumbnailerVersion=1
diff --git a/desk/mime/aseprite.xml b/desk/mime/aseprite.xml
new file mode 100644
index 0000000..52b2adb
--- /dev/null
+++ b/desk/mime/aseprite.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+  <mime-type type="image/x-aseprite">
+         <comment xml:lang="en">Aseprite Pixel Art</comment>
+         <magic priority="50">
+                <match type="little16" value="0xA5E0" offset="4"/>
+         </magic>
+         <glob pattern="*.ase"/>
+         <glob pattern="*.aseprite"/>
+        <icon name="aseprite"/>
+  </mime-type>
+</mime-info>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list