Start remove app
This commit is contained in:
parent
9bc67682ad
commit
bc4e44d9c8
|
@ -66,6 +66,7 @@ name = "config-manager-client"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"f-uuid",
|
||||
"gio",
|
||||
"glib-build-tools",
|
||||
"gtk4",
|
||||
"libadwaita",
|
||||
|
@ -239,9 +240,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gio"
|
||||
version = "0.18.1"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7884cba6b1c5db1607d970cadf44b14a43913d42bc68766eea6a5e2fe0891524"
|
||||
checksum = "57052f84e8e5999b258e8adf8f5f2af0ac69033864936b8b6838321db2f759b1"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
|
|
|
@ -8,6 +8,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
adw = { version = "0.5.2", package = "libadwaita", features = ["v1_3"] }
|
||||
f-uuid = { version = "1.0.0", registry = "gitea" }
|
||||
gio = { version = "0.18.2", features = ["v2_74"] }
|
||||
gtk = { version = "0.7.1", package = "gtk4", features = ["v4_10"] }
|
||||
log = { version = "0.4", features = ["max_level_debug", "release_max_level_info"] }
|
||||
simplelog = "^0.12.0"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::cell::RefCell;
|
||||
use adw::glib;
|
||||
use glib::subclass::InitializingObject;
|
||||
use gtk::{Button, CompositeTemplate};
|
||||
use gtk::{Button, CompositeTemplate, template_callbacks};
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use crate::ui::objects::app::AppObject;
|
||||
|
@ -15,6 +15,14 @@ pub struct AppView {
|
|||
pub application: RefCell<Option<AppObject>>
|
||||
}
|
||||
|
||||
#[template_callbacks]
|
||||
impl AppView {
|
||||
#[template_callback]
|
||||
fn handle_remove_button_clicked(&self, button: &Button) {
|
||||
println!("Clicked!");
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for AppView {
|
||||
const NAME: &'static str = "CmAppView";
|
||||
|
|
|
@ -124,6 +124,21 @@ impl Window {
|
|||
dialog.present();
|
||||
}
|
||||
|
||||
fn remove_application(&self, id: &str) {
|
||||
let apps = self.imp().apps.get().unwrap();
|
||||
let index = apps.find_with_equal_func(|obj| -> bool {
|
||||
let id_prop = obj
|
||||
.downcast_ref::<AppObject>()
|
||||
.expect("The object should be of type 'AppObject'")
|
||||
.property_value("id");
|
||||
|
||||
let app_id = id_prop.get::<String>().expect("AppObject 'id' property should be a string");
|
||||
app_id == id
|
||||
});
|
||||
|
||||
dbg!(index);
|
||||
}
|
||||
|
||||
fn restore_data(&self) {
|
||||
let data = vec!(
|
||||
AppData {
|
||||
|
|
Loading…
Reference in New Issue