Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit aa53d61

Browse files
Merge pull request #308 from alatiera/alatiera/fix-subclass-typename
basic_subclass: fix name of our GObject subclasss type
2 parents 2686f4b + 6dcd9c9 commit aa53d61

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/bin/basic_subclass.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct SimpleWindowPrivate {
4242
}
4343

4444
impl ObjectSubclass for SimpleWindowPrivate {
45-
const NAME: &'static str = "SimpleWindowPrivate";
45+
const NAME: &'static str = "SimpleWindow";
4646
type ParentType = gtk::ApplicationWindow;
4747
type Instance = subclass::simple::InstanceStruct<Self>;
4848
type Class = subclass::simple::ClassStruct<Self>;
@@ -139,7 +139,7 @@ pub struct SimpleApplicationPrivate {
139139
}
140140

141141
impl ObjectSubclass for SimpleApplicationPrivate {
142-
const NAME: &'static str = "SimpleApplicationPrivate";
142+
const NAME: &'static str = "SimpleApplication";
143143
type ParentType = gtk::Application;
144144
type Instance = subclass::simple::InstanceStruct<Self>;
145145
type Class = subclass::simple::ClassStruct<Self>;
@@ -165,10 +165,8 @@ impl ApplicationImpl for SimpleApplicationPrivate {
165165
// `gio::Application::activate` is what gets called when the
166166
// application is launched by the desktop environment and
167167
// aksed to present itself.
168-
fn activate(&self, app: &gio::Application) {
169-
let app = app.downcast_ref::<gtk::Application>().unwrap();
170-
let priv_ = SimpleApplicationPrivate::from_instance(app);
171-
let window = priv_
168+
fn activate(&self, _app: &gio::Application) {
169+
let window = self
172170
.window
173171
.get()
174172
.expect("Should always be initiliazed in gio_application_startup");
@@ -187,10 +185,8 @@ impl ApplicationImpl for SimpleApplicationPrivate {
187185
self.parent_startup(app);
188186

189187
let app = app.downcast_ref::<gtk::Application>().unwrap();
190-
let priv_ = SimpleApplicationPrivate::from_instance(app);
191188
let window = SimpleWindow::new(&app);
192-
priv_
193-
.window
189+
self.window
194190
.set(window)
195191
.expect("Failed to initialize application window");
196192
}

0 commit comments

Comments
 (0)