commit 13334bc4c41ec3cf9cfcb70c8aadca3be936172b
parent 686998ce4d669390d4169e0455549f891cb1c308
Author: MTRNord <mtrnord1@gmail.com>
Date: Sun, 19 Feb 2023 15:58:56 +0100
Add flatpak and main view basics
Diffstat:
13 files changed, 312 insertions(+), 67 deletions(-)
diff --git a/.editorconfig b/.editorconfig
@@ -0,0 +1,8 @@
+root = true
+[*]
+indent_style = space
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = true
+charset = utf-8
+indent_size = 4
+\ No newline at end of file
diff --git a/.gitignore b/.gitignore
@@ -1 +1,4 @@
/target
+/_builddir
+/.flatpak-builder
+/flatpak_app
+\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-gtk = { version = "0.5", package = "gtk4" }
+gtk = { version = "0.5", package = "gtk4", features = ["v4_8"] }
relm4 = "0.5.0-rc.2"
relm4-macros = "0.5.0-rc.2"
relm4-components = "0.5.0-rc.2"
diff --git a/blueprints/mainpage/main.blp b/blueprints/mainpage/main.blp
@@ -28,64 +28,87 @@ Box outer {
halign: fill;
valign: fill;
vexpand: true;
+ hexpand: true;
- ScrolledWindow {
- propagate-natural-width:true;
- child: Box sidebar {
- orientation: vertical;
- halign: start;
- valign: fill;
- Expander {
- expanded: true;
- styles [
- "expander"
- ]
- label-widget: Box{
- Image {
- margin-end: 8;
- icon-name: "mail-symbolic";
- }
- Label {
- label: "dont@dox.myself";
+
+ Paned {
+ position: 200;
+ hexpand: true;
+ ScrolledWindow {
+ propagate-natural-width:true;
+ child: Box sidebar {
+ orientation: vertical;
+ halign: fill;
+ valign: fill;
+ Expander {
+ expanded: true;
+ styles [
+ "expander"
+ ]
+ label-widget: Box{
+ Image {
+ margin-end: 8;
+ icon-name: "mail-symbolic";
+ }
+ Label {
+ label: "dont@dox.myself";
+ }
+ };
+ child: Box {
+ orientation: vertical;
+ Button {
+ styles [
+ "tree-item"
+ ]
+ Box {
+ margin-start: 40;
+ Image {
+ margin-end: 8;
+ icon-name: "inbox-symbolic";
+ }
+ Label {
+ label: "Inbox";
+ }
+ }
}
};
- child: Box {
- orientation: vertical;
- Button {
- styles [
- "tree-item"
- ]
+ }
+ };
+ }
+ Paned main {
+ orientation: vertical;
+ halign: fill;
+ valign: fill;
+ position: 300;
+ ScrolledWindow {
+ ListBox {
+ ListBoxRow {
Box {
- margin-start: 40;
- Image {
- margin-end: 8;
- icon-name: "inbox-symbolic";
+ Label {
+ label: "test3";
}
+ }
+ }
+ ListBoxRow {
+ Box {
Label {
- label: "Inbox";
+ label: "test3";
}
}
}
- };
+ }
+ }
+ Box {
+ margin-start: 8;
+ margin-end: 8;
+ margin-top: 8;
+ margin-bottom: 8;
+ valign: start;
+ halign: start;
+ Label {
+ label: "test2";
+ }
}
- };
- }
- Separator {}
- Box main {
- margin-top: 8;
- margin-start: 8;
- margin-bottom: 8;
- margin-end: 8;
- orientation: horizontal;
- halign: start;
- valign: start;
- spacing: 6;
- styles [
- "main",
- ]
- Label {
- halign: start;
- label: "test2";
}
}
}
diff --git a/build-aux/de.nordgedanken.Email.Devel.json b/build-aux/de.nordgedanken.Email.Devel.json
@@ -0,0 +1,45 @@
+{
+ "app-id": "de.nordgedanken.Email",
+ "runtime": "org.gnome.Platform",
+ "runtime-version": "43",
+ "sdk": "org.gnome.Sdk",
+ "sdk-extensions": [
+ "org.freedesktop.Sdk.Extension.rust-stable",
+ "org.freedesktop.Sdk.Extension.llvm14"
+ ],
+ "command": "mail-client",
+ "finish-args": [
+ "--socket=fallback-x11",
+ "--socket=wayland",
+ "--device=dri",
+ "--share=network",
+ "--socket=session-bus",
+ "--env=RUST_LOG=mail_client=debug",
+ "--env=G_MESSAGES_DEBUG=none",
+ "--env=RUST_BACKTRACE=1"
+ ],
+ "build-options": {
+ "append-path": "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm14/bin",
+ "build-args": [
+ "--share=network"
+ ],
+ "env": {
+ "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER": "clang",
+ "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS": "-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold",
+ "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER": "clang",
+ "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS": "-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold"
+ }
+ },
+ "modules": [
+ {
+ "name": "mail-client",
+ "buildsystem": "meson",
+ "sources": [
+ {
+ "type": "dir",
+ "path": "../"
+ }
+ ]
+ }
+ ]
+}
+\ No newline at end of file
diff --git a/build-aux/dist-vendor.sh b/build-aux/dist-vendor.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+export DIST="$1"
+export SOURCE_ROOT="$2"
+
+cd "$SOURCE_ROOT"
+mkdir "$DIST"/.cargo
+cargo vendor | sed 's/^directory = ".*"/directory = "vendor"/g' > $DIST/.cargo/config
+# Move vendor into dist tarball directory
+mv vendor "$DIST"
+\ No newline at end of file
diff --git a/data/dev.nordgedanken.Email.desktop b/data/dev.nordgedanken.Email.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=Email Client
+Comment=A Rust GTK4 email client
+Type=Application
+# should be the same as the Cargo project name
+Exec=mail-client
+Terminal=false
+Categories=Network;GTK;Email;
+Keywords=Rust;Flatpak;GTK;Email;Network;
+# Icon=dev.nordgedanken.Email
+StartupNotify=true
diff --git a/data/dev.nordgedanken.Email.metainfo.xml b/data/dev.nordgedanken.Email.metainfo.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Bilal Elmoussaoui 2020 <bilal.elmoussaoui@gnome.org> -->
+<component type="desktop-application">
+ <id>dev.nordgedanken.Email</id>
+ <metadata_license>CC0</metadata_license>
+ <project_license>AGPL-3.0-or-later</project_license>
+ <name>Email Client</name>
+ <summary>A Rust GTK4 email client</summary>
+ <description>
+ <p>A Rust GTK4 email client</p>
+ </description>
+ <url type="homepage">https://github.com/erooster-mail/email-client</url>
+ <url type="bugtracker">https://github.com/erooster-mail/email-client/issues</url>
+ <!--
+ Open Age Rating Service
+ https://hughsie.github.io/oars/index.html
+ -->
+ <content_rating type="oars-1.1">
+ <content_attribute id="social-chat">intense</content_attribute>
+ <content_attribute id="social-contacts">intense</content_attribute>
+ </content_rating>
+
+ <releases>
+ <release version="0.0.1" date="2023-02-31">
+ <description>
+ <p>First release</p>
+ </description>
+ </release>
+ </releases>
+ <kudos>
+ <!--
+ GNOME Software kudos:
+ https://gitlab.gnome.org/GNOME/gnome-software/blob/master/doc/kudos.md
+ -->
+ <kudo>ModernToolkit</kudo>
+ <kudo>HiDpiIcon</kudo>
+ <kudo>Notifications</kudo>
+ </kudos>
+ <developer_name>MTRNord</developer_name>
+ <update_contact>support@nordgedanken.dev</update_contact>
+
+ <launchable type="desktop-id">dev.nordgedanken.Email.desktop</launchable>
+</component>
+
diff --git a/data/meson.build b/data/meson.build
@@ -0,0 +1,19 @@
+datadir = get_option('prefix') / get_option('datadir')
+
+application_id = 'dev.nordgedanken.Email'
+# Read more <https://mesonbuild.com/Reference-manual.html#install_data>
+
+install_data(
+ '@0@.desktop'.format(application_id),
+ install_dir: datadir / 'applications'
+)
+
+install_data(
+ '@0@.metainfo.xml'.format(application_id),
+ install_dir: datadir / 'metainfo'
+)
+
+#install_data(
+# '@0@.svg'.format(application_id),
+# install_dir: datadir / 'icons' / 'hicolor' / 'scalable' / 'apps'
+#)
diff --git a/meson.build b/meson.build
@@ -0,0 +1,33 @@
+project(
+ 'mail-client',
+ 'rust',
+ version: '0.1.0',
+ meson_version: '>= 0.59',
+)
+
+gnome = import('gnome')
+
+cargo = find_program('cargo', required: true)
+
+version = meson.project_version()
+prefix = get_option('prefix')
+bindir = prefix / get_option('bindir')
+
+dependency('glib-2.0', version: '>= 2.66')
+dependency('gio-2.0', version: '>= 2.66')
+dependency('gtk4', version: '>= 4.8.0')
+
+meson.add_dist_script(
+ 'build-aux/dist-vendor.sh',
+ meson.project_build_root() / 'meson-dist' / meson.project_name() + '-' + version,
+ meson.project_source_root()
+)
+
+subdir('data')
+subdir('src')
+
+gnome.post_install(
+ gtk_update_icon_cache: false,
+ glib_compile_schemas: false,
+ update_desktop_database: true,
+)
diff --git a/meson_options.txt b/meson_options.txt
@@ -0,0 +1,10 @@
+option(
+ 'profile',
+ type: 'combo',
+ choices: [
+ 'default',
+ 'development'
+ ],
+ value: 'default',
+ description: 'The build profile. One of "default" or "development".'
+)
diff --git a/src/main.rs b/src/main.rs
@@ -63,16 +63,28 @@ impl Component for App {
set_start_child = model.mailboxes.widget(),
#[wrap(Some)]
- set_end_child = >k::Box {
- set_margin_all: 8,
- set_halign: gtk::Align::Start,
- set_valign: gtk::Align::Start,
- set_spacing: 6,
- add_css_class: "main",
-
- gtk::Label {
+ set_end_child = >k::Paned {
+ set_orientation: gtk::Orientation::Vertical,
+ set_halign: gtk::Align::Fill,
+ set_valign: gtk::Align::Fill,
+ set_shrink_start_child: false,
+ set_position: 300,
+
+ #[wrap(Some)]
+ set_start_child = >k::ScrolledWindow {
+
+ },
+ #[wrap(Some)]
+ set_end_child = >k::Box {
+ add_css_class: "main",
+ set_margin_all: 8,
set_halign: gtk::Align::Start,
- set_label: "test2"
+ set_valign: gtk::Align::Start,
+ set_spacing: 8,
+
+ gtk::Label {
+ set_label: "test2"
+ }
}
}
},
@@ -104,14 +116,6 @@ impl Component for App {
ComponentParts { model, widgets }
}
-
- fn update_cmd(
- &mut self,
- msg: Self::CommandOutput,
- _sender: ComponentSender<Self>,
- _root: &Self::Root,
- ) {
- }
}
fn main() {
@@ -126,7 +130,7 @@ fn main() {
gio::resources_register_include!("resources.gresource").expect("Failed to register resources.");
let app = Application::builder()
- .application_id("dev.nordgedanken.email")
+ .application_id("dev.nordgedanken.Email")
.build();
// Connect to signals
app.connect_startup(|_| load_css());
diff --git a/src/meson.build b/src/meson.build
@@ -0,0 +1,31 @@
+cargo_options = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ]
+cargo_options += [ '--target-dir', meson.project_build_root() / 'src' ]
+
+if get_option('profile') == 'default'
+ cargo_options += [ '--release' ]
+ rust_target = 'release'
+ message('Building in release mode')
+else
+ rust_target = 'debug'
+ message('Building in debug mode')
+endif
+
+cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ]
+
+cargo_build = custom_target(
+ 'cargo-build',
+ build_by_default: true,
+ build_always_stale: true,
+ output: meson.project_name(),
+ console: true,
+ install: true,
+ install_dir: bindir,
+ command: [
+ 'env',
+ cargo_env,
+ cargo, 'build',
+ cargo_options,
+ '&&',
+ 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@',
+ ]
+)
+\ No newline at end of file