-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
Half-baked subclass example. Remove unneeded types from derived class example. Move drawing in to a receiver method. Split derived class and instance across two files. Use a struct instead of dodgy pointer maths. Add another virtual function override to example. Add colour to the example derived widget. Add more comments explaining subclassing example. Add some documentation around subclassing. Reference custom-drawing example from subclassing example.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
There is no direct support in gobbi for subclassing | ||
GObject derived classes | ||
or for implementing interfaces. | ||
Following exploration and the production of a | ||
proof of concept for class derivation, | ||
it became apparent that an awful lots of work | ||
would have to be put it for a fairly small reward. | ||
Lots more generation code would have to be written, | ||
and many tens of thousands of new lines of code | ||
would be generated. | ||
And even then there would likely be many | ||
cases not covered. | ||
|
||
Deriving classes, implementing interfaces, | ||
and implementing virtual functions are | ||
unlikely to be particularly common activities | ||
in gobbi based applications. | ||
So for now at least adding support to make this | ||
easy has been put to one side. | ||
|
||
## example | ||
Instead of providing direct support in gobbi, a | ||
[subclassing](https://github.com/pekim/gobbi/blob/master/example/subclass-drawingarea) | ||
example is provided. | ||
This illustrates how the DrawingAreas widget | ||
can be subclassed, some virtual functions implemented. | ||
|
||
## pre-requisites | ||
For the most part using gobbi does not require | ||
a detailed knowledge C or gobject. | ||
With some familiarity with Go, Gtk and perhaps | ||
a passing knowledge of cgo, | ||
it should be possible to write an application | ||
with gobbi. | ||
|
||
However subclassing and the implementation of | ||
virtual functions will require a bit | ||
more knowledge. | ||
|
||
- comfort with Go | ||
- familiarity with C | ||
- familiarity with cgo | ||
- an understanding of the [gobject base class](https://developer.gnome.org/gobject/stable/chapter-gobject.html) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# subclassing example | ||
|
||
This example demonstrates an approach for | ||
subclassing a gtk widget. | ||
A subclass of GtkDrawingArea is registered, | ||
and two virtual functions are implemented. | ||
|
||
The `draw` virtual function calls a Go function | ||
that marshals the arguments in to Go objects, | ||
and calls another function to draw in a cairo context. | ||
The same result could have been achieved by | ||
connecting to the `draw` signal instead, | ||
(The [custom-drawing](https://github.com/pekim/gobbi/blob/master/example/custom-drawing/main.go) | ||
example uses that approach.) | ||
however the point of this example is to | ||
illustrate class derivation and | ||
the overriding of virtual functions. | ||
|
||
The `adjust_size_request` virtual function's | ||
implementation is trivial, | ||
and is implemented entirely in C. | ||
|
||
For more background about subclassing with gobbi see | ||
[subclassing](https://pekim.github.io/gobbi/subclassing) | ||
in the documentation. |