Beispiel #1
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()
}
Beispiel #2
0
func set_relative_indicators(bufp unsafe.Pointer, viewp unsafe.Pointer, offsets []int, indicators []unsafe.Pointer) {
	buf := (*C.GtkTextBuffer)(bufp)
	view := (*C.GtkTextView)(viewp)
	var it C.GtkTextIter
	C.gtk_text_buffer_get_start_iter(buf, &it)
	var location C.GdkRectangle
	var left, top C.gint
	var indicator *C.GtkWidget
	for i, offset := range offsets {
		C.gtk_text_iter_set_offset(&it, C.gint(offset))
		C.gtk_text_view_get_iter_location(view, &it, &location)
		C.gtk_text_view_buffer_to_window_coords(view, C.GTK_TEXT_WINDOW_WIDGET, C.gint(location.x), C.gint(location.y), &left, &top)
		indicator = (*C.GtkWidget)(indicators[i])
		top += 8
		if left >= C.gint(0) && top >= C.gint(0) {
			C.gtk_widget_set_margin_start(indicator, left)
			C.gtk_widget_set_margin_top(indicator, top)
			C.gtk_widget_show(indicator)
		}
	}
}
Beispiel #3
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
}
Beispiel #4
0
// Widget standard funcs
func (self *Widget) Show() {
	C.gtk_widget_show(self.object)
}
Beispiel #5
0
func (v *GtkWidget) Show() {
	C.gtk_widget_show(v.Widget)
}
Beispiel #6
0
func (w *Widget) Show() {
	C.gtk_widget_show(w.g())
}
Beispiel #7
0
func (w *Window) Show() {
	C.gtk_widget_show(w.gtkWin)
}
Beispiel #8
0
// Show is a wrapper around gtk_widget_show().
func (v *Widget) Show() {
	C.gtk_widget_show(v.native())
}
Beispiel #9
0
func (w *Window) Show() {
	C.gtk_widget_show(ToWidget(unsafe.Pointer(w.c)).c)
}
Beispiel #10
0
func gtk_widget_show(item GtkWidget) {
	C.gtk_widget_show(Arg(item))
}