Skip to content

Commit

Permalink
Provide support for gdk.Event.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekim committed Oct 11, 2019
1 parent d705fdc commit c626093
Show file tree
Hide file tree
Showing 75 changed files with 26,908 additions and 865 deletions.
4 changes: 3 additions & 1 deletion internal/generate/records.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ func (rr Records) forName(name string) *Record {
return nil
}

func (rr Records) mergeAddenda(addenda Records) {
func (rr *Records) mergeAddenda(addenda Records) {
for _, addendaRecord := range addenda {
if record := rr.forName(addendaRecord.Name); record != nil {
record.mergeAddenda(addendaRecord)
} else {
*rr = append(*rr, addendaRecord)
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions internal/gir-files/Gdk-3.0-addenda.gir
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
xmlns:c="https://www.gtk.org/introspection/c/1.0"
xmlns:glib="https://www.gtk.org/introspection/glib/1.0"
>
<c:include name="gdk_event.h"/>

<namespace>
<bitfield name="ModifierType" c:type="guint"/>

Expand All @@ -29,6 +31,16 @@
<record version="3.22" name="DrawingContextClass"/>
<record version="3.22" name="MonitorClass"/>

<!--
gobbi does not support generation for C union types.
To work around this, define GdkEvent as a record (struct).
-->
<record name="Event" c:type="GdkEvent_">
<field name="type" writable="1">
<type name="EventType" c:type="GdkEventType"/>
</field>
</record>

<interface name="DevicePad" version="3.22"/>
</namespace>
</repository>
2 changes: 2 additions & 0 deletions internal/gir-files/Gtk-3.0-addenda.gir
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
xmlns:c="https://www.gtk.org/introspection/c/1.0"
xmlns:glib="https://www.gtk.org/introspection/glib/1.0"
>
<c:include name="../gdk/gdk_event.h"/>

<namespace>
<bitfield name="StyleContextPrintFlags" version="3.20"/>

Expand Down
3 changes: 2 additions & 1 deletion internal/gir-files/GtkSource-3.0-addenda.gir
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
xmlns:glib="https://www.gtk.org/introspection/glib/1.0"
>
<c:include name="gtksourceview/completion-providers/words/gtksourcecompletionwords.h"/>
<c:include name="../gdk/gdk_event.h"/>

<namespace>
<namespace>
<class name="Region" version="3.22"/>
<class name="SpaceDrawer" version="3.24"/>
<class name="Tag" version="3.20"/>
Expand Down
1 change: 1 addition & 0 deletions lib/gdk/boolean.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions lib/gdk/gdk_event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <gdk/gdk.h>

/*
Although cgo can access C struct field names that are keywords,
by prefixing them with an underscore, it cannot do the same
for C unions. This causes a problem for the "type" field in
the GdkEvent union.
To work around this, define an equivalent struct for GdkEvent.
*/
typedef struct _GdkEvent_
{
GdkEventType type;
} GdkEvent_;
37 changes: 33 additions & 4 deletions lib/gdk/v-.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 68 additions & 7 deletions lib/gdk/v-2.10.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 68 additions & 7 deletions lib/gdk/v-2.12.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c626093

Please sign in to comment.