-
-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
137 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use glib::{object_subclass, wrapper}; | ||
use glib_macros::Properties; | ||
use gtk::{prelude::*, subclass::prelude::*}; | ||
use std::cell::RefCell; | ||
|
||
wrapper! { | ||
pub struct Window(ObjectSubclass<WindowPriv>) | ||
@extends gtk::Window, gtk::Bin, gtk::Container, gtk::Widget, @implements gtk::Buildable; | ||
} | ||
|
||
#[derive(Properties)] | ||
#[properties(wrapper_type = Window)] | ||
pub struct WindowPriv { | ||
#[property(get, name = "x", nick = "X", blurb = "Global x coordinate", default = 0)] | ||
x: RefCell<i32>, | ||
|
||
#[property(get, name = "y", nick = "Y", blurb = "Global y coordinate", default = 0)] | ||
y: RefCell<i32>, | ||
} | ||
|
||
// This should match the default values from the ParamSpecs | ||
impl Default for WindowPriv { | ||
fn default() -> Self { | ||
WindowPriv { x: RefCell::new(0), y: RefCell::new(0) } | ||
} | ||
} | ||
|
||
#[object_subclass] | ||
impl ObjectSubclass for WindowPriv { | ||
type ParentType = gtk::Window; | ||
type Type = Window; | ||
|
||
const NAME: &'static str = "WindowEww"; | ||
} | ||
|
||
impl Default for Window { | ||
fn default() -> Self { | ||
glib::Object::new::<Self>() | ||
} | ||
} | ||
|
||
impl Window { | ||
pub fn new(type_: gtk::WindowType, x_: i32, y_: i32) -> Self { | ||
let w: Self = glib::Object::builder().property("type", type_).build(); | ||
let priv_ = w.imp(); | ||
priv_.x.replace(x_); | ||
priv_.y.replace(y_); | ||
w | ||
} | ||
} | ||
|
||
impl ObjectImpl for WindowPriv { | ||
fn properties() -> &'static [glib::ParamSpec] { | ||
Self::derived_properties() | ||
} | ||
|
||
fn property(&self, id: usize, pspec: &glib::ParamSpec) -> glib::Value { | ||
self.derived_property(id, pspec) | ||
} | ||
} | ||
impl WindowImpl for WindowPriv {} | ||
impl BinImpl for WindowPriv {} | ||
impl ContainerImpl for WindowPriv {} | ||
impl WidgetImpl for WindowPriv {} |