Setup project with working icon resources

This commit is contained in:
Daniele Verducci
2024-03-28 07:33:25 +01:00
commit ef006ae99b
27 changed files with 1327 additions and 0 deletions

0
src/__init__.py Normal file
View File

29
src/gtk/help-overlay.ui Normal file
View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkShortcutsWindow" id="help_overlay">
<property name="modal">True</property>
<child>
<object class="GtkShortcutsSection">
<property name="section-name">shortcuts</property>
<property name="max-height">10</property>
<child>
<object class="GtkShortcutsGroup">
<property name="title" translatable="yes" context="shortcut window">General</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Show Shortcuts</property>
<property name="action-name">win.show-help-overlay</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Quit</property>
<property name="action-name">app.quit</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

7
src/lumos.gresource.xml Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/eu/ichibi/Lumos">
<file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
</gresource>
</gresources>

49
src/lumos.in Executable file
View File

@@ -0,0 +1,49 @@
#!@PYTHON@
# lumos.in
#
# Copyright 2024 Daniele Verducci
#
# 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/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
import os
import sys
import signal
import locale
import gettext
VERSION = '@VERSION@'
pkgdatadir = '@pkgdatadir@'
localedir = '@localedir@'
sys.path.insert(1, pkgdatadir)
signal.signal(signal.SIGINT, signal.SIG_DFL)
locale.bindtextdomain('lumos', localedir)
locale.textdomain('lumos')
gettext.install('lumos', localedir)
if __name__ == '__main__':
import gi
from gi.repository import Gio
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'lumos.gresource'))
resource._register()
resource_icons = Gio.Resource.load(os.path.join(pkgdatadir, 'resources.gresource'))
resource_icons._register()
from lumos import main
sys.exit(main.main(VERSION))

86
src/main.py Normal file
View File

@@ -0,0 +1,86 @@
# main.py
#
# Copyright 2024 Daniele Verducci
#
# 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/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
import sys
import gi
import os
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Gio, Adw
from .window import LumosWindow
class LumosApplication(Adw.Application):
"""The main application singleton class."""
def __init__(self):
super().__init__(application_id='eu.ichibi.Lumos',
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
self.create_action('quit', lambda *_: self.quit(), ['<primary>q'])
self.create_action('about', self.on_about_action)
self.create_action('preferences', self.on_preferences_action)
def do_activate(self):
"""Called when the application is activated.
We raise the application's main window, creating it if
necessary.
"""
win = self.props.active_window
if not win:
win = LumosWindow(application=self)
win.present()
def on_about_action(self, widget, _):
"""Callback for the app.about action."""
about = Adw.AboutWindow(transient_for=self.props.active_window,
application_name='lumos',
application_icon='eu.ichibi.Lumos',
developer_name='Daniele Verducci',
version='0.1.0',
developers=['Daniele Verducci'],
copyright='© 2024 Daniele Verducci')
about.present()
def on_preferences_action(self, widget, _):
"""Callback for the app.preferences action."""
print('app.preferences action activated')
def create_action(self, name, callback, shortcuts=None):
"""Add an application action.
Args:
name: the name of the action
callback: the function to be called when the action is
activated
shortcuts: an optional list of accelerators
"""
action = Gio.SimpleAction.new(name, None)
action.connect("activate", callback)
self.add_action(action)
if shortcuts:
self.set_accels_for_action(f"app.{name}", shortcuts)
def main(version):
"""The application's entry point."""
app = LumosApplication()
return app.run(sys.argv)

35
src/meson.build Normal file
View File

@@ -0,0 +1,35 @@
pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name()
moduledir = pkgdatadir / 'lumos'
gnome = import('gnome')
gnome.compile_resources('lumos',
'lumos.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', get_option('prefix') / get_option('localedir'))
conf.set('pkgdatadir', pkgdatadir)
configure_file(
input: 'lumos.in',
output: 'lumos',
configuration: conf,
install: true,
install_dir: get_option('bindir'),
install_mode: 'r-xr--r--'
)
lumos_sources = [
'__init__.py',
'main.py',
'window.py',
]
install_data(lumos_sources, install_dir: moduledir)

30
src/window.py Normal file
View File

@@ -0,0 +1,30 @@
# window.py
#
# Copyright 2024 Daniele Verducci
#
# 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/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
from gi.repository import Adw
from gi.repository import Gtk
@Gtk.Template(resource_path='/eu/ichibi/Lumos/window.ui')
class LumosWindow(Adw.ApplicationWindow):
__gtype_name__ = 'LumosWindow'
#label = Gtk.Template.Child()
def __init__(self, **kwargs):
super().__init__(**kwargs)

116
src/window.ui Normal file
View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="Adw" version="1.0"/>
<template class="LumosWindow" parent="AdwApplicationWindow">
<property name="default-width">480</property>
<property name="default-height">800</property>
<property name="content">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" id="header_bar">
<child type="end">
<object class="GtkMenuButton">
<property name="primary">True</property>
<property name="icon-name">open-menu-symbolic</property>
<property name="tooltip-text" translatable="yes">Menu</property>
<property name="menu-model">primary_menu</property>
</object>
</child>
</object>
</child>
<property name="content">
<object class="GtkBox">
<property name="orientation">1</property>
<!-- Pages Stack -->
<child>
<object class="AdwViewStack" id="stack">
<property name="vexpand">true</property>
<child>
<!-- Aperture priority page -->
<object class="AdwViewStackPage" id="aperture-priority-page">
<property name="name">aperture-priority-page</property>
<property name="title" translatable="true">Aperture priority</property>
<property name="icon-name">camera-shutter-symbolic</property>
<property name="use-underline">true</property>
<property name="child">
<object class="GtkLabel" id="aperture-label">
<property name="label">Aperture priority mode!</property>
<style>
<class name="title-1"/>
</style>
</object>
</property>
</object>
</child>
<!-- Time priority page -->
<child>
<object class="AdwViewStackPage" id="time-priority-page">
<property name="name">time-priority-page</property>help
<property name="title" translatable="true">Time priority</property>
<property name="icon-name">camera-timer-symbolic</property>
<property name="use-underline">true</property>
<property name="child">
<object class="GtkLabel" id="time-label">
<property name="label">Time priority mode!</property>
<style>
<class name="title-1"/>
</style>
</object>
</property>
</object>
</child>
<!-- Manual mode page -->
<child>
<object class="AdwViewStackPage" id="manual-mode-page">
<property name="name">manual-mode-page</property>
<property name="title" translatable="true">Manual</property>
<property name="icon-name">encoder-knob-symbolic</property>
<property name="use-underline">true</property>
<property name="child">
<object class="GtkLabel" id="manual-label">
<property name="label">Manual mode!</property>
<style>
<class name="title-1"/>
</style>
</object>
</property>
</object>
</child>
</object>
</child>
<!-- Bottom tab bar -->
<child>
<object class="AdwViewSwitcher" id="switcher_title">
<property name="stack">stack</property>
</object>
</child>
</object>
</property>
</object>
</property>
</template>
<menu id="primary_menu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">win.show-help-overlay</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About Lumos</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
</interface>