add a simple gui window
This commit is contained in:
parent
e802e87c28
commit
567b56748e
1247
Cargo.lock
generated
1247
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,2 @@
|
||||
[workspace]
|
||||
members = ["cat_cli", "catdex"]
|
||||
members = ["cat_cli", "cat_gui", "catdex"]
|
||||
|
||||
7
cat_gui/Cargo.toml
Normal file
7
cat_gui/Cargo.toml
Normal 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
21
cat_gui/src/lib.rs
Normal 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();
|
||||
}
|
||||
@ -6,3 +6,4 @@ edition = "2024"
|
||||
[dependencies]
|
||||
anyhow = "1.0.98"
|
||||
cat_cli = { path = "../cat_cli" }
|
||||
cat_gui = { path = "../cat_gui" }
|
||||
|
||||
@ -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
BIN
resources/cat_img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 386 KiB |
Loading…
x
Reference in New Issue
Block a user