Libadwaita Apps
GTK4, libAdwaitaのアプリケーションをWindowsでビルド&実行してみました。
- https://gtk-rs.org/gtk4-rs/stable/latest/book/introduction.html
GUI development with Rust and GTK 4
以下はlibadwaitaアプリケーション情報
https://apps.gnome.org/
Apps for GNOMEhttps://arewelibadwaitayet.com/
Discover the Best LibAdwaita Apps in One Placehttps://github.com/valpackett/awesome-gtk
Awesome GTK - Collections of awesome native open-source GTK (4 and 3) applications.
環境
- Windows 11 24H2
- rust 1.82.0
- libadwaita 0.7.1 / v1_6
- gtk4 0.9.4 / v4_16
構築(Windowsの場合)
rustup
https://rustup.rs/
rustup‑init.exerustup default stable-msvc
Git
winget install --id Git.Git -e --source winget
MSYS2
winget install --id MSYS2.MSYS2 -e --source winget
Visual Studio 2022
winget install Microsoft.VisualStudio.2022.BuildTools -e --source winget --silent --override "--wait --quiet --add ProductLang En-us --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
Python
winget install --id Python.Python.3.13 -e --source winget
gvsbuild
install
py -3.13 -m pip install --user pipx
py -3.13 -m pipx ensurepath
exitpipx install gvsbuild
build
gvsbuild build gtk4
Environmental Variables
Variable Value PKG_CONFIG_PATH C:\gtk-build\gtk\x64\release\lib\pkgconfig
Path add C:\gtk-build\gtk\x64\release\bin
Lib C:\gtk-build\gtk\x64\release\lib
実行
CUI版
- プロジェクトの作成
cargo new my-gtk-app
cd my-gtk-app
pkg-config --modversion gtk4 - ソース
main.rs fn main() {
println!("Hello, world!");
} - ビルドと実行
cargo add gtk4 --rename gtk --features v4_16
cargo run
GTK版
- ソースの更新
main.rs use gtk::prelude::*;
use gtk::{glib, Application, ApplicationWindow, Button};
const APP_ID: &str = "org.gtk_rs.HelloWorld3";
fn main() -> glib::ExitCode {
// Create a new application
let app = Application::builder().application_id(APP_ID).build();
// Connect to "activate" signal of `app`
app.connect_activate(build_ui);
// Run the application
app.run()
}
fn build_ui(app: &Application) {
// Create a button with label and margins
let button = Button::builder()
.label("Press me!")
.margin_top(12)
.margin_bottom(12)
.margin_start(12)
.margin_end(12)
.build();
// Connect to "clicked" signal of `button`
button.connect_clicked(|button| {
// Set the label to "Hello World!" after the button has been clicked on
button.set_label("Hello World!");
});
// Create a window
let window = ApplicationWindow::builder()
.application(app)
.title("My GTK App")
.child(&button)
.build();
// Present window
window.present();
} - ビルドと実行
cargo run
libAdwaita版
- ソースの更新
GTK版で以下を修正する。main.rs // use gtk::{glib, Application, ApplicationWindow, Button};
use gtk::{glib, ApplicationWindow, Button};main.rs // let app = Application::builder().application_id(APP_ID).build();
let app = adw::Application::builder().application_id(APP_ID).build();main.rs // fn build_ui(app: &Application) {
fn build_ui(app: &adw::Application) {
以下、管理者権限で実行
- UnicodeDecodeError: ‘cp932’ codec can’t decode byte… 対策
New-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'ACP' -Value '65001' -PropertyType String -Force;
New-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'OEMCP' -Value '65001' -PropertyType String -Force;
New-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'MACCP' -Value '65001' -PropertyType String -Force; - build
cargo add libadwaita --rename adw --features v1_6
gvsbuild build libadwaita librsvg - UnicodeDecodeError: ‘cp932’ codec can’t decode byte… 対策の戻し
New-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'ACP' -Value '932' -PropertyType String -Force;
New-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'OEMCP' -Value '932' -PropertyType String -Force;
New-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'MACCP' -Value '932' -PropertyType String -Force;
一般ユーザで
- ビルドと実行
cargo run
libAdwaita Apps
https://arewelibadwaitayet.com/
使ったことのあるアプリ、使ってみたいアプリ
- Amberol
Plays music, and nothing else - Black Box
A beautiful GTK 4 terminal - Bottles
Run Windows Software - Ear Tag
Edit audio file tags - Extension Manager
Browse, install, and manage GNOME Shell Extensions - Flatseal
Manage Flatpak permissions - Gapless
Play your music elegantly - GDM Settings
Customize your login screen - Maps
Find places around the world - Music
Play and organize your music collection - Radio
A simple radio with stations from the website radio-browser.info - Translation Editor
Translate and localize applications and libraries - Turn On
Turn on devices in your network - Wallpaper Selector
Downloads and applies wallpapers
Comment