~dmxe/lifeograph/1.0

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#! /usr/bin/env python

#   Copyright (C) 2007-2012 Ahmet Öztürk (aoz_2@yahoo.com)
#
#   This file is part of Lifeograph.
#
#   Lifeograph is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   Lifeograph is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with Lifeograph.  If not, see <http://www.gnu.org/licenses/>.


# Parts of this script was created using the waf script of Midori as a source
# of inspiration. Thank you guys.


import Options

APPNAME='lifeograph'
VERSION='1.0.0'

lifeograph_sources = [
    'src/dialog_export.cpp', 'src/dialog_password.cpp', 'src/dialog_preferences.cpp',
    'src/diary.cpp', 'src/diarydata.cpp', 'src/entry.cpp',
    'src/entry_parser.cpp', 'src/helpers.cpp',
    'src/lifeobase.cpp', 'src/lifeograph.cpp','src/main.cpp',
    'src/panel_diary.cpp', 'src/panel_extra.cpp', 'src/panel_main.cpp',
    'src/printing.cpp', 'src/settings.cpp', 
    'src/view_entry.cpp','src/view_login.cpp','src/views.cpp',
    'src/widget_chart.cpp', 'src/widget_entrylist.cpp',
    'src/widget_tag_list.cpp', 'src/widget_textview.cpp',
    'src/undo.cpp'
    ]

srcdir = '.'
blddir = 'build'


def set_options(opt):
    opt.tool_options('compiler_cxx')
    opt.tool_options('intltool')

    opt.add_option('--update-po', action='store_true', default=False,
        help='update the message catalogs for translation', dest='update_po')

    opt.add_option('--debug', action='store_true', default=False,
        help='create a debug build', dest='debug_build')


def configure(conf):
    import os

    # checks
    conf.check_tool('compiler_cxx')
    conf.check_cfg(package='gtkmm-3.0', atleast_version='3.0', args='--cflags --libs', uselib_store='gtkmm', mandatory=1)
    conf.check_cfg(package='enchant', args='--cflags --libs', uselib_store='enchant', mandatory=True)
    conf.check(lib='gcrypt',  uselib_store='gcrypt', mandatory=True)
    conf.check_tool('intltool')

    # defines
    conf.define('PACKAGE', APPNAME)
    conf.define('VERSION', VERSION)
    # TODO: use the methods explained here: http://live.gnome.org/ThemableAppSpecificIcons
    # and here: http://live.gnome.org/GnomeGoals/AppIcon)
    conf.define('PIXMAPDIR', os.path.join(conf.env['PREFIX'], 'share/pixmaps'))
    conf.define('ICONDIR', os.path.join(conf.env['PREFIX'], 'share', APPNAME, 'icons'))
    conf.define('UIDIR', os.path.join(conf.env['PREFIX'], 'share', APPNAME, 'ui'))
    conf.define('DIARYDIR', os.path.join(conf.env['PREFIX'], 'share', APPNAME, 'diaries'))

    # default prefix
    #conf.env.PREFIX = '/usr'

    if Options.options.debug_build:
        conf.env.CXXFLAGS = ['-DHAVE_CONFIG_H', '-Wall', '-O0', '-g']
        conf.define('LIFEOGRAPH_DEBUG_BUILD', 1)
    else:
        conf.env.CXXFLAGS = ['-DHAVE_CONFIG_H', '-Wall', '-O2']
        conf.env.LINKFLAGS = ['-s']

    conf.write_config_header('config.h')

    if Options.options.update_po:
        import Utils

        os.chdir('%s/po' % srcdir)
        try:
            try:
                size_old = os.stat(APPNAME + '.pot').st_size
            except:
                size_old = 0
            Utils.exec_command('intltool-update -p -g %s' % APPNAME)
            size_new = os.stat(APPNAME + '.pot').st_size
            #if size_new <> size_old:
            Utils.pprint ('YELLOW', "Updated po template.")
            try:
                Utils.exec_command('intltool-update -r -g %s' % APPNAME)
                Utils.pprint ('YELLOW', "Updated translations.")
            except:
                Utils.pprint ('RED', "Failed to update translations.")
            #else:
                #print('Po template is up to date.')
        except:
            Utils.pprint('RED', 'Failed to generate po template.')
        os.chdir('..')


def build(bld):
    binary = bld.new_task_gen(
        features    = 'cxx cprogram',
        source      = lifeograph_sources,
        uselib      = 'gtkmm enchant gcrypt',
        includes    = '.',
        target      = 'lifeograph')

    if bld.env['INTLTOOL']:
        bld.new_task_gen(
            features        = 'intltool_po',
            podir           = 'po',
            install_path    = '${LOCALEDIR}',
            appname         = 'lifeograph')

    # .desktop
    if bld.env['INTLTOOL']:
        bld.new_task_gen(
            features        = 'intltool_in',
            source          = 'lifeograph.desktop.in',
            flags           = [ '-d', '-q', '-u', '-c' ],
            install_path    = '${DATADIR}/applications'
            )

    # lifeograph.1
    """bld.new_task_gen(
        features        = 'subst',
        source          = 'lifeograph.1.in',
        target          = 'lifeograph.1',
        dict            = { 'VERSION' : VERSION,
                            'LIFEOGRAPH_DATA_DIR': bld.env['DATADIR'] + '/lifeograph' },
        install_path    = '${MANDIR}/man1'
    )"""

    # icons
    bld.install_as('${DATADIR}/icons/hicolor/16x16/apps/lifeograph.png',
                   'icons/lifeograph-16.png')

    bld.install_as('${DATADIR}/icons/hicolor/22x22/apps/lifeograph.png',
                    'icons/lifeograph-22.png')
    
    bld.install_as('${DATADIR}/icons/hicolor/24x24/apps/lifeograph.png',
                   'icons/lifeograph-24.png')

    bld.install_as('${DATADIR}/icons/hicolor/32x32/apps/lifeograph.png',
                   'icons/lifeograph-32.png')

    bld.install_as('${DATADIR}/icons/hicolor/48x48/apps/lifeograph.png',
                   'icons/lifeograph-48.png')

    bld.install_as('${DATADIR}/icons/hicolor/scalable/apps/lifeograph.svg',
                   'icons/scalable/lifeograph.svg')

    bld.install_as('${DATADIR}/pixmaps/lifeograph.png',
                   'icons/lifeograph-48.png')

    bld.install_files('${DATADIR}/lifeograph/icons', [ 'icons/category_tags-16.png',
                                                       'icons/category_tags-32.png',
                                                       'icons/chapter-16.png',
                                                       'icons/chapter-32.png',
                                                       'icons/diary-16.png',
                                                       'icons/diary-32.png',
                                                       'icons/entry-16.png',
                                                       'icons/entry-32.png',
                                                       'icons/favorite-16.png',
                                                       'icons/favorite-32.png',
                                                       'icons/filter-16.png',
                                                       'icons/filter_remove-16.png',
                                                       'icons/filter_symbolic-32.png',
                                                       'icons/gear-32.png',
                                                       'icons/month-16.png',
                                                       'icons/month-32.png',
                                                       'icons/tag-16.png',
                                                       'icons/tag-32.png' ] )

    # ui
    bld.install_files('${DATADIR}/lifeograph/ui', 'ui/*.ui')
    
    # diaries
    bld.install_as('${DATADIR}/lifeograph/diaries/example.diary', 'diaries/example.diary')
    bld.install_as('${DATADIR}/lifeograph/diaries/Lifeograph Manual', 'diaries/Lifeograph Manual')
    bld.install_files('${DATADIR}/lifeograph/diaries/images', 'diaries/images/*.gif')