static void ccpSetOptionFromContext (CompObject *object, CompOption *o, const char *plugin) { CCP_CORE (&core); CCSPlugin *bsp; CCSSetting *setting; CompOptionValue value; Bool screen = (object->type == COMP_OBJECT_TYPE_SCREEN); int screenNum = 0; /* we currently only support screen and display opton types */ if (object->type != COMP_OBJECT_TYPE_SCREEN && object->type != COMP_OBJECT_TYPE_DISPLAY) return; if (screen) { char *name = compObjectName (object); if (name) { screenNum = atoi (name); free (name); } } bsp = ccsFindPlugin (cc->context, (plugin) ? plugin : CORE_VTABLE_NAME); if (!bsp) return; setting = ccsFindSetting (bsp, o->name, screen, screenNum); if (!setting) return; if (!ccpTypeCheck (setting, o)) return; compInitOptionValue (&value); ccpSettingToValue (object, setting, &value); cc->applyingSettings = TRUE; (*core.setOptionForPlugin) (object, plugin, o->name, &value); cc->applyingSettings = FALSE; compFiniOptionValue (&value, o->type); }
static Bool kconfigReadOptionValue (CompObject *object, KConfig *config, CompOption *o, CompOptionValue *value) { compInitOptionValue (value); switch (o->type) { case CompOptionTypeBool: case CompOptionTypeBell: kconfigBoolToValue (config->readBoolEntry (o->name), o->type, value); break; case CompOptionTypeInt: value->i = config->readNumEntry (o->name); break; case CompOptionTypeFloat: value->f = config->readDoubleNumEntry (o->name); break; case CompOptionTypeString: case CompOptionTypeColor: case CompOptionTypeKey: case CompOptionTypeButton: case CompOptionTypeEdge: case CompOptionTypeMatch: if (!kconfigStringToValue (object, config->readEntry (o->name), o->type, value)) return FALSE; break; case CompOptionTypeList: { int n, i; value->list.value = NULL; value->list.nValue = 0; value->list.type = o->value.list.type; switch (o->value.list.type) { case CompOptionTypeInt: { QValueList< int > list; list = config->readIntListEntry (o->name); n = list.size (); if (n) { value->list.value = (CompOptionValue *) malloc (sizeof (CompOptionValue) * n); if (value->list.value) { for (i = 0; i < n; i++) value->list.value[i].i = list[i]; value->list.nValue = n; } } } break; case CompOptionTypeBool: case CompOptionTypeFloat: case CompOptionTypeString: case CompOptionTypeColor: case CompOptionTypeKey: case CompOptionTypeButton: case CompOptionTypeEdge: case CompOptionTypeBell: case CompOptionTypeMatch: { QStringList list; list = config->readListEntry (o->name); n = list.size (); if (n) { value->list.value = (CompOptionValue *) malloc (sizeof (CompOptionValue) * n); if (value->list.value) { for (i = 0; i < n; i++) { if (!kconfigStringToValue (object, list[i], value->list.type, &value->list.value[i])) break; value->list.nValue++; } if (value->list.nValue != n) { compFiniOptionValue (value, o->type); return FALSE; } } } } break; case CompOptionTypeList: case CompOptionTypeAction: return FALSE; } } break; case CompOptionTypeAction: return FALSE; break; } return TRUE; }