Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Separate app-id for development build #198

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: pinit.flatpak
manifest-path: com.github.ryonakano.pinit.yml
manifest-path: build-aux/flathub/com.github.ryonakano.pinit.Devel.yml
run-tests: true
cache-key: "flatpak-builder-${{ github.sha }}"
arch: ${{ matrix.arch }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# build dirs
.flatpak-builder
build*
builddir*

# vim
*.swp
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/fl
To build and install, use `flatpak-builder`, then execute with `flatpak run`:

```
flatpak-builder builddir --user --install --force-clean --install-deps-from=flathub com.github.ryonakano.pinit.yml
flatpak run com.github.ryonakano.pinit
flatpak-builder builddir --user --install --force-clean --install-deps-from=flathub build-aux/flathub/com.github.ryonakano.pinit.Devel.yml
flatpak run com.github.ryonakano.pinit.Devel
```

### From Source Code (Native)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
app-id: com.github.ryonakano.pinit
app-id: com.github.ryonakano.pinit.Devel
runtime: org.gnome.Platform
runtime-version: '46'
sdk: org.gnome.Sdk
command: com.github.ryonakano.pinit
command: com.github.ryonakano.pinit.Devel
finish-args:
- '--share=ipc'
- '--socket=wayland'
Expand All @@ -22,6 +22,8 @@ modules:

- name: pinit
buildsystem: meson
config_opts:
- '-Ddevelopment=true'
sources:
- type: dir
path: .
path: ../../
38 changes: 32 additions & 6 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,56 @@ icon_sizes = ['16', '32', '48', '64', '128']
foreach i : icon_sizes
install_data(
'icons' / i / meson.project_name() + '.svg',
rename: app_id + '.svg',
install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i / 'apps'
)
endforeach

desktop_conf = configuration_data()
desktop_conf.set('APP_NAME', app_name)
desktop_conf.set('APP_ID', app_id)
desktop_file_in = configure_file(
input: 'pinit.desktop.in.in',
output: '@[email protected]'.format(app_id),
configuration: desktop_conf
)

desktop_file = i18n.merge_file(
input: 'pinit.desktop.in',
output: meson.project_name() + '.desktop',
input: desktop_file_in,
output: '@0@.desktop'.format(app_id),
po_dir: meson.project_source_root() / 'po',
type: 'desktop',
install: true,
install_dir: get_option('datadir') / 'applications'
)

appstream_conf = configuration_data()
appstream_conf.set('APP_ID', app_id)
appstream_conf.set('GETTEXT_PACKAGE', meson.project_name())
appstream_file_in = configure_file(
input: 'pinit.metainfo.xml.in.in',
output: '@[email protected]'.format(app_id),
configuration: appstream_conf
)

appstream_file = i18n.merge_file(
input: 'pinit.metainfo.xml.in',
output: meson.project_name() + '.metainfo.xml',
input: appstream_file_in,
output: '@0@.metainfo.xml'.format(app_id),
po_dir: meson.project_source_root() / 'po',
install: true,
install_dir: get_option('datadir') / 'metainfo'
)

gschema_conf = configuration_data()
gschema_conf.set('APP_ID', app_id)
gschema_file = configure_file(
input: 'pinit.gschema.xml.in',
output: '@[email protected]'.format(app_id),
configuration: gschema_conf
)

install_data(
'pinit.gschema.xml',
rename: meson.project_name() + '.gschema.xml',
gschema_file,
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas'
)

Expand Down
6 changes: 3 additions & 3 deletions data/pinit.desktop.in → data/pinit.desktop.in.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[Desktop Entry]
Name=Pin It!
Name=@APP_NAME@
GenericName=Desktop File Creator
Comment=Pin portable apps to the launcher
Categories=System;Utility;
Exec=com.github.ryonakano.pinit
Icon=com.github.ryonakano.pinit
Exec=@APP_ID@
Icon=@APP_ID@
Terminal=false
Type=Application
Keywords=Desktop;File;Create;Edit;Info;Icon;AppImage;
2 changes: 1 addition & 1 deletion data/pinit.gschema.xml → data/pinit.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<value value="2" nick="dark"/>
</enum>

<schema path="/com/github/ryonakano/pinit/" id="com.github.ryonakano.pinit">
<schema path="/com/github/ryonakano/pinit/" id="@APP_ID@">
<key name="color-scheme" enum="style">
<default>'default'</default>
<summary>Color scheme</summary>
Expand Down
6 changes: 3 additions & 3 deletions data/pinit.metainfo.xml.in → data/pinit.metainfo.xml.in.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2021-2024 Ryo Nakano -->
<component type="desktop-application">
<id>com.github.ryonakano.pinit</id>
<launchable type="desktop-id">com.github.ryonakano.pinit.desktop</launchable>
<translation type="gettext">com.github.ryonakano.pinit</translation>
<id>@APP_ID@</id>
<launchable type="desktop-id">@APP_ID@.desktop</launchable>
<translation type="gettext">@GETTEXT_PACKAGE@</translation>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>

Expand Down
10 changes: 9 additions & 1 deletion data/resources/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ blueprints = custom_target('blueprints',
]
)

gresource_conf = configuration_data()
gresource_conf.set('APP_ID', app_id)
gresource_file_in = configure_file(
input: 'pinit.gresource.xml.in',
output: '@[email protected]'.format(app_id),
configuration: gresource_conf
)

asresources = gnome.compile_resources(
'as-resources',
'pinit.gresource.xml',
gresource_file_in,
dependencies: blueprints,
c_name: 'as'
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/github/ryonakano/pinit">
<file preprocess="xml-stripblanks" alias="com.github.ryonakano.pinit.metainfo.xml">../pinit.metainfo.xml.in</file>
<file preprocess="xml-stripblanks" alias="@APP_ID@.metainfo.xml">../@APP_ID@.metainfo.xml</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
</gresource>
</gresources>
7 changes: 7 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ project(
meson_version: '>=0.58.0'
)

app_name = 'Pin It!'
app_id = meson.project_name()
if get_option('development')
app_name += ' (Development)'
app_id += '.Devel'
endif

gnome = import('gnome')
i18n = import('i18n')

Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
option('doc', type: 'boolean', value: false, description: 'Whether to generate valadoc')
option('development', type: 'boolean', value: false, description: 'If this is a development build')
4 changes: 2 additions & 2 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data/pinit.desktop.in
data/pinit.metainfo.xml.in
data/pinit.desktop.in.in
data/pinit.metainfo.xml.in.in
data/resources/gtk/help-overlay.blp
src/MainWindow.vala
src/View/EditView.vala
Expand Down
13 changes: 7 additions & 6 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ public class Application : Adw.Application {

public Application () {
Object (
application_id: Config.PROJECT_NAME,
flags: ApplicationFlags.DEFAULT_FLAGS
application_id: Config.APP_ID,
flags: ApplicationFlags.DEFAULT_FLAGS,
resource_base_path: Config.RESOURCE_PREFIX
);
}

static construct {
settings = new Settings (Config.PROJECT_NAME);
settings = new Settings (Config.APP_ID);

// Get the user's system language and use it when loading desktop files
unowned var languages = Intl.get_language_names ();
Expand Down Expand Up @@ -199,9 +200,9 @@ public class Application : Adw.Application {
// Make sure the app is shown in the user's language.
// https://docs.gtk.org/glib/i18n.html#internationalization
Intl.setlocale (LocaleCategory.ALL, "");
Intl.bindtextdomain (Config.PROJECT_NAME, Config.LOCALEDIR);
Intl.bind_textdomain_codeset (Config.PROJECT_NAME, "UTF-8");
Intl.textdomain (Config.PROJECT_NAME);
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Config.GETTEXT_PACKAGE);

setup_style ();

Expand Down
3 changes: 2 additions & 1 deletion src/Config.vala.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Config {
public const string LOCALEDIR = @LOCALEDIR@;
public const string PROJECT_NAME = @PROJECT_NAME@;
public const string GETTEXT_PACKAGE = @GETTEXT_PACKAGE@;
public const string APP_ID = @APP_ID@;
public const string PROJECT_VERSION = @PROJECT_VERSION@;
public const string RESOURCE_PREFIX = @RESOURCE_PREFIX@;
}
14 changes: 12 additions & 2 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class MainWindow : Adw.ApplicationWindow {
}

construct {
// Distinct development build visually
if (".Devel" in Config.APP_ID) {
add_css_class ("devel");
}

add_action_entries (ACTION_ENTRIES, this);

width_request = 450;
Expand Down Expand Up @@ -211,7 +216,7 @@ public class MainWindow : Adw.ApplicationWindow {
* Create a new DesktopFile with random filename and start editing it.
*/
private void on_new_activate () {
string filename = Config.PROJECT_NAME + "." + Uuid.string_random ();
string filename = Config.APP_ID + "." + Uuid.string_random ();
string path = Path.build_filename (Environment.get_home_dir (), ".local/share/applications",
filename + Model.DesktopFile.DESKTOP_SUFFIX);

Expand Down Expand Up @@ -240,7 +245,7 @@ public class MainWindow : Adw.ApplicationWindow {
};

var about_window = new Adw.AboutWindow.from_appdata (
"%s/%s.metainfo.xml".printf (Config.RESOURCE_PREFIX, Config.PROJECT_NAME),
"%s/%s.metainfo.xml".printf (Config.RESOURCE_PREFIX, Config.APP_ID),
null
) {
transient_for = this,
Expand All @@ -255,6 +260,11 @@ public class MainWindow : Adw.ApplicationWindow {
translator_credits = _("translator-credits")
};

// Distinct development build visually
if (".Devel" in Config.APP_ID) {
about_window.add_css_class ("devel");
}

about_window.present ();
}
}
5 changes: 3 additions & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
config_data = configuration_data()
config_data.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir'))
config_data.set_quoted('PROJECT_NAME', meson.project_name())
config_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
config_data.set_quoted('APP_ID', app_id)
config_data.set_quoted('PROJECT_VERSION', meson.project_version())
config_data.set_quoted('RESOURCE_PREFIX', '/' + meson.project_name().replace('.', '/'))
config_file = configure_file(
Expand Down Expand Up @@ -33,7 +34,7 @@ sources = files(
)

executable(
meson.project_name(),
app_id,
asresources,
config_file,
sources,
Expand Down