mirror of
https://github.com/GradienceTeam/Gradience.git
synced 2024-07-05 10:37:52 +00:00
Merge pull request #121 from tfuxu/meson-refactor
Refactoring meson architecture
This commit is contained in:
commit
fd010a84d7
41
meson.build
41
meson.build
|
@ -6,14 +6,43 @@ project('adwcustomizer',
|
|||
],
|
||||
)
|
||||
|
||||
dependency('glib-2.0')
|
||||
dependency('pygobject-3.0')
|
||||
dependency('libadwaita-1')
|
||||
|
||||
i18n = import('i18n')
|
||||
|
||||
# Import modules
|
||||
gnome = import('gnome')
|
||||
i18n = import('i18n')
|
||||
python = import('python')
|
||||
|
||||
# Constants
|
||||
PROJECT_RDNN_NAME = 'com.github.AdwCustomizerTeam.AdwCustomizer'
|
||||
APPLICATION_ID = PROJECT_RDNN_NAME
|
||||
|
||||
dependency('glib-2.0')
|
||||
dependency('gtk4', version: '>= 4.5.0')
|
||||
dependency('libadwaita-1', version: '>= 1.2.alpha')
|
||||
dependency('pygobject-3.0', version: '>= 3.42.0')
|
||||
|
||||
# Python installation directory
|
||||
PY_INSTALLDIR = python.find_installation('python3')
|
||||
|
||||
# Check if python3 is installed
|
||||
if not PY_INSTALLDIR.found()
|
||||
error('No valid python3 binary found')
|
||||
endif
|
||||
|
||||
PKGDATA_DIR = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
|
||||
MODULE_DIR = join_paths(PKGDATA_DIR, 'adwcustomizer')
|
||||
PLUGINS_DIR = join_paths(PKGDATA_DIR, 'adwcustomizer', 'plugins')
|
||||
|
||||
# Install configuration data
|
||||
conf = configuration_data()
|
||||
conf.set('APP_ID', PROJECT_RDNN_NAME)
|
||||
conf.set('PKGDATA_DIR', PKGDATA_DIR)
|
||||
conf.set('DATA_DIR', join_paths(get_option('prefix'), get_option('datadir')))
|
||||
conf.set('LOCALE_DIR', join_paths(get_option('prefix'), get_option('localedir')))
|
||||
conf.set('PYTHON', PY_INSTALLDIR.full_path())
|
||||
conf.set('VERSION', meson.project_version())
|
||||
conf.set('BUILD_TYPE', get_option('buildtype'))
|
||||
|
||||
# Subdirs
|
||||
subdir('data')
|
||||
subdir('src')
|
||||
subdir('po')
|
||||
|
|
|
@ -24,15 +24,17 @@ import signal
|
|||
import locale
|
||||
import gettext
|
||||
|
||||
VERSION = '@VERSION@'
|
||||
pkgdatadir = '@pkgdatadir@'
|
||||
localedir = '@localedir@'
|
||||
pkgdatadir = '@PKGDATA_DIR@'
|
||||
localedir = '@LOCALE_DIR@'
|
||||
version = '@VERSION@'
|
||||
|
||||
sys.path.insert(1, pkgdatadir)
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
gettext.install('adwcustomizer', localedir)
|
||||
|
||||
locale.bindtextdomain('adwcustomizer', localedir)
|
||||
locale.textdomain('adwcustomizer')
|
||||
gettext.install('adwcustomizer', localedir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import gi
|
||||
|
@ -43,8 +45,9 @@ if __name__ == '__main__':
|
|||
gi.require_version('XdpGtk4', '1.0')
|
||||
|
||||
from gi.repository import Gio
|
||||
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'adwcustomizer.gresource'))
|
||||
resource = Gio.Resource.load(
|
||||
os.path.join(pkgdatadir, 'adwcustomizer.gresource'))
|
||||
resource._register()
|
||||
|
||||
from adwcustomizer import main
|
||||
sys.exit(main.main(VERSION))
|
||||
sys.exit(main.main(version))
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
from gi.repository import Gtk, Adw
|
||||
|
||||
from .constants import rootdir
|
||||
|
||||
@Gtk.Template(
|
||||
resource_path="/com/github/AdwCustomizerTeam/AdwCustomizer/ui/app_type_dialog.ui"
|
||||
)
|
||||
|
||||
@Gtk.Template(resource_path=f"{rootdir}/ui/app_type_dialog.ui")
|
||||
class AdwcustomizerAppTypeDialog(Adw.MessageDialog):
|
||||
__gtype_name__ = "AdwcustomizerAppTypeDialog"
|
||||
|
||||
|
|
4
src/constants.py.in
Normal file
4
src/constants.py.in
Normal file
|
@ -0,0 +1,4 @@
|
|||
rootdir = '/com/github/AdwCustomizerTeam/AdwCustomizer'
|
||||
app_id = '@APP_ID@'
|
||||
version = '@VERSION@'
|
||||
build_type = '@BUILD_TYPE@'
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
from gi.repository import Gtk, Adw
|
||||
|
||||
from .constants import rootdir
|
||||
|
||||
@Gtk.Template(
|
||||
resource_path="/com/github/AdwCustomizerTeam/AdwCustomizer/ui/custom_css_group.ui"
|
||||
)
|
||||
|
||||
@Gtk.Template(resource_path=f"{rootdir}/ui/custom_css_group.ui")
|
||||
class AdwcustomizerCustomCSSGroup(Adw.PreferencesGroup):
|
||||
__gtype_name__ = "AdwcustomizerCustomCSSGroup"
|
||||
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .constants import rootdir
|
||||
|
||||
@Gtk.Template(resource_path="/com/github/AdwCustomizerTeam/AdwCustomizer/ui/error.ui")
|
||||
|
||||
@Gtk.Template(resource_path=f"{rootdir}/ui/error.ui")
|
||||
class AdwcustomizerError(Gtk.ListBoxRow):
|
||||
__gtype_name__ = "AdwcustomizerError"
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
version = '@version@'
|
||||
build_type = '@build_type@'
|
12
src/main.py
12
src/main.py
|
@ -35,7 +35,7 @@ from .option import AdwcustomizerOption
|
|||
from .app_type_dialog import AdwcustomizerAppTypeDialog
|
||||
from .custom_css_group import AdwcustomizerCustomCSSGroup
|
||||
from .plugins_list import AdwcustomizerPluginsList
|
||||
from . import info
|
||||
from .constants import rootdir, app_id, version
|
||||
|
||||
|
||||
def to_slug_case(non_slug):
|
||||
|
@ -47,7 +47,7 @@ class AdwcustomizerApplication(Adw.Application):
|
|||
|
||||
def __init__(self, version):
|
||||
super().__init__(
|
||||
application_id="com.github.AdwCustomizerTeam.AdwCustomizer",
|
||||
application_id=app_id,
|
||||
flags=Gio.ApplicationFlags.FLAGS_NONE,
|
||||
)
|
||||
self.version = version
|
||||
|
@ -100,11 +100,11 @@ class AdwcustomizerApplication(Adw.Application):
|
|||
self.style_manager = Adw.StyleManager.get_default()
|
||||
if self.style_manager.get_dark():
|
||||
self.load_preset_from_resource(
|
||||
"/com/github/AdwCustomizerTeam/AdwCustomizer/presets/adwaita-dark.json"
|
||||
f"{rootdir}/presets/adwaita-dark.json"
|
||||
)
|
||||
else:
|
||||
self.load_preset_from_resource(
|
||||
"/com/github/AdwCustomizerTeam/AdwCustomizer/presets/adwaita.json"
|
||||
f"{rootdir}/presets/adwaita.json"
|
||||
)
|
||||
|
||||
self.win.present()
|
||||
|
@ -412,7 +412,7 @@ class AdwcustomizerApplication(Adw.Application):
|
|||
)
|
||||
else:
|
||||
self.load_preset_from_resource(
|
||||
"/com/github/AdwCustomizerTeam/AdwCustomizer/presets/"
|
||||
f"{rootdir}/presets/"
|
||||
+ args[0].get_string()
|
||||
+ ".json"
|
||||
)
|
||||
|
@ -665,7 +665,7 @@ class AdwcustomizerApplication(Adw.Application):
|
|||
Taylan Tatlı https://www.transifex.com/user/profile/TaylanTatli34/""",
|
||||
copyright="© 2022 Adwaita Manager Team",
|
||||
license_type=Gtk.License.GPL_3_0,
|
||||
version=f"{info.version}",
|
||||
version=f"{version}",
|
||||
release_notes="""
|
||||
<ul>
|
||||
<li>Add AdwViewSwitcher in the header bar.</li>
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
|
||||
moduledir = join_paths(pkgdatadir, 'adwcustomizer')
|
||||
pluginsdir = join_paths(pkgdatadir, 'adwcustomizer', 'plugins')
|
||||
gnome = import('gnome')
|
||||
|
||||
blueprints = custom_target('blueprints',
|
||||
|
@ -20,18 +17,10 @@ gnome.compile_resources('adwcustomizer',
|
|||
'adwcustomizer.gresource.xml',
|
||||
gresource_bundle: true,
|
||||
install: true,
|
||||
install_dir: pkgdatadir,
|
||||
install_dir: PKGDATA_DIR,
|
||||
dependencies: blueprints,
|
||||
)
|
||||
|
||||
python = import('python')
|
||||
|
||||
conf = configuration_data()
|
||||
conf.set('PYTHON', python.find_installation('python3').full_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: 'adwcustomizer.in',
|
||||
output: 'adwcustomizer',
|
||||
|
@ -41,16 +30,14 @@ configure_file(
|
|||
)
|
||||
|
||||
configure_file(
|
||||
input: 'info.py.in',
|
||||
output: '@BASENAME@',
|
||||
install: true,
|
||||
install_dir: moduledir,
|
||||
configuration: configuration_data({
|
||||
'version': meson.project_version(),
|
||||
'build_type': get_option('buildtype'),
|
||||
}),
|
||||
input: 'constants.py.in',
|
||||
output: 'constants.py',
|
||||
configuration: conf,
|
||||
install: true,
|
||||
install_dir: MODULE_DIR
|
||||
)
|
||||
|
||||
# Install sources
|
||||
adwcustomizer_sources = [
|
||||
'__init__.py',
|
||||
'settings_schema.py',
|
||||
|
@ -65,11 +52,10 @@ adwcustomizer_sources = [
|
|||
'app_type_dialog.py',
|
||||
'custom_css_group.py',
|
||||
]
|
||||
install_data(adwcustomizer_sources, install_dir: MODULE_DIR)
|
||||
|
||||
plugins_sources = [
|
||||
'plugins/__init__.py',
|
||||
'plugins/gtk4.py'
|
||||
]
|
||||
|
||||
install_data(adwcustomizer_sources, install_dir: moduledir)
|
||||
install_data(plugins_sources, install_dir: pluginsdir)
|
||||
install_data(plugins_sources, install_dir: PLUGINS_DIR)
|
|
@ -18,8 +18,10 @@
|
|||
|
||||
from gi.repository import Gtk, Gdk, Adw
|
||||
|
||||
from .constants import rootdir
|
||||
|
||||
@Gtk.Template(resource_path="/com/github/AdwCustomizerTeam/AdwCustomizer/ui/option.ui")
|
||||
|
||||
@Gtk.Template(resource_path=f"{rootdir}/ui/option.ui")
|
||||
class AdwcustomizerOption(Adw.ActionRow):
|
||||
__gtype_name__ = "AdwcustomizerOption"
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
from gi.repository import Gtk, Gdk, Adw
|
||||
|
||||
from .constants import rootdir
|
||||
|
||||
@Gtk.Template(
|
||||
resource_path="/com/github/AdwCustomizerTeam/AdwCustomizer/ui/palette_shades.ui"
|
||||
)
|
||||
|
||||
@Gtk.Template(resource_path=f"{rootdir}/ui/palette_shades.ui")
|
||||
class AdwcustomizerPaletteShades(Adw.ActionRow):
|
||||
__gtype_name__ = "AdwcustomizerPaletteShades"
|
||||
|
||||
|
|
|
@ -34,9 +34,10 @@ from .option import AdwcustomizerOption
|
|||
from .app_type_dialog import AdwcustomizerAppTypeDialog
|
||||
from .custom_css_group import AdwcustomizerCustomCSSGroup
|
||||
from material_color_utilities_python import *
|
||||
from .constants import rootdir, build_type
|
||||
|
||||
|
||||
@Gtk.Template(resource_path="/com/github/AdwCustomizerTeam/AdwCustomizer/ui/window.ui")
|
||||
@Gtk.Template(resource_path=f"{rootdir}/ui/window.ui")
|
||||
class AdwcustomizerMainWindow(Adw.ApplicationWindow):
|
||||
__gtype_name__ = "AdwcustomizerMainWindow"
|
||||
|
||||
|
@ -57,6 +58,10 @@ class AdwcustomizerMainWindow(Adw.ApplicationWindow):
|
|||
"show", self.on_presets_dropdown_activate
|
||||
)
|
||||
|
||||
# Set devel style
|
||||
if build_type == "debug":
|
||||
self.get_style_context().add_class("devel")
|
||||
|
||||
self.setup_monet_page()
|
||||
self.setup_plugins_page()
|
||||
self.setup_colors_page()
|
||||
|
|
Loading…
Reference in a new issue