-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicon_theme.go
111 lines (95 loc) · 3 KB
/
icon_theme.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package gotk3extra
// #cgo pkg-config: gdk-3.0 gio-2.0 glib-2.0 gobject-2.0 gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #include "icon_theme.go.h"
// #cgo CFLAGS: -Wno-deprecated-declarations
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_icon_theme_get_type()), marshalIconTheme},
}
glib.RegisterGValueMarshalers(tm)
gtk.WrapMap["GtkIconTheme"] = wrapIconTheme
}
// IconTheme is a representation of GTK's GtkIconTheme.
type IconTheme struct {
*glib.Object
}
func marshalIconTheme(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := glib.Take(unsafe.Pointer(c))
return wrapIconTheme(obj), nil
}
func wrapIconTheme(obj *glib.Object) *IconTheme {
return &IconTheme{obj}
}
func (v *IconTheme) native() *C.GtkIconTheme {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkIconTheme(p)
}
// IconThemeNew is a wrapper around gtk_icon_theme_new()
func IconThemeNew() (*IconTheme, error) {
c := C.gtk_icon_theme_new()
if c == nil {
return nil, nilPtrErr
}
return wrapIconTheme(glib.Take(unsafe.Pointer(c))), nil
}
// IconThemeGetDefault is a wrapper around gtk_icon_theme_get_default()
func IconThemeGetDefault() *IconTheme {
c := C.gtk_icon_theme_get_default()
if c == nil {
return nil
}
return wrapIconTheme(glib.Take(unsafe.Pointer(c)))
}
// IconThemeGetForScreen is a wrapper around gtk_icon_theme_get_for_screen()
func IconThemeGetForScreen(screen *gdk.Screen) *IconTheme {
c := C.gtk_icon_theme_get_for_screen(C.toGdkScreen(unsafe.Pointer(screen.Native())))
if c == nil {
return nil
}
return wrapIconTheme(glib.Take(unsafe.Pointer(c)))
}
// AddResourcePath is a wrapper around gtk_icon_theme_add_resource_path()
func (v *IconTheme) AddResourcePath(s string) {
cstr := C.CString(s)
defer C.free(unsafe.Pointer(cstr))
C.gtk_icon_theme_add_resource_path(v.native(), (*C.gchar)(cstr))
}
// AppendSearchPath is a wrapper around gtk_icon_theme_append_search_path()
func (v *IconTheme) AppendSearchPath(s string) {
cstr := C.CString(s)
defer C.free(unsafe.Pointer(cstr))
C.gtk_icon_theme_append_search_path(v.native(), (*C.gchar)(cstr))
}
// GetExampleIconName is a wrapper around gtk_icon_theme_get_example_icon_name()
func (v *IconTheme) GetExampleIconName() string {
c := C.gtk_icon_theme_get_example_icon_name(v.native())
if c == nil {
return ""
}
return C.GoString((*C.char)(c))
}
// HasIcon is a wrapper around gtk_icon_theme_has_icon()
func (v *IconTheme) HasIcon(s string) bool {
cstr := C.CString(s)
defer C.free(unsafe.Pointer(cstr))
return gobool(C.gtk_icon_theme_has_icon(v.native(), (*C.gchar)(cstr)))
}
// PrependSearchPath is a wrapper around gtk_icon_theme_prepend_search_path()
func (v *IconTheme) PrependSearchPath(s string) {
cstr := C.CString(s)
defer C.free(unsafe.Pointer(cstr))
C.gtk_icon_theme_prepend_search_path(v.native(), (*C.gchar)(cstr))
}