Esempio n. 1
0
// Uninstall removes the external applet package dir.
//
func (v *AppletDownload) Uninstall() error {
	externalUserDir := globals.DirDockData(cdglobal.AppletsDirName)
	e := v.AppletPackage.Uninstall(externalUserDir)
	if e == nil {
		v.app = nil
	}
	return e
}
Esempio n. 2
0
// New creates a GUI bridge that will answer to all GUI events.
//
func New(log cdtype.Logger) *Bridge {
	return &Bridge{
		Source: &confdata.Data{
			Crypto: gldi.Crypto,
			SourceCommon: datatype.SourceCommon{
				Log:     log,
				ConfDir: globals.DirDockData(),
			},
		},
		Log: log,
	}
}
Esempio n. 3
0
func createConfigDir(settings *DockSettings) {
	log.Info("creating configuration directory", globals.DirDockData())

	themeName := "Default-Single"

	if os.Getenv("DESKTOP_SESSION") == "cairo-dock" { // We're using the CD session for the first time
		themeName = "Default-Panel"
		settings.sessionWasUsed = true
		updateHiddenFile("cd session", true)
	}

	files.CopyDir(globals.DirShareData(cdglobal.ConfigDirDockThemes, themeName), globals.CurrentThemePath())
}
Esempio n. 4
0
// ListDockThemeLoad builds the list of dock themes for load widget (local and distant).
//
func (d Data) ListDockThemeLoad() (map[string]datatype.Appleter, error) {
	dir := globals.DirDockData(cdglobal.ConfigDirDockThemes)
	packs, e := packages.ListDownloadDockThemes(d.Log, dir)
	if e != nil {
		return nil, e
	}

	list := make(map[string]datatype.Appleter)
	for _, v := range packs {
		list[v.DisplayedName] = &dockTheme{AppletPackage: *v}
	}

	return list, nil
}
Esempio n. 5
0
// ListDockThemeSave builds the list of dock themes for save widget (local).
//
func (d Data) ListDockThemeSave() []datatype.Field {
	dir := globals.DirDockData(cdglobal.ConfigDirDockThemes)
	packs, e := packages.ListFromDir(d.Log, dir, packages.TypeUser, packages.SourceDockTheme)
	if e != nil {
		println("ListDockThemeSave wrong dir:", dir) // TODO: use a logger.
		return nil
	}

	var list []datatype.Field
	for _, pack := range packs {
		list = append(list, datatype.Field{
			Key:  pack.DisplayedName,
			Name: pack.GetName(),
		})
	}
	return list
}
Esempio n. 6
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
}
Esempio n. 7
0
// Install downloads and extract an external archive to package dir.
//
func (v *AppletDownload) Install(options string) error {
	// Using the "drop data signal" trick to ask the Dbus applet to work for us.
	// Only way I found for now to interact with it and let it know it will have
	// a new applet to handle. As a bonus, it also activate the applet, which
	// will toggle the activated button with the UpdateModuleState signal.
	url := packages.DistantURL + v.SrvTag + "/" + v.DisplayedName + "/" + v.DisplayedName + ".tar.gz"
	gldi.EmitSignalDropData(globals.Maindock().Container(), url, nil, 0)

	v.app = gldi.ModuleGet(v.DisplayedName)
	if v.app == nil {
		return errors.New("install failed: v.DisplayedName")
	}

	externalUserDir := globals.DirDockData(cdglobal.AppletsDirName)
	v.SetInstalled(externalUserDir)
	return nil

	// return v.AppletPackage.Install(options)
}
Esempio n. 8
0
// startApplet starts a new applet instance connected to its dock icon and instance.
//
func (o *AppManager) startApplet(mi *gldi.ModuleInstance, kf *keyfile.KeyFile) {
	icon := mi.Icon()
	vc := mi.Module().VisitCard()
	name := vc.GetName()

	// Get the mandatory create applet func.
	newfunc := cdtype.Applets.GetNewFunc(name)
	if newfunc == nil {
		o.log.NewErr(name, "StartApplet: applet unknown (maybe not enabled at compile)")
		return
	}

	// Default desklet renderer.
	if desklet := mi.Desklet(); desklet != nil {
		desklet.SetRendererByName("Simple")
	}

	// Default icon image.
	if icon != nil && icon.GetFileName() == "" {
		icon.SetIcon(mi.Module().VisitCard().GetIconFilePath())

		// 		gtk_widget_queue_draw (pModuleInstance->pContainer->pWidget);
	}

	// Upgrade configuration file if needed.
	// It seem it's already done by the dock, but we'll display a readable info.
	if kf != nil && gldi.ConfFileNeedUpdate(kf, vc.GetModuleVersion()) {
		original := filepath.Join(vc.GetShareDataDir(), vc.GetConfFileName())

		o.log.Info("Conf file upgrade", mi.GetConfFilePath(), original)
		// gldi.ConfFileUpgrade(kf, mi.GetConfFilePath(), original, true)

		// 			gchar *cTemplate = g_strdup_printf ("%s/%s", pModuleInstance->pModule->pVisitCard->cShareDataDir, pModuleInstance->pModule->pVisitCard->cConfFileName);
		// 			cairo_dock_upgrade_conf_file (pModuleInstance->cConfFilePath, pKeyFile, cTemplate);
		// 			g_free (cTemplate);
	}

	// Create applet instance and set its core data.
	callnew := cdtype.Applets.GetNewFunc(name)
	appbase := cdapplet.New()
	appbase.SetBase(name, mi.GetConfFilePath(), globals.DirDockData(), vc.GetShareDataDir()) // TODO: need rootdir
	app := cdapplet.Start(callnew, appbase)

	if app == nil {
		o.log.NewErr(name, "failed to start applet")
		return
	}

	if o.log.GetDebug() { // If the service debug is active, force it also on applets.
		app.Log().SetDebug(true)
	}
	o.log.Debug("applet started", name)

	app.SetBackend(appgldi.New(mi))
	callinit := app.SetEvents(app)
	e := callinit()
	if app.Log().Err(e, "failed to init") {
		return
	}

	// Everything was fine. We can add the applet in the managed list.
	o.actives[unsafe.Pointer(icon.ToNative())] = app
}
Esempio n. 9
0
func updateHiddenFile(key string, value interface{}) {
	file := globals.DirDockData(cdglobal.FileHiddenConfig)
	e := config.UpdateFile(log, file, hiddenGroup, key, value)
	log.Err(e, "updateHiddenFile", key, value)
}