implement self construction

This commit is contained in:
yggverse 2024-10-12 07:10:56 +03:00
parent c499f10320
commit 6aedb21794
3 changed files with 13 additions and 5 deletions

View File

@ -76,7 +76,7 @@ Quick start guide and maintenance protocol
* implementable `struct` is public, where it members - private * implementable `struct` is public, where it members - private
* contain main `struct` implementation: * contain main `struct` implementation:
* at least one constructor that must: * at least one constructor that must:
* have common for application name: `new` or/and `new_arc`, `new_mutex`, etc - on return object in container * have common for application names: `from`, `new` or/and `new_arc`, `new_mutex`, etc - on return object in container
* grant ownership for new `Self` object created * grant ownership for new `Self` object created
* public `activate` action if the new object can not be activated on construct * public `activate` action if the new object can not be activated on construct
* public `link` getter for GTK `widget` (parental composition) * public `link` getter for GTK `widget` (parental composition)

View File

@ -57,7 +57,7 @@ impl Reader {
markup.push_str(Plain::from(line).markup()) markup.push_str(Plain::from(line).markup())
*/ */
buffer.insert(&mut buffer.end_iter(), &Plain::from(line)); buffer.insert(&mut buffer.end_iter(), Plain::from(line).as_str());
} }
// Init widget // Init widget

View File

@ -1,11 +1,19 @@
use gtk::glib::{gformat, GString}; use gtk::glib::{gformat, GString};
pub struct Plain { pub struct Plain {
// nothing yet.. line: GString,
} }
impl Plain { impl Plain {
pub fn from(line: &str) -> GString { // Construct
gformat!("{}\n", line) pub fn from(line: &str) -> Self {
Self {
line: gformat!("{}\n", line),
}
}
// Getters
pub fn as_str(&self) -> &str {
self.line.as_str()
} }
} }