Advertisement · 728 × 90
#
Hashtag
#gobject
Advertisement · 728 × 90
This code:

applicationClass.OverrideActivate(func(a *gio.Application) {
			exampleApp := (*exampleApplication)(unsafe.Pointer(a.GetData(dataKeyGoInstance)))

			var app gtk.Application
			a.Cast(&app)

			obj := gobject.NewObject(senbaragtk.MainApplicationWindowGLibType(),
				"application", app,
			)

			var window senbaragtk.MainApplicationWindow
			obj.Cast(&window)

			exampleApp.window = &window

			var cb func(senbaragtk.MainApplicationWindow) = func(w senbaragtk.MainApplicationWindow) {
				fmt.Println("Test button clicked")

				exampleApp.window.ShowToast("Button was clicked!")
				exampleApp.window.SetPropertyTestButtonSensitive(false)

				time.AfterFunc(time.Second*3, func() {
					exampleApp.window.ShowToast("Button re-enabled after 3 seconds")
					exampleApp.window.SetPropertyTestButtonSensitive(true)
				})
			}
			exampleApp.window.ConnectButtonTestClicked(&cb)

			exampleApp.window.Present()
		})

This code: applicationClass.OverrideActivate(func(a *gio.Application) { exampleApp := (*exampleApplication)(unsafe.Pointer(a.GetData(dataKeyGoInstance))) var app gtk.Application a.Cast(&app) obj := gobject.NewObject(senbaragtk.MainApplicationWindowGLibType(), "application", app, ) var window senbaragtk.MainApplicationWindow obj.Cast(&window) exampleApp.window = &window var cb func(senbaragtk.MainApplicationWindow) = func(w senbaragtk.MainApplicationWindow) { fmt.Println("Test button clicked") exampleApp.window.ShowToast("Button was clicked!") exampleApp.window.SetPropertyTestButtonSensitive(false) time.AfterFunc(time.Second*3, func() { exampleApp.window.ShowToast("Button re-enabled after 3 seconds") exampleApp.window.SetPropertyTestButtonSensitive(true) }) } exampleApp.window.ConnectButtonTestClicked(&cb) exampleApp.window.Present() })

This code:

vfunc_activate() {
      this.#window = new SenbaraGtk.MainApplicationWindow({
        application: this,
      });

      this.#window.connect("button-test-clicked", () => {
        console.log("Test button clicked");

        this.#window.show_toast("Button was clicked!");
        this.#window.test_button_sensitive = false;

        setTimeout(() => {
          this.#window.show_toast("Button re-enabled after 3 seconds");
          this.#window.test_button_sensitive = true;
        }, 3000);
      });

      this.#window.present();
    }

This code: vfunc_activate() { this.#window = new SenbaraGtk.MainApplicationWindow({ application: this, }); this.#window.connect("button-test-clicked", () => { console.log("Test button clicked"); this.#window.show_toast("Button was clicked!"); this.#window.test_button_sensitive = false; setTimeout(() => { this.#window.show_toast("Button re-enabled after 3 seconds"); this.#window.test_button_sensitive = true; }, 3000); }); this.#window.present(); }

New progress on the #puregotk #GObject introspection things I'm working on in #Go . It's super early, but I added preliminary support for generated getters/setters for properties. No more manual value setup & `SetProperty` calls required, just a simple `SetPropertyX` call.

1 0 1 0
This code:

applicationClass.OverrideActivate(func(a *gio.Application) {
			exampleApp := (*exampleApplication)(unsafe.Pointer(a.GetData(dataKeyGoInstance)))

			var app gtk.Application
			a.Cast(&app)

			obj := gobject.NewObject(senbaragtk.MainApplicationWindowGLibType(),
				"application", app,
			)

			var window senbaragtk.MainApplicationWindow
			obj.Cast(&window)

			exampleApp.window = &window

			var cb func(senbaragtk.MainApplicationWindow) = func(w senbaragtk.MainApplicationWindow) {
				fmt.Println("Test button clicked")

				exampleApp.window.ShowToast("Button was clicked!")
				exampleApp.window.SetPropertyTestButtonSensitive(false)

				time.AfterFunc(time.Second*3, func() {
					exampleApp.window.ShowToast("Button re-enabled after 3 seconds")
					exampleApp.window.SetPropertyTestButtonSensitive(true)
				})
			}
			exampleApp.window.ConnectButtonTestClicked(&cb)

			exampleApp.window.Present()
		})

This code: applicationClass.OverrideActivate(func(a *gio.Application) { exampleApp := (*exampleApplication)(unsafe.Pointer(a.GetData(dataKeyGoInstance))) var app gtk.Application a.Cast(&app) obj := gobject.NewObject(senbaragtk.MainApplicationWindowGLibType(), "application", app, ) var window senbaragtk.MainApplicationWindow obj.Cast(&window) exampleApp.window = &window var cb func(senbaragtk.MainApplicationWindow) = func(w senbaragtk.MainApplicationWindow) { fmt.Println("Test button clicked") exampleApp.window.ShowToast("Button was clicked!") exampleApp.window.SetPropertyTestButtonSensitive(false) time.AfterFunc(time.Second*3, func() { exampleApp.window.ShowToast("Button re-enabled after 3 seconds") exampleApp.window.SetPropertyTestButtonSensitive(true) }) } exampleApp.window.ConnectButtonTestClicked(&cb) exampleApp.window.Present() })

This code:

vfunc_activate() {
      this.#window = new SenbaraGtk.MainApplicationWindow({
        application: this,
      });

      this.#window.connect("button-test-clicked", () => {
        console.log("Test button clicked");

        this.#window.show_toast("Button was clicked!");
        this.#window.test_button_sensitive = false;

        setTimeout(() => {
          this.#window.show_toast("Button re-enabled after 3 seconds");
          this.#window.test_button_sensitive = true;
        }, 3000);
      });

      this.#window.present();
    }

This code: vfunc_activate() { this.#window = new SenbaraGtk.MainApplicationWindow({ application: this, }); this.#window.connect("button-test-clicked", () => { console.log("Test button clicked"); this.#window.show_toast("Button was clicked!"); this.#window.test_button_sensitive = false; setTimeout(() => { this.#window.show_toast("Button re-enabled after 3 seconds"); this.#window.test_button_sensitive = true; }, 3000); }); this.#window.present(); }

New progress on the #puregotk #GObject introspection things I'm working on in #Go. It's super early, but I added preliminary support for generated getters/setters for properties. No more manual value setup & `SetProperty` calls required, just a simple […]

[Original post on mastodon.social]

0 0 0 0
An example application window with GTK inspector open, showing ExampleApplication as it's type.

An example application window with GTK inspector open, showing ExampleApplication as it's type.

Continued some #GObject subclassing support in Go. Turns out I messed up the C memory alignment in #Go for and ended up embedding the parent class as a reference, when GObject expects it to be the actual struct.

1 0 1 0
An example application window with GTK inspector open, showing ExampleApplication as it's type.

An example application window with GTK inspector open, showing ExampleApplication as it's type.

Continued some #GObject subclassing support in Go. Turns out I messed up the C memory alignment in #Go for and ended up embedding the parent class as a reference, when GObject expects it to be the actual struct. Funnily enough some callbacks still worked […]

[Original post on mastodon.social]

1 0 1 0
Sessions running with the GTK inspector open. A custom widget shows up in the inspector.

Sessions running with the GTK inspector open. A custom widget shows up in the inspector.

Now that my PRs for #GObject subclassing support in Go are up on GitHub and ready for review, I can get started porting over Sessions to Gsk instead of Cairo.

1 0 1 0
Sessions running with the GTK inspector open. A custom widget shows up in the inspector.

Sessions running with the GTK inspector open. A custom widget shows up in the inspector.

Now that my PRs for #GObject subclassing support in Go are up on GitHub and ready for review, I can get started porting over Sessions to Gsk instead of Cairo. It was easier to do find examples in JS, so that's what I used, but next up is getting this to work […]

[Original post on mastodon.social]

0 0 1 0
GTK inspector showing an app with a custom SenbaraGtkMainApplicationWindow window

GTK inspector showing an app with a custom SenbaraGtkMainApplicationWindow window

This source code, in VSCode:

objClass.SetCallbackSetProperty(func(o *gobject.Object, u uint, v *gobject.Value, ps *gobject.ParamSpec) {
			switch u {
			case propertyIdTestButtonSensitive:
				w := (*senbaraGtkMainApplicationWindow)(unsafe.Pointer(o.GetData(dataKeyGoInstance)))

				w.buttonTest.SetSensitive(v.GetBoolean())
			}
		})

		objClass.SetCallbackGetProperty(func(o *gobject.Object, u uint, v *gobject.Value, ps *gobject.ParamSpec) {
			switch u {
			case propertyIdTestButtonSensitive:
				w := (*senbaraGtkMainApplicationWindow)(unsafe.Pointer(o.GetData(dataKeyGoInstance)))

				v.SetBoolean(w.buttonTest.IsSensitive())
			}
		})

This source code, in VSCode: objClass.SetCallbackSetProperty(func(o *gobject.Object, u uint, v *gobject.Value, ps *gobject.ParamSpec) { switch u { case propertyIdTestButtonSensitive: w := (*senbaraGtkMainApplicationWindow)(unsafe.Pointer(o.GetData(dataKeyGoInstance))) w.buttonTest.SetSensitive(v.GetBoolean()) } }) objClass.SetCallbackGetProperty(func(o *gobject.Object, u uint, v *gobject.Value, ps *gobject.ParamSpec) { switch u { case propertyIdTestButtonSensitive: w := (*senbaraGtkMainApplicationWindow)(unsafe.Pointer(o.GetData(dataKeyGoInstance))) v.SetBoolean(w.buttonTest.IsSensitive()) } })

May I present: Typed subclassing of #GObject classes in Golang! Still a WIP, but this is enough now to create proper custom #GTK widgets in #Golang without needing to import any `purego`/CGo code to subclass.

3 0 1 0
GTK inspector showing an app with a custom SenbaraGtkMainApplicationWindow window

GTK inspector showing an app with a custom SenbaraGtkMainApplicationWindow window

This source code, in VSCode:

objClass.SetCallbackSetProperty(func(o *gobject.Object, u uint, v *gobject.Value, ps *gobject.ParamSpec) {
			switch u {
			case propertyIdTestButtonSensitive:
				w := (*senbaraGtkMainApplicationWindow)(unsafe.Pointer(o.GetData(dataKeyGoInstance)))

				w.buttonTest.SetSensitive(v.GetBoolean())
			}
		})

		objClass.SetCallbackGetProperty(func(o *gobject.Object, u uint, v *gobject.Value, ps *gobject.ParamSpec) {
			switch u {
			case propertyIdTestButtonSensitive:
				w := (*senbaraGtkMainApplicationWindow)(unsafe.Pointer(o.GetData(dataKeyGoInstance)))

				v.SetBoolean(w.buttonTest.IsSensitive())
			}
		})

This source code, in VSCode: objClass.SetCallbackSetProperty(func(o *gobject.Object, u uint, v *gobject.Value, ps *gobject.ParamSpec) { switch u { case propertyIdTestButtonSensitive: w := (*senbaraGtkMainApplicationWindow)(unsafe.Pointer(o.GetData(dataKeyGoInstance))) w.buttonTest.SetSensitive(v.GetBoolean()) } }) objClass.SetCallbackGetProperty(func(o *gobject.Object, u uint, v *gobject.Value, ps *gobject.ParamSpec) { switch u { case propertyIdTestButtonSensitive: w := (*senbaraGtkMainApplicationWindow)(unsafe.Pointer(o.GetData(dataKeyGoInstance))) v.SetBoolean(w.buttonTest.IsSensitive()) } })

May I present: Typed subclassing of GObject classes in Golang! Still a WIP, but this is enough now to create proper custom GTK widgets in Golang without needing to import any `purego`/CGo code to subclass. Please ignore the `Constructed` callback call here […]

[Original post on mastodon.social]

1 0 0 0
GTK Inspector showing a GObject subclassing example in Go

GTK Inspector showing a GObject subclassing example in Go

Just got GObject subclassing to work in Go thanks to some new bindings by https://github.com/jwijenbergh 👀

0 0 0 0
Preview
Draft: Build vapi file and add vala plugin example (!1727) · Merge requests · World / Phosh / phosh · GitLab Let's make plugin writing a bit simpler for folks that don't want to do C. To test

If you ever wanted to write a #QuickSetting or #LockScreen plugin for #phosh but didn't fancy #GObject C: Here's an example in #vala : gitlab.gnome.org/World/Phosh/phosh/-/merg...

#ValaLanguage

1 3 0 0
Preview
Керування пам’яттю в програмах GTK Доповнений переклад PDF документу CSci493.70 "Introduction to Memory Management in GTK+" Стюарта Вайса - доцента Кафедри інформатики Гантерського коледжу Міського університету, Нью-Йорк. Нотатки Термін GTK+ було змінено на більш сучасний варіант наз...

Керування пам’яттю в програмах GTK

#gtk #gtk+ #c #c++ #glib #gobject #memory-leak

4 0 0 0