Skip to content

Commit e3c6a51

Browse files
author
Alex Robinson
committed
initial project scaffolding
1 parent dc979a4 commit e3c6a51

17 files changed

+270
-0
lines changed

build-aux/meson/postinstall.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python3
2+
3+
from os import environ, path
4+
from subprocess import call
5+
6+
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
7+
datadir = path.join(prefix, 'share')
8+
destdir = environ.get('DESTDIR', '')
9+
10+
# Package managers set this so we don't need to run
11+
if not destdir:
12+
print('Updating icon cache...')
13+
call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
14+
15+
print('Updating desktop database...')
16+
call(['update-desktop-database', '-q', path.join(datadir, 'applications')])
17+
18+
print('Compiling GSettings schemas...')
19+
call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')])
20+
21+

data/meson.build

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
desktop_file = i18n.merge_file(
2+
input: 'org.gnome.siglo.desktop.in',
3+
output: 'org.gnome.siglo.desktop',
4+
type: 'desktop',
5+
po_dir: '../po',
6+
install: true,
7+
install_dir: join_paths(get_option('datadir'), 'applications')
8+
)
9+
10+
desktop_utils = find_program('desktop-file-validate', required: false)
11+
if desktop_utils.found()
12+
test('Validate desktop file', desktop_utils,
13+
args: [desktop_file]
14+
)
15+
endif
16+
17+
appstream_file = i18n.merge_file(
18+
input: 'org.gnome.siglo.appdata.xml.in',
19+
output: 'org.gnome.siglo.appdata.xml',
20+
po_dir: '../po',
21+
install: true,
22+
install_dir: join_paths(get_option('datadir'), 'appdata')
23+
)
24+
25+
appstream_util = find_program('appstream-util', required: false)
26+
if appstream_util.found()
27+
test('Validate appstream file', appstream_util,
28+
args: ['validate', appstream_file]
29+
)
30+
endif
31+
32+
install_data('org.gnome.siglo.gschema.xml',
33+
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
34+
)
35+
36+
compile_schemas = find_program('glib-compile-schemas', required: false)
37+
if compile_schemas.found()
38+
test('Validate schema file', compile_schemas,
39+
args: ['--strict', '--dry-run', meson.current_source_dir()]
40+
)
41+
endif

data/org.gnome.siglo.appdata.xml.in

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<component type="desktop">
3+
<id>org.gnome.siglo.desktop</id>
4+
<metadata_license>CC0-1.0</metadata_license>
5+
<project_license>LicenseRef-proprietary</project_license>
6+
<description>
7+
</description>
8+
</component>

data/org.gnome.siglo.desktop.in

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Desktop Entry]
2+
Name=siglo
3+
Exec=siglo
4+
Terminal=false
5+
Type=Application
6+
Categories=GTK;
7+
StartupNotify=true

data/org.gnome.siglo.gschema.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<schemalist gettext-domain="siglo">
3+
<schema id="org.gnome.siglo" path="/org/gnome/siglo/">
4+
</schema>
5+
</schemalist>

meson.build

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
project('siglo',
2+
version: '0.1.0',
3+
meson_version: '>= 0.50.0',
4+
default_options: [ 'warning_level=2',
5+
],
6+
)
7+
8+
i18n = import('i18n')
9+
10+
11+
subdir('data')
12+
subdir('src')
13+
subdir('po')
14+
15+
meson.add_install_script('build-aux/meson/postinstall.py')

org.gnome.siglo.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"app-id" : "org.gnome.siglo",
3+
"runtime" : "org.gnome.Platform",
4+
"runtime-version" : "3.38",
5+
"sdk" : "org.gnome.Sdk",
6+
"command" : "siglo",
7+
"finish-args" : [
8+
"--share=network",
9+
"--share=ipc",
10+
"--socket=fallback-x11",
11+
"--socket=wayland"
12+
],
13+
"cleanup" : [
14+
"/include",
15+
"/lib/pkgconfig",
16+
"/man",
17+
"/share/doc",
18+
"/share/gtk-doc",
19+
"/share/man",
20+
"/share/pkgconfig",
21+
"*.la",
22+
"*.a"
23+
],
24+
"modules" : [
25+
{
26+
"name" : "siglo",
27+
"builddir" : true,
28+
"buildsystem" : "meson",
29+
"sources" : [
30+
{
31+
"type" : "git",
32+
"url" : "file:///home/malex/Projects/siglo"
33+
}
34+
]
35+
}
36+
]
37+
}

po/LINGUAS

Whitespace-only changes.

po/POTFILES

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
data/org.gnome.siglo.desktop.in
2+
data/org.gnome.siglo.appdata.xml.in
3+
data/org.gnome.siglo.gschema.xml
4+
src/window.ui
5+
src/main.py
6+
src/window.py
7+

po/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
i18n.gettext('siglo', preset: 'glib')

src/__init__.py

Whitespace-only changes.

src/main.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
import sys
3+
import gi
4+
5+
gi.require_version('Gtk', '3.0')
6+
7+
from gi.repository import Gtk, Gio
8+
9+
from .window import SigloWindow
10+
11+
12+
class Application(Gtk.Application):
13+
def __init__(self):
14+
super().__init__(application_id='org.gnome.siglo',
15+
flags=Gio.ApplicationFlags.FLAGS_NONE)
16+
17+
def do_activate(self):
18+
win = self.props.active_window
19+
if not win:
20+
win = SigloWindow(application=self)
21+
win.present()
22+
23+
24+
def main(version):
25+
app = Application()
26+
return app.run(sys.argv)

src/meson.build

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
2+
moduledir = join_paths(pkgdatadir, 'siglo')
3+
gnome = import('gnome')
4+
5+
gnome.compile_resources('siglo',
6+
'siglo.gresource.xml',
7+
gresource_bundle: true,
8+
install: true,
9+
install_dir: pkgdatadir,
10+
)
11+
12+
python = import('python')
13+
14+
conf = configuration_data()
15+
conf.set('PYTHON', python.find_installation('python3').path())
16+
conf.set('VERSION', meson.project_version())
17+
conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
18+
conf.set('pkgdatadir', pkgdatadir)
19+
20+
configure_file(
21+
input: 'siglo.in',
22+
output: 'siglo',
23+
configuration: conf,
24+
install: true,
25+
install_dir: get_option('bindir')
26+
)
27+
28+
siglo_sources = [
29+
'__init__.py',
30+
'main.py',
31+
'window.py',
32+
]
33+
34+
install_data(siglo_sources, install_dir: moduledir)

src/siglo.gresource.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<gresources>
3+
<gresource prefix="/org/gnome/siglo">
4+
<file>window.ui</file>
5+
</gresource>
6+
</gresources>

src/siglo.in

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!@PYTHON@
2+
3+
4+
import os
5+
import sys
6+
import signal
7+
import gettext
8+
9+
VERSION = '@VERSION@'
10+
pkgdatadir = '@pkgdatadir@'
11+
localedir = '@localedir@'
12+
13+
sys.path.insert(1, pkgdatadir)
14+
signal.signal(signal.SIGINT, signal.SIG_DFL)
15+
gettext.install('siglo', localedir)
16+
17+
if __name__ == '__main__':
18+
import gi
19+
20+
from gi.repository import Gio
21+
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'siglo.gresource'))
22+
resource._register()
23+
24+
from siglo import main
25+
sys.exit(main.main(VERSION))

src/window.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
from gi.repository import Gtk
3+
4+
5+
@Gtk.Template(resource_path='/org/gnome/siglo/window.ui')
6+
class SigloWindow(Gtk.ApplicationWindow):
7+
__gtype_name__ = 'SigloWindow'
8+
9+
label = Gtk.Template.Child()
10+
11+
def __init__(self, **kwargs):
12+
super().__init__(**kwargs)

src/window.ui

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<interface>
3+
<requires lib="gtk+" version="3.24"/>
4+
<template class="SigloWindow" parent="GtkApplicationWindow">
5+
<property name="default-width">600</property>
6+
<property name="default-height">300</property>
7+
<child type="titlebar">
8+
<object class="GtkHeaderBar" id="header_bar">
9+
<property name="visible">True</property>
10+
<property name="show-close-button">True</property>
11+
<property name="title">Hello, World!</property>
12+
</object>
13+
</child>
14+
<child>
15+
<object class="GtkLabel" id="label">
16+
<property name="label">Hello, World!</property>
17+
<property name="visible">True</property>
18+
<attributes>
19+
<attribute name="weight" value="bold"/>
20+
<attribute name="scale" value="2"/>
21+
</attributes>
22+
</object>
23+
</child>
24+
</template>
25+
</interface>

0 commit comments

Comments
 (0)