Skip to content
Snippets Groups Projects
Commit f29433d8 authored by David Boddie's avatar David Boddie :speech_balloon:
Browse files

Rename a tutorial to make it a part of a longer tutorial


Signed-off-by: default avatarDavid Boddie <david.boddie@puri.sm>
parents
No related branches found
No related tags found
No related merge requests found
#!/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')])
print('Updating desktop database...')
call(['update-desktop-database', '-q', path.join(datadir, 'applications')])
{
"app-id": "com.example.title_bar",
"runtime": "org.gnome.Platform",
"runtime-version": "3.30",
"sdk": "org.gnome.Sdk",
"command": "title-bar",
"finish-args": [
"--socket=wayland"
],
"modules": [
{
"name": "title_bar",
"buildsystem": "meson",
"builddir": true,
"sources": [
{
"type": "dir",
"path": "."
}
]
},
{
"name" : "libhandy",
"buildsystem" : "meson",
"builddir": true,
"config-opts": [
"-Dglade_catalog=disabled"
],
"sources" : [
{
"type" : "git",
"branch": "v0.0.8",
"url" : "https://source.puri.sm/Librem5/libhandy.git"
}
]
}
]
}
[Desktop Entry]
Name=Title Bar
Icon=com.example.title_bar
Exec=title-bar
Terminal=false
Type=Application
Categories=
StartupNotify=false
<?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="1" y="1" width="98" height="98" stroke="black" stroke-width="1" fill="white" />
<rect x="1" y="1" width="98" height="24" stroke="black" stroke-width="1" fill="#c0c0c0" />
</svg>
configure_file(
input: 'com.example.title_bar.desktop',
output: 'com.example.title_bar.desktop',
copy: true,
install: true,
install_dir: join_paths(get_option('datadir'), 'applications')
)
install_data('com.example.title_bar.svg',
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'scalable', 'apps'))
project('title_bar',
version: '0.1.0',
meson_version: '>= 0.48.0',
)
subdir('data')
subdir('src')
meson.add_install_script('build-aux/meson/postinstall.py')
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg" height="600" version="1.1" width="600"
viewBox="0 0 600 600">
<defs>
<linearGradient id="background" x2="0%" y2="100%" spreadMethod="reflect">
<stop offset="0%" stop-color="#202040" opacity="0" />
<stop offset="100%" stop-color="#202020" />
</linearGradient>
<radialGradient id="sphere" fx="75%" fy="25%">
<stop offset="0%" stop-color="white" />
<stop offset="25%" stop-color="#a0ffa0" />
<stop offset="100%" stop-color="#002000" />
</radialGradient>
</defs>
<rect x="0" y="0" width="600" height="600" stroke="none" fill="url(#background)" />
<circle cx="300" cy="300" r="200" stroke="none" fill="url(#sphere)" />
</svg>
# -*- coding: utf-8 -*-
# Copyright (C) 2019 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
gi.require_version('Handy', '0.0')
from gi.repository import Handy
Handy.init()
class Application(Gtk.Application):
def __init__(self):
super().__init__(application_id='com.example.title_bar')
GLib.set_application_name('Title Bar')
def do_activate(self):
window = Gtk.ApplicationWindow(application=self)
window.set_icon_name('com.example.title_bar')
title_bar = Handy.TitleBar()
header = Gtk.HeaderBar(title='Title Bar', show_close_button=True)
title_bar.add(header)
window.set_titlebar(title_bar)
label = Gtk.Label(wrap=True)
label.set_markup('<big>This example shows how to use a libhandy '
'title bar to hold a regular header bar.</big>')
window.add(label)
window.show_all()
def main(version):
app = Application()
return app.run(sys.argv)
# Initialize local variables to hold installation paths.
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
moduledir = join_paths(pkgdatadir, meson.project_name())
# Find the python3 program to help define the PYTHON configuration variable
# that will be used in the title-bar.in template.
python3 = find_program('python3')
conf = configuration_data()
conf.set('PYTHON', python3.path())
conf.set('VERSION', meson.project_version())
conf.set('pkgdatadir', pkgdatadir)
# Replace placeholders in templates with the configuration data defined above
# and create the versions of these files for installation in the build
# directory.
configure_file(
input: 'title-bar.in',
output: 'title-bar',
configuration: conf,
install: true,
install_dir: get_option('bindir')
)
# Declare the application's sources and their installation directory.
sources = [
'__init__.py',
'main.py'
]
install_data(sources, install_dir: moduledir)
#!@PYTHON@
# -*- coding: utf-8 -*-
# Copyright (C) 2019 Purism SPC
# SPDX-License-Identifier: GPL-3.0+
# Author: David Boddie <david.boddie@puri.sm>
import os
import signal
import sys
VERSION = '@VERSION@'
pkgdatadir = '@pkgdatadir@'
sys.path.insert(1, pkgdatadir)
signal.signal(signal.SIGINT, signal.SIG_DFL)
if __name__ == '__main__':
import gi
from gi.repository import Gio
from title_bar import main
sys.exit(main.main(VERSION))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment