Start remove app
This commit is contained in:
parent
2ef3557932
commit
8e0bf14cc8
|
@ -6,7 +6,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
adw = { version = "0.5.2", package = "libadwaita", features = ["v1_2"] }
|
adw = { version = "0.5.2", package = "libadwaita", features = ["v1_3"] }
|
||||||
gtk = { version = "0.7.1", package = "gtk4", features = ["v4_10"] }
|
gtk = { version = "0.7.1", package = "gtk4", features = ["v4_10"] }
|
||||||
log = { version = "0.4", features = ["max_level_debug", "release_max_level_info"] }
|
log = { version = "0.4", features = ["max_level_debug", "release_max_level_info"] }
|
||||||
simplelog = "^0.12.0"
|
simplelog = "^0.12.0"
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<interface>
|
||||||
|
<template class="ConfigManagerAppView" parent="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton">
|
||||||
|
<property name="label" translatable="yes">_Test</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
|
@ -2,5 +2,6 @@
|
||||||
<gresources>
|
<gresources>
|
||||||
<gresource prefix="/dev/fyloz/example/">
|
<gresource prefix="/dev/fyloz/example/">
|
||||||
<file compressed="true" preprocess="xml-stripblanks">window.ui</file>
|
<file compressed="true" preprocess="xml-stripblanks">window.ui</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks">app_view.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
|
|
@ -128,6 +128,9 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
|
<child>
|
||||||
|
<object class="CmAppView" />
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
use adw::glib;
|
||||||
|
use glib::subclass::InitializingObject;
|
||||||
|
use gtk::CompositeTemplate;
|
||||||
|
use gtk::prelude::*;
|
||||||
|
use gtk::subclass::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Default, CompositeTemplate)]
|
||||||
|
#[template(resource = "dev/fyloz/example/app_view.ui")]
|
||||||
|
pub struct AppView {}
|
||||||
|
|
||||||
|
#[glib::object_subclass]
|
||||||
|
impl ObjectSubclass for AppView {
|
||||||
|
const NAME: &'static str = "CmAppView";
|
||||||
|
type Type = super::AppView;
|
||||||
|
type ParentType = gtk::Box;
|
||||||
|
|
||||||
|
fn class_init(klass: &mut Self::Class) {
|
||||||
|
klass.bind_template();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn instance_init(obj: &InitializingObject<Self>) {
|
||||||
|
obj.init_template();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ObjectImpl for AppView {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WidgetImpl for AppView {}
|
||||||
|
|
||||||
|
impl BoxImpl for AppView {}
|
|
@ -0,0 +1,9 @@
|
||||||
|
use adw::glib;
|
||||||
|
|
||||||
|
mod imp;
|
||||||
|
|
||||||
|
glib::wrapper! {
|
||||||
|
pub struct AppView(ObjectSubclass<imp::AppView>)
|
||||||
|
@extends gtk::Box, gtk::Widget,
|
||||||
|
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
|
||||||
|
}
|
|
@ -1,2 +1,4 @@
|
||||||
pub mod objects;
|
pub mod objects;
|
||||||
pub mod window;
|
pub mod window;
|
||||||
|
|
||||||
|
pub mod appview;
|
||||||
|
|
|
@ -9,6 +9,7 @@ use adw::subclass::prelude::*;
|
||||||
use glib::once_cell::sync::OnceCell;
|
use glib::once_cell::sync::OnceCell;
|
||||||
use glib::subclass::InitializingObject;
|
use glib::subclass::InitializingObject;
|
||||||
use gtk::{gio, glib, CompositeTemplate, ListBox, TemplateChild, Stack};
|
use gtk::{gio, glib, CompositeTemplate, ListBox, TemplateChild, Stack};
|
||||||
|
use crate::ui::appview::AppView;
|
||||||
|
|
||||||
#[derive(CompositeTemplate, Default)]
|
#[derive(CompositeTemplate, Default)]
|
||||||
#[template(resource = "/dev/fyloz/example/window.ui")]
|
#[template(resource = "/dev/fyloz/example/window.ui")]
|
||||||
|
@ -19,6 +20,8 @@ pub struct Window {
|
||||||
pub leaflet: TemplateChild<Leaflet>,
|
pub leaflet: TemplateChild<Leaflet>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub stack: TemplateChild<Stack>,
|
pub stack: TemplateChild<Stack>,
|
||||||
|
#[template_child]
|
||||||
|
pub app_view: TemplateChild<AppView>,
|
||||||
pub apps: OnceCell<gio::ListStore>,
|
pub apps: OnceCell<gio::ListStore>,
|
||||||
pub current_app: RefCell<Option<AppObject>>,
|
pub current_app: RefCell<Option<AppObject>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::ui::objects::app::{AppData, AppObject};
|
||||||
|
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use gtk::{gio, glib, Entry, ListBoxRow, Label, pango, SelectionMode};
|
use gtk::{gio, glib, Entry, ListBoxRow, Label, pango, SelectionMode, Button, Orientation, CenterBox};
|
||||||
use glib::{clone, Object};
|
use glib::{clone, Object};
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
|
@ -34,12 +34,27 @@ impl Window {
|
||||||
.xalign(0.0)
|
.xalign(0.0)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
let remove_button = Button::builder()
|
||||||
|
.icon_name("user-trash-symbolic")
|
||||||
|
.tooltip_text("Remove the application")
|
||||||
|
.action_name("win.remove-application")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let bbox = CenterBox::builder()
|
||||||
|
.orientation(Orientation::Horizontal)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
bbox.set_start_widget(Some(&label));
|
||||||
|
bbox.set_end_widget(Some(&remove_button));
|
||||||
|
|
||||||
|
self.imp().apps_list.remove(&bbox);
|
||||||
|
|
||||||
app_object
|
app_object
|
||||||
.bind_property("name", &label, "label")
|
.bind_property("name", &label, "label")
|
||||||
.sync_create()
|
.sync_create()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ListBoxRow::builder().child(&label).build()
|
ListBoxRow::builder().child(&bbox).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn current_app(&self) -> AppObject {
|
fn current_app(&self) -> AppObject {
|
||||||
|
|
Loading…
Reference in New Issue