From fd3c2bfb92e09d4ab5aeb1055e3dbb0a1040f72b Mon Sep 17 00:00:00 2001
From: Romain Failliot
Date: Sun, 29 Mar 2020 10:08:15 -0400
Subject: [PATCH] Start modularizing the code
* The entry point (`__main__`) is in diffuxe.in
* The main (almost all) code is now in main.py
* Some util functions and variables are in utils.py
* Following the same folder structure as with a new project with GNOME
Builder:
- `src/` is now just for the code itself
- `data/` is for the other files (metainfo, desktop, config, ...)
- `po/` for the translations
- The Desktop file is renamed with the app ID
- The `meson.build` files are closer to what GNOME Builder generates
- More tests for the package (appstream and desktop)
- Almost all the files in `etc/`, `usr/` are properly handled by
meson now
- Just use `gettext.install()` to initialize gettext
- Remove call to `Gtk.Window.set_default_icon_name()`
* Website now points to https://mightycreak.github.io/diffuse/
---
.github/workflows/main.yml | 13 +-
.gitignore | 3 +-
.vscode/launch.json | 28 +
CHANGELOG.md | 2 +
README.md | 85 ++--
.../meson/postinstall.py | 8 +-
src/etc/diffuserc.py.in => data/diffuserc.in | 0
.../io.github.mightycreak.Diffuse.Devel.svg | 0
.../apps/io.github.mightycreak.Diffuse.svg | 0
...io.github.mightycreak.Diffuse-symbolic.svg | 0
data/icons/meson.build | 13 +
... io.github.mightycreak.Diffuse.desktop.in} | 0
...github.mightycreak.Diffuse.metainfo.xml.in | 11 +-
data/meson.build | 53 +-
.../usr/share/diffuse/syntax/bash.syntax | 0
.../usr/share/diffuse/syntax/c++.syntax | 0
.../usr/share/diffuse/syntax/csh.syntax | 0
.../usr/share/diffuse/syntax/csharp.syntax | 0
.../usr/share/diffuse/syntax/css.syntax | 0
.../usr/share/diffuse/syntax/erlang.syntax | 0
.../usr/share/diffuse/syntax/fortran.syntax | 0
.../usr/share/diffuse/syntax/gettext.syntax | 0
.../usr/share/diffuse/syntax/glsl.syntax | 0
.../usr/share/diffuse/syntax/html.syntax | 0
.../usr/share/diffuse/syntax/ini.syntax | 0
.../usr/share/diffuse/syntax/java.syntax | 0
.../share/diffuse/syntax/javascript.syntax | 0
.../usr/share/diffuse/syntax/json.syntax | 0
.../usr/share/diffuse/syntax/jsp.syntax | 0
.../usr/share/diffuse/syntax/makefile.syntax | 0
.../share/diffuse/syntax/objective-c++.syntax | 0
.../usr/share/diffuse/syntax/octave.syntax | 0
.../usr/share/diffuse/syntax/opencl.syntax | 0
.../usr/share/diffuse/syntax/pascal.syntax | 0
.../usr/share/diffuse/syntax/patch.syntax | 0
.../usr/share/diffuse/syntax/perl.syntax | 0
.../usr/share/diffuse/syntax/php.syntax | 0
.../usr/share/diffuse/syntax/python.syntax | 0
.../usr/share/diffuse/syntax/r.syntax | 0
.../usr/share/diffuse/syntax/ruby.syntax | 0
.../usr/share/diffuse/syntax/sql.syntax | 0
.../usr/share/diffuse/syntax/tcl.syntax | 0
.../usr/share/diffuse/syntax/vb.syntax | 0
.../usr/share/diffuse/syntax/verilog.syntax | 0
.../usr/share/diffuse/syntax/vhdl.syntax | 0
.../usr/share/diffuse/syntax/xml.syntax | 0
.../share/gnome/help/diffuse/C/diffuse.xml | 0
.../share/gnome/help/diffuse/cs/diffuse.xml | 0
.../share/gnome/help/diffuse/it/diffuse.xml | 0
.../share/gnome/help/diffuse/ru/diffuse.xml | 0
{src => data}/usr/share/man/cs/man1/diffuse.1 | 0
{src => data}/usr/share/man/it/man1/diffuse.1 | 0
{src => data}/usr/share/man/man1/diffuse.1 | 0
{src => data}/usr/share/man/ru/man1/diffuse.1 | 0
.../usr/share/omf/diffuse/diffuse-C.omf | 0
.../usr/share/omf/diffuse/diffuse-cs.omf | 0
.../usr/share/omf/diffuse/diffuse-it.omf | 0
.../usr/share/omf/diffuse/diffuse-ru.omf | 0
io.github.mightycreak.Diffuse.yml | 13 +-
meson.build | 26 +-
src/__init__.py | 0
src/diffuse.in | 37 ++
src/{usr/bin/diffuse.py.in => main.py} | 414 +++++++--------
src/meson.build | 56 +-
src/utils.py | 93 ++++
windows-installer/build.py | 478 +++++++++---------
66 files changed, 737 insertions(+), 596 deletions(-)
create mode 100644 .vscode/launch.json
rename build-scripts/meson-postinstall.py => build-aux/meson/postinstall.py (62%)
rename src/etc/diffuserc.py.in => data/diffuserc.in (100%)
rename {src/usr/share => data}/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.Devel.svg (100%)
rename {src/usr/share => data}/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.svg (100%)
rename {src/usr/share => data}/icons/hicolor/symbolic/apps/io.github.mightycreak.Diffuse-symbolic.svg (100%)
create mode 100644 data/icons/meson.build
rename data/{diffuse.desktop.in => io.github.mightycreak.Diffuse.desktop.in} (100%)
rename src/usr/share/metainfo/io.github.mightycreak.Diffuse.metainfo.xml => data/io.github.mightycreak.Diffuse.metainfo.xml.in (98%)
rename {src => data}/usr/share/diffuse/syntax/bash.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/c++.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/csh.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/csharp.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/css.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/erlang.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/fortran.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/gettext.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/glsl.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/html.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/ini.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/java.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/javascript.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/json.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/jsp.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/makefile.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/objective-c++.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/octave.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/opencl.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/pascal.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/patch.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/perl.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/php.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/python.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/r.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/ruby.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/sql.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/tcl.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/vb.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/verilog.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/vhdl.syntax (100%)
rename {src => data}/usr/share/diffuse/syntax/xml.syntax (100%)
rename {src => data}/usr/share/gnome/help/diffuse/C/diffuse.xml (100%)
rename {src => data}/usr/share/gnome/help/diffuse/cs/diffuse.xml (100%)
rename {src => data}/usr/share/gnome/help/diffuse/it/diffuse.xml (100%)
rename {src => data}/usr/share/gnome/help/diffuse/ru/diffuse.xml (100%)
rename {src => data}/usr/share/man/cs/man1/diffuse.1 (100%)
rename {src => data}/usr/share/man/it/man1/diffuse.1 (100%)
rename {src => data}/usr/share/man/man1/diffuse.1 (100%)
rename {src => data}/usr/share/man/ru/man1/diffuse.1 (100%)
rename {src => data}/usr/share/omf/diffuse/diffuse-C.omf (100%)
rename {src => data}/usr/share/omf/diffuse/diffuse-cs.omf (100%)
rename {src => data}/usr/share/omf/diffuse/diffuse-it.omf (100%)
rename {src => data}/usr/share/omf/diffuse/diffuse-ru.omf (100%)
create mode 100644 src/__init__.py
create mode 100755 src/diffuse.in
rename src/{usr/bin/diffuse.py.in => main.py} (97%)
mode change 100755 => 100644
create mode 100644 src/utils.py
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index ccd8bd2..04179b5 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -2,7 +2,7 @@
name: CI
-# Controls when the action will run.
+# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
@@ -26,12 +26,15 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- - name: Meson Build
- uses: BSFishy/meson-build@v1.0.1
+ - name: Install dependencies
+ run: sudo apt-get -y install appstream appstream-util desktop-file-utils gettext
+
+ - name: Meson build
+ uses: BSFishy/meson-build@v1.0.3
with:
action: build
- - name: Meson Test
- uses: BSFishy/meson-build@v1.0.1
+ - name: Meson test
+ uses: BSFishy/meson-build@v1.0.3
with:
action: test
diff --git a/.gitignore b/.gitignore
index 8d6a672..04a5dc8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,8 +13,7 @@ __pycache__/
# Distribution / packaging
.Python
build/
-builddir/
-builddir-flatpak/
+build-flatpak/
develop-eggs/
dist/
downloads/
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..5a30cb8
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,28 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Python: Debug",
+ "type": "python",
+ "request": "launch",
+ "program": "${workspaceFolder}/main.py",
+ "console": "integratedTerminal",
+ // "env": {
+ // "PYTHONPATH": "."
+ // }
+ },
+ {
+ "name": "Python: Remote Attach",
+ "type": "python",
+ "request": "attach",
+ "port": 5678,
+ "host": "localhost",
+ "pathMappings": [
+ {
+ "localRoot": "${workspaceFolder}",
+ "remoteRoot": "."
+ }
+ ]
+ }
+ ]
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6dc933a..57922e6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added MetaInfo file
- New SVG icon (thanks @creepertron95, @jimmac and @freddii)
+- Started modularizing the code
### Changed
- Changed AppID to io.github.mightycreak.Diffuse (as explained in
@@ -21,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add .desktop translations in .po files
### Fixed
+- Fixed some GTK deprecation warnings
## [0.6.0] - 2020-11-29
diff --git a/README.md b/README.md
index 6e527cf..3a7b157 100644
--- a/README.md
+++ b/README.md
@@ -20,48 +20,71 @@ Some key features of Diffuse:
## Requirements
+Diffuse is implemented entirely in Python and should run on any platform with
+Python and PyGObject.
+
* Python >= 3.4
* PyGObject >= 3.18
-Diffuse is implemented entirely in Python and should run on any platform with
-Python and PyGTK. If you need to manually install PyGTK, please be aware its
-dependencies should be installed prior to installing PyGTK.
+## Users
-Diffuse can be run directly from an untared source distribution on any POSIX
-system or installed with the instructions described in the next section.
+### Installing using Flatpak
-The location of the personal preferences, state, and initialisation files have
-changed in the 0.4.1 release. Old settings may be migrated using the following
-commands:
+This is the easiest way to install Diffuse:
- $ mkdir -p ~/.config/diffuse
- $ mv ~/.diffuse/config ~/.config/diffuse/state
- $ mv ~/.diffuse/* ~/.config/diffuse
- $ rmdir ~/.diffuse
+```sh
+flatpak install io.github.mightycreak.Diffuse
+```
-The rules for parsing files in `~/.diffuse` changed in the 0.3.0 release.
-Non-fatal errors may be reported when parsing old files. These errors can be
-fixed by removing the offending lines (or the entire file) from
-`~/.config/diffuse/diffuserc`.
+## Developers
-## Installing on POSIX systems
+### Setup
+
+#### Run Diffuse from source
+
+To run Diffuse from the source code, type this:
+```sh
+python main.py
+```
+
+To debug with VS Code, open the directory in VS Code, place your breakpoints and hit F5.
+
+#### Build Diffuse
+
+To build Diffuse, type this:
+```sh
+python setup.py build
+```
+
+To run from the build, type this:
+```sh
+PYTHONPATH=build/lib ./build/scripts-3.7/diffuse
+```
+
+#### Install Diffuse locally
Diffuse build system is meson.
To install diffuse locally:
- meson builddir
- meson install -C builddir
+```sh
+meson setup build
+cd build
+meson compile
+meson install # requires admin privileges
+```
To uninstall diffuse afterwards:
- sudo ninja uninstall -C builddir
- sudo rm -v /usr/local/share/locale/*/LC_MESSAGES/diffuse.mo
+```sh
+sudo ninja uninstall -C build
+sudo rm -v /usr/local/share/locale/*/LC_MESSAGES/diffuse.mo
+```
Meson allows to change the default installation directories, see
[command-line documentation](https://mesonbuild.com/Commands.html#configure).
-## Installing on Windows
+### Installing on Windows
The `windows-installer` directory contains scripts for building an installable
package for Windows that includes all dependencies.
@@ -73,24 +96,26 @@ Diffuse. The `XDG_CONFIG_HOME` and `XDG_DATA_DIR` environment variables
indicate where Diffuse should store persistent settings (eg. the path to a
writable directory on the pen drive).
-## Installing the Flatpak package
-
- flatpak install io.github.mightycreak.Diffuse
-
## Building and testing the Flatpak package
To install Diffuse locally:
- flatpak install flatpak install runtime/org.gnome.Sdk/$(uname -p)/3.38
- flatpak-builder builddir-flatpak --user --install io.github.mightycreak.Diffuse.yml
+```sh
+flatpak install runtime/org.gnome.Sdk/$(uname -p)/3.38
+flatpak-builder build-flatpak --user --install io.github.mightycreak.Diffuse.yml
+```
To run Diffuse through Flatpak:
- flatpak run io.github.mightycreak.Diffuse
+```sh
+flatpak run io.github.mightycreak.Diffuse
+```
To uninstall Diffuse:
- flatpak remove io.github.mightycreak.Diffuse
+```sh
+flatpak remove io.github.mightycreak.Diffuse
+```
## Help Documentation
diff --git a/build-scripts/meson-postinstall.py b/build-aux/meson/postinstall.py
similarity index 62%
rename from build-scripts/meson-postinstall.py
rename to build-aux/meson/postinstall.py
index 6999cb4..2e07613 100644
--- a/build-scripts/meson-postinstall.py
+++ b/build-aux/meson/postinstall.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python3
-import sysconfig
-from compileall import compile_dir
from os import environ, path
from subprocess import call
@@ -13,3 +11,9 @@ destdir = environ.get('DESTDIR', '')
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')])
diff --git a/src/etc/diffuserc.py.in b/data/diffuserc.in
similarity index 100%
rename from src/etc/diffuserc.py.in
rename to data/diffuserc.in
diff --git a/src/usr/share/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.Devel.svg b/data/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.Devel.svg
similarity index 100%
rename from src/usr/share/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.Devel.svg
rename to data/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.Devel.svg
diff --git a/src/usr/share/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.svg b/data/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.svg
similarity index 100%
rename from src/usr/share/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.svg
rename to data/icons/hicolor/scalable/apps/io.github.mightycreak.Diffuse.svg
diff --git a/src/usr/share/icons/hicolor/symbolic/apps/io.github.mightycreak.Diffuse-symbolic.svg b/data/icons/hicolor/symbolic/apps/io.github.mightycreak.Diffuse-symbolic.svg
similarity index 100%
rename from src/usr/share/icons/hicolor/symbolic/apps/io.github.mightycreak.Diffuse-symbolic.svg
rename to data/icons/hicolor/symbolic/apps/io.github.mightycreak.Diffuse-symbolic.svg
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 0000000..2e3a308
--- /dev/null
+++ b/data/icons/meson.build
@@ -0,0 +1,13 @@
+application_id = 'io.github.mightycreak.Diffuse'
+
+scalable_dir = join_paths('hicolor', 'scalable', 'apps')
+install_data(
+ join_paths(scalable_dir, ('@0@.svg').format(application_id)),
+ install_dir: join_paths(get_option('datadir'), 'icons', scalable_dir)
+)
+
+symbolic_dir = join_paths('hicolor', 'symbolic', 'apps')
+install_data(
+ join_paths(symbolic_dir, ('@0@-symbolic.svg').format(application_id)),
+ install_dir: join_paths(get_option('datadir'), 'icons', symbolic_dir)
+)
diff --git a/data/diffuse.desktop.in b/data/io.github.mightycreak.Diffuse.desktop.in
similarity index 100%
rename from data/diffuse.desktop.in
rename to data/io.github.mightycreak.Diffuse.desktop.in
diff --git a/src/usr/share/metainfo/io.github.mightycreak.Diffuse.metainfo.xml b/data/io.github.mightycreak.Diffuse.metainfo.xml.in
similarity index 98%
rename from src/usr/share/metainfo/io.github.mightycreak.Diffuse.metainfo.xml
rename to data/io.github.mightycreak.Diffuse.metainfo.xml.in
index 86a598f..00e3ed9 100644
--- a/src/usr/share/metainfo/io.github.mightycreak.Diffuse.metainfo.xml
+++ b/data/io.github.mightycreak.Diffuse.metainfo.xml.in
@@ -1,7 +1,6 @@
io.github.mightycreak.Diffuse
-
Diffuse Merge Tool
Graphical tool for merging and comparing text files
@@ -9,23 +8,18 @@
Diffuse is a graphical tool for comparing and merging text files. It can retrieve files for comparison from Bazaar, CVS, Darcs, Git, Mercurial, Monotone, RCS, Subversion, and SVK repositories.
-
FSFAP
GPL-2.0-or-later
-
-
+
io.github.mightycreak.Diffuse.desktop
-
https://mightycreak.github.io/diffuse/
https://github.com/MightyCreak/diffuse/issues
-
- https://mightycreak.github.io/diffuse/images/screenshot_v0.5.0.png
Main window: diff between two files
+ https://mightycreak.github.io/diffuse/images/screenshot_v0.7.0.png
-
@@ -102,7 +96,6 @@
-
Romain Failliot
romain.failliot@foolstep.com
diff --git a/data/meson.build b/data/meson.build
index fa85471..19a354a 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,10 +1,49 @@
-desktop_file = 'diffuse.desktop'
-i18n.merge_file(
- desktop_file,
- input: desktop_file + '.in',
- output: desktop_file,
+pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
+
+desktop_file = i18n.merge_file(
+ input: 'io.github.mightycreak.Diffuse.desktop.in',
+ output: 'io.github.mightycreak.Diffuse.desktop',
+ type: 'desktop',
po_dir: '../po',
install: true,
- install_dir: join_paths(datadir, 'applications'),
- type: 'desktop'
+ 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: 'io.github.mightycreak.Diffuse.metainfo.xml.in',
+ output: 'io.github.mightycreak.Diffuse.metainfo.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
+
+# Diffuse config file
+conf = configuration_data()
+conf.set('PKGDATADIR', pkgdatadir)
+
+configure_file(
+ input: 'diffuserc.in',
+ output: 'diffuserc',
+ configuration: conf,
+ install: true,
+ install_dir: get_option('sysconfdir')
+)
+
+# Data files
+install_subdir('usr/share', install_dir: get_option('datadir'), strip_directory: true)
+
+subdir('icons')
diff --git a/src/usr/share/diffuse/syntax/bash.syntax b/data/usr/share/diffuse/syntax/bash.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/bash.syntax
rename to data/usr/share/diffuse/syntax/bash.syntax
diff --git a/src/usr/share/diffuse/syntax/c++.syntax b/data/usr/share/diffuse/syntax/c++.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/c++.syntax
rename to data/usr/share/diffuse/syntax/c++.syntax
diff --git a/src/usr/share/diffuse/syntax/csh.syntax b/data/usr/share/diffuse/syntax/csh.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/csh.syntax
rename to data/usr/share/diffuse/syntax/csh.syntax
diff --git a/src/usr/share/diffuse/syntax/csharp.syntax b/data/usr/share/diffuse/syntax/csharp.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/csharp.syntax
rename to data/usr/share/diffuse/syntax/csharp.syntax
diff --git a/src/usr/share/diffuse/syntax/css.syntax b/data/usr/share/diffuse/syntax/css.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/css.syntax
rename to data/usr/share/diffuse/syntax/css.syntax
diff --git a/src/usr/share/diffuse/syntax/erlang.syntax b/data/usr/share/diffuse/syntax/erlang.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/erlang.syntax
rename to data/usr/share/diffuse/syntax/erlang.syntax
diff --git a/src/usr/share/diffuse/syntax/fortran.syntax b/data/usr/share/diffuse/syntax/fortran.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/fortran.syntax
rename to data/usr/share/diffuse/syntax/fortran.syntax
diff --git a/src/usr/share/diffuse/syntax/gettext.syntax b/data/usr/share/diffuse/syntax/gettext.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/gettext.syntax
rename to data/usr/share/diffuse/syntax/gettext.syntax
diff --git a/src/usr/share/diffuse/syntax/glsl.syntax b/data/usr/share/diffuse/syntax/glsl.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/glsl.syntax
rename to data/usr/share/diffuse/syntax/glsl.syntax
diff --git a/src/usr/share/diffuse/syntax/html.syntax b/data/usr/share/diffuse/syntax/html.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/html.syntax
rename to data/usr/share/diffuse/syntax/html.syntax
diff --git a/src/usr/share/diffuse/syntax/ini.syntax b/data/usr/share/diffuse/syntax/ini.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/ini.syntax
rename to data/usr/share/diffuse/syntax/ini.syntax
diff --git a/src/usr/share/diffuse/syntax/java.syntax b/data/usr/share/diffuse/syntax/java.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/java.syntax
rename to data/usr/share/diffuse/syntax/java.syntax
diff --git a/src/usr/share/diffuse/syntax/javascript.syntax b/data/usr/share/diffuse/syntax/javascript.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/javascript.syntax
rename to data/usr/share/diffuse/syntax/javascript.syntax
diff --git a/src/usr/share/diffuse/syntax/json.syntax b/data/usr/share/diffuse/syntax/json.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/json.syntax
rename to data/usr/share/diffuse/syntax/json.syntax
diff --git a/src/usr/share/diffuse/syntax/jsp.syntax b/data/usr/share/diffuse/syntax/jsp.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/jsp.syntax
rename to data/usr/share/diffuse/syntax/jsp.syntax
diff --git a/src/usr/share/diffuse/syntax/makefile.syntax b/data/usr/share/diffuse/syntax/makefile.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/makefile.syntax
rename to data/usr/share/diffuse/syntax/makefile.syntax
diff --git a/src/usr/share/diffuse/syntax/objective-c++.syntax b/data/usr/share/diffuse/syntax/objective-c++.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/objective-c++.syntax
rename to data/usr/share/diffuse/syntax/objective-c++.syntax
diff --git a/src/usr/share/diffuse/syntax/octave.syntax b/data/usr/share/diffuse/syntax/octave.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/octave.syntax
rename to data/usr/share/diffuse/syntax/octave.syntax
diff --git a/src/usr/share/diffuse/syntax/opencl.syntax b/data/usr/share/diffuse/syntax/opencl.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/opencl.syntax
rename to data/usr/share/diffuse/syntax/opencl.syntax
diff --git a/src/usr/share/diffuse/syntax/pascal.syntax b/data/usr/share/diffuse/syntax/pascal.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/pascal.syntax
rename to data/usr/share/diffuse/syntax/pascal.syntax
diff --git a/src/usr/share/diffuse/syntax/patch.syntax b/data/usr/share/diffuse/syntax/patch.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/patch.syntax
rename to data/usr/share/diffuse/syntax/patch.syntax
diff --git a/src/usr/share/diffuse/syntax/perl.syntax b/data/usr/share/diffuse/syntax/perl.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/perl.syntax
rename to data/usr/share/diffuse/syntax/perl.syntax
diff --git a/src/usr/share/diffuse/syntax/php.syntax b/data/usr/share/diffuse/syntax/php.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/php.syntax
rename to data/usr/share/diffuse/syntax/php.syntax
diff --git a/src/usr/share/diffuse/syntax/python.syntax b/data/usr/share/diffuse/syntax/python.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/python.syntax
rename to data/usr/share/diffuse/syntax/python.syntax
diff --git a/src/usr/share/diffuse/syntax/r.syntax b/data/usr/share/diffuse/syntax/r.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/r.syntax
rename to data/usr/share/diffuse/syntax/r.syntax
diff --git a/src/usr/share/diffuse/syntax/ruby.syntax b/data/usr/share/diffuse/syntax/ruby.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/ruby.syntax
rename to data/usr/share/diffuse/syntax/ruby.syntax
diff --git a/src/usr/share/diffuse/syntax/sql.syntax b/data/usr/share/diffuse/syntax/sql.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/sql.syntax
rename to data/usr/share/diffuse/syntax/sql.syntax
diff --git a/src/usr/share/diffuse/syntax/tcl.syntax b/data/usr/share/diffuse/syntax/tcl.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/tcl.syntax
rename to data/usr/share/diffuse/syntax/tcl.syntax
diff --git a/src/usr/share/diffuse/syntax/vb.syntax b/data/usr/share/diffuse/syntax/vb.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/vb.syntax
rename to data/usr/share/diffuse/syntax/vb.syntax
diff --git a/src/usr/share/diffuse/syntax/verilog.syntax b/data/usr/share/diffuse/syntax/verilog.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/verilog.syntax
rename to data/usr/share/diffuse/syntax/verilog.syntax
diff --git a/src/usr/share/diffuse/syntax/vhdl.syntax b/data/usr/share/diffuse/syntax/vhdl.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/vhdl.syntax
rename to data/usr/share/diffuse/syntax/vhdl.syntax
diff --git a/src/usr/share/diffuse/syntax/xml.syntax b/data/usr/share/diffuse/syntax/xml.syntax
similarity index 100%
rename from src/usr/share/diffuse/syntax/xml.syntax
rename to data/usr/share/diffuse/syntax/xml.syntax
diff --git a/src/usr/share/gnome/help/diffuse/C/diffuse.xml b/data/usr/share/gnome/help/diffuse/C/diffuse.xml
similarity index 100%
rename from src/usr/share/gnome/help/diffuse/C/diffuse.xml
rename to data/usr/share/gnome/help/diffuse/C/diffuse.xml
diff --git a/src/usr/share/gnome/help/diffuse/cs/diffuse.xml b/data/usr/share/gnome/help/diffuse/cs/diffuse.xml
similarity index 100%
rename from src/usr/share/gnome/help/diffuse/cs/diffuse.xml
rename to data/usr/share/gnome/help/diffuse/cs/diffuse.xml
diff --git a/src/usr/share/gnome/help/diffuse/it/diffuse.xml b/data/usr/share/gnome/help/diffuse/it/diffuse.xml
similarity index 100%
rename from src/usr/share/gnome/help/diffuse/it/diffuse.xml
rename to data/usr/share/gnome/help/diffuse/it/diffuse.xml
diff --git a/src/usr/share/gnome/help/diffuse/ru/diffuse.xml b/data/usr/share/gnome/help/diffuse/ru/diffuse.xml
similarity index 100%
rename from src/usr/share/gnome/help/diffuse/ru/diffuse.xml
rename to data/usr/share/gnome/help/diffuse/ru/diffuse.xml
diff --git a/src/usr/share/man/cs/man1/diffuse.1 b/data/usr/share/man/cs/man1/diffuse.1
similarity index 100%
rename from src/usr/share/man/cs/man1/diffuse.1
rename to data/usr/share/man/cs/man1/diffuse.1
diff --git a/src/usr/share/man/it/man1/diffuse.1 b/data/usr/share/man/it/man1/diffuse.1
similarity index 100%
rename from src/usr/share/man/it/man1/diffuse.1
rename to data/usr/share/man/it/man1/diffuse.1
diff --git a/src/usr/share/man/man1/diffuse.1 b/data/usr/share/man/man1/diffuse.1
similarity index 100%
rename from src/usr/share/man/man1/diffuse.1
rename to data/usr/share/man/man1/diffuse.1
diff --git a/src/usr/share/man/ru/man1/diffuse.1 b/data/usr/share/man/ru/man1/diffuse.1
similarity index 100%
rename from src/usr/share/man/ru/man1/diffuse.1
rename to data/usr/share/man/ru/man1/diffuse.1
diff --git a/src/usr/share/omf/diffuse/diffuse-C.omf b/data/usr/share/omf/diffuse/diffuse-C.omf
similarity index 100%
rename from src/usr/share/omf/diffuse/diffuse-C.omf
rename to data/usr/share/omf/diffuse/diffuse-C.omf
diff --git a/src/usr/share/omf/diffuse/diffuse-cs.omf b/data/usr/share/omf/diffuse/diffuse-cs.omf
similarity index 100%
rename from src/usr/share/omf/diffuse/diffuse-cs.omf
rename to data/usr/share/omf/diffuse/diffuse-cs.omf
diff --git a/src/usr/share/omf/diffuse/diffuse-it.omf b/data/usr/share/omf/diffuse/diffuse-it.omf
similarity index 100%
rename from src/usr/share/omf/diffuse/diffuse-it.omf
rename to data/usr/share/omf/diffuse/diffuse-it.omf
diff --git a/src/usr/share/omf/diffuse/diffuse-ru.omf b/data/usr/share/omf/diffuse/diffuse-ru.omf
similarity index 100%
rename from src/usr/share/omf/diffuse/diffuse-ru.omf
rename to data/usr/share/omf/diffuse/diffuse-ru.omf
diff --git a/io.github.mightycreak.Diffuse.yml b/io.github.mightycreak.Diffuse.yml
index a9cde15..288e50f 100644
--- a/io.github.mightycreak.Diffuse.yml
+++ b/io.github.mightycreak.Diffuse.yml
@@ -10,9 +10,14 @@ finish-args:
- --filesystem=home
modules:
- name: diffuse
+ builddir: true
buildsystem: meson
sources:
- - type: git
- url: https://github.com/MightyCreak/diffuse
- branch: v0.6.0
-rename-desktop-file: diffuse.desktop
+ - type: dir
+ path: .
+ # - type: git
+ # url: file:///home/creak/dev/diffuse
+ # branch: split-code-into-modules
+ # - type: git
+ # url: https://github.com/MightyCreak/diffuse
+ # branch: v0.6.0
diff --git a/meson.build b/meson.build
index 3a5589e..2545b38 100644
--- a/meson.build
+++ b/meson.build
@@ -1,29 +1,13 @@
project('diffuse',
- version: '0.6.0',
+ version: '0.7.0',
meson_version: '>= 0.50',
- license: 'GPL-2.0-or-later')
+ license: 'GPL-2.0-or-later',
+ default_options: [ 'warning_level=2' ])
i18n = import('i18n')
-python = import('python')
-py_installation = python.find_installation('python3')
-
-find_program('gtk-update-icon-cache', required: false)
-
-prefix = get_option('prefix')
-
-bindir = prefix / get_option('bindir')
-datadir = prefix / get_option('datadir')
-localedir = prefix / get_option('localedir')
-libexecdir = prefix / get_option('libexecdir')
-sysconfdir = prefix / get_option('sysconfdir')
-pythondir = py_installation.get_path('purelib')
-
-pkgdatadir = join_paths(datadir, meson.project_name())
-podir = join_paths(meson.source_root(), 'po')
-
-subdir('po')
subdir('data')
subdir('src')
+subdir('po')
-meson.add_install_script('build-scripts/meson-postinstall.py')
+meson.add_install_script('build-aux/meson/postinstall.py')
diff --git a/src/__init__.py b/src/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/diffuse.in b/src/diffuse.in
new file mode 100755
index 0000000..56da64c
--- /dev/null
+++ b/src/diffuse.in
@@ -0,0 +1,37 @@
+#!@PYTHON@
+
+# Diffuse: a graphical tool for merging and comparing text files.
+#
+# Copyright (C) 2019 Derrick Moser
+# Copyright (C) 2021 Romain Failliot
+#
+# 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 2 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import sys
+import gettext
+import locale
+
+VERSION = '@VERSION@'
+pkgdatadir = '@pkgdatadir@'
+localedir = '@localedir@'
+sysconfigdir = '@sysconfigdir@'
+
+sys.path.insert(1, pkgdatadir)
+gettext.install('diffuse', localedir)
+
+if __name__ == '__main__':
+ from diffuse import main
+
+ sys.exit(main.main(VERSION, sysconfigdir))
diff --git a/src/usr/bin/diffuse.py.in b/src/main.py
old mode 100755
new mode 100644
similarity index 97%
rename from src/usr/bin/diffuse.py.in
rename to src/main.py
index 96139b9..2c6b941
--- a/src/usr/bin/diffuse.py.in
+++ b/src/main.py
@@ -1,121 +1,34 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# Diffuse: a graphical tool for merging and comparing text files.
+#
+# Copyright (C) 2019 Derrick Moser
+# Copyright (C) 2021 Romain Failliot
+#
+# 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 2 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# Copyright (C) 2006-2019 Derrick Moser
-# Copyright (C) 2015-2020 Romain Failliot
-#
-# 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 2 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. You may also obtain a copy of the GNU General Public License
-# from the Free Software Foundation by visiting their web site
-# (http://www.fsf.org/) or by writing to the Free Software Foundation, Inc.,
-# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import codecs
-import gettext
-import locale
import os
import sys
-
-# use the program's location as a starting place to search for supporting files
-# such as icon and help documentation
-if hasattr(sys, 'frozen'):
- app_path = sys.executable
-else:
- app_path = os.path.realpath(sys.argv[0])
-bin_dir = os.path.dirname(app_path)
-
-# platform test
-def isWindows():
- return os.name == 'nt'
-
-# translation location: '../share/locale//LC_MESSAGES/diffuse.mo'
-# where '' is the language key
-lang = locale.getdefaultlocale()[0]
-if isWindows():
- # gettext looks for the language using environment variables which
- # are normally not set on Windows so we try setting it for them
- for v in 'LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG':
- if v in os.environ:
- lang = os.environ[v]
- # remove any additional languages, encodings, or modifications
- for v in ':.@':
- lang = lang.split(v)[0]
- break
- else:
- if lang is not None:
- os.environ['LANG'] = lang
- del v
- locale_dir = 'locale'
-else:
- locale_dir = '../share/locale'
-locale_dir = os.path.join(bin_dir, locale_dir)
-gettext.bindtextdomain('diffuse', locale_dir)
-
-gettext.textdomain('diffuse')
-_ = gettext.gettext
-
-APP_NAME = 'Diffuse'
-VERSION = '0.6.0'
-COPYRIGHT = '''{copyright} © 2006-2019 Derrick Moser
-{copyright} © 2015-2020 Romain Failliot'''.format(copyright=_("Copyright"))
-WEBSITE = 'https://github.com/MightyCreak/diffuse'
-
-# process help options
-if __name__ == '__main__':
- args = sys.argv
- argc = len(args)
- if argc == 2 and args[1] in [ '-v', '--version' ]:
- print(f'{APP_NAME} {VERSION}\n{COPYRIGHT}')
- sys.exit(0)
- if argc == 2 and args[1] in [ '-h', '-?', '--help' ]:
- print(_('''Usage:
- diffuse [ [OPTION...] [FILE...] ]...
- diffuse ( -h | -? | --help | -v | --version )
-
-Diffuse is a graphical tool for merging and comparing text files. Diffuse is
-able to compare an arbitrary number of files side-by-side and gives users the
-ability to manually adjust line matching and directly edit files. Diffuse can
-also retrieve revisions of files from Bazaar, CVS, Darcs, Git, Mercurial,
-Monotone, RCS, Subversion, and SVK repositories for comparison and merging.
-
-Help Options:
- ( -h | -? | --help ) Display this usage information
- ( -v | --version ) Display version and copyright information
-
-Configuration Options:
- --no-rcfile Do not read any resource files
- --rcfile Specify explicit resource file
-
-General Options:
- ( -c | --commit ) File revisions and
- ( -D | --close-if-same ) Close all tabs with no differences
- ( -e | --encoding ) Use to read and write files
- ( -L | --label )