window: Add edit view
This commit is contained in:
parent
9205c93fae
commit
4b0d5f7b6d
5 changed files with 102 additions and 8 deletions
|
|
@ -28,6 +28,7 @@ mod properties_view;
|
||||||
mod shy_bin;
|
mod shy_bin;
|
||||||
mod sliding_view;
|
mod sliding_view;
|
||||||
mod window_content;
|
mod window_content;
|
||||||
|
mod window_edit;
|
||||||
mod window_image;
|
mod window_image;
|
||||||
|
|
||||||
pub use drag_overlay::LpDragOverlay;
|
pub use drag_overlay::LpDragOverlay;
|
||||||
|
|
@ -41,4 +42,5 @@ pub use properties_view::LpPropertiesView;
|
||||||
pub use shy_bin::LpShyBin;
|
pub use shy_bin::LpShyBin;
|
||||||
pub use sliding_view::LpSlidingView;
|
pub use sliding_view::LpSlidingView;
|
||||||
pub use window_content::LpWindowContent;
|
pub use window_content::LpWindowContent;
|
||||||
|
pub use window_edit::LpWindowEdit;
|
||||||
pub use window_image::LpWindowImage;
|
pub use window_image::LpWindowImage;
|
||||||
|
|
|
||||||
67
src/widgets/window_edit.rs
Normal file
67
src/widgets/window_edit.rs
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
// Copyright (c) 2024 Sophie Herold
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
use adw::prelude::*;
|
||||||
|
use adw::subclass::prelude::*;
|
||||||
|
use adw::{glib, gtk};
|
||||||
|
|
||||||
|
mod imp {
|
||||||
|
use super::*;
|
||||||
|
#[derive(Debug, Default, gtk::CompositeTemplate, glib::Properties)]
|
||||||
|
#[properties(wrapper_type = super::LpWindowEdit)]
|
||||||
|
#[template(file = "window_edit.ui")]
|
||||||
|
pub struct LpWindowEdit {
|
||||||
|
#[property(get)]
|
||||||
|
example: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[glib::object_subclass]
|
||||||
|
impl ObjectSubclass for LpWindowEdit {
|
||||||
|
const NAME: &'static str = "LpWindowEdit";
|
||||||
|
type Type = super::LpWindowEdit;
|
||||||
|
type ParentType = adw::Bin;
|
||||||
|
|
||||||
|
fn class_init(klass: &mut Self::Class) {
|
||||||
|
Self::bind_template(klass);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||||
|
obj.init_template();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[glib::derived_properties]
|
||||||
|
impl ObjectImpl for LpWindowEdit {
|
||||||
|
fn constructed(&self) {
|
||||||
|
self.parent_constructed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WidgetImpl for LpWindowEdit {}
|
||||||
|
impl BinImpl for LpWindowEdit {}
|
||||||
|
}
|
||||||
|
|
||||||
|
glib::wrapper! {
|
||||||
|
pub struct LpWindowEdit(ObjectSubclass<imp::LpWindowEdit>)
|
||||||
|
@extends gtk::Widget, adw::Bin;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LpWindowEdit {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
glib::Object::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/widgets/window_edit.ui
Normal file
17
src/widgets/window_edit.ui
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="LpWindowEdit" parent="AdwBin">
|
||||||
|
<property name="child">
|
||||||
|
<object class="AdwToolbarView" id="toolbar_view">
|
||||||
|
<child type="top">
|
||||||
|
<object class="AdwHeaderBar"></object>
|
||||||
|
</child>
|
||||||
|
<property name="content">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label">Edit Image</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
|
|
@ -17,21 +17,18 @@
|
||||||
|
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
|
use gio::glib::VariantTy;
|
||||||
use gtk::CompositeTemplate;
|
use gtk::CompositeTemplate;
|
||||||
|
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use crate::deps::*;
|
use crate::deps::*;
|
||||||
use crate::widgets::LpImageView;
|
use crate::widgets::{LpImageView, LpWindowEdit, LpWindowImage};
|
||||||
|
|
||||||
/// Show window after X milliseconds even if image dimensions are not known yet
|
/// Show window after X milliseconds even if image dimensions are not known yet
|
||||||
const SHOW_WINDOW_AFTER: u64 = 2000;
|
const SHOW_WINDOW_AFTER: u64 = 2000;
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
|
|
||||||
use gio::glib::VariantTy;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::widgets::LpWindowImage;
|
|
||||||
|
|
||||||
// To use composite templates, you need
|
// To use composite templates, you need
|
||||||
// to use derive macro. Derive macros generate
|
// to use derive macro. Derive macros generate
|
||||||
|
|
@ -52,9 +49,13 @@ mod imp {
|
||||||
pub struct LpWindow {
|
pub struct LpWindow {
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub(super) toast_overlay: TemplateChild<adw::ToastOverlay>,
|
pub(super) toast_overlay: TemplateChild<adw::ToastOverlay>,
|
||||||
|
#[template_child]
|
||||||
|
pub(super) stack: TemplateChild<adw::ViewStack>,
|
||||||
|
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub(super) window_image: TemplateChild<LpWindowImage>,
|
pub(super) window_image: TemplateChild<LpWindowImage>,
|
||||||
|
#[template_child]
|
||||||
|
pub(super) window_edit: TemplateChild<LpWindowEdit>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
|
|
@ -190,7 +191,7 @@ impl LpWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_edit(&self) {
|
pub fn show_edit(&self) {
|
||||||
todo!()
|
self.imp().stack.set_visible_child(&*self.imp().window_edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn image_view(&self) -> LpImageView {
|
pub fn image_view(&self) -> LpImageView {
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,16 @@
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="AdwToastOverlay" id="toast_overlay">
|
<object class="AdwToastOverlay" id="toast_overlay">
|
||||||
<property name="child">
|
<property name="child">
|
||||||
|
<object class="AdwViewStack" id="stack">
|
||||||
|
<child>
|
||||||
<object class="LpWindowImage" id="window_image">
|
<object class="LpWindowImage" id="window_image">
|
||||||
<property name="window">LpWindow</property>
|
<property name="window">LpWindow</property>
|
||||||
</object>
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="LpWindowEdit" id="window_edit"></object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue