diff --git a/meson.build b/meson.build index e22a4fc1..b20af991 100644 --- a/meson.build +++ b/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') diff --git a/src/adwcustomizer.in b/src/adwcustomizer.in index 7f88fc5f..14610ac8 100755 --- a/src/adwcustomizer.in +++ b/src/adwcustomizer.in @@ -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)) diff --git a/src/app_type_dialog.py b/src/app_type_dialog.py index f7f88133..600d9452 100644 --- a/src/app_type_dialog.py +++ b/src/app_type_dialog.py @@ -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" diff --git a/src/constants.py.in b/src/constants.py.in new file mode 100644 index 00000000..67eb90c7 --- /dev/null +++ b/src/constants.py.in @@ -0,0 +1,4 @@ +rootdir = '/com/github/AdwCustomizerTeam/AdwCustomizer' +app_id = '@APP_ID@' +version = '@VERSION@' +build_type = '@BUILD_TYPE@' \ No newline at end of file diff --git a/src/custom_css_group.py b/src/custom_css_group.py index 1f98ab80..d241fbc3 100644 --- a/src/custom_css_group.py +++ b/src/custom_css_group.py @@ -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" diff --git a/src/error.py b/src/error.py index 2760bd54..8c87839e 100644 --- a/src/error.py +++ b/src/error.py @@ -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" diff --git a/src/info.py.in b/src/info.py.in deleted file mode 100644 index 20fc3494..00000000 --- a/src/info.py.in +++ /dev/null @@ -1,2 +0,0 @@ -version = '@version@' -build_type = '@build_type@' \ No newline at end of file diff --git a/src/main.py b/src/main.py index acd4983c..f572e6ac 100644 --- a/src/main.py +++ b/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="""