예제 #1
0
파일: webkit.go 프로젝트: lamproae/hgui
func startGui(width, height int, title string, port int) {
	C.gtk_init(nil, nil) //gtk.Init(nil)

	window := C.window
	window = C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)
	C.gtk_window_set_title(C.to_GtkWindow(window), C.to_gcharptr(C.CString(title)))
	C.connect_destroy(window)

	vbox := C.gtk_hbox_new(0, 1)

	C.webview = C._new_webkit()

	C.gtk_container_add(C.to_GtkContainer(vbox), C.webview)

	C.loadUri(C.webview, C.to_gcharptr(C.CString(fmt.Sprintf("http://127.0.0.1:%d", port))))

	C.gtk_container_add(C.to_GtkContainer(window), vbox)
	C.gtk_widget_set_size_request(window, C.gint(width), C.gint(height))

	C.gtk_widget_show(vbox)
	C.gtk_widget_show(window) //Window.ShowAll()
	C.gtk_widget_show(C.webview)

	/*
		This only matters if proxy is stupid!
		proxy := os.Getenv("HTTP_PROXY")
		if len(proxy) > 0 {
			ptr := C.CString(uri)
			C.proxyshit(ptr)
			C.free(ptr)
		}
	*/

	C.gtk_main() //gtk.GtkMain()
}
예제 #2
0
파일: window.go 프로젝트: napsy/go-gtk3
// Create new window
func NewWindow(wtype GtkWindowType, properties map[string]interface{}) (w *Window) {
	w = &Window{}

	o := C.gtk_window_new(C.GtkWindowType(wtype))

	w.Container = NewContainer(unsafe.Pointer(o))

	w.object = C.to_GtkWindow(unsafe.Pointer(o))
	return w
}
예제 #3
0
파일: window.go 프로젝트: napsy/go-gtk3
// Conversion function for gobject registration map
func newWindowFromNative(obj unsafe.Pointer) interface{} {
	var window Window
	window.object = C.to_GtkWindow(obj)
	window.Container = NewContainer(unsafe.Pointer(window.object))
	return &window
}