diff --git a/.gitignore b/.gitignore index ca6cfcb..3b2ab93 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,12 @@ *~ build +_build/ +.flatpak-builder/ .ninja_* build.ninja data/writeas + +# Files generated by gb +pkg/ +bin/ diff --git a/.travis.yml b/.travis.yml index a2ba685..f9bccea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,44 @@ --- - -language: node_js - -node_js: - - lts/* - -sudo: required - -services: - - docker - -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - libstdc++-5-dev - -install: - - npm i -g @elementaryos/houston - -script: - - houston ci +language: c notifications: email: false + +matrix: + include: + - language: node_js + node_js: + - lts/* + sudo: required + env: [] + before_install: [] + services: + - docker + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - libstdc++-5-dev + install: + - npm i -g @elementaryos/houston + script: + - houston ci + language: c + services: + - docker + sudo: required + env: + - MANIFEST_PATH=/build/writeas/writeas-gtk/flatpak/com.abunchtell.WriteAsDesktop.json + before_install: + - ls + - docker pull christopherdavis/elementary-flatpak-writeas:latest + - docker run --privileged -v "$(pwd)":/build/writeas/writeas-gtk -it -d --name flatpak christopherdavis/elementary-flatpak-writeas bash + - docker exec flatpak chmod +x /usr/bin/fusermount + addons: [] + install: [] + script: + - docker exec flatpak flatpak-builder --stop-at=writeas-gtk app ${MANIFEST_PATH} + - docker exec flatpak flatpak-builder --run app ${MANIFEST_PATH} meson _build /build/writeas/writeas-gtk --prefix=/app -Dauto_build_cli=true + - docker exec flatpak flatpak-builder --run app ${MANIFEST_PATH} ninja -C _build install + - docker exec flatpak flatpak-builder --finish-only app ${MANIFEST_PATH} diff --git a/data/writeas-gtk.appdata.xml.in b/data/com.abunchtell.WriteAsDesktop.appdata.xml.in similarity index 99% rename from data/writeas-gtk.appdata.xml.in rename to data/com.abunchtell.WriteAsDesktop.appdata.xml.in index 7107478..d9a0081 100644 --- a/data/writeas-gtk.appdata.xml.in +++ b/data/com.abunchtell.WriteAsDesktop.appdata.xml.in @@ -28,7 +28,7 @@ hello@write.as - @app_id@ + @exec@ diff --git a/data/writeas-gtk.desktop.in b/data/com.abunchtell.WriteAsDesktop.desktop.in similarity index 93% rename from data/writeas-gtk.desktop.in rename to data/com.abunchtell.WriteAsDesktop.desktop.in index 0ec22b5..0ec54e7 100644 --- a/data/writeas-gtk.desktop.in +++ b/data/com.abunchtell.WriteAsDesktop.desktop.in @@ -2,7 +2,7 @@ Type=Application Name=Write.as Comment=Publish a thought in seconds. -Exec=@app_id@ +Exec=@exec@ Icon=@app_id@ Terminal=false MimeType= diff --git a/data/icons/128/writeas-gtk.png b/data/icons/128/com.abunchtell.WriteAsDesktop.png similarity index 100% rename from data/icons/128/writeas-gtk.png rename to data/icons/128/com.abunchtell.WriteAsDesktop.png diff --git a/data/icons/16/writeas-gtk.png b/data/icons/16/com.abunchtell.WriteAsDesktop.png similarity index 100% rename from data/icons/16/writeas-gtk.png rename to data/icons/16/com.abunchtell.WriteAsDesktop.png diff --git a/data/icons/24/writeas-gtk.png b/data/icons/24/com.abunchtell.WriteAsDesktop.png similarity index 100% rename from data/icons/24/writeas-gtk.png rename to data/icons/24/com.abunchtell.WriteAsDesktop.png diff --git a/data/icons/32/writeas-gtk.png b/data/icons/32/com.abunchtell.WriteAsDesktop.png similarity index 100% rename from data/icons/32/writeas-gtk.png rename to data/icons/32/com.abunchtell.WriteAsDesktop.png diff --git a/data/icons/48/writeas-gtk.png b/data/icons/48/com.abunchtell.WriteAsDesktop.png similarity index 100% rename from data/icons/48/writeas-gtk.png rename to data/icons/48/com.abunchtell.WriteAsDesktop.png diff --git a/data/icons/64/writeas-gtk.png b/data/icons/64/com.abunchtell.WriteAsDesktop.png similarity index 100% rename from data/icons/64/writeas-gtk.png rename to data/icons/64/com.abunchtell.WriteAsDesktop.png diff --git a/data/meson.build b/data/meson.build index 73b7444..82d7659 100644 --- a/data/meson.build +++ b/data/meson.build @@ -2,7 +2,7 @@ icon_sizes = ['16', '24', '32', '48', '64', '128'] foreach i : icon_sizes install_data( - join_paths('icons', i, meson.project_name() + '.png'), + join_paths('icons', i, 'com.abunchtell.WriteAsDesktop.png'), install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', i + 'x' + i, 'apps'), rename: '@0@.png'.format(app_id) ) @@ -10,14 +10,15 @@ endforeach data_conf = configuration_data() data_conf.set('app_id', app_id) +data_conf.set('exec', executable) configure_file( - input: 'writeas-gtk.desktop.in', + input: 'com.abunchtell.WriteAsDesktop.desktop.in', output: '@0@.desktop'.format(app_id), configuration: data_conf, install_dir: join_paths(get_option('datadir'), 'applications') ) configure_file( - input: 'writeas-gtk.appdata.xml.in', + input: 'com.abunchtell.WriteAsDesktop.appdata.xml.in', output: '@0@.appdata.xml'.format(app_id), configuration: data_conf, install_dir: join_paths(get_option('datadir'), 'metainfo') diff --git a/debian/control b/debian/control index a849fba..8e65d76 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: com.github.writeas.writeas-gtk Section: x11 Priority: extra Maintainer: Write.as -Build-Depends: meson, +Build-Depends: meson (>= 0.48), debhelper (>= 9), libgtk-3-dev, libgtksourceview-3.0-dev, diff --git a/debian/rules b/debian/rules index d3fbd4c..176ce5e 100755 --- a/debian/rules +++ b/debian/rules @@ -19,15 +19,13 @@ override_dh_auto_clean: override_dh_auto_configure: mkdir -p debian/build - cd debian/build && meson --prefix=/usr ../.. -Dplatform=elementary + cd debian/build && meson --prefix=/usr ../.. -Dplatform=elementary -Dauto_build_cli=true override_dh_auto_build: - cd debian/build && ninja -v && ninja build + cd debian/build && ninja -v override_dh_auto_test: cd debian/build && ninja test override_dh_auto_install: cd debian/build && DESTDIR=${CURDIR}/debian/com.github.writeas.writeas-gtk ninja install - mkdir -p debian/com.github.writeas.writeas-gtk/usr/bin - cp bin/writeas debian/com.github.writeas.writeas-gtk/usr/bin/ diff --git a/flatpak/com.abunchtell.WriteAsDesktop.json b/flatpak/com.abunchtell.WriteAsDesktop.json new file mode 100644 index 0000000..29110ce --- /dev/null +++ b/flatpak/com.abunchtell.WriteAsDesktop.json @@ -0,0 +1,110 @@ +{ + "app-id": "com.abunchtell.WriteAsDesktop", + "base": "io.elementary.BaseApp", + "base-version": "juno", + "runtime": "org.gnome.Platform", + "runtime-version": "3.32", + "sdk": "org.gnome.Sdk", + "sdk-extensions": [ + "org.freedesktop.Sdk.Extension.golang" + ], + "command": "writeas-gtk", + "finish-args": [ + "--socket=wayland", + "--share=ipc", + "--socket=x11", + "--device=dri", + "--share=network", + "--filesystem=~/.writeas:rw" + ], + "build-options": { + "append-path": "/usr/lib/sdk/golang/bin/", + "build-args" : [ + "--share=network" + ], + "env": { + "GOROOT": "/usr/lib/sdk/golang/" + } + }, + "modules": [ + { + "name": "gb", + "buildsystem": "simple", + "build-commands": [ + "/usr/lib/sdk/golang/enable.sh; env GOPATH=\"$(pwd)\" go build github.com/constabulary/gb/cmd/gb", + "install -Dm0755 -t /app/bin gb" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/pkg/errors.git", + "dest": "src/github.com/pkg/errors" + }, + { + "type": "git", + "url": "https://github.com/constabulary/gb.git", + "dest": "src/github.com/constabulary/gb" + } + ] + }, + { + "name": "gtksourceview3", + "config-opts" : [ + "--disable-Werror" + ], + "sources": [ + { + "type": "git", + "url": "https://gitlab.gnome.org/GNOME/gtksourceview.git", + "branch": "gnome-3-24" + } + ] + }, + { + "name": "wl-clipboard", + "buildsystem": "meson", + "sources": [ + { + "type": "git", + "url": "https://github.com/bugaevc/wl-clipboard.git" + } + ] + }, + { + "name": "libXmu", + "config-opts": [ + "--disable-static", + "--disable-docs" + ], + "sources": [ + { + "type": "archive", + "url": "https://www.x.org/releases/individual/lib/libXmu-1.1.2.tar.bz2", + "sha256": "756edc7c383254eef8b4e1b733c3bf1dc061b523c9f9833ac7058378b8349d0b" + } + ] + }, + { + "name": "xclip", + "sources": [ + { + "type": "git", + "url": "https://github.com/astrand/xclip.git" + } + ] + }, + { + "name": "writeas-gtk", + "buildsystem": "meson", + "config-opts": [ + "-Dauto_build_cli=true" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/writeas/writeas-gtk.git" + } + ] + } + ] +} diff --git a/meson.build b/meson.build index 00b1074..c424f86 100644 --- a/meson.build +++ b/meson.build @@ -1,17 +1,20 @@ project('writeas-gtk', ['vala', 'c'], version: '1.0.2', license: 'GPL', - meson_version: '>=0.46.0') + meson_version: '>=0.48.0') i18n = import('i18n') build_platform = get_option('platform') if build_platform == 'elementary' app_id = 'com.github.writeas.writeas-gtk' + executable = 'com.github.writeas.writeas-gtk' else - app_id = 'writeas-gtk' + app_id = 'com.abunchtell.WriteAsDesktop' + executable = 'writeas-gtk' endif + conf = configuration_data() conf.set_quoted('GETTEXT_PACKAGE', app_id) conf.set_quoted('APP_ID', app_id) @@ -19,7 +22,7 @@ conf.set_quoted('BUILD_PLATFORM', build_platform) config_h = configure_file(output: 'config.h', configuration: conf) config_h_dir = include_directories('.') -run_target('build', command: 'meson/build-cli.sh') +cli_build_script = find_program('meson/build-cli.sh') subdir('data') subdir('src') diff --git a/meson/build-cli.sh b/meson/build-cli.sh index 023c655..2dfc7a2 100755 --- a/meson/build-cli.sh +++ b/meson/build-cli.sh @@ -3,5 +3,10 @@ exec_name=writeas echo "Building $exec_name CLI..." +cd $1 && gb build github.com/writeas/writeas-cli/cmd/writeas && +mv bin/writeas $3/$2 && +# Cleanup +rm -rf bin/ && +rm -rf pkg/ && echo "Success." diff --git a/meson_options.txt b/meson_options.txt index 29bd56e..113c1f9 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ option('platform', type: 'combo', choices: ['default', 'elementary'], value: 'default') +option('auto_build_cli', type: 'boolean', value: 'false') diff --git a/src/application.vala b/src/application.vala index 848daa9..c77e3c9 100644 --- a/src/application.vala +++ b/src/application.vala @@ -26,7 +26,7 @@ public class WriteAs.Application : Gtk.Application { Intl.setlocale(LocaleCategory.ALL, ""); Intl.textdomain("write.as"); - application_id = APP_ID + ".desktop"; + application_id = APP_ID; } public override void activate() { diff --git a/src/meson.build b/src/meson.build index 75de727..48de256 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,4 +1,22 @@ -executable(app_id, +if get_option('auto_build_cli') + gb = find_program('gb') + + cli_target = custom_target('build-cli', + build_by_default: true, + output: 'writeas', + install: true, + install_dir: get_option('bindir'), + console: true, + command: [ + cli_build_script, + '@SOURCE_ROOT@', + '@OUTPUT@', + meson.build_root() + ] + ) +endif + +executable(executable, 'application.vala', 'window.vala', 'Granite/Accels.vala', diff --git a/src/window.vala b/src/window.vala index fe91c6a..b109df2 100644 --- a/src/window.vala +++ b/src/window.vala @@ -386,21 +386,18 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow { private File prompt_file(Gtk.FileChooserAction mode, string action) throws UserCancellable { - var file_chooser = new Gtk.FileChooserDialog(action, this, mode, - _("Cancel"), Gtk.ResponseType.CANCEL, - action, Gtk.ResponseType.ACCEPT); - + var file_chooser = new Gtk.FileChooserNative(action, this, mode, + _("Save"), _("Cancel")); file_chooser.select_multiple = false; var filter = new Gtk.FileFilter(); filter.add_mime_type("text/plain"); file_chooser.set_filter(filter); var resp = file_chooser.run(); - file_chooser.close(); if (resp == Gtk.ResponseType.ACCEPT) { return file_chooser.get_file(); } else { - throw new UserCancellable.USER_CANCELLED("FileChooserDialog"); + throw new UserCancellable.USER_CANCELLED("FileChooserNative"); } }