File: tooltip.go

package info (click to toggle)
golang-github-gotk3-gotk3 0.6.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,392 kB
  • sloc: ansic: 914; makefile: 4
file content (83 lines) | stat: -rw-r--r-- 2,063 bytes parent folder | download | duplicates (2)
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
package gtk

// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
	"unsafe"

	"github.com/gotk3/gotk3/gdk"
	"github.com/gotk3/gotk3/glib"
)

/*
 * GtkTooltip
 */

type Tooltip struct {
	Widget
}

// native returns a pointer to the underlying GtkIconView.
func (t *Tooltip) native() *C.GtkTooltip {
	if t == nil || t.GObject == nil {
		return nil
	}
	p := unsafe.Pointer(t.GObject)
	return C.toGtkTooltip(p)
}

func marshalTooltip(p uintptr) (interface{}, error) {
	c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
	obj := glib.Take(unsafe.Pointer(c))
	return wrapTooltip(obj), nil
}

func wrapTooltip(obj *glib.Object) *Tooltip {
	if obj == nil {
		return nil
	}

	return &Tooltip{Widget{glib.InitiallyUnowned{obj}}}
}

// SetMarkup is a wrapper around gtk_tooltip_set_markup().
func (t *Tooltip) SetMarkup(str string) {
	cstr := C.CString(str)
	defer C.free(unsafe.Pointer(cstr))
	C.gtk_tooltip_set_markup(t.native(), (*C.gchar)(cstr))
}

// SetText is a wrapper around gtk_tooltip_set_text().
func (t *Tooltip) SetText(str string) {
	cstr := C.CString(str)
	defer C.free(unsafe.Pointer(cstr))
	C.gtk_tooltip_set_text(t.native(), (*C.gchar)(cstr))
}

// SetIcon is a wrapper around gtk_tooltip_set_icon().
func (t *Tooltip) SetIcon(pixbuf *gdk.Pixbuf) {
	C.gtk_tooltip_set_icon(t.native(),
		(*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native())))
}

// SetIconFromIconName is a wrapper around gtk_tooltip_set_icon_from_icon_name().
func (t *Tooltip) SetIconFromIconName(iconName string, size IconSize) {
	cstr := C.CString(iconName)
	defer C.free(unsafe.Pointer(cstr))
	C.gtk_tooltip_set_icon_from_icon_name(t.native(),
		(*C.gchar)(cstr),
		C.GtkIconSize(size))
}

// func (t *Tooltip) SetIconFromGIcon() { }

// SetCustom is a wrapper around gtk_tooltip_set_custom().
func (t *Tooltip) SetCustom(w *Widget) {
	C.gtk_tooltip_set_custom(t.native(), w.native())
}

// SetTipArea is a wrapper around gtk_tooltip_set_tip_area().
func (t *Tooltip) SetTipArea(rect gdk.Rectangle) {
	C.gtk_tooltip_set_tip_area(t.native(), nativeGdkRectangle(rect))
}