Skip to content

Commit

Permalink
created project with gnome-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Jul 4, 2019
0 parents commit acbdbf7
Show file tree
Hide file tree
Showing 18 changed files with 982 additions and 0 deletions.
675 changes: 675 additions & 0 deletions COPYING

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions build-aux/meson/postinstall.py
@@ -0,0 +1,21 @@
#!/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')])

print('Compiling GSettings schemas...')
call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')])


41 changes: 41 additions & 0 deletions data/meson.build
@@ -0,0 +1,41 @@
desktop_file = i18n.merge_file(
input: 're.sonny.gigagram.desktop.in',
output: 're.sonny.gigagram.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'applications')
)

desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils,
args: [desktop_file]
)
endif

appstream_file = i18n.merge_file(
input: 're.sonny.gigagram.appdata.xml.in',
output: 're.sonny.gigagram.appdata.xml',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'appdata')
)

appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
test('Validate appstream file', appstream_util,
args: ['validate', appstream_file]
)
endif

install_data('re.sonny.gigagram.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
)

compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found()
test('Validate schema file', compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()]
)
endif
8 changes: 8 additions & 0 deletions data/re.sonny.gigagram.appdata.xml.in
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>re.sonny.gigagram.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<description>
</description>
</component>
7 changes: 7 additions & 0 deletions data/re.sonny.gigagram.desktop.in
@@ -0,0 +1,7 @@
[Desktop Entry]
Name=gigagram
Exec=re.sonny.gigagram
Terminal=false
Type=Application
Categories=GTK;
StartupNotify=true
5 changes: 5 additions & 0 deletions data/re.sonny.gigagram.gschema.xml
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="gigagram">
<schema id="re.sonny.gigagram" path="/re/sonny/gigagram/">
</schema>
</schemalist>
13 changes: 13 additions & 0 deletions meson.build
@@ -0,0 +1,13 @@
project('gigagram',
version: '0.1.0',
meson_version: '>= 0.40.0',
)

i18n = import('i18n')


subdir('data')
subdir('src')
subdir('po')

meson.add_install_script('build-aux/meson/postinstall.py')
Empty file added po/LINGUAS
Empty file.
7 changes: 7 additions & 0 deletions po/POTFILES
@@ -0,0 +1,7 @@
data/re.sonny.gigagram.desktop.in
data/re.sonny.gigagram.appdata.xml.in
data/re.sonny.gigagram.gschema.xml
src/window.ui
src/main.js
src/window.js

1 change: 1 addition & 0 deletions po/meson.build
@@ -0,0 +1 @@
i18n.gettext('gigagram', preset: 'glib')
48 changes: 48 additions & 0 deletions re.sonny.gigagram.json
@@ -0,0 +1,48 @@
{
"app-id": "re.sonny.gigagram",
"runtime": "org.gnome.Platform",
"runtime-version": "3.32",
"sdk": "org.gnome.Sdk",
"command": "re.sonny.gigagram",
"finish-args": [
"--share=network",
"--share=ipc",
"--socket=x11",
"--socket=wayland",
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf"
],
"build-options": {
"cflags": "-O2 -g",
"cxxflags": "-O2 -g",
"env": {
"V": "1"
}
},
"cleanup": [
"/include",
"/lib/pkgconfig",
"/man",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"*.la",
"*.a"
],
"modules": [
{
"name": "gigagram",
"builddir": true,
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "file:///home/sonny/Projects/gigagram"
}
]
}
]
}
47 changes: 47 additions & 0 deletions src/main.js
@@ -0,0 +1,47 @@
/* main.js
*
* Copyright 2019 Sonny Piers
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/

pkg.initGettext();
pkg.initFormat();
pkg.require({
'Gio': '2.0',
'Gtk': '3.0'
});

const { Gio, Gtk } = imports.gi;

const { GigagramWindow } = imports.window;

function main(argv) {
const application = new Gtk.Application({
application_id: 're.sonny.gigagram',
flags: Gio.ApplicationFlags.FLAGS_NONE,
});

application.connect('activate', app => {
let activeWindow = app.activeWindow;

if (!activeWindow) {
activeWindow = new GigagramWindow(app);
}

activeWindow.present();
});

return application.run(argv);
}
32 changes: 32 additions & 0 deletions src/meson.build
@@ -0,0 +1,32 @@
pkgdatadir = join_paths(get_option('datadir'), meson.project_name())
gnome = import('gnome')

src_res = gnome.compile_resources('re.sonny.gigagram.src',
're.sonny.gigagram.src.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)

data_res = gnome.compile_resources('re.sonny.gigagram.data',
're.sonny.gigagram.data.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)

bin_conf = configuration_data()
bin_conf.set('GJS', find_program('gjs').path())
bin_conf.set('PACKAGE_VERSION', meson.project_version())
bin_conf.set('PACKAGE_NAME', meson.project_name())
bin_conf.set('prefix', get_option('prefix'))
bin_conf.set('libdir', join_paths(get_option('prefix'), get_option('libdir')))
bin_conf.set('datadir', join_paths(get_option('prefix'), get_option('datadir')))

configure_file(
input: 're.sonny.gigagram.in',
output: 're.sonny.gigagram',
configuration: bin_conf,
install: true,
install_dir: get_option('bindir')
)
6 changes: 6 additions & 0 deletions src/re.sonny.gigagram.data.gresource.xml
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/re/sonny/gigagram">
<file>window.ui</file>
</gresource>
</gresources>
9 changes: 9 additions & 0 deletions src/re.sonny.gigagram.in
@@ -0,0 +1,9 @@
#!@GJS@
imports.package.init({
name: "@PACKAGE_NAME@",
version: "@PACKAGE_VERSION@",
prefix: "@prefix@",
libdir: "@libdir@",
datadir: "@datadir@",
});
imports.package.run(imports.main);
7 changes: 7 additions & 0 deletions src/re.sonny.gigagram.src.gresource.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/re/sonny/gigagram/js">
<file>main.js</file>
<file>window.js</file>
</gresource>
</gresources>
30 changes: 30 additions & 0 deletions src/window.js
@@ -0,0 +1,30 @@
/* window.js
*
* Copyright 2019 Sonny Piers
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/

const { GObject, Gtk } = imports.gi;

var GigagramWindow = GObject.registerClass({
GTypeName: 'GigagramWindow',
Template: 'resource:///re/sonny/gigagram/window.ui',
InternalChildren: ['label']
}, class GigagramWindow extends Gtk.ApplicationWindow {
_init(application) {
super._init({ application });
}
});

25 changes: 25 additions & 0 deletions src/window.ui
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="GigagramWindow" parent="GtkApplicationWindow">
<property name="default-width">600</property>
<property name="default-height">300</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerBar">
<property name="visible">True</property>
<property name="show-close-button">True</property>
<property name="title">Hello, World!</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label">
<property name="label">Hello, World!</property>
<property name="visible">True</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="2"/>
</attributes>
</object>
</child>
</template>
</interface>

0 comments on commit acbdbf7

Please sign in to comment.