コード例 #1
0
ファイル: example_config_test.go プロジェクト: sqp/godock
func testApplet(callnew cdtype.NewAppletFunc) {
	// This is not a valid way to start an applet.
	// Only used here to trigger the loading and output check.
	base := cdapplet.New()
	app := cdapplet.Start(callnew, base)
	fmt.Println(app != nil, app.Name())
}
コード例 #2
0
ファイル: appdbus.go プロジェクト: sqp/godock
// New creates a new applet instance with args from command line.
//
func New(callnew cdtype.NewAppletFunc, args []string, dir string) (cdtype.AppInstance, *CDDbus, func() error) {
	name := args[0][2:] // Strip ./ in the beginning.

	base := cdapplet.New()
	base.SetBase(name, args[3], args[4], dir)

	app := cdapplet.Start(callnew, base)
	if app == nil {
		return nil, nil, nil
	}

	// app.ParentAppName = args[5]

	backend := &CDDbus{
		icons:   make(map[string]*SubIcon),
		busPath: dbus.ObjectPath(args[2]),
		menu:    &Menu{},
		log:     app.Log(),
	}
	app.SetBackend(backend)
	callinit := app.SetEvents(app)
	return app, backend, callinit
}
コード例 #3
0
ファイル: mgrgldi.go プロジェクト: sqp/godock
// 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
}