Skip to content

Commit

Permalink
Implement adaptive adwaita UI
Browse files Browse the repository at this point in the history
  • Loading branch information
matzipan committed Sep 17, 2023
1 parent 47517be commit 2f3b95b
Show file tree
Hide file tree
Showing 12 changed files with 478 additions and 103 deletions.
174 changes: 101 additions & 73 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ pangocairo = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "pan

[dependencies.gtk]
package = "gtk4"
git = "https://github.com/gtk-rs/gtk4-rs"
git = "https://github.com/gtk-rs/gtk4-rs"

[dependencies.adw]
package = "libadwaita"
git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs"
features = ["v1_4"]
15 changes: 11 additions & 4 deletions build-aux/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ id: com.github.matzipan.envoyer
tags:
- "nightly"
runtime: org.gnome.Platform
runtime-version: "43"
runtime-version: "45beta"
sdk: org.gnome.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.rust-nightly
- org.freedesktop.Sdk.Extension.llvm14
- org.freedesktop.Sdk.Extension.llvm16
command: envoyer
finish-args:
- --share=ipc
Expand All @@ -16,12 +16,19 @@ finish-args:
- --talk-name=org.freedesktop.portal.OpenURI
build-options:
append-path: "/usr/lib/sdk/rust-nightly/bin"
prepend-path: "/usr/lib/sdk/llvm14/bin"
prepend-ld-library-path: "/usr/lib/sdk/llvm14/lib"
prepend-path: "/usr/lib/sdk/llvm16/bin"
prepend-ld-library-path: "/usr/lib/sdk/llvm16/lib"
build-args:
- --share=network
- --socket=session-bus
modules:
- name: blueprint-compiler
buildsystem: meson
builddir: true
sources:
- type: git
url: https://gitlab.gnome.org/jwestman/blueprint-compiler.git/
tag: v0.10.0
- name: com.github.matzipan.envoyer
buildsystem: meson
run-tests: true
Expand Down
15 changes: 15 additions & 0 deletions data/resources/blabla.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="Window" parent="GtkApplicationWindow">
<property name="title">My GTK App</property>
<child>
<object class="GtkButton" id="button">
<property name="label">Press me!</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
</object>
</child>
</template>
</interface>
10 changes: 9 additions & 1 deletion data/resources/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Resources
blueprints = custom_target('blueprints',
input: [
'window.blp',
],
output: '.',
command: [blueprint_compiler, 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
)

resources = gnome.compile_resources(
'resources',
'resources.gresource.xml',
gresource_bundle: true,
dependencies: blueprints,
source_dir: meson.current_build_dir(),
install: true,
install_dir: pkgdatadir,
Expand Down
1 change: 1 addition & 0 deletions data/resources/resources.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/com/github/matzipan/envoyer/">
<!-- see https://gtk-rs.org/gtk4-rs/git/docs/gtk4/struct.Application.html#automatic-resources -->
<file compressed="true" preprocess="xml-stripblanks">window.ui</file>
</gresource>
</gresources>
260 changes: 260 additions & 0 deletions data/resources/window.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
using Gtk 4.0;
using Adw 1;

template $Window : Adw.ApplicationWindow {
width-request: 360;
height-request: 200;
default-width: 1200;
default-height: 600;
title: _("Mail");
content: Adw.NavigationSplitView outer_view {
min-sidebar-width: 470;
max-sidebar-width: 780;
sidebar-width-fraction: 0.47;
sidebar: Adw.NavigationPage inner_view_page {
title: _("Inbox");
child: Adw.NavigationSplitView inner_view {
max-sidebar-width: 260;
sidebar-width-fraction: 0.38;
sidebar: Adw.NavigationPage {
title: _("Mail");
child: Adw.ToolbarView {
[top]
Adw.HeaderBar {
[start]
Gtk.MenuButton {
child: Adw.Avatar avatar {
size: 24;
};
popover: Gtk.Popover {};
styles [ "image-button" ]
}
[end]
Gtk.MenuButton {
primary: true;
icon-name: "open-menu-symbolic";
menu-model: primary_menu;
}
}
content: Gtk.ScrolledWindow {
hscrollbar-policy: never;
child: Gtk.ListBox folders_list {
selection-mode: browse;
row-activated => $folders_row_activated_cb();
styles ["navigation-sidebar"]
};
};
};
};
content: Adw.NavigationPage inbox_page {
title: _("Inbox");
tag: "inbox";
child: Adw.ToolbarView {
[top]
Adw.HeaderBar {
[start]
Gtk.ToggleButton start_inbox_search_btn {
active: bind inbox_search_bar.search-mode-enabled bidirectional;
icon-name: "edit-find-symbolic";
}
[end]
Gtk.ToggleButton end_inbox_search_btn {
active: bind inbox_search_bar.search-mode-enabled bidirectional;
icon-name: "edit-find-symbolic";
visible: false;
}
[end]
Gtk.Button {
icon-name: "selection-mode-symbolic";
}
}
[top]
Gtk.SearchBar inbox_search_bar {
key-capture-widget: inbox_page;
child: Adw.Clamp {
maximum-size: 400;
child: Gtk.SearchEntry inbox_search_entry {
hexpand: true;
};
};
}
content: Gtk.Overlay {
[overlay]
Gtk.Button {
halign: end;
valign: end;
icon-name: "document-edit-symbolic";
styles ["suggested-action", "circular", "fab"]
}
child: Gtk.ScrolledWindow {
hscrollbar-policy: never;
child: Gtk.ListBox inbox_list {
selection-mode: browse;
row-activated => $inbox_row_activated_cb();
styles ["navigation-sidebar"]
};
};
};
};
};
};
};
content: Adw.NavigationPage message_page {
tag: "message";
title: _("Message");
child: Adw.ToolbarView {
[top]
Adw.HeaderBar {
show-title: false;

[start]
Gtk.Button reply_btn {
icon-name: 'mail-reply-sender-symbolic';
}
[start]
Gtk.Button reply_all_btn {
icon-name: 'mail-reply-all-symbolic';
}
[start]
Gtk.Button forward_btn {
icon-name: 'mail-forward-symbolic';
}

[end]
Gtk.ToggleButton {
icon-name: 'edit-find-symbolic';
active: bind message_search_bar.search-mode-enabled bidirectional;
}
[end]
Gtk.Button delete_btn {
icon-name: 'user-trash-symbolic';
}
[end]
Gtk.Button spam_btn {
icon-name: 'junk-symbolic';
}
}
[top]
Gtk.SearchBar message_search_bar {
key-capture-widget: message_page;
child: Adw.Clamp {
maximum-size: 400;
child: Gtk.SearchEntry message_search_entry {
hexpand: true;
};
};
}
content: Gtk.ScrolledWindow {
hscrollbar-policy: never;
child: Adw.Clamp {
maximum-size: 1200;
child: Gtk.Box {
orientation: vertical;
styles ["conversation"]
Gtk.Label {
label: "Weekend Hike";
xalign: 0;
styles ["title-2"]
}
Adw.Bin {
height-request: 240;
styles ["card"]
}
Adw.Bin {
height-request: 240;
styles ["card"]
}
Adw.Bin {
height-request: 240;
styles ["card"]
}
Adw.Bin {
height-request: 240;
styles ["card"]
}
};
};
};
[bottom]
Gtk.Box toolbar {
visible: false;
homogeneous: true;
Gtk.Button {
icon-name: 'mail-reply-sender-symbolic';
}
Gtk.Button {
icon-name: 'mail-reply-all-symbolic';
}
Gtk.Button {
icon-name: 'mail-forward-symbolic';
}
Gtk.Button {
icon-name: 'junk-symbolic';
}
Gtk.Button {
icon-name: 'user-trash-symbolic';
}
styles ["toolbar"]
}
};
};
};
Adw.Breakpoint {
condition ("max-width: 860sp")
apply => $two_pane_apply_cb();
unapply => $two_pane_unapply_cb();
setters {
outer_view.collapsed: true;
inbox_list.selection-mode: none;
inner_view.sidebar-width-fraction: 0.33;
}
}
Adw.Breakpoint {
condition ("max-width: 500sp")
unapply => $one_pane_unapply_cb();
setters {
outer_view.collapsed: true;
inbox_list.selection-mode: none;
inner_view.sidebar-width-fraction: 0.33;

inner_view.collapsed: true;
folders_list.selection-mode: none;

start_inbox_search_btn.visible: false;
end_inbox_search_btn.visible: true;

reply_btn.visible: false;
reply_all_btn.visible: false;
forward_btn.visible: false;
delete_btn.visible: false;
spam_btn.visible: false;
toolbar.visible: true;
}
}
}
menu primary_menu {
section {
item {
label: _("A_ccounts");
action: "app.accounts";
}
}
section {
item {
label: _("_Preferences");
action: "app.preferences";
}
item {
label: _("_Keyboard Shortcuts");
action: "win.show-help-overlay";
}
item {
label: _("_Help");
action: "app.help";
}
item {
label: _("_About Mail");
action: "app.about";
}
}
}
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ base_id = 'com.github.matzipan.envoyer'
dependency('glib-2.0', version: '>= 2.66')
dependency('gio-2.0', version: '>= 2.66')
dependency('gtk4', version: '>= 4.0.0')
dependency('libadwaita-1', version: '>= 1.2')

glib_compile_resources = find_program('glib-compile-resources', required: true)
glib_compile_schemas = find_program('glib-compile-schemas', required: true)
desktop_file_validate = find_program('desktop-file-validate', required: false)
appstream_util = find_program('appstream-util', required: false)
cargo = find_program('cargo', required: true)
blueprint_compiler = find_program('blueprint-compiler', required: true)

version = meson.project_version()

Expand Down
Loading

0 comments on commit 2f3b95b

Please sign in to comment.