Splitted main layout in widgets, implemented widgets loader

This commit is contained in:
Daniele Verducci 2024-04-02 08:47:09 +02:00
parent e22f17dbc1
commit 96c675c6b8
8 changed files with 122 additions and 69 deletions

View File

@ -4,3 +4,5 @@ data/eu.ichibi.Lumos.gschema.xml
src/main.py src/main.py
src/window.py src/window.py
src/window.ui src/window.ui
src/widgets/time_priority_page.py
src/widgets/time_priority_page.ui

View File

@ -2,6 +2,7 @@
<gresources> <gresources>
<gresource prefix="/eu/ichibi/Lumos"> <gresource prefix="/eu/ichibi/Lumos">
<file preprocess="xml-stripblanks">window.ui</file> <file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">widgets/time_priority_page.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file> <file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
</gresource> </gresource>
</gresources> </gresources>

View File

@ -26,6 +26,7 @@ gi.require_version('Adw', '1')
from gi.repository import Gtk, Gio, Adw from gi.repository import Gtk, Gio, Adw
from .window import LumosWindow from .window import LumosWindow
from .widgets_loader import registerWidgets
class LumosApplication(Adw.Application): class LumosApplication(Adw.Application):
@ -44,6 +45,11 @@ class LumosApplication(Adw.Application):
We raise the application's main window, creating it if We raise the application's main window, creating it if
necessary. necessary.
""" """
# Register all widgets
registerWidgets();
# Create window
win = self.props.active_window win = self.props.active_window
if not win: if not win:
win = LumosWindow(application=self) win = LumosWindow(application=self)

View File

@ -30,6 +30,8 @@ lumos_sources = [
'__init__.py', '__init__.py',
'main.py', 'main.py',
'window.py', 'window.py',
'widgets/widgets_loader.py',
'widgets/time_priority_page.py',
] ]
install_data(lumos_sources, install_dir: moduledir) install_data(lumos_sources, install_dir: moduledir)

View File

@ -0,0 +1,26 @@
# time_priority_page.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/widgets/time_priority_page.ui')
class TimePriorityPage(Gtk.Box):
__gtype_name__ = 'TimePriorityPage'

View File

@ -0,0 +1,76 @@
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="adw" version="1.0"/>
<template class="TimePriorityPage" parent="GtkBox">
<property name="orientation">1</property>
<property name="valign">3</property>
<property name="halign">3</property>
<child>
<object class="GtkImage">
<property name="icon-name">camera-timer-symbolic</property>
<property name="pixel-size">64</property>
<property name="margin-bottom">30</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Time priority</property>
<style>
<class name="title-1"/>
</style>
<property name="margin-bottom">30</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Set this aperture value:</property>
<property name="margin-bottom">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="time-priority-aperture-label">
<property name="label" translatable="no">f/11</property>
<style>
<class name="lumos-big-result"/>
</style>
<property name="margin-bottom">30</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Your camera's time setting is:</property>
<property name="margin-bottom">15</property>
</object>
</child>
<child>
<object class="GtkDropDown" id="time-priority-speed-dropdown">
<property name="model">
<object class="GtkStringList">
<items>
<item translatable="no">1/ 4000</item>
<item translatable="no">1/ 2000</item>
<item translatable="no">1/ 1000</item>
<item translatable="no">1/ 500</item>
<item translatable="no">1/ 250</item>
<item translatable="no">1/ 125</item>
<item translatable="no">1/ 60</item>
<item translatable="no">1/ 30</item>
<item translatable="no">1/ 15</item>
<item translatable="no">1/ 8</item>
<item translatable="no">1/ 4</item>
<item translatable="no">1/ 2</item>
<item translatable="no">1 sec</item>
<item translatable="no">2 sec</item>
<item translatable="no">4 sec</item>
<item translatable="no">8 sec</item>
<item translatable="no">15 sec</item>
<item translatable="no">30 sec</item>
</items>
</object>
</property>
</object>
</child>
</template>
</interface>

View File

@ -0,0 +1,8 @@
from gi.repository import GObject
from .time_priority_page import TimePriorityPage
# Register widgets to be used in templates UI
def registerWidgets() -> None:
GObject.type_ensure(TimePriorityPage)

View File

@ -53,75 +53,7 @@
<property name="icon-name">camera-timer-symbolic</property> <property name="icon-name">camera-timer-symbolic</property>
<property name="use-underline">true</property> <property name="use-underline">true</property>
<property name="child"> <property name="child">
<object class="GtkBox"> <object class="TimePriorityPage" id="time-priority-page-widget">
<property name="orientation">1</property>
<property name="valign">3</property>
<property name="halign">3</property>
<child>
<object class="GtkImage">
<property name="icon-name">camera-timer-symbolic</property>
<property name="pixel-size">64</property>
<property name="margin-bottom">30</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Time priority</property>
<style>
<class name="title-1"/>
</style>
<property name="margin-bottom">30</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Set this aperture value:</property>
<property name="margin-bottom">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="time-priority-aperture-label">
<property name="label" translatable="no">f/11</property>
<style>
<class name="title-1"/>
</style>
<property name="margin-bottom">30</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Your camera's time setting is:</property>
<property name="margin-bottom">15</property>
</object>
</child>
<child>
<object class="GtkDropDown" id="time-priority-speed-dropdown">
<property name="model">
<object class="GtkStringList">
<items>
<item translatable="no">1/ 4000</item>
<item translatable="no">1/ 2000</item>
<item translatable="no">1/ 1000</item>
<item translatable="no">1/ 500</item>
<item translatable="no">1/ 250</item>
<item translatable="no">1/ 125</item>
<item translatable="no">1/ 60</item>
<item translatable="no">1/ 30</item>
<item translatable="no">1/ 15</item>
<item translatable="no">1/ 8</item>
<item translatable="no">1/ 4</item>
<item translatable="no">1/ 2</item>
<item translatable="no">1 sec</item>
<item translatable="no">2 sec</item>
<item translatable="no">4 sec</item>
<item translatable="no">8 sec</item>
<item translatable="no">15 sec</item>
<item translatable="no">30 sec</item>
</items>
</object>
</property>
</object>
</child>
</object> </object>
</property> </property>
</object> </object>