Initial commit

This commit is contained in:
Hugo Posnic 2019-10-03 18:33:49 +02:00
parent c88f3edb54
commit 2ff0dcad00
18 changed files with 316 additions and 4 deletions

View File

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
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 <https://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@ -664,11 +664,12 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

21
build-aux/meson/postinstall.py Executable file
View File

@ -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')])

View File

@ -0,0 +1,30 @@
{
"app-id": "com.github.ImCompressor",
"runtime": "org.gnome.Platform",
"runtime-version": "3.34",
"sdk": "org.gnome.Sdk",
"command": "imcompressor",
"finish-args": [
"--share=network",
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf"
],
"modules": [
{
"name": "imcompressor",
"builddir": true,
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "file:///home/hugoposnic/Documents/Dev/ImCompressor"
}
]
}
]
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>com.github.ImCompressor.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<description>
</description>
</component>

View File

@ -0,0 +1,7 @@
[Desktop Entry]
Name=imcompressor
Exec=imcompressor
Terminal=false
Type=Application
Categories=GTK;
StartupNotify=true

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="imcompressor">
<schema id="com.github.ImCompressor" path="/com/github/ImCompressor/">
</schema>
</schemalist>

41
data/meson.build Normal file
View File

@ -0,0 +1,41 @@
desktop_file = i18n.merge_file(
input: 'com.github.ImCompressor.desktop.in',
output: 'com.github.ImCompressor.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: 'com.github.ImCompressor.appdata.xml.in',
output: 'com.github.ImCompressor.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('com.github.ImCompressor.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

15
meson.build Normal file
View File

@ -0,0 +1,15 @@
project('imcompressor',
version: '0.1.0',
meson_version: '>= 0.50.0',
default_options: [ 'warning_level=2',
],
)
i18n = import('i18n')
subdir('data')
subdir('src')
subdir('po')
meson.add_install_script('build-aux/meson/postinstall.py')

0
po/LINGUAS Normal file
View File

7
po/POTFILES Normal file
View File

@ -0,0 +1,7 @@
data/com.github.ImCompressor.desktop.in
data/com.github.ImCompressor.appdata.xml.in
data/com.github.ImCompressor.gschema.xml
src/window.ui
src/main.py
src/window.py

1
po/meson.build Normal file
View File

@ -0,0 +1 @@
i18n.gettext('imcompressor', preset: 'glib')

0
src/__init__.py Normal file
View File

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/github/ImCompressor">
<file>window.ui</file>
</gresource>
</gresources>

41
src/imcompressor.in Executable file
View File

@ -0,0 +1,41 @@
#!@PYTHON@
# imcompressor.in
#
# Copyright 2019 Hugo Posnic
#
# 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/>.
import os
import sys
import signal
import gettext
VERSION = '@VERSION@'
pkgdatadir = '@pkgdatadir@'
localedir = '@localedir@'
sys.path.insert(1, pkgdatadir)
signal.signal(signal.SIGINT, signal.SIG_DFL)
gettext.install('imcompressor', localedir)
if __name__ == '__main__':
import gi
from gi.repository import Gio
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'imcompressor.gresource'))
resource._register()
from imcompressor import main
sys.exit(main.main(VERSION))

42
src/main.py Normal file
View File

@ -0,0 +1,42 @@
# main.py
#
# Copyright 2019 Hugo Posnic
#
# 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/>.
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio
from .window import ImcompressorWindow
class Application(Gtk.Application):
def __init__(self):
super().__init__(application_id='com.github.ImCompressor',
flags=Gio.ApplicationFlags.FLAGS_NONE)
def do_activate(self):
win = self.props.active_window
if not win:
win = ImcompressorWindow(application=self)
win.present()
def main(version):
app = Application()
return app.run(sys.argv)

34
src/meson.build Normal file
View File

@ -0,0 +1,34 @@
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
moduledir = join_paths(pkgdatadir, 'imcompressor')
gnome = import('gnome')
gnome.compile_resources('imcompressor',
'imcompressor.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)
python = import('python')
conf = configuration_data()
conf.set('PYTHON', python.find_installation('python3').path())
conf.set('VERSION', meson.project_version())
conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
conf.set('pkgdatadir', pkgdatadir)
configure_file(
input: 'imcompressor.in',
output: 'imcompressor',
configuration: conf,
install: true,
install_dir: get_option('bindir')
)
imcompressor_sources = [
'__init__.py',
'main.py',
'window.py',
]
install_data(imcompressor_sources, install_dir: moduledir)

28
src/window.py Normal file
View File

@ -0,0 +1,28 @@
# window.py
#
# Copyright 2019 Hugo Posnic
#
# 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/>.
from gi.repository import Gtk
@Gtk.Template(resource_path='/com/github/ImCompressor/window.ui')
class ImcompressorWindow(Gtk.ApplicationWindow):
__gtype_name__ = 'ImcompressorWindow'
label = Gtk.Template.Child()
def __init__(self, **kwargs):
super().__init__(**kwargs)

25
src/window.ui Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="ImcompressorWindow" parent="GtkApplicationWindow">
<property name="default-width">600</property>
<property name="default-height">300</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header_bar">
<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>