summaryrefslogtreecommitdiff
path: root/icons/wscript_build
blob: 5a73b4bde8a000d18f3a8717e38828dcee1cfd46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env python
# WAF build script for midori
# This file is licensed under the terms of the expat license, see the file EXPAT.

import Utils
import os

def add_image (bld, category, name):

    srcdir = os.getcwd ()
    blddir = bld.bdir

    rsvg_convert = bld.env['RSVG_CONVERT']

    if rsvg_convert:
        Utils.check_dir (blddir + '/icons')

    if bld.env['HAVE_HILDON']:
        category = 'hildon'
        icon_sizes = [48, 64]
    else:
        icon_sizes = [16, 22, 24, 32, 48]

    for size in icon_sizes:
        format = str (size) + 'x' + str (size)
        if os.access (srcdir + '/icons/' + format + '/' + name + '.png', os.F_OK):
            bld.install_files ('${MDATADIR}/icons/hicolor/' + format + '/' + category,
                               srcdir + '/icons/' + format + '/' + name + '.png')
        elif not rsvg_convert:
            pass
        elif os.access (srcdir + '/icons/scalable/' + name + '.svg', os.F_OK):
            Utils.check_dir (blddir + '/icons/' + format)
            command = rsvg_convert + ' -w ' + str(size) + \
                ' -h ' + str(size) + \
                ' -o ' + blddir + '/icons/' + format + '/' + name + '.png' + \
                ' ' + srcdir + '/icons/scalable/' + name + '.svg'
            if not Utils.exec_command (command):
                bld.install_files ('${MDATADIR}/icons/hicolor/' + format + '/' + category,
                                   blddir + '/icons/' + format + '/' + name + '.png')
            else:
                Utils.pprint ('BLUE', "Optimized icons could not be created.")
                break

add_image (bld, 'categories', 'extension')
add_image (bld, 'apps', 'midori')
add_image (bld, 'status', 'news-feed')