Exemplo n.º 1
0
func newWindow(title string, width int, height int, control Control) *window {
	widget := C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)
	ctitle := togstr(title)
	defer freegstr(ctitle)
	w := &window{
		widget:  widget,
		wc:      (*C.GtkContainer)(unsafe.Pointer(widget)),
		bin:     (*C.GtkBin)(unsafe.Pointer(widget)),
		window:  (*C.GtkWindow)(unsafe.Pointer(widget)),
		closing: newEvent(),
	}
	C.gtk_window_set_title(w.window, ctitle)
	g_signal_connect(
		C.gpointer(unsafe.Pointer(w.window)),
		"delete-event",
		C.GCallback(C.windowClosing),
		C.gpointer(unsafe.Pointer(w)))
	C.gtk_window_resize(w.window, C.gint(width), C.gint(height))
	w.container = newContainer(control)
	w.container.setParent(&controlParent{w.wc})
	// for dialogs; otherwise, they will be modal to all windows, not just this one
	w.group = C.gtk_window_group_new()
	C.gtk_window_group_add_window(w.group, w.window)
	return w
}
Exemplo n.º 2
0
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()
}
Exemplo n.º 3
0
Arquivo: gtk.go Projeto: kayon/cef2go
func CreateWindow(title string, width int, height int) unsafe.Pointer {
	Logger.Println("CreateWindow")

	// Create window.
	window := C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)

	// Default size.
	C.gtk_window_set_default_size(C.ToGtkWindow(window),
		C.gint(width), C.gint(height))

	// Center.
	C.gtk_window_set_position(C.ToGtkWindow(window), C.GTK_WIN_POS_CENTER)

	// Title.
	csTitle := C.CString(title)
	defer C.free(unsafe.Pointer(csTitle))
	C.gtk_window_set_title(C.ToGtkWindow(window), (*C.gchar)(csTitle))

	// TODO: focus
	// g_signal_connect(window, "focus", G_CALLBACK(&HandleFocus), NULL);

	// CEF requires a container. Embedding browser in a top
	// level window fails.
	vbox := C.gtk_vbox_new(0, 0)
	C.gtk_container_add(C.ToGtkContainer(window), vbox)

	// Show.
	C.gtk_widget_show_all(window)

	return unsafe.Pointer(vbox)
}
Exemplo n.º 4
0
func (window *GTKWindow) Create(width uint, height uint, title string) bool {

	C.gtk_init(nil, nil)

	gtk_window := C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)
	C.gtk_window_set_title((*C.GtkWindow)(unsafe.Pointer(gtk_window)), (*C.gchar)(C.CString(title)))

	f := func() {
		window.destroy = true
	}

	r := func() {
		window.render = true
	}

	//g_signal_connect (G_OBJECT (canvas), "expose-event", G_CALLBACK (expose_cb), NULL);
	C.GtkSetEvent((*C.gpointer)(unsafe.Pointer(gtk_window)), C.CString("destroy"), unsafe.Pointer(&f))
	C.GtkSetEvent((*C.gpointer)(unsafe.Pointer(gtk_window)), C.CString("expose-event"), unsafe.Pointer(&r))
	C.gtk_widget_show(gtk_window)

	return true
}
Exemplo n.º 5
0
func (s *Window) SetTitle(title string) {
	w := C.gwindow((*C.GtkWidget)(unsafe.Pointer(s.GetHwnd())))
	C.gtk_window_set_title(w, (*C.gchar)(unsafe.Pointer(&([]byte(title))[0])))
}
Exemplo n.º 6
0
func gtk_window_set_title(window *C.GtkWidget, title string) {
	ctitle := C.CString(title)
	defer C.free(unsafe.Pointer(ctitle))
	C.gtk_window_set_title(togtkwindow(window), togstr(ctitle))
}
Exemplo n.º 7
0
// SetTitle is a wrapper around gtk_window_set_title().
func (v *Window) SetTitle(title string) {
	cstr := C.CString(title)
	defer C.free(unsafe.Pointer(cstr))
	C.gtk_window_set_title(v.native(), (*C.gchar)(cstr))
}
Exemplo n.º 8
0
func (w *window) SetTitle(title string) {
	ctitle := togstr(title)
	defer freegstr(ctitle)
	C.gtk_window_set_title(w.window, ctitle)
}
Exemplo n.º 9
0
func (win *Window) SetTitle(t string) {
	title := _GString(t)
	defer _GFree(unsafe.Pointer(title))
	C.gtk_window_set_title(win.c, title)
}
Exemplo n.º 10
0
Arquivo: window.go Projeto: ziutek/gtk
func (w *Window) SetTitle(title string) {
	C.gtk_window_set_title(w.g(), (*C.gchar)(C.CString(title)))
}