Gtk.Label to the window with the text "Hello Again World!"/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2023 Your Name <[email protected]>
*/
public class MyApp : Gtk.Application {
public MyApp () {
Object (
application_id: "io.github.yourusername.yourrepositoryname",
flags: ApplicationFlags.DEFAULT_FLAGS
);
}
protected override void activate () {
var label = new Gtk.Label ("Hello Again World!");
var main_window = new Gtk.ApplicationWindow (this) {
child = label,
default_height = 300,
default_width = 300,
title = "Hello World"
};
main_window.present ();
}
public static int main (string[] args) {
return new MyApp ().run (args);
}
}git remote add origin [email protected]:yourusername/yourrepositoryname.git
git push -u origin master# project name, programming language, and required meson version
project('io.github.yourusername.yourrepositoryname',
'vala', 'c',
meson_version: '>= 0.56.0'
)
# Create a new executable, list the files we want to compile, list the dependencies we need, and install
executable(
meson.project_name(),
'src' / 'Application.vala',
dependencies: [
dependency('gtk4')
],
install: true
)
# Install our .desktop file so the Applications Menu will see it
install_data(
'data' / 'hello-again.desktop',
install_dir: get_option('datadir') / 'applications',
rename: meson.project_name() + '.desktop'
)
# Install our .metainfo.xml file so AppCenter will see it
install_data(
'data' / 'hello-again.metainfo.xml',
install_dir: get_option('datadir') / 'metainfo',
rename: meson.project_name() + '.metainfo.xml'
)meson setup build --prefix=/usrcd build
ninja
ninja installsudo ninja uninstall<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>io.github.myteam.myapp</id>
<name>My App</name>
<summary>Proves that we can use Vala and Gtk</summary>
<metadata_license>CC-BY-4.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<description>
<p>
A quick summary of your app's main selling points and features. Just a couple sentences per paragraph is best
</p>
</description>
<launchable type="desktop-id">io.github.myteam.myapp.desktop</launchable>
</component><screenshots>
<screenshot type="default">
<caption>The most important feature of my app</caption>
<image>https://raw.githubusercontent.com/myteam/myapp/1.0.0/data/screenshot.png</image>
</screenshot>
</screenshots><branding>
<color type="primary">#f37329</color>
</branding><custom>
<value key="x-appcenter-suggested-price">5</value>
<value key="x-appcenter-stripe">pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</value>
</custom><releases>
<release version="1.0.0" date="2022-09-08">
<description>
<p>Initial release, includes features such as:</p>
<ul>
<li>Application can be launched</li>
</ul>
</description>
</release>
</releases>[Desktop Entry]
Version=1.0
Type=Application
Name=My App
Comment=Proves that we can use Vala and Gtk
Categories=Development;Education;
Icon=io.github.myteam.myapp
Exec=io.github.myteam.myapp
Terminal=falsegit add data/
git commit -am "Add Metadata files"
git push# This is the same ID that you've used in meson.build and other files
id: io.github.yourusername.yourrepositoryname
# Instead of manually specifying a long list of build and runtime dependencies,
# we can use a convenient pre-made runtime and SDK. For this example, we'll be
# using the runtime and SDK provided by elementary.
runtime: io.elementary.Platform
runtime-version: '8'
sdk: io.elementary.Sdk
# This should match the exec line in your .desktop file and usually is the same
# as your app ID
command: io.github.yourusername.yourrepositoryname
# Here we can specify the kinds of permissions our app needs to run. Since we're
# not using hardware like webcams, making sound, or reading external files, we
# only need permission to draw our app on screen using either X11 or Wayland.
finish-args:
- '--share=ipc'
- '--socket=fallback-x11'
- '--socket=wayland'
# This section is where you list all the source code required to build your app.
# If we had external dependencies that weren't included in our SDK, we would list
# them here.
modules:
- name: yourrepositoryname
buildsystem: meson
sources:
- type: dir
path: .flatpak-builder build io.github.yourusername.yourrepositoryname.yml --user --install --force-cleanflatpak remove io.github.yourusername.yourrepositorynameflatpak uninstall io.github.yourusername.yourrepositoryname --delete-data
ID Branch Op
1. io.github.yourusername.yourrepositoryname master r
2. io.github.yourusername.yourrepositoryname.Locale master r
Proceed with these changes to the user installation? [Y/n]:#Translate and install our .desktop file
i18n.merge_file(
input: 'data' / 'hello-again.desktop.in',
output: meson.project_name() + '.desktop',
po_dir: meson.project_source_root() / 'po',
type: 'desktop',
install: true,
install_dir: get_option('datadir') / 'applications'
)
#Translate and install our .metainfo file
i18n.merge_file(
input: 'data' / 'hello-again.metainfo.xml.in',
output: meson.project_name() + '.metainfo.xml',
po_dir: meson.project_source_root() / 'po',
install: true,
install_dir: get_option('datadir') / 'metainfo'
)subdir('po')git mv data/hello-again.desktop data/hello-again.desktop.in
git mv data/hello-again.metainfo.xml data/hello-again.metainfo.xml.ini18n.gettext(meson.project_name(),
args: '--directory=' + meson.project_source_root(),
preset: 'glib'
)src/Application.vala
data/hello-again.desktop.in
data/hello-again.metainfo.xml.inninja io.github.yourusername.yourrepositoryname-potde
esninja io.github.yourusername.yourrepositoryname-update-pogit add src/Application.vala meson.build po/ data/
git commit -am "Add translations"
git pushstdout.printf ("Not Translatable string");
stdout.printf (_("Translatable string!"));
string normal = "Another non-translatable string";
string translated = _("Another translatable string");# Include the translations module
i18n = import('i18n')
# Set our translation domain
add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language:'c')/// TRANSLATORS: The first %s is search term, the second is the name of default browser
title = _("Search for %s in %s").printf (query, get_default_browser_name ());main.ymlhello-again
data
16.svg
24.svg
32.svg
48.svg
64.svg
128.svg# Install our icons in all the required sizes
icon_sizes = ['16', '24', '32', '48', '64', '128']
foreach i : icon_sizes
install_data(
'data' / i + '.svg',
install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i / 'apps',
rename: meson.project_name() + '.svg'
)
install_data(
'data' / i + '.svg',
install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i + '@2' / 'apps',
rename: meson.project_name() + '.svg'
)
endforeachsudo update-icon-caches /usr/share/icons/*name: CI
# This workflow will run for any pull request or pushed commit
on: [push, pull_request]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "flatpak"
flatpak:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# This job runs in a special container designed for building Flatpaks for AppCenter
container:
image: ghcr.io/elementary/flatpak-platform/runtime:8
options: --privileged
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so the job can access it
- uses: actions/checkout@v3
# Builds your flatpak manifest using the Flatpak Builder action
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
# This is the name of the Bundle file we're building and can be anything you like
bundle: MyApp.flatpak
# This uses your app's RDNN ID
manifest-path: io.github.yourusername.yourrepositoryname.yml
# You can automatically run any of the tests you've created as part of this workflow
run-tests: true
# These lines specify the location of the elementary Runtime and Sdk
repository-name: appcenter
repository-url: https://flatpak.elementary.io/repo.flatpakrepo
cache-key: "flatpak-builder-${{ github.sha }}"