[aravis] viewer: use the application icons and provide a desktop file.



commit 0192e6d513ff2687268106d0fac5bac1ddffa193
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Wed Aug 8 10:27:29 2012 +0200

    viewer: use the application icons and provide a desktop file.

 Makefile.am                                |    1 +
 configure.ac                               |    1 +
 po/.gitignore                              |    1 +
 po/POTFILES.in                             |    1 +
 po/POTFILES.skip                           |    1 +
 tools/render-icon-theme.py                 |  173 ++++++++++++++++++++++++++++
 viewer/Makefile.am                         |   36 ++++++
 viewer/arv-viewer-2.ui                     |    1 +
 viewer/arv-viewer-3.ui                     |    2 +-
 viewer/arvviewer.c                         |    2 +-
 viewer/data/.gitignore                     |    2 +
 viewer/data/arv-viewer.desktop.in.in       |   14 +++
 viewer/icons/README                        |    6 +
 viewer/icons/gnome/22x22/apps/aravis.png   |  Bin 0 -> 1211 bytes
 viewer/icons/gnome/256x256/apps/aravis.png |  Bin 0 -> 21558 bytes
 viewer/icons/gnome/32x32/apps/aravis.png   |  Bin 0 -> 1570 bytes
 viewer/icons/gnome/48x48/apps/aravis.png   |  Bin 0 -> 2424 bytes
 {icons => viewer/icons/src}/aravis.svg     |    0
 18 files changed, 239 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 1e12ef3..82f25ab 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,3 +44,4 @@ CLEANFILES = $(pkgconfig_DATA)
 
 %- ARAVIS_API_VERSION@.pc: %.pc
 	cp $< $@
+
diff --git a/configure.ac b/configure.ac
index 4dabd63..0b7f549 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,6 +125,7 @@ AC_CONFIG_FILES([
 Makefile
 src/Makefile
 viewer/Makefile
+viewer/data/arv-viewer.desktop.in
 gst/Makefile
 tests/Makefile
 po/Makefile.in
diff --git a/po/.gitignore b/po/.gitignore
index eba3890..5ac9e05 100644
--- a/po/.gitignore
+++ b/po/.gitignore
@@ -2,3 +2,4 @@ POTFILES
 *.gmo
 notexist
 *.pot
+.intltool*
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 515dfa9..5ae2b74 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,3 +1,4 @@
 # List of source files containing translatable strings.
 [type: gettext/glade]viewer/arv-viewer-2.ui
 [type: gettext/glade]viewer/arv-viewer-3.ui
+viewer/data/arv-viewer.desktop.in.in
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
new file mode 100644
index 0000000..c9d928c
--- /dev/null
+++ b/po/POTFILES.skip
@@ -0,0 +1 @@
+viewer/data/arv-viewer.desktop.in
diff --git a/tools/render-icon-theme.py b/tools/render-icon-theme.py
new file mode 100755
index 0000000..c02925f
--- /dev/null
+++ b/tools/render-icon-theme.py
@@ -0,0 +1,173 @@
+#!/usr/bin/env python
+#
+# Script from the GNOME icon theme project
+# GNOME icon theme is distributed under the terms of
+# either GNU LGPL v.3 or Creative Commons BY-SA 3.0 license.
+
+import os
+import sys
+import xml.sax
+import subprocess
+
+INKSCAPE = '/usr/bin/inkscape'
+OPTIPNG = '/usr/bin/optipng'
+SRC = os.path.join('.', 'src')
+
+inkscape_process = None
+
+def optimize_png(png_file):
+    if os.path.exists(OPTIPNG):
+        process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
+        process.wait()
+
+def wait_for_prompt(process, command=None):
+    if command is not None:
+        process.stdin.write(command+'\n')
+
+    # This is kinda ugly ...
+    # Wait for just a '>', or '\n>' if some other char appearead first
+    output = process.stdout.read(1)
+    if output == '>':
+        return
+
+    output += process.stdout.read(1)
+    while output != "\n>":
+        output += process.stdout.read(1)
+        output = output[1:]
+
+def start_inkscape():
+    process = subprocess.Popen([INKSCAPE, '--shell'], bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+    wait_for_prompt(process)
+    return process
+
+def inkscape_render_rect(icon_file, rect, output_file):
+    global inkscape_process
+    if inkscape_process is None:
+        inkscape_process = start_inkscape()
+    wait_for_prompt(inkscape_process, '%s -i %s -e %s' % (icon_file, rect, output_file))
+    optimize_png(output_file)
+
+class ContentHandler(xml.sax.ContentHandler):
+    ROOT = 0
+    SVG = 1
+    LAYER = 2
+    OTHER = 3
+    TEXT = 4
+    def __init__(self, path, force=False, filter=None):
+        self.stack = [self.ROOT]
+        self.inside = [self.ROOT]
+        self.path = path
+        self.rects = []
+        self.state = self.ROOT
+        self.chars = ""
+        self.force = force
+        self.filter = filter
+
+    def endDocument(self):
+        pass
+
+    def startElement(self, name, attrs):
+        if self.inside[-1] == self.ROOT:
+            if name == "svg":
+                self.stack.append(self.SVG)
+                self.inside.append(self.SVG)
+                return
+        elif self.inside[-1] == self.SVG:
+            if (name == "g" and attrs.has_key('inkscape:groupmode') and attrs.has_key('inkscape:label')
+               and attrs['inkscape:groupmode'] == 'layer' and attrs['inkscape:label'].startswith('baseplate')):
+                self.stack.append(self.LAYER)
+                self.inside.append(self.LAYER)
+                self.context = None
+                self.icon_name = None
+                self.rects = []
+                return
+        elif self.inside[-1] == self.LAYER:
+            if name == "text" and attrs.has_key('inkscape:label') and attrs['inkscape:label'] == 'context':
+                self.stack.append(self.TEXT)
+                self.inside.append(self.TEXT)
+                self.text='context'
+                self.chars = ""
+                return
+            elif name == "text" and attrs.has_key('inkscape:label') and attrs['inkscape:label'] == 'icon-name':
+                self.stack.append(self.TEXT)
+                self.inside.append(self.TEXT)
+                self.text='icon-name'
+                self.chars = ""
+                return
+            elif name == "rect":
+                self.rects.append(attrs)
+
+        self.stack.append(self.OTHER)
+
+
+    def endElement(self, name):
+        stacked = self.stack.pop()
+        if self.inside[-1] == stacked:
+            self.inside.pop()
+
+        if stacked == self.TEXT and self.text is not None:
+            assert self.text in ['context', 'icon-name']
+            if self.text == 'context':
+                self.context = self.chars
+            elif self.text == 'icon-name':
+                self.icon_name = self.chars
+            self.text = None
+        elif stacked == self.LAYER:
+            assert self.icon_name
+            assert self.context
+
+            if self.filter is not None and not self.icon_name in self.filter:
+                return
+
+            print '%s %s' % (self.context, self.icon_name)
+            for rect in self.rects:
+                width = rect['width']
+                height = rect['height']
+                id = rect['id']
+
+                dir = os.path.join("gnome", "%sx%s" % (width, height), self.context)
+                outfile = os.path.join(dir, self.icon_name+'.png')
+                if not os.path.exists(dir):
+                    os.makedirs(dir)
+                # Do a time based check!
+                if self.force or not os.path.exists(outfile):
+                    inkscape_render_rect(self.path, id, outfile)
+                    sys.stdout.write('.')
+                else:
+                    stat_in = os.stat(self.path)
+                    stat_out = os.stat(outfile)
+                    if stat_in.st_mtime > stat_out.st_mtime:
+                        inkscape_render_rect(self.path, id, outfile)
+                        sys.stdout.write('.')
+                    else:
+                        sys.stdout.write('-')
+                sys.stdout.flush()
+            sys.stdout.write('\n')
+            sys.stdout.flush()
+
+    def characters(self, chars):
+        self.chars += chars.strip()
+
+if len(sys.argv) == 1:
+    if not os.path.exists('gnome'):
+        os.mkdir('gnome')
+    print 'Rendering from SVGs in %s' % SRC
+    for file in os.listdir(SRC):
+        if file[-4:] == '.svg':
+            file = os.path.join(SRC, file)
+            handler = ContentHandler(file)
+            xml.sax.parse(open(file), handler)
+else:
+    file = os.path.join(SRC, sys.argv[1] + '.svg')
+    if len(sys.argv) > 2:
+        icons = sys.argv[2:]
+    else:
+        icons = None
+    if os.path.exists(os.path.join(file)):
+        handler = ContentHandler(file, True, filter=icons)
+        xml.sax.parse(open(file), handler)
+    else:
+        print "Error: No such file %s" % file
+        sys.exit(1)
+
+
diff --git a/viewer/Makefile.am b/viewer/Makefile.am
index a370bc1..2b83b49 100644
--- a/viewer/Makefile.am
+++ b/viewer/Makefile.am
@@ -28,3 +28,39 @@ endif
 
 EXTRA_DIST += arv-viewer-2.ui arv-viewer-3.ui
 
+iconthemedir = $(datadir)/icons/hicolor
+icondir = ./icons/gnome
+
+appsicon22dir = $(iconthemedir)/22x22/apps
+appsicon32dir = $(iconthemedir)/32x32/apps
+appsicon48dir = $(iconthemedir)/48x48/apps
+appsicon256dir = $(iconthemedir)/256x256/apps
+
+dist_appsicon22_DATA = $(icondir)/22x22/apps/aravis.png
+dist_appsicon32_DATA = $(icondir)/32x32/apps/aravis.png
+dist_appsicon48_DATA = $(icondir)/48x48/apps/aravis.png
+dist_appsicon256_DATA = $(icondir)/256x256/apps/aravis.png
+
+update_icon_cache = gtk-update-icon-cache --ignore-theme-index --force
+
+install-data-hook: install-update-icon-cache
+uninstall-hook: uninstall-update-icon-cache
+
+install-update-icon-cache:
+	$(AM_V_at)$(POST_INSTALL)
+	test -n "$(DESTDIR)" || $(update_icon_cache) "$(iconthemedir)"
+
+uninstall-update-icon-cache:
+	$(AM_V_at)$(POST_UNINSTALL)
+	test -n "$(DESTDIR)" || $(update_icon_cache) "$(iconthemedir)"
+
+ INTLTOOL_DESKTOP_RULE@
+desktopdir = $(datadir)/applications
+desktop_in_files = data/arv-viewer.desktop.in
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+
+dist_noinst_DATA = \
+	$(desktop_in_files)
+
+CLEANFILES = \
+	$(desktop_DATA)
diff --git a/viewer/arv-viewer-2.ui b/viewer/arv-viewer-2.ui
index 92920df..7d2a4d6 100644
--- a/viewer/arv-viewer-2.ui
+++ b/viewer/arv-viewer-2.ui
@@ -5,6 +5,7 @@
   <object class="GtkWindow" id="main_window">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Aravis</property>
+    <property name="icon_name">aravis</property>
     <child>
       <object class="GtkVBox" id="vbox1">
         <property name="visible">True</property>
diff --git a/viewer/arv-viewer-3.ui b/viewer/arv-viewer-3.ui
index 29cd8f7..312c9d8 100644
--- a/viewer/arv-viewer-3.ui
+++ b/viewer/arv-viewer-3.ui
@@ -4,7 +4,7 @@
   <object class="GtkWindow" id="main_window">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Aravis</property>
-    <property name="icon_name">camera-video</property>
+    <property name="icon_name">aravis</property>
     <child>
       <object class="GtkGrid" id="grid1">
         <property name="visible">True</property>
diff --git a/viewer/arvviewer.c b/viewer/arvviewer.c
index 769817b..a535011 100644
--- a/viewer/arvviewer.c
+++ b/viewer/arvviewer.c
@@ -1,6 +1,6 @@
 /* Aravis - Digital camera library
  *
- * Copyright  2009-2011 Emmanuel Pacaud
+ * Copyright  2009-2012 Emmanuel Pacaud
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/viewer/data/.gitignore b/viewer/data/.gitignore
new file mode 100644
index 0000000..71dee7c
--- /dev/null
+++ b/viewer/data/.gitignore
@@ -0,0 +1,2 @@
+*.desktop
+*.desktop.in
diff --git a/viewer/data/arv-viewer.desktop.in.in b/viewer/data/arv-viewer.desktop.in.in
new file mode 100644
index 0000000..32696f4
--- /dev/null
+++ b/viewer/data/arv-viewer.desktop.in.in
@@ -0,0 +1,14 @@
+[Desktop Entry]
+_Name=Aravis
+_X-GNOME-FullName=Aravis Simple Viewer
+_Comment=Display the video stream from your cameras
+Exec=arv-viewer-0.2
+Terminal=false
+Type=Application
+StartupNotify=false
+Icon=aravis
+Categories=GNOME;AudioVideo;
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=aravis
+X-GNOME-Bugzilla-Component=viewer
+X-GNOME-Bugzilla-Version= VERSION@
diff --git a/viewer/icons/README b/viewer/icons/README
new file mode 100644
index 0000000..6185601
--- /dev/null
+++ b/viewer/icons/README
@@ -0,0 +1,6 @@
+The source files for Aravis icons are SVG files in viewer/icons/src.
+
+The rendering to the different sizes is done manually, in order to avoid
+a build dependency on Inkscape. After you have modified one of the source
+file, please don't forget to launch ../../tools/render-icon-theme.py from
+the icons directory.
diff --git a/viewer/icons/gnome/22x22/apps/aravis.png b/viewer/icons/gnome/22x22/apps/aravis.png
new file mode 100644
index 0000000..7312363
Binary files /dev/null and b/viewer/icons/gnome/22x22/apps/aravis.png differ
diff --git a/viewer/icons/gnome/256x256/apps/aravis.png b/viewer/icons/gnome/256x256/apps/aravis.png
new file mode 100644
index 0000000..bfede49
Binary files /dev/null and b/viewer/icons/gnome/256x256/apps/aravis.png differ
diff --git a/viewer/icons/gnome/32x32/apps/aravis.png b/viewer/icons/gnome/32x32/apps/aravis.png
new file mode 100644
index 0000000..e175275
Binary files /dev/null and b/viewer/icons/gnome/32x32/apps/aravis.png differ
diff --git a/viewer/icons/gnome/48x48/apps/aravis.png b/viewer/icons/gnome/48x48/apps/aravis.png
new file mode 100644
index 0000000..2a6e275
Binary files /dev/null and b/viewer/icons/gnome/48x48/apps/aravis.png differ
diff --git a/icons/aravis.svg b/viewer/icons/src/aravis.svg
similarity index 100%
rename from icons/aravis.svg
rename to viewer/icons/src/aravis.svg



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