add a simple gui window

This commit is contained in:
hendrik 2025-06-07 03:00:12 +02:00
parent e802e87c28
commit 567b56748e
8 changed files with 1204 additions and 88 deletions

1247
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,2 @@
[workspace]
members = ["cat_cli", "catdex"]
members = ["cat_cli", "cat_gui", "catdex"]

7
cat_gui/Cargo.toml Normal file
View File

@ -0,0 +1,7 @@
[package]
name = "cat_gui"
version = "0.1.0"
edition = "2021"
[dependencies]
gtk = { version = "0.18.2", features = ["v3_24"] }

21
cat_gui/src/lib.rs Normal file
View File

@ -0,0 +1,21 @@
use gtk::{
gio::{prelude::ApplicationExtManual, traits::ApplicationExt}, traits::{ContainerExt, GtkWindowExt, WidgetExt}, Application, ApplicationWindow, Box, Image, Label, Orientation
};
pub fn run_gui() {
let app = Application::new(Some("com.shinglyu.cat-gui"), Default::default());
app.connect_activate(|app| {
let window = ApplicationWindow::new(app);
window.set_title("Catty");
window.set_default_size(500, 270);
let label = Label::new(Some("Meow!\n \\\n \\"));
let layout_box = Box::new(Orientation::Vertical, 0);
let cat_img = Image::from_file("../resources/cat_img.png");
layout_box.add(&label);
layout_box.add(&cat_img);
window.add(&layout_box);
window.show_all();
});
app.run();
}

View File

@ -6,3 +6,4 @@ edition = "2024"
[dependencies]
anyhow = "1.0.98"
cat_cli = { path = "../cat_cli" }
cat_gui = { path = "../cat_gui" }

View File

@ -1,8 +1,9 @@
use anyhow::Error;
use cat_cli::run::run_cli;
use cat_cli::tui::run_tui;
use cat_gui::run_gui;
fn main() -> Result<(), Error> {
run_cli()?;
run_gui();
Ok(())
}

BIN
resources/cat_img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 KiB

9
tmp
View File

@ -1,9 +0,0 @@
miau
\
\
\
("`-''-/").___..--''"`-._
`x_ x ) `-. ( ).`-.__.`)
(_Y_.)' ._ ) `._ `. ``-..-'
_..`--'_..-_/ /--'_.' ,'
(il),-'' (li),' ((!.-'