예제 #1
0
파일: packages_test.go 프로젝트: sqp/godock
func TestDir(t *testing.T) {
	home := os.Getenv("HOME")
	for in, out := range map[string]string{
		"":     home + "/.config/cairo-dock/third-party",
		"/tmp": "/tmp/third-party",
	} {
		str, e := packages.DirAppletsExternal(in)
		assert.NoError(t, e, "DirAppletsExternal")
		assert.Equal(t, out, str, "DirAppletsExternal")
	}

	for in, out := range map[string]string{
		"":     home + "/.config/cairo-dock/extras/gauges",
		"/tmp": "/tmp/extras/gauges",
	} {
		str, e := packages.DirThemeExtra(in, "gauges")
		assert.NoError(t, e, "DirTheme")
		assert.Equal(t, out, str, "DirTheme")
	}

	gauges, e := packages.ListThemesDir(logger, "/usr/share/cairo-dock/gauges", packages.TypeLocal)
	assert.NoError(t, e, "ListThemesDir")
	assert.True(t, len(gauges) > 3, "ListThemesDir count")
	gauge := gauges[0]
	assert.Equal(t, "Battery[0]", gauge.GetName(), "gauge.GetName()")
	assert.Equal(t, "Battery", gauge.GetTitle(), "gauge.GetTitle()")
	assert.Equal(t, "Adrien Pilleboue", gauge.GetAuthor(), "gauge.GetAuthor()")
	assert.Equal(t, "2", gauge.GetModuleVersion(), "gauge.GetModuleVersion()")
	assert.Equal(t, packages.TypeLocal, gauge.Type, "gauge.Type")
	// assert.Equal(t, "", gauge.GetGettextDomain(), "gauge.GetGettextDomain()")
	assert.Equal(t, "Made by Necropotame for Cairo-Dock.\n", gauge.GetDescription(), "gauge.GetDescription()")
	assert.Equal(t, "/usr/share/cairo-dock/gauges/Battery/preview", gauge.GetPreviewFilePath(), "gauge.GetPreviewFilePath()")
}
예제 #2
0
파일: datatype.go 프로젝트: sqp/godock
// ListThemeXML builds a list of icon theme in system and user dir.
//
func (sc SourceCommon) ListThemeXML(localSystem, localUser, distant string) map[string]Handbooker {
	// list, _ := packages.ListExternalUser(localSystem, "theme")
	// Themes installed in system dir.
	list, _ := packages.ListThemesDir(sc.Log, localSystem, packages.TypeLocal)

	// Themes installed in user dir.
	userDir, e := packages.DirThemeExtra(sc.ConfDir, localUser)
	if e == nil {
		users, _ := packages.ListThemesDir(sc.Log, userDir, packages.TypeUser)
		list = append(list, users...)
	}
	sc.Log.Debug("ListThemeXML found total ", len(list), userDir)

	// Rename theme title with the online list.
	// TODO: maybe need to use hint here.
	dist, _ := packages.ListDistant(sc.Log, distant)
	for k, v := range list {
		more := dist.Get(v.DirName)
		if more != nil && more.Title != "" {
			list[k].Title = more.Title
		}
	}

	// TODO: Distant theme management will have to be moved into the download area.
	// dist, _ := packages.ListDistant(distant)
	// for _, v := range dist {
	// 	log.DEV("", v)
	// }

	out := make(map[string]Handbooker)
	for _, v := range list {
		out[v.GetName()] = v
	}

	return out
}