Esempio n. 1
0
// NewWidget creates the main Cairo-Dock configuration widget.
//
func NewWidget(source datatype.Source, log cdtype.Logger) *GuiConfigure {
	box := newgtk.Box(gtk.ORIENTATION_VERTICAL, 0)

	widget := &GuiConfigure{
		Box:    *box,
		Source: source,

		stack:     newgtk.Stack(),
		btnAction: make(map[string]btnaction.Tune),
		pages:     make(map[string]*Page),
		log:       log,
	}

	// Create widgets.

	widget.Menu = confmenu.New(widget)
	menuIcons := pageswitch.New()
	menuIcons.Set("no-show-all", true)
	menuCore := pageswitch.New()
	menuCore.Set("no-show-all", true)

	// Box for separator on left of menuIcons.
	boxIcons := newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 0)
	sepIcons := newgtk.Separator(gtk.ORIENTATION_VERTICAL)
	boxIcons.PackStart(sepIcons, false, false, 6)
	boxIcons.PackStart(menuIcons, false, false, 0)
	boxIcons.PackStart(menuCore, false, false, 0)

	widget.mainSwitch = pageswitch.New()

	btnIcons := btnaction.New(widget.Menu.Save)
	btnCore := btnaction.New(widget.Menu.Save)
	btnAdd := btnaction.New(widget.Menu.Save)
	btnAdd.SetAdd()

	icons := conficons.New(widget, log, menuIcons, btnIcons)
	core := confcore.New(widget, log, menuCore, btnCore)
	add := confapplets.New(widget, log, nil, confapplets.ListCanAdd)
	add.Hide() // TODO: REMOVE THE NEED OF THAT.

	// Add pages to the switcher. This will pack the pages widgets to the gui box.

	widget.AddPage(GroupIcons, "", icons, btnIcons, menuIcons.Show, menuIcons.Hide)
	widget.AddPage(GroupAdd, "list-add", add, btnAdd, nil, nil)
	widget.AddPage(GroupConfig, "", core, btnCore, menuCore.Show, menuCore.Hide)

	// Packing menu.

	sep := newgtk.Separator(gtk.ORIENTATION_HORIZONTAL)

	widget.Menu.PackStart(widget.mainSwitch, false, false, 0)
	widget.Menu.PackStart(boxIcons, false, false, 0)

	widget.PackStart(widget.Menu, false, false, 2)
	widget.PackStart(sep, false, false, 0)

	widget.PackStart(widget.stack, true, true, 0)

	return widget
}
Esempio n. 2
0
func packWindow(win *gtk.Window, source vdata.Sourcer, build cftype.Grouper) func() {
	return func() {
		win.SetDefaultSize(winWidth, winHeight)
		win.SetTitle(winTitle)
		win.SetIconFromFile(source.AppIcon())
		win.Connect("destroy", gtk.MainQuit)

		// widgets.
		box := newgtk.Box(gtk.ORIENTATION_VERTICAL, 0)
		source.SetBox(box)

		menu := confmenu.New(source)
		switcher := pageswitch.New()
		w := build.BuildAll(switcher)

		btnAdd := btnaction.New(menu.Save)
		btnAdd.SetTest()

		btnHack := newgtk.ButtonWithLabel("Hack")
		btnHack.Connect("clicked", func() { build.KeyWalk(vdata.TestValues) })

		menu.PackStart(switcher, false, false, 0)
		menu.PackEnd(btnHack, false, false, 0)
		win.Add(box)
		box.PackStart(menu, false, false, 0)
		box.PackStart(w, true, true, 0)
		win.ShowAll()
	}
}
Esempio n. 3
0
// New creates a welcome widget with informations about the program.
//
func New(source cftype.Source, log cdtype.Logger, switcher *pageswitch.Switcher) cftype.Grouper {
	const group = "Dev"
	title := tran.Slate("hi")

	// all packages in the application gopath.
	pathGoTest := strings.Join(append(cdglobal.AppBuildPath, "..."), "/")

	pathTestConfCmd := cdglobal.AppBuildPathFull("test", "confcmd", "confcmd.go")
	pathTestConfGUI := cdglobal.AppBuildPathFull("test", "confgui", "confgui.go")
	pathTestConfCmd, _ = filepath.EvalSymlinks(pathTestConfCmd)
	pathTestConfGUI, _ = filepath.EvalSymlinks(pathTestConfGUI)

	printConfig := func(showAll bool) {
		path := source.MainConfigFile()
		def := source.MainConfigDefault()

		otherSw := pageswitch.New()
		defer otherSw.Destroy()
		build, e := cfbuild.NewFromFile(source, log, path, def, "")
		if !log.Err(e, "load current dock config file") {
			// build.BuildSingle("TaskBar")
			build.BuildAll(otherSw)
			println("conf", path, def)
			cfprint.Default(build, showAll)
			build.Destroy()
		}
	}

	buildInfo := cfbuild.TweakAddGroup(group,
		newkey.TextLabel(group, "txt_title", common.Bold(common.Big(title))),
		newkey.Separator(group, "sep_title"),
		newkey.TextLabel(group, "txt_dev_page", "Test page, with useful tools for the developer."),
		newkey.CustomButtonLabel(group, "printConfig", "Print configuration", "show mainconf edited", func() { printConfig(false) }),
		newkey.CustomButtonLabel(group, "printConfig", "Print configuration", "show mainconf all", func() { printConfig(true) }),
		newkey.Separator(group, "sep_go_area"),
		newkey.TextLabel(group, "txt_go_area", "<b>Those commands requires the application sources in their Go environment</b>."),
		newkey.Separator(group, "sep_tests_gui"),
		newkey.LaunchCommand(group, "testConfGUI", "Launch config GUI test", "go run "+pathTestConfGUI),
		newkey.Separator(group, "sep_tests_cmd"),
		newkey.LaunchCommand(group, "testConfGUI", "Launch config console test", "go run "+pathTestConfCmd),
		newkey.LaunchCommand(group, "testConfGUI", "Launch config console mainconf diff", "go run "+pathTestConfCmd+" "+source.MainConfigFile()),
		newkey.Separator(group, "sep_tests_go"),
		newkey.LaunchCommand(group, "gotest", "Launch go tests", "go test "+pathGoTest),
		newkey.LaunchCommand(group, "golint", "Launch go lint", "golint "+pathGoTest),
		newkey.LaunchCommand(group, "govet", "Launch go vet", "go vet "+pathGoTest),
	)

	build := cfbuild.NewVirtual(source, log, "", "", "").BuildAll(switcher, buildInfo)

	build.ShowAll()
	return build
}
Esempio n. 4
0
func TestConfig(t *testing.T) {
	gtk.Init(nil)

	build := vdata.TestInit(vdata.New(log.NewLog(log.Logs), nil, nil), vdata.PathTestConf())
	if build == nil {
		return
	}
	build.BuildAll(pageswitch.New())

	assert.Equal(t, countChanged(t, build), 0, "Build unchanged")

	build.KeyWalk(vdata.TestValues)
	assert.Equal(t, countChanged(t, build), 32, "Build full change")
}
Esempio n. 5
0
func main() {
	path, isTest := vdata.TestPathDefault()

	// path := cdglobal.ConfigDirDock("") + "/current_theme/cairo-dock.conf"

	// path := cdglobal.AppBuildPathFull(pathGoGmail...)

	gtk.Init(nil)

	source := vdata.New(log.NewLog(log.Logs), nil, nil)
	build := vdata.TestInit(source, path)
	if build == nil {
		return
	}
	build.BuildAll(pageswitch.New())
	if isTest {
		cfprint.Updated(build)
		build.KeyWalk(vdata.TestValues)
		cfprint.Updated(build)
	} else {
		cfprint.Default(build, true)
	}
}