// New creates a AppGldi connection. // func New(mi *gldi.ModuleInstance) *AppGldi { return &AppGldi{ IconBase: &IconBase{Icon: mi.Icon()}, mi: mi, icons: make(map[string]*IconBase), shortkeys: make(map[string]cdglobal.Shortkeyer), } }
// StopApplet close the applet instance. // func (o *AppManager) stopApplet(mi *gldi.ModuleInstance) { icon := mi.Icon() o.sendApp(icon, "on_stop_module") if subdock := icon.GetSubDock(); subdock != nil { gldi.ObjectUnref(subdock) // mi.Icon().pSubDock = nil } icon.RemoveDataRenderer() desklet := mi.Desklet() if desklet != nil && desklet.HasIcons() { desklet.RemoveIcons() } o.log.Debug("Applet stopped", mi.Module().VisitCard().GetName()) delete(o.actives, unsafe.Pointer(icon.ToNative())) }
func (o *AppManager) reloadApplet(mi *gldi.ModuleInstance, oldContainer *gldi.Container, kf *keyfile.KeyFile) bool { o.log.Info("reload", mi.Module().VisitCard().GetName()) icon := mi.Icon() o.sendApp(icon, "on_reload_module", kf != nil) if o.log.GetDebug() { // If the service debug is active, force it also on applets. app := o.actives[unsafe.Pointer(icon.ToNative())] if app != nil { app.Log().SetDebug(true) } } // Default desklet renderer. if desklet := mi.Desklet(); desklet != nil { if desklet.HasIcons() { desklet.SetRendererByNameData("Caroussel", true, false) } else { desklet.SetRendererByName("Simple") } } // Default icon image. if icon != nil && icon.GetFileName() == "" { icon.SetIcon(mi.Module().VisitCard().GetIconFilePath()) // gtk_widget_queue_draw (pModuleInstance->pContainer->pWidget); } // Update data renderer size. if kf == nil { // CairoDataRenderer *pDataRenderer = cairo_dock_get_icon_data_renderer (pIcon); // if (pDataRenderer != NULL) // { // CairoDataToRenderer *pData = cairo_data_renderer_get_data (pDataRenderer); // if (pData->iMemorySize > 2) // cairo_dock_resize_data_renderer_history (pIcon, pIcon->fWidth); // } } return notif.AnswerIntercept }
// 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 }