You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.2 KiB
Rust
71 lines
2.2 KiB
Rust
/* window.rs
|
|
*
|
|
* Copyright 2022 axtlos
|
|
*
|
|
* 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 gtk::prelude::*;
|
|
use adw::subclass::prelude::*;
|
|
use gtk::{gio, glib, CompositeTemplate};
|
|
|
|
mod imp {
|
|
use super::*;
|
|
|
|
#[derive(Debug, Default, CompositeTemplate)]
|
|
#[template(resource = "/al/getcryst/opal/window.ui")]
|
|
pub struct OpalWindow {
|
|
// Template widgets
|
|
#[template_child]
|
|
pub header_bar: TemplateChild<gtk::HeaderBar>,
|
|
#[template_child]
|
|
pub label: TemplateChild<gtk::Label>,
|
|
}
|
|
|
|
#[glib::object_subclass]
|
|
impl ObjectSubclass for OpalWindow {
|
|
const NAME: &'static str = "OpalWindow";
|
|
type Type = super::OpalWindow;
|
|
type ParentType = adw::ApplicationWindow;
|
|
|
|
fn class_init(klass: &mut Self::Class) {
|
|
Self::bind_template(klass);
|
|
}
|
|
|
|
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
|
obj.init_template();
|
|
}
|
|
}
|
|
|
|
impl ObjectImpl for OpalWindow {}
|
|
impl WidgetImpl for OpalWindow {}
|
|
impl WindowImpl for OpalWindow {}
|
|
impl ApplicationWindowImpl for OpalWindow {}
|
|
impl AdwApplicationWindowImpl for OpalWindow {}
|
|
}
|
|
|
|
glib::wrapper! {
|
|
pub struct OpalWindow(ObjectSubclass<imp::OpalWindow>)
|
|
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, @implements gio::ActionGroup, gio::ActionMap;
|
|
}
|
|
|
|
impl OpalWindow {
|
|
pub fn new<P: glib::IsA<gtk::Application>>(application: &P) -> Self {
|
|
glib::Object::new(&[("application", application)])
|
|
.expect("Failed to create OpalWindow")
|
|
}
|
|
}
|