Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.

Commit 0897464

Browse files
committed
Implement CheckMenuItem and RadioMenuItem bindings.
Closes #51.
1 parent 24ced38 commit 0897464

File tree

2 files changed

+269
-0
lines changed

2 files changed

+269
-0
lines changed

gtk/gtk.go

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func init() {
109109
{glib.Type(C.gtk_cell_renderer_text_get_type()), marshalCellRendererText},
110110
{glib.Type(C.gtk_cell_renderer_toggle_get_type()), marshalCellRendererToggle},
111111
{glib.Type(C.gtk_check_button_get_type()), marshalCheckButton},
112+
{glib.Type(C.gtk_check_menu_item_get_type()), marshalCheckMenuItem},
112113
{glib.Type(C.gtk_clipboard_get_type()), marshalClipboard},
113114
{glib.Type(C.gtk_combo_box_get_type()), marshalComboBox},
114115
{glib.Type(C.gtk_container_get_type()), marshalContainer},
@@ -137,6 +138,7 @@ func init() {
137138
{glib.Type(C.gtk_orientable_get_type()), marshalOrientable},
138139
{glib.Type(C.gtk_progress_bar_get_type()), marshalProgressBar},
139140
{glib.Type(C.gtk_radio_button_get_type()), marshalRadioButton},
141+
{glib.Type(C.gtk_radio_menu_item_get_type()), marshalRadioMenuItem},
140142
{glib.Type(C.gtk_range_get_type()), marshalRange},
141143
{glib.Type(C.gtk_scrollbar_get_type()), marshalScrollbar},
142144
{glib.Type(C.gtk_scrolled_window_get_type()), marshalScrolledWindow},
@@ -2072,6 +2074,117 @@ func CheckButtonNewWithMnemonic(label string) (*CheckButton, error) {
20722074
return cb, nil
20732075
}
20742076

2077+
/*
2078+
* GtkCheckMenuItem
2079+
*/
2080+
2081+
type CheckMenuItem struct {
2082+
MenuItem
2083+
}
2084+
2085+
// Native returns a pointer to the underlying GtkCheckMenuItem.
2086+
func (v *CheckMenuItem) Native() *C.GtkCheckMenuItem {
2087+
if v == nil || v.GObject == nil {
2088+
return nil
2089+
}
2090+
p := unsafe.Pointer(v.GObject)
2091+
return C.toGtkCheckMenuItem(p)
2092+
}
2093+
2094+
func marshalCheckMenuItem(p uintptr) (interface{}, error) {
2095+
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
2096+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
2097+
return wrapCheckMenuItem(obj), nil
2098+
}
2099+
2100+
func wrapCheckMenuItem(obj *glib.Object) *CheckMenuItem {
2101+
return &CheckMenuItem{MenuItem{Bin{Container{Widget{
2102+
glib.InitiallyUnowned{obj}}}}}}
2103+
}
2104+
2105+
// CheckMenuItemNew is a wrapper around gtk_check_menu_item_new().
2106+
func CheckMenuItemNew() (*CheckMenuItem, error) {
2107+
c := C.gtk_check_menu_item_new()
2108+
if c == nil {
2109+
return nil, nilPtrErr
2110+
}
2111+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
2112+
cm := wrapCheckMenuItem(obj)
2113+
obj.RefSink()
2114+
runtime.SetFinalizer(obj, (*glib.Object).Unref)
2115+
return cm, nil
2116+
}
2117+
2118+
// CheckMenuItemNewWithLabel is a wrapper around
2119+
// gtk_check_menu_item_new_with_label().
2120+
func CheckMenuItemNewWithLabel(label string) (*CheckMenuItem, error) {
2121+
cstr := C.CString(label)
2122+
defer C.free(unsafe.Pointer(cstr))
2123+
c := C.gtk_check_menu_item_new_with_label((*C.gchar)(cstr))
2124+
if c == nil {
2125+
return nil, nilPtrErr
2126+
}
2127+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
2128+
cm := wrapCheckMenuItem(obj)
2129+
obj.RefSink()
2130+
runtime.SetFinalizer(obj, (*glib.Object).Unref)
2131+
return cm, nil
2132+
}
2133+
2134+
// CheckMenuItemNewWithMnemonic is a wrapper around
2135+
// gtk_check_menu_item_new_with_mnemonic().
2136+
func CheckMenuItemNewWithMnemonic(label string) (*CheckMenuItem, error) {
2137+
cstr := C.CString(label)
2138+
defer C.free(unsafe.Pointer(cstr))
2139+
c := C.gtk_check_menu_item_new_with_mnemonic((*C.gchar)(cstr))
2140+
if c == nil {
2141+
return nil, nilPtrErr
2142+
}
2143+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
2144+
cm := wrapCheckMenuItem(obj)
2145+
obj.RefSink()
2146+
runtime.SetFinalizer(obj, (*glib.Object).Unref)
2147+
return cm, nil
2148+
}
2149+
2150+
// GetActive is a wrapper around gtk_check_menu_item_get_active().
2151+
func (v *CheckMenuItem) GetActive() bool {
2152+
c := C.gtk_check_menu_item_get_active(v.Native())
2153+
return gobool(c)
2154+
}
2155+
2156+
// SetActive is a wrapper around gtk_check_menu_item_set_active().
2157+
func (v *CheckMenuItem) SetActive(isActive bool) {
2158+
C.gtk_check_menu_item_set_active(v.Native(), gbool(isActive))
2159+
}
2160+
2161+
// Toggled is a wrapper around gtk_check_menu_item_toggled().
2162+
func (v *CheckMenuItem) Toggled() {
2163+
C.gtk_check_menu_item_toggled(v.Native())
2164+
}
2165+
2166+
// GetInconsistent is a wrapper around gtk_check_menu_item_get_inconsistent().
2167+
func (v *CheckMenuItem) GetInconsistent() bool {
2168+
c := C.gtk_check_menu_item_get_inconsistent(v.Native())
2169+
return gobool(c)
2170+
}
2171+
2172+
// SetInconsistent is a wrapper around gtk_check_menu_item_set_inconsistent().
2173+
func (v *CheckMenuItem) SetInconsistent(setting bool) {
2174+
C.gtk_check_menu_item_set_inconsistent(v.Native(), gbool(setting))
2175+
}
2176+
2177+
// SetDrawAsRadio is a wrapper around gtk_check_menu_item_set_draw_as_radio().
2178+
func (v *CheckMenuItem) SetDrawAsRadio(drawAsRadio bool) {
2179+
C.gtk_check_menu_item_set_draw_as_radio(v.Native(), gbool(drawAsRadio))
2180+
}
2181+
2182+
// GetDrawAsRadio is a wrapper around gtk_check_menu_item_get_draw_as_radio().
2183+
func (v *CheckMenuItem) GetDrawAsRadio() bool {
2184+
c := C.gtk_check_menu_item_get_draw_as_radio(v.Native())
2185+
return gobool(c)
2186+
}
2187+
20752188
/*
20762189
* GtkClipboard
20772190
*/
@@ -5217,6 +5330,146 @@ func (v *RadioButton) JoinGroup(groupSource *RadioButton) {
52175330
C.gtk_radio_button_join_group(v.Native(), groupSource.Native())
52185331
}
52195332

5333+
/*
5334+
* GtkRadioMenuItem
5335+
*/
5336+
5337+
// RadioMenuItem is a representation of GTK's GtkRadioMenuItem.
5338+
type RadioMenuItem struct {
5339+
CheckMenuItem
5340+
}
5341+
5342+
// Native returns a pointer to the underlying GtkRadioMenuItem.
5343+
func (v *RadioMenuItem) Native() *C.GtkRadioMenuItem {
5344+
if v == nil || v.GObject == nil {
5345+
return nil
5346+
}
5347+
p := unsafe.Pointer(v.GObject)
5348+
return C.toGtkRadioMenuItem(p)
5349+
}
5350+
5351+
func marshalRadioMenuItem(p uintptr) (interface{}, error) {
5352+
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
5353+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
5354+
return wrapRadioMenuItem(obj), nil
5355+
}
5356+
5357+
func wrapRadioMenuItem(obj *glib.Object) *RadioMenuItem {
5358+
return &RadioMenuItem{CheckMenuItem{MenuItem{Bin{Container{
5359+
Widget{glib.InitiallyUnowned{obj}}}}}}}
5360+
}
5361+
5362+
// RadioMenuItemNew is a wrapper around gtk_radio_menu_item_new().
5363+
func RadioMenuItemNew(group *glib.SList) (*RadioMenuItem, error) {
5364+
gslist := (*C.GSList)(unsafe.Pointer(group))
5365+
c := C.gtk_radio_menu_item_new(gslist)
5366+
if c == nil {
5367+
return nil, nilPtrErr
5368+
}
5369+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
5370+
r := wrapRadioMenuItem(obj)
5371+
obj.RefSink()
5372+
runtime.SetFinalizer(obj, (*glib.Object).Unref)
5373+
return r, nil
5374+
}
5375+
5376+
// RadioMenuItemNewWithLabel is a wrapper around
5377+
// gtk_radio_menu_item_new_with_label().
5378+
func RadioMenuItemNewWithLabel(group *glib.SList, label string) (*RadioMenuItem, error) {
5379+
gslist := (*C.GSList)(unsafe.Pointer(group))
5380+
cstr := C.CString(label)
5381+
defer C.free(unsafe.Pointer(cstr))
5382+
c := C.gtk_radio_menu_item_new_with_label(gslist, (*C.gchar)(cstr))
5383+
if c == nil {
5384+
return nil, nilPtrErr
5385+
}
5386+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
5387+
r := wrapRadioMenuItem(obj)
5388+
obj.RefSink()
5389+
runtime.SetFinalizer(obj, (*glib.Object).Unref)
5390+
return r, nil
5391+
}
5392+
5393+
// RadioMenuItemNewWithMnemonic is a wrapper around
5394+
// gtk_radio_menu_item_new_with_mnemonic().
5395+
func RadioMenuItemNewWithMnemonic(group *glib.SList, label string) (*RadioMenuItem, error) {
5396+
gslist := (*C.GSList)(unsafe.Pointer(group))
5397+
cstr := C.CString(label)
5398+
defer C.free(unsafe.Pointer(cstr))
5399+
c := C.gtk_radio_menu_item_new_with_mnemonic(gslist, (*C.gchar)(cstr))
5400+
if c == nil {
5401+
return nil, nilPtrErr
5402+
}
5403+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
5404+
r := wrapRadioMenuItem(obj)
5405+
obj.RefSink()
5406+
runtime.SetFinalizer(obj, (*glib.Object).Unref)
5407+
return r, nil
5408+
}
5409+
5410+
// RadioMenuItemNewFromWidget is a wrapper around
5411+
// gtk_radio_menu_item_new_from_widget().
5412+
func RadioMenuItemNewFromWidget(group *RadioMenuItem) (*RadioMenuItem, error) {
5413+
c := C.gtk_radio_menu_item_new_from_widget(group.Native())
5414+
if c == nil {
5415+
return nil, nilPtrErr
5416+
}
5417+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
5418+
r := wrapRadioMenuItem(obj)
5419+
obj.RefSink()
5420+
runtime.SetFinalizer(obj, (*glib.Object).Unref)
5421+
return r, nil
5422+
}
5423+
5424+
// RadioMenuItemNewWithLabelFromWidget is a wrapper around
5425+
// gtk_radio_menu_item_new_with_label_from_widget().
5426+
func RadioMenuItemNewWithLabelFromWidget(group *RadioMenuItem, label string) (*RadioMenuItem, error) {
5427+
cstr := C.CString(label)
5428+
defer C.free(unsafe.Pointer(cstr))
5429+
c := C.gtk_radio_menu_item_new_with_label_from_widget(group.Native(),
5430+
(*C.gchar)(cstr))
5431+
if c == nil {
5432+
return nil, nilPtrErr
5433+
}
5434+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
5435+
r := wrapRadioMenuItem(obj)
5436+
obj.RefSink()
5437+
runtime.SetFinalizer(obj, (*glib.Object).Unref)
5438+
return r, nil
5439+
}
5440+
5441+
// RadioMenuItemNewWithMnemonicFromWidget is a wrapper around
5442+
// gtk_radio_menu_item_new_with_mnemonic_from_widget().
5443+
func RadioMenuItemNewWithMnemonicFromWidget(group *RadioMenuItem, label string) (*RadioMenuItem, error) {
5444+
cstr := C.CString(label)
5445+
defer C.free(unsafe.Pointer(cstr))
5446+
c := C.gtk_radio_menu_item_new_with_mnemonic_from_widget(group.Native(),
5447+
(*C.gchar)(cstr))
5448+
if c == nil {
5449+
return nil, nilPtrErr
5450+
}
5451+
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
5452+
r := wrapRadioMenuItem(obj)
5453+
obj.RefSink()
5454+
runtime.SetFinalizer(obj, (*glib.Object).Unref)
5455+
return r, nil
5456+
}
5457+
5458+
// SetGroup is a wrapper around gtk_radio_menu_item_set_group().
5459+
func (v *RadioMenuItem) SetGroup(group *glib.SList) {
5460+
gslist := (*C.GSList)(unsafe.Pointer(group))
5461+
C.gtk_radio_menu_item_set_group(v.Native(), gslist)
5462+
}
5463+
5464+
// GetGroup is a wrapper around gtk_radio_menu_item_get_group().
5465+
func (v *RadioMenuItem) GetGroup() (*glib.SList, error) {
5466+
c := C.gtk_radio_menu_item_get_group(v.Native())
5467+
if c == nil {
5468+
return nil, nilPtrErr
5469+
}
5470+
return (*glib.SList)(unsafe.Pointer(c)), nil
5471+
}
5472+
52205473
/*
52215474
* GtkRange
52225475
*/
@@ -7646,6 +7899,8 @@ func cast(c *C.GObject) (glib.IObject, error) {
76467899
g = wrapCellRendererToggle(obj)
76477900
case "GtkCheckButton":
76487901
g = wrapCheckButton(obj)
7902+
case "GtkCheckMenuItem":
7903+
g = wrapCheckMenuItem(obj)
76497904
case "GtkClipboard":
76507905
g = wrapClipboard(obj)
76517906
case "GtkComboBox":
@@ -7698,6 +7953,8 @@ func cast(c *C.GObject) (glib.IObject, error) {
76987953
g = wrapProgressBar(obj)
76997954
case "GtkRadioButton":
77007955
g = wrapRadioButton(obj)
7956+
case "GtkRadioMenuItem":
7957+
g = wrapRadioMenuItem(obj)
77017958
case "GtkRange":
77027959
g = wrapRange(obj)
77037960
case "GtkScrollbar":

gtk/gtk.go.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,18 @@ toGtkRadioButton(void *p)
398398
return (GTK_RADIO_BUTTON(p));
399399
}
400400

401+
static GtkCheckMenuItem *
402+
toGtkCheckMenuItem(void *p)
403+
{
404+
return (GTK_CHECK_MENU_ITEM(p));
405+
}
406+
407+
static GtkRadioMenuItem *
408+
toGtkRadioMenuItem(void *p)
409+
{
410+
return (GTK_RADIO_MENU_ITEM(p));
411+
}
412+
401413
static GType *
402414
alloc_types(int n) {
403415
return ((GType *)g_new0(GType, n));

0 commit comments

Comments
 (0)