Exemple #1
0
func uiSetup() {
	var err error

	cssProvider, err = gtk.CssProviderNew()
	e.Exit(err)
	err = cssProvider.LoadFromData(css)
	e.Exit(err)

	w.count, err = gtk.SpinButtonNewWithRange(1, 999, 1)
	e.Exit(err)
	w.count.SetValue(1)

	shuffle, err := gtk.ButtonNewWithLabel("Shuffle")
	e.Exit(err)

	w.showActionsText, err = gtk.CheckButtonNewWithMnemonic("Show actions _text")
	e.Exit(err)
	w.showPermutation, err = gtk.CheckButtonNewWithMnemonic("Show _permutation")
	e.Exit(err)

	w.cellSize, err = gtk.SpinButtonNewWithRange(1, 999, 1)
	e.Exit(err)
	w.cellSize.SetValue(32)

	cellSizeLabel, err := gtk.LabelNew("Cell size:")
	e.Exit(err)

	w.count.Connect("changed", uiShuffle)
	w.count.Connect("activate", uiShuffle)
	shuffle.Connect("clicked", uiShuffle)
	w.showActionsText.Connect("toggled", uiReset)
	w.showPermutation.Connect("toggled", uiReset)
	w.cellSize.Connect("changed", uiReset)

	panel, err := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
	e.Exit(err)
	panel.SetSpacing(5)
	panel.Add(w.count)
	panel.Add(shuffle)
	panel.Add(w.showActionsText)
	panel.Add(w.showPermutation)
	panel.Add(cellSizeLabel)
	panel.Add(w.cellSize)

	w.fieldWindow, err = gtk.ScrolledWindowNew(nil, nil)
	e.Exit(err)

	layout, err := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
	e.Exit(err)
	layout.Add(panel)
	layout.PackStart(w.fieldWindow, true, true, 0)

	window, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	e.Exit(err)
	window.SetTitle(title)
	window.Add(layout)
	window.Connect("destroy", gtk.MainQuit)
	uiShuffle()
	window.ShowAll()
}
Exemple #2
0
func newDisplaySettings() *displaySettings {
	ds := &displaySettings{}
	prov, _ := gtk.CssProviderNew()
	ds.provider = prov
	ds.defaultFontSize = 12
	return ds
}
Exemple #3
0
// See #189
func fixPopupMenusWithoutFocus() {
	prov, _ := gtk.CssProviderNew()
	prov.LoadFromData("GtkMenu { margin: 0; }")

	// It must be added to the screen.
	// Adding to the main window has the same effect as putting the CSS in
	// gtk-keys.css (it is overwritten by the theme)
	screen, _ := gdk.ScreenGetDefault()
	gtk.AddProviderForScreen(screen, prov, gtk.STYLE_PROVIDER_PRIORITY_USER)
}
Exemple #4
0
// MainCSS provides a common css for widgets.
//
func MainCSS() *gtk.CssProvider {
	if css == nil {
		css, _ = gtk.CssProviderNew()
		e := css.LoadFromData(".DefaultValue {\n color: rgba(" + cftype.DefaultTextColor + ");\n}")
		if e != nil {
			println(e.Error())
		}
	}
	return css
}
Exemple #5
0
func (u *gtkUI) applyStyle() {
	css, err := gtk.CssProviderNew()
	if err != nil {
		log.Println("Failed to apply style:", err)
		return
	}

	err = css.LoadFromData(style)
	if err != nil {
		log.Println("Failed to apply style:", err)
	}
}
Exemple #6
0
func (*RealGtk) CssProviderNew() (gtki.CssProvider, error) {
	return wrapCssProvider(gtk.CssProviderNew())
}