Exemplo n.º 1
0
// Add adds an item to the map (from C callback).
//
func (im *itemMap) Add(cstr *C.gchar, cdr C.gpointer) {
	name := C.GoString((*C.char)(cstr))
	free := true

	switch im.typ {
	case itemMapTypeAnimation:
		im.list[name] = gldi.NewAnimationFromNative(unsafe.Pointer(cdr))

	case itemMapTypeCairoDeskletDecoration:
		im.list[name] = gldi.NewCairoDeskletDecorationFromNative(unsafe.Pointer(cdr))

	case itemMapTypeCairoDockRenderer:
		im.list[name] = gldi.NewCairoDockRendererFromNative(unsafe.Pointer(cdr))

	case itemMapTypeDialogDecorator:
		im.list[name] = gldi.NewDialogDecoratorFromNative(unsafe.Pointer(cdr))

	case itemMapTypeModule:
		im.list[name] = gldi.NewModuleFromNative(unsafe.Pointer(cdr))
		free = false
	}

	if free {
		C.free(unsafe.Pointer((*C.char)(cstr)))
	}
}
Exemplo n.º 2
0
func (o *AppManager) registerOneApplet(pack *packages.AppletPackage) {
	if gldi.ModuleGet(pack.DisplayedName) != nil {
		o.log.Debug("register applet, already known = dropped", pack.DisplayedName)
		return
	}

	vc := gldi.NewVisitCardFromPackage(pack)
	o.visitCards = append(o.visitCards, vc)
	c := C.newModule(C.gpointer(vc.Ptr))
	mod := gldi.NewModuleFromNative(unsafe.Pointer(c))
	o.log.Debug("register applet", mod != nil, vc.GetName(), vc.GetShareDataDir())
}