Пример #1
0
// ListKnownApplets builds the list of all user applets.
//
func (Data) ListKnownApplets() map[string]datatype.Appleter {
	list := make(map[string]datatype.Appleter)
	for name, app := range docklist.Module() {
		if !app.IsAutoLoaded() { // don't display modules that can't be disabled
			list[name] = &AppletConf{
				VisitCard: *app.VisitCard(),
				app:       app,
			}
		}
	}
	return list
}
Пример #2
0
// ListDownloadApplets builds the list of downloadable user applets (installed or not).
//
func (d Data) ListDownloadApplets() (map[string]datatype.Appleter, error) {
	externalUserDir := globals.DirDockData(cdglobal.AppletsDirName)
	packs, e := packages.ListDownloadApplets(d.Log, externalUserDir)
	if e != nil {
		return nil, e
	}

	applets := docklist.Module()
	list := make(map[string]datatype.Appleter)
	for k, v := range packs {
		list[k] = &AppletDownload{
			AppletPackage: *v,
			app:           applets[k],
		}
	}

	return list, nil
}
Пример #3
0
// ListIcons builds the list of all icons.
//
func (Data) ListIcons() *datatype.ListIcon {
	list := datatype.NewListIcon()

	// Add icons in docks.
	taskbarSet := false
	for _, dock := range gldi.GetAllAvailableDocks(nil, nil) {
		// for _, dock := range gldi.ListDocksRoot() {

		var found []datatype.Iconer
		for _, icon := range dock.Icons() {
			if dock.GetRefCount() == 0 { // Maindocks.

				// Group taskbar icons and separators.
				if icon.ConfigPath() == "" || icon.IsSeparatorAuto() {
					// if icon.IsTaskbar() || icon.IsSeparatorAuto() {
					if !taskbarSet {
						taskbarSet = true
						ic := datatype.NewIconSimple(
							globals.ConfigFile(),
							datatype.FieldTaskBar,
							datatype.TitleTaskBar,
							globals.DirShareData("icons/icon-taskbar.png"))

						ic.Taskbar = true

						found = append(found, ic)
					}

				} else {
					found = append(found, &IconConf{icon})
				}

			} else { // Subdock.
				parentName := icon.GetParentDockName()
				list.Subdocks[parentName] = append(list.Subdocks[parentName], &IconConf{icon})
			}
		}

		if len(found) > 0 {
			var file, group string

			if dock.IsMainDock() {
				// Only maindocks after the first one have a config file.
				// So the first maindock use a custom group.
				group = datatype.KeyMainDock

			} else {
				// Other maindocks have a dedicated config file.
				// So the group is empty to load all of them (auto find).
				file = globals.CurrentThemePath(dock.GetDockName() + ".conf")
			}
			container := datatype.NewIconSimple(
				file,
				group,
				dock.GetReadableName(),
				"") // TODO: maybe get an icon for the maindock.

			list.Add(container, found)
		}
	}

	// Add modules in desklets.
	var desklets []datatype.Iconer
	for _, desklet := range docklist.Desklet() {
		icon := desklet.GetIcon()
		if icon != nil {
			desklets = append(desklets, &IconConf{icon})
		}
	}

	if len(desklets) > 0 {
		container := datatype.NewIconSimple(
			globals.ConfigFile(),
			datatype.GroupDesklets,
			datatype.TitleDesklets,
			"") // TODO: maybe get an icon for the desklets group.

		list.Add(container, desklets)
	}

	// Add other modules (not in a dock or a desklet) : plug-in or detached applet.
	// We need to create custom icons for them.
	var services []datatype.Iconer
	for _, mod := range docklist.Module() {
		cat := mod.VisitCard().GetCategory()

		if cat != gldi.CategoryBehavior && cat != gldi.CategoryTheme && !mod.IsAutoLoaded() {
			for _, mi := range mod.InstancesList() {

				if mi.Icon() == nil || (mi.Dock() != nil && mi.Icon().GetContainer() == nil) {
					icon := datatype.NewIconSimple(
						mi.GetConfFilePath(),
						"", // no group, we need all of them for an applet.
						mod.VisitCard().GetTitle(),
						mod.VisitCard().GetIconFilePath())

					services = append(services, icon)
				}
			}
		}
	}
	if len(services) > 0 {
		container := datatype.NewIconSimple(
			"", // no config file available.
			datatype.GroupServices, // so we set a custom group.
			tran.Slate(datatype.TitleServices),
			"") // TODO: maybe get an icon for the services group.

		list.Add(container, services)
	}

	return list
}