Add most of the first tutorial
Signed-off-by: David Boddie <david.boddie@puri.sm>
This commit is contained in:
commit
065649aaad
8 changed files with 127 additions and 0 deletions
13
build-aux/meson/postinstall.py
Executable file
13
build-aux/meson/postinstall.py
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from os import environ, path
|
||||||
|
from subprocess import call
|
||||||
|
|
||||||
|
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
|
||||||
|
datadir = path.join(prefix, 'share')
|
||||||
|
destdir = environ.get('DESTDIR', '')
|
||||||
|
|
||||||
|
# Package managers set this so we don't need to run
|
||||||
|
if not destdir:
|
||||||
|
print('Updating icon cache...')
|
||||||
|
call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
|
38
com.example.first_application.json
Normal file
38
com.example.first_application.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"app-id": "com.example.first_application",
|
||||||
|
"runtime": "org.gnome.Platform",
|
||||||
|
"runtime-version": "master",
|
||||||
|
"sdk": "org.gnome.Sdk",
|
||||||
|
"command": "your-first-application",
|
||||||
|
"finish-args": [
|
||||||
|
"--socket=wayland"
|
||||||
|
],
|
||||||
|
"build-options": {
|
||||||
|
"env": {
|
||||||
|
"V": "1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cleanup": [
|
||||||
|
"/lib/pkgconfig",
|
||||||
|
"/man",
|
||||||
|
"/share/doc",
|
||||||
|
"/share/gtk-doc",
|
||||||
|
"/share/man",
|
||||||
|
"/share/pkgconfig"
|
||||||
|
],
|
||||||
|
"modules": [
|
||||||
|
{
|
||||||
|
"name": "first-application",
|
||||||
|
"buildsystem": "meson",
|
||||||
|
"builddir": true,
|
||||||
|
"subdir": "First_Application",
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"branch": "master",
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://source.puri.sm/david.boddie/tutorials.git"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
8
data/com.example.first_application.desktop
Normal file
8
data/com.example.first_application.desktop
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=Your First Application
|
||||||
|
Icon=com.example.first_application
|
||||||
|
Exec=your-first-application
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
Categories=
|
||||||
|
StartupNotify=false
|
8
data/com.example.first_application.svg
Normal file
8
data/com.example.first_application.svg
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="64" version="1.1" width="64"
|
||||||
|
viewBox="0 0 100 100">
|
||||||
|
|
||||||
|
<rect x="0" y="0" width="100" height="100" stroke="none" fill="#8080c0" />
|
||||||
|
<rect x="0" y="60" width="100" height="40" stroke="none" fill="#80c080" />
|
||||||
|
<circle cx="70" cy="30" r="20" stroke="none" fill="#f0f080" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 388 B |
10
data/meson.build
Normal file
10
data/meson.build
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
configure_file(
|
||||||
|
input: 'com.example.first_application.desktop',
|
||||||
|
output: 'com.example.first_application.desktop',
|
||||||
|
copy: true,
|
||||||
|
install: true,
|
||||||
|
install_dir: join_paths(get_option('datadir'), 'applications')
|
||||||
|
)
|
||||||
|
|
||||||
|
install_data('com.example.first_application.svg',
|
||||||
|
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'scalable', 'apps'))
|
9
meson.build
Normal file
9
meson.build
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
project('first-application',
|
||||||
|
version: '0.1.0',
|
||||||
|
meson_version: '>= 0.40.0',
|
||||||
|
)
|
||||||
|
|
||||||
|
subdir('data')
|
||||||
|
subdir('src')
|
||||||
|
|
||||||
|
meson.add_install_script('build-aux/meson/postinstall.py')
|
34
src/main.py
Executable file
34
src/main.py
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2018 Purism SPC
|
||||||
|
# SPDX-License-Identifier: GPL-3.0+
|
||||||
|
# Author: David Boddie <david.boddie@puri.sm>
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import gi
|
||||||
|
gi.require_version('Gtk', '3.0')
|
||||||
|
from gi.repository import GLib, Gtk
|
||||||
|
|
||||||
|
|
||||||
|
class Application(Gtk.Application):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(application_id='com.example.first_application')
|
||||||
|
GLib.set_application_name('Your First Application')
|
||||||
|
|
||||||
|
def do_activate(self):
|
||||||
|
window = Gtk.ApplicationWindow(application=self)
|
||||||
|
window.set_icon_name('com.example.first_application')
|
||||||
|
|
||||||
|
label = Gtk.Label()
|
||||||
|
label.set_markup('<span font="40">Hello World!</span>')
|
||||||
|
window.add(label)
|
||||||
|
window.show_all()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
app = Application()
|
||||||
|
result = app.run(sys.argv)
|
||||||
|
sys.exit(result)
|
7
src/meson.build
Normal file
7
src/meson.build
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
configure_file(
|
||||||
|
input: 'main.py',
|
||||||
|
output: 'your-first-application',
|
||||||
|
copy: true,
|
||||||
|
install: true,
|
||||||
|
install_dir: get_option('bindir')
|
||||||
|
)
|
Loading…
Reference in a new issue