Exemplo n.º 1
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.º 2
0
func (a *area) OpenTextFieldAt(x, y int) {
	if x < 0 || x >= a.width || y < 0 || y >= a.height {
		panic(fmt.Errorf("point (%d,%d) outside Area in Area.OpenTextFieldAt()", x, y))
	}
	a.textfieldx = x
	a.textfieldy = y
	a.inmenu = false // to start
	// we disabled this for the initial Area show; we don't need to anymore
	C.gtk_widget_set_no_show_all(a.textfieldw, C.FALSE)
	C.gtk_widget_show_all(a.textfieldw)
	C.gtk_widget_grab_focus(a.textfieldw)
}
Exemplo n.º 3
0
func (w *window) openFile(f func(filename string)) {
	widget := C.newOpenFileDialog(w.window)
	window := (*C.GtkWindow)(unsafe.Pointer(widget))
	dialog := (*C.GtkDialog)(unsafe.Pointer(widget))
	fc := (*C.GtkFileChooser)(unsafe.Pointer(widget))
	C.gtk_file_chooser_set_local_only(fc, C.FALSE)
	C.gtk_file_chooser_set_select_multiple(fc, C.FALSE)
	C.gtk_file_chooser_set_show_hidden(fc, C.TRUE)
	C.gtk_window_set_modal(window, C.TRUE)
	g_signal_connect(
		C.gpointer(unsafe.Pointer(dialog)),
		"response",
		C.GCallback(C.our_openfile_response_callback),
		C.gpointer(unsafe.Pointer(&f)))
	C.gtk_widget_show_all(widget)
}
Exemplo n.º 4
0
func (w *window) openFile(f func(filename string)) {
	widget := C.newOpenFileDialog(w.window)
	window := (*C.GtkWindow)(unsafe.Pointer(widget))
	dialog := (*C.GtkDialog)(unsafe.Pointer(widget))
	fc := (*C.GtkFileChooser)(unsafe.Pointer(widget))
	// non-local filenames are relevant mainly to GIO where we can open *anything*, not to Go os.File; see https://twitter.com/braket/status/506142849654870016
	C.gtk_file_chooser_set_local_only(fc, C.TRUE)
	C.gtk_file_chooser_set_select_multiple(fc, C.FALSE)
	C.gtk_file_chooser_set_show_hidden(fc, C.TRUE)
	C.gtk_window_set_modal(window, C.TRUE)
	g_signal_connect(
		C.gpointer(unsafe.Pointer(dialog)),
		"response",
		C.GCallback(C.our_openfile_response_callback),
		C.gpointer(unsafe.Pointer(&f)))
	C.gtk_widget_show_all(widget)
}
Exemplo n.º 5
0
func (d *dialog) run(mk func() *C.GtkWidget) {
	d.prepare()
	box := mk()
	if d.parent == dialogWindow {
		go func() {
			res := make(chan C.gint)
			defer close(res)
			uitask <- func() {
				r := C.gtk_dialog_run((*C.GtkDialog)(unsafe.Pointer(box)))
				d.cleanup(box)
				res <- r
			}
			d.send(<-res)
		}()
		return
	}
	// otherwise just connect the delete signal
	g_signal_connect_pointer(box, "response", dialog_response_callback, unsafe.Pointer(d))
	C.gtk_widget_show_all(box)
}
Exemplo n.º 6
0
func NewView() *View {
	widget := C.webkit_web_view_new()
	view := &View{
		Widget: widget,
		View:   (*C.WebKitWebView)(unsafe.Pointer(widget)),
	}

	// ready to show
	connect(view.View, "ready-to-show", func() {
		C.gtk_widget_show_all(view.Widget)
	})

	// page load state changed
	connect(view.View, "load-changed", func(_, ev interface{}) {
		p("load changed %d\n", ev.(int))
	})

	// context
	context := C.webkit_web_view_get_context(view.View)
	C.webkit_web_context_set_spell_checking_enabled(context, C.gtk_false())
	C.webkit_web_context_set_tls_errors_policy(context, C.WEBKIT_TLS_ERRORS_POLICY_IGNORE)
	C.webkit_web_context_set_disk_cache_directory(context, toGStr(os.TempDir()))

	// settings
	settings := C.webkit_web_view_get_settings(view.View)
	C.webkit_settings_set_enable_java(settings, C.gtk_false())
	C.webkit_settings_set_enable_tabs_to_links(settings, C.gtk_false())
	C.webkit_settings_set_enable_dns_prefetching(settings, C.gtk_true())
	C.webkit_settings_set_javascript_can_access_clipboard(settings, C.gtk_true())
	C.webkit_settings_set_enable_site_specific_quirks(settings, C.gtk_true())
	C.webkit_settings_set_enable_smooth_scrolling(settings, C.gtk_true())

	// handle cookie
	cookieManager := C.webkit_web_context_get_cookie_manager(context)
	C.webkit_cookie_manager_set_persistent_storage(cookieManager, toGStr(cookieFilePath),
		C.WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT)

	return view
}
Exemplo n.º 7
0
func gtk_widget_show(widget *C.GtkWidget) {
	C.gtk_widget_show_all(widget)
}
Exemplo n.º 8
0
func FromLua(code string) map[string]unsafe.Pointer {
	lua := lgo.NewLua()
	bindings := make(map[string]unsafe.Pointer)

	processActorArgs := func(actor *C.ClutterActor, args map[interface{}]interface{}) unsafe.Pointer {
		pointer := unsafe.Pointer(actor)
		var minFilter, magFilter *C.ClutterScalingFilter
		var scaleX C.gdouble = 1.0
		var scaleY C.gdouble = 1.0
		var translationX, translationY, translationZ C.gfloat
		for k, v := range args {
			switch key := k.(type) {
			case string:
				switch key {
				case "id":
					bindings[v.(string)] = pointer
				case "bgcolor", "background_color":
					C.clutter_actor_set_background_color(actor, NewColorFromString(v.(string)))
				case "clip_rect":
					clip := (*C.ClutterRect)(v.(unsafe.Pointer))
					C.clutter_actor_set_clip(actor,
						C.gfloat(clip.origin.x),
						C.gfloat(clip.origin.y),
						C.gfloat(clip.size.width),
						C.gfloat(clip.size.height))
				case "content":
					C.clutter_actor_set_content(actor, (*C.ClutterContent)(v.(unsafe.Pointer)))
				case "content_gravity":
					switch v.(string) {
					case "top-left":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_TOP_LEFT)
					case "top":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_TOP)
					case "top-right":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_TOP_RIGHT)
					case "left":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_LEFT)
					case "center":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_CENTER)
					case "right":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_RIGHT)
					case "bottom-left":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_BOTTOM_LEFT)
					case "bottom":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_BOTTOM)
					case "bottom-right":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_BOTTOM_RIGHT)
					case "resize-fill":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_RESIZE_FILL)
					case "resize-aspect":
						C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT)
					default:
						log.Fatalf("unknown content gravity: %s", v.(string))
					}
				case "content_repeat":
					switch v.(string) {
					case "none":
						C.clutter_actor_set_content_repeat(actor, C.CLUTTER_REPEAT_NONE)
					case "x", "x-axis":
						C.clutter_actor_set_content_repeat(actor, C.CLUTTER_REPEAT_X_AXIS)
					case "y", "y-axis":
						C.clutter_actor_set_content_repeat(actor, C.CLUTTER_REPEAT_Y_AXIS)
					case "both":
						C.clutter_actor_set_content_repeat(actor, C.CLUTTER_REPEAT_BOTH)
					default:
						log.Fatalf("unknown content repeat: %s", v.(string))
					}
				case "x", "fixed_x":
					C.clutter_actor_set_x(actor, C.gfloat(v.(float64)))
				case "y", "fixed_y":
					C.clutter_actor_set_y(actor, C.gfloat(v.(float64)))
				case "height":
					C.clutter_actor_set_height(actor, C.gfloat(v.(float64)))
				case "layout", "layout_manager":
					C.clutter_actor_set_layout_manager(actor, (*C.ClutterLayoutManager)(v.(unsafe.Pointer)))
				case "mag_filter", "magnification_filter":
					magFilter = (*C.ClutterScalingFilter)(v.(unsafe.Pointer))
					C.clutter_actor_set_content_scaling_filters(actor, *minFilter, *magFilter)
				case "margin_bottom":
					C.clutter_actor_set_margin_bottom(actor, C.gfloat(v.(float64)))
				case "margin_left":
					C.clutter_actor_set_margin_left(actor, C.gfloat(v.(float64)))
				case "margin_right":
					C.clutter_actor_set_margin_right(actor, C.gfloat(v.(float64)))
				case "margin_top":
					C.clutter_actor_set_margin_top(actor, C.gfloat(v.(float64)))
				//TODO min height
				//TODO min width
				case "min_filter", "minification_filter":
					minFilter = (*C.ClutterScalingFilter)(v.(unsafe.Pointer))
					C.clutter_actor_set_content_scaling_filters(actor, *minFilter, *magFilter)
				case "name":
					C.clutter_actor_set_name(actor, toGStr(v.(string)))
				//TODO natural height
				//TODO natural width
				case "offscreen_redirect":
					switch v.(string) {
					case "auto", "automatic-for-opacity":
						C.clutter_actor_set_offscreen_redirect(actor, C.CLUTTER_OFFSCREEN_REDIRECT_AUTOMATIC_FOR_OPACITY)
					case "always":
						C.clutter_actor_set_offscreen_redirect(actor, C.CLUTTER_OFFSCREEN_REDIRECT_ALWAYS)
					default:
						log.Fatalf("unknown offscreen redirect option: %s", v.(string))
					}
				case "opacity":
					C.clutter_actor_set_opacity(actor, C.guint8(uint8(v.(float64))))
				case "pivot_point":
					point := (*C.ClutterPoint)(v.(unsafe.Pointer))
					C.clutter_actor_set_pivot_point(actor, C.gfloat(point.x), C.gfloat(point.y))
				case "pivot_point_z":
					C.clutter_actor_set_pivot_point_z(actor, C.gfloat(v.(float64)))
				case "position":
					point := (*C.ClutterPoint)(v.(unsafe.Pointer))
					C.clutter_actor_set_position(actor, C.gfloat(point.x), C.gfloat(point.y))
				case "reactive":
					b := C.FALSE
					if v.(bool) {
						b = C.TRUE
					}
					C.clutter_actor_set_reactive(actor, C.gboolean(b))
				case "request_mode":
					switch v.(string) {
					case "height", "height_for_width":
						C.clutter_actor_set_request_mode(actor, C.CLUTTER_REQUEST_HEIGHT_FOR_WIDTH)
					case "width", "width_for_height":
						C.clutter_actor_set_request_mode(actor, C.CLUTTER_REQUEST_WIDTH_FOR_HEIGHT)
					default:
						log.Fatalf("unknown request mode: %s", v.(string))
					}
				case "rotation_angle_x":
					C.clutter_actor_set_rotation_angle(actor, C.CLUTTER_X_AXIS, C.gdouble(v.(float64)))
				case "rotation_angle_y":
					C.clutter_actor_set_rotation_angle(actor, C.CLUTTER_Y_AXIS, C.gdouble(v.(float64)))
				case "rotation_angle_z":
					C.clutter_actor_set_rotation_angle(actor, C.CLUTTER_Z_AXIS, C.gdouble(v.(float64)))
				case "scale_x":
					scaleX = C.gdouble(v.(float64))
					C.clutter_actor_set_scale(actor, scaleX, scaleY)
				case "scale_y":
					scaleY = C.gdouble(v.(float64))
					C.clutter_actor_set_scale(actor, scaleX, scaleY)
				case "scale_z":
					C.clutter_actor_set_scale_z(actor, C.gdouble(v.(float64)))
				case "size":
					size := (*C.ClutterSize)(v.(unsafe.Pointer))
					C.clutter_actor_set_size(actor, C.gfloat(size.width), C.gfloat(size.height))
				case "text_direction", "text_dir":
					switch v.(string) {
					case "default":
						C.clutter_actor_set_text_direction(actor, C.CLUTTER_TEXT_DIRECTION_DEFAULT)
					case "left", "left-to-right", "ltr":
						C.clutter_actor_set_text_direction(actor, C.CLUTTER_TEXT_DIRECTION_LTR)
					case "right", "right-to-left", "rtl":
						C.clutter_actor_set_text_direction(actor, C.CLUTTER_TEXT_DIRECTION_RTL)
					default:
						log.Fatalf("unknown text direction: %s", v.(string))
					}
				//TODO transform
				case "translation_x":
					translationX = C.gfloat(v.(float64))
					C.clutter_actor_set_translation(actor, translationX, translationY, translationZ)
				case "translation_y":
					translationY = C.gfloat(v.(float64))
					C.clutter_actor_set_translation(actor, translationX, translationY, translationZ)
				case "translation_z":
					translationZ = C.gfloat(v.(float64))
					C.clutter_actor_set_translation(actor, translationX, translationY, translationZ)
				case "visible":
					if v.(bool) {
						C.clutter_actor_show(actor)
					} else {
						C.clutter_actor_hide(actor)
					}
				case "width":
					C.clutter_actor_set_width(actor, C.gfloat(v.(float64)))
				case "x_align":
					switch v.(string) {
					case "fill":
						C.clutter_actor_set_x_align(actor, C.CLUTTER_ACTOR_ALIGN_FILL)
					case "start":
						C.clutter_actor_set_x_align(actor, C.CLUTTER_ACTOR_ALIGN_START)
					case "center":
						C.clutter_actor_set_x_align(actor, C.CLUTTER_ACTOR_ALIGN_CENTER)
					case "end":
						C.clutter_actor_set_x_align(actor, C.CLUTTER_ACTOR_ALIGN_END)
					default:
						log.Fatalf("unknown x align: %s", v.(string))
					}
				case "x_expand":
					b := C.FALSE
					if v.(bool) {
						b = C.TRUE
					}
					C.clutter_actor_set_x_expand(actor, C.gboolean(b))
				case "y_align":
					switch v.(string) {
					case "fill":
						C.clutter_actor_set_y_align(actor, C.CLUTTER_ACTOR_ALIGN_FILL)
					case "start":
						C.clutter_actor_set_y_align(actor, C.CLUTTER_ACTOR_ALIGN_START)
					case "center":
						C.clutter_actor_set_y_align(actor, C.CLUTTER_ACTOR_ALIGN_CENTER)
					case "end":
						C.clutter_actor_set_y_align(actor, C.CLUTTER_ACTOR_ALIGN_END)
					default:
						log.Fatalf("unknown y align: %s", v.(string))
					}
				case "y_expand":
					b := C.FALSE
					if v.(bool) {
						b = C.TRUE
					}
					C.clutter_actor_set_y_expand(actor, C.gboolean(b))
				case "z", "z_position":
					C.clutter_actor_set_z_position(actor, C.gfloat(v.(float64)))
				}
			case float64:
				switch value := v.(type) {
				case unsafe.Pointer:
					//TODO add tests
					if IsActor(value) { // actor child
						C.clutter_actor_add_child(actor, (*C.ClutterActor)(value))
					} else if IsAction(value) { // action
						C.clutter_actor_add_action(actor, (*C.ClutterAction)(value))
					} else if IsConstraint(value) { // constraint
						C.clutter_actor_add_constraint(actor, (*C.ClutterConstraint)(value))
					} else if IsEffect(value) { // effect
						C.clutter_actor_add_effect(actor, (*C.ClutterEffect)(value))
					} else {
						log.Fatalf("unknown subelement type")
					}
				}
			}
		}
		return pointer
	}

	processBoxArgs := func(box *C.ClutterLayoutManager, args map[string]interface{}) {
		//TODO
	}

	lua.RegisterFunctions(map[string]interface{}{

		// actors

		"Actor": func(args map[interface{}]interface{}) unsafe.Pointer {
			actor := C.clutter_actor_new()
			return processActorArgs(actor, args)
		},

		"Stage": func(args map[interface{}]interface{}) unsafe.Pointer {
			window := C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)
			embed := C.gtk_clutter_embed_new()
			C.gtk_container_add((*C.GtkContainer)(unsafe.Pointer(window)), embed)
			actor := C.gtk_clutter_embed_get_stage((*C.GtkClutterEmbed)(unsafe.Pointer(embed)))
			C.clutter_actor_show(actor)
			C.gtk_widget_show_all((*C.GtkWidget)(unsafe.Pointer(window)))
			pointer := processActorArgs(actor, args)
			stage := (*C.ClutterStage)(unsafe.Pointer(actor))
			for k, v := range args {
				//TODO other properties
				switch key := k.(type) {
				case string:
					switch key {
					case "title":
						C.clutter_stage_set_title(stage, toGStr(v.(string)))
					}
				}
			}
			return pointer
		},

		"Text": func(args map[interface{}]interface{}) unsafe.Pointer {
			actor := C.clutter_text_new()
			pointer := processActorArgs(actor, args)
			text := (*C.ClutterText)(unsafe.Pointer(actor))
			for k, v := range args {
				//TODO other properties
				switch key := k.(type) {
				case string:
					switch key {
					case "text":
						C.clutter_text_set_text(text, toGStr(v.(string)))
					case "use_markup":
						b := C.FALSE
						if v.(bool) {
							b = C.TRUE
						}
						C.clutter_text_set_use_markup(text, C.gboolean(b))
					case "markup":
						C.clutter_text_set_markup(text, toGStr(v.(string)))
					case "color":
						C.clutter_text_set_color(text, NewColorFromString(v.(string)))
					}
				case float64:
				}
			}
			return pointer
		},

		// data structures

		"Point": func(args []float64) unsafe.Pointer {
			var point C.ClutterPoint
			point.x = C.float(args[0])
			point.y = C.float(args[1])
			return unsafe.Pointer(&point)
		},

		"Size": func(args []float64) unsafe.Pointer {
			var size C.ClutterSize
			size.width = C.float(args[0])
			size.height = C.float(args[1])
			return unsafe.Pointer(&size)
		},

		"Rect": func(args []float64) unsafe.Pointer {
			var rect C.ClutterRect
			var point C.ClutterPoint
			var size C.ClutterSize
			point.x = C.float(args[0])
			point.y = C.float(args[1])
			size.width = C.float(args[2])
			size.height = C.float(args[3])
			rect.origin = point
			rect.size = size
			return unsafe.Pointer(&rect)
		},

		// contents

		"Image": func(args []string) unsafe.Pointer {
			//TODO set data
			image := C.clutter_image_new()
			return unsafe.Pointer(image)
		},

		// layouts

		"Box": func(args map[string]interface{}) unsafe.Pointer {
			box := C.clutter_box_layout_new()
			processBoxArgs(box, args)
			return unsafe.Pointer(box)
		},

		"HBox": func(args map[string]interface{}) unsafe.Pointer {
			box := C.clutter_box_layout_new()
			C.clutter_box_layout_set_orientation((*C.ClutterBoxLayout)(unsafe.Pointer(box)), C.CLUTTER_ORIENTATION_HORIZONTAL)
			processBoxArgs(box, args)
			return unsafe.Pointer(box)
		},

		"VBox": func(args map[string]interface{}) unsafe.Pointer {
			box := C.clutter_box_layout_new()
			C.clutter_box_layout_set_orientation((*C.ClutterBoxLayout)(unsafe.Pointer(box)), C.CLUTTER_ORIENTATION_VERTICAL)
			processBoxArgs(box, args)
			return unsafe.Pointer(box)
		},

		// effects

		"Blur": func(args map[string]interface{}) unsafe.Pointer {
			effect := C.clutter_blur_effect_new()
			return unsafe.Pointer(effect)
		},

		// constraints
		"Align": func(args map[string]interface{}) unsafe.Pointer {
			constraint := C.clutter_align_constraint_new(nil, C.CLUTTER_ALIGN_X_AXIS, 0)
			align := (*C.ClutterAlignConstraint)(unsafe.Pointer(constraint))
			for key, v := range args {
				switch key {
				case "source":
					C.clutter_align_constraint_set_source(align, (*C.ClutterActor)(bindings[v.(string)]))
				case "axis":
					switch v.(string) {
					case "x", "X":
						C.clutter_align_constraint_set_align_axis(align, C.CLUTTER_ALIGN_X_AXIS)
					case "y", "Y":
						C.clutter_align_constraint_set_align_axis(align, C.CLUTTER_ALIGN_Y_AXIS)
					case "both", "BOTH", "Both":
						C.clutter_align_constraint_set_align_axis(align, C.CLUTTER_ALIGN_BOTH)
					}
				case "factor":
					C.clutter_align_constraint_set_factor(align, C.gfloat(v.(float64)))
				}
			}
			return unsafe.Pointer(constraint)
		},
	})
	lua.RunString(code)
	return bindings
}
Exemplo n.º 9
0
func basesetParent(c controlPrivate, p *controlParent) {
	widget := c.widget() // avoid multiple interface lookups
	C.gtk_container_add(p.c, widget)
	// make sure the new widget is shown if not explicitly hidden
	C.gtk_widget_show_all(widget)
}
Exemplo n.º 10
0
// ShowAll is a wrapper around gtk_widget_show_all().
func (v *Widget) ShowAll() {
	C.gtk_widget_show_all(v.native())
}
Exemplo n.º 11
0
func (w *window) Show() {
	C.gtk_widget_show_all(w.widget)
}
Exemplo n.º 12
0
func main() {
	// init gtk
	var argc C.int
	C.gtk_init(&argc, nil)

	// root window
	win := C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)
	connect(win, "destroy", func() { // quit gtk when window is closed
		C.gtk_main_quit()
	})

	// root grid
	grid := C.gtk_grid_new()
	C.gtk_container_add(asContainer(win), grid)

	// webview container
	pages := C.gtk_notebook_new()
	C.gtk_grid_attach(asGrid(grid), pages, 0, 0, 1, 1)
	C.gtk_widget_set_vexpand(pages, C.gtk_true())
	C.gtk_widget_set_hexpand(pages, C.gtk_true())
	C.gtk_notebook_set_tab_pos(asNotebook(pages), C.GTK_POS_LEFT)

	// new view constructor
	var newView func() *View
	newView = func() *View {
		view := NewView()

		label := C.gtk_label_new(nil)
		C.gtk_label_set_use_markup(asLabel(label), C.gtk_true())
		C.gtk_misc_set_alignment(asMisc(label), 0, 0.5)

		C.gtk_notebook_append_page(asNotebook(pages), view.Widget, label)

		// new view is requested
		connect(view.View, "create", func() *C.GtkWidget {
			return newView().Widget
		})

		// set tab label to page title
		connect(view.View, "notify::title", func() {
			var title string
			// trim long title
			for _, r := range fromGStr(C.webkit_web_view_get_title(view.View)) {
				if len(title) > 32 {
					break
				}
				title += string(r)
			}
			C.gtk_label_set_markup(asLabel(label), toGStr(fmt.Sprintf(`<span font="10">%s</span>`, title)))
		})

		return view
	}

	// first view
	view := newView()
	C.webkit_web_view_load_uri(view.View, toGStr("http://www.bilibili.tv"))

	// show window and run
	C.gtk_widget_show_all(win)
	C.gtk_main()
}
Exemplo n.º 13
0
func (c *controlSingleWidget) xsetParent(p *controlParent) {
	C.gtk_container_add(p.c, c.widget)
	// make sure the new widget is shown if not explicitly hidden
	// TODO why did I have this again?
	C.gtk_widget_show_all(c.widget)
}
Exemplo n.º 14
0
func (w *Window) ShowAll() {
	C.gtk_widget_show_all(ToWidget(unsafe.Pointer(w.c)).c)
}
Exemplo n.º 15
0
func gtk_widget_show_all(container GtkWidget) {
	C.gtk_widget_show_all(Arg(container))
}
Exemplo n.º 16
0
Arquivo: widget.go Projeto: ziutek/gtk
func (w *Widget) ShowAll() {
	C.gtk_widget_show_all(w.g())
}
Exemplo n.º 17
0
func (self *Widget) ShowAll() {
	C.gtk_widget_show_all(self.object)
}
Exemplo n.º 18
0
func (s *scroller) setParent(p *controlParent) {
	C.gtk_container_add(p.c, s.addShowWhich)
	// see basesetParent() above for why we call gtk_widget_show_all()
	C.gtk_widget_show_all(s.addShowWhich)
}