1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
use gtk;
use libphosh as phosh;
use libphosh::prelude::*;
fn main() {
gtk::init().unwrap();
let clock = phosh::WallClock::new();
clock.set_default();
let shell = custom_shell::CustomShell::new();
shell.set_default();
shell.set_locked(true);
shell.connect_ready(|_| {
glib::g_message!("example", "Custom Rusty shell ready");
});
gtk::main();
}
mod custom_shell {
use glib::Object;
use gtk::glib;
glib::wrapper! {
pub struct CustomShell(ObjectSubclass<imp::CustomShell>)
@extends libphosh::Shell;
}
impl CustomShell {
pub fn new() -> Self {
Object::builder().build()
}
}
impl Default for CustomShell {
fn default() -> Self {
Self::new()
}
}
mod imp {
use gtk::glib;
use gtk::glib::Type;
use gtk::prelude::StaticType;
use gtk::subclass::prelude::{ObjectImpl, ObjectSubclass};
use libphosh::subclass::shell::ShellImpl;
use crate::custom_lockscreen::CustomLockscreen;
#[derive(Default)]
pub struct CustomShell;
#[glib::object_subclass]
impl ObjectSubclass for CustomShell {
const NAME: &'static str = "CustomShell";
type Type = super::CustomShell;
type ParentType = libphosh::Shell;
}
impl ObjectImpl for CustomShell {}
impl ShellImpl for CustomShell {
fn get_lockscreen_type(&self) -> Type {
CustomLockscreen::static_type()
}
}
}
}
mod custom_lockscreen {
use glib::Object;
glib::wrapper! {
pub struct CustomLockscreen(ObjectSubclass<imp::CustomLockscreen>)
@extends libphosh::Lockscreen;
}
impl CustomLockscreen {
pub fn new() -> Self {
Object::builder().build()
}
}
impl Default for CustomLockscreen {
fn default() -> Self {
Self::new()
}
}
mod imp {
use gtk::subclass::prelude::*;
use gtk::{glib, Image};
use gtk::prelude::WidgetExt;
use libphosh::Lockscreen;
use libphosh::prelude::LockscreenExt;
use libphosh::subclass::lockscreen::LockscreenImpl;
#[derive(Default)]
pub struct CustomLockscreen {}
#[glib::object_subclass]
impl ObjectSubclass for CustomLockscreen {
const NAME: &'static str = "CustomLockscreen";
type Type = super::CustomLockscreen;
type ParentType = Lockscreen;
}
impl ObjectImpl for CustomLockscreen {
fn constructed(&self) {
self.parent_constructed();
glib::g_message!("example", "Constructed custom Lockscreen");
let hi = Image::builder()
.icon_name("face-kiss")
.pixel_size(100)
.build();
self.obj().add_extra_page(&hi);
hi.set_visible(true);
self.obj().connect_lockscreen_unlock(|_| {
glib::g_message!("example", "Custom Lockscreen was unlocked.");
});
self.obj().connect_page_notify(|me| {
glib::g_message!("example", "Lockscreen page changed to {:?}", me.page());
});
}
}
impl WidgetImpl for CustomLockscreen {}
impl ContainerImpl for CustomLockscreen {}
impl BinImpl for CustomLockscreen {}
impl WindowImpl for CustomLockscreen {}
impl LockscreenImpl for CustomLockscreen {}
}
}
|