settings-gconf.cpp
来自「celestia源代码」· C++ 代码 · 共 468 行 · 第 1/2 页
CPP
468 行
int oldOrbit = app->renderer->getOrbitMask(); /* Reload all the orbits */ int newOrbit = readGConfOrbits(app->client); /* Set orbit flags */ if (newOrbit != oldOrbit) app->renderer->setOrbitMask(newOrbit);}/* GCONF CALLBACK: Sets window width upon change */static void confWinWidth(GConfClient*, guint, GConfEntry* e, AppData* app){ int w = gconf_value_get_int(e->value); if (w != getWinWidth(app)) setSaneWinSize(app, w, getWinHeight(app));}/* GCONF CALLBACK: Sets window height upon change */static void confWinHeight(GConfClient*, guint, GConfEntry* e, AppData* app){ int h = gconf_value_get_int(e->value); if (h != getWinHeight(app)) setSaneWinSize(app, getWinWidth(app), h);}/* GCONF CALLBACK: Sets window X position upon change */static void confWinX(GConfClient*, guint, GConfEntry* e, AppData* app){ int x = gconf_value_get_int(e->value); if (x != getWinX(app)) setSaneWinPosition(app, x, getWinY(app));}/* GCONF CALLBACK: Sets window Y position upon change */static void confWinY(GConfClient*, guint, GConfEntry* e, AppData* app){ int y = gconf_value_get_int(e->value); if (y != getWinY(app)) setSaneWinPosition(app, getWinX(app), y);}/* GCONF CALLBACK: Reloads ambient light setting upon change */static void confAmbientLight(GConfClient*, guint, GConfEntry* e, AppData* app){ float value = gconf_value_get_float(e->value); /* Comparing floats is tricky. Three decimal places is "close enough." */ if (abs(value - app->renderer->getAmbientLightLevel()) < 0.001) return; setSaneAmbientLight(app, value);}/* GCONF CALLBACK: Reloads visual magnitude setting upon change */static void confVisualMagnitude(GConfClient*, guint, GConfEntry* e, AppData* app){ float value = gconf_value_get_float(e->value); if (abs(value - app->simulation->getFaintestVisible()) < 0.001) return; setSaneVisualMagnitude(app, value);}/* GCONF CALLBACK: Reloads galaxy light gain setting upon change */static void confGalaxyLightGain(GConfClient*, guint, GConfEntry* e, AppData*){ float value = gconf_value_get_float(e->value); if (abs(value - Galaxy::getLightGain()) < 0.001) return; setSaneGalaxyLightGain(value);}/* GCONF CALLBACK: Sets "show local time" setting upon change */static void confShowLocalTime(GConfClient*, guint, GConfEntry* e, AppData* app){ gboolean value = gconf_value_get_bool(e->value); if (value == app->showLocalTime) return; app->showLocalTime = value; updateTimeZone(app, app->showLocalTime);}/* GCONF CALLBACK: Sets HUD detail when changed */static void confVerbosity(GConfClient*, guint, GConfEntry* e, AppData* app){ int value = gconf_value_get_int(e->value); if (value == app->core->getHudDetail()) return; setSaneVerbosity(app, value);}/* GCONF CALLBACK: Sets window to fullscreen when change occurs */static void confFullScreen(GConfClient*, guint, GConfEntry* e, AppData* app){ gboolean value = gconf_value_get_bool(e->value); /* There is no way to determine if the window is actually full screen */ if (value == app->fullScreen) return; /* The Action handler for full-screen toggles for us, so we set it opposite * of what is wanted, and... */ app->fullScreen = !value; /* ... tickle it. */ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_action_group_get_action(app->agMain, "FullScreen")), value);}/* GCONF CALLBACK: Sets star style when changed */static void confStarStyle(GConfClient*, guint, GConfEntry* e, AppData* app){ int value = gconf_value_get_int(e->value); if (value == app->renderer->getStarStyle()) return; setSaneStarStyle(app, (Renderer::StarStyle)value);}/* GCONF CALLBACK: Sets alternate surface texture when changed */static void confAltSurfaceName(GConfClient*, guint, GConfEntry* e, AppData* app){ const char* value = gconf_value_get_string(e->value); if (string(value) == app->simulation->getActiveObserver()->getDisplayedSurface()) return; setSaneAltSurface(app, (char*)value);}/* HELPER: Reads in GConf->Render preferences and returns as int mask */static int readGConfRender(GConfClient* client){ int rf = Renderer::ShowNothing; rf |= Renderer::ShowStars * gconf_client_get_bool(client, "/apps/celestia/render/stars", NULL); rf |= Renderer::ShowPlanets * gconf_client_get_bool(client, "/apps/celestia/render/planets", NULL); rf |= Renderer::ShowGalaxies * gconf_client_get_bool(client, "/apps/celestia/render/galaxies", NULL); rf |= Renderer::ShowDiagrams * gconf_client_get_bool(client, "/apps/celestia/render/diagrams", NULL); rf |= Renderer::ShowCloudMaps * gconf_client_get_bool(client, "/apps/celestia/render/cloudMaps", NULL); rf |= Renderer::ShowOrbits * gconf_client_get_bool(client, "/apps/celestia/render/orbits", NULL); rf |= Renderer::ShowCelestialSphere * gconf_client_get_bool(client, "/apps/celestia/render/celestialSphere", NULL); rf |= Renderer::ShowNightMaps * gconf_client_get_bool(client, "/apps/celestia/render/nightMaps", NULL); rf |= Renderer::ShowAtmospheres * gconf_client_get_bool(client, "/apps/celestia/render/atmospheres", NULL); rf |= Renderer::ShowSmoothLines * gconf_client_get_bool(client, "/apps/celestia/render/smoothLines", NULL); rf |= Renderer::ShowEclipseShadows * gconf_client_get_bool(client, "/apps/celestia/render/eclipseShadows", NULL); rf |= Renderer::ShowRingShadows * gconf_client_get_bool(client, "/apps/celestia/render/ringShadows", NULL); rf |= Renderer::ShowBoundaries * gconf_client_get_bool(client, "/apps/celestia/render/boundaries", NULL); rf |= Renderer::ShowAutoMag * gconf_client_get_bool(client, "/apps/celestia/render/autoMag", NULL); rf |= Renderer::ShowCometTails * gconf_client_get_bool(client, "/apps/celestia/render/cometTails", NULL); rf |= Renderer::ShowMarkers * gconf_client_get_bool(client, "/apps/celestia/render/markers", NULL); rf |= Renderer::ShowPartialTrajectories * gconf_client_get_bool(client, "/apps/celestia/render/partialTrajectories", NULL); rf |= Renderer::ShowNebulae * gconf_client_get_bool(client, "/apps/celestia/render/nebulae", NULL); rf |= Renderer::ShowOpenClusters * gconf_client_get_bool(client, "/apps/celestia/render/openClusters", NULL); return rf;}/* HELPER: Reads in GConf->Orbits preferences and returns as int mask */static int readGConfOrbits(GConfClient* client){ int om = 0; om |= Body::Planet * gconf_client_get_bool(client, "/apps/celestia/orbits/planet", NULL); om |= Body::Moon * gconf_client_get_bool(client, "/apps/celestia/orbits/moon", NULL); om |= Body::Asteroid * gconf_client_get_bool(client, "/apps/celestia/orbits/asteroid", NULL); om |= Body::Comet * gconf_client_get_bool(client, "/apps/celestia/orbits/comet", NULL); om |= Body::Spacecraft * gconf_client_get_bool(client, "/apps/celestia/orbits/spacecraft", NULL); om |= Body::Invisible * gconf_client_get_bool(client, "/apps/celestia/orbits/invisible", NULL); om |= Body::Unknown * gconf_client_get_bool(client, "/apps/celestia/orbits/unknown", NULL); return om;}/* HELPER: Reads in GConf->Labels preferences and returns as int mask */static int readGConfLabels(GConfClient* client){ int lm = Renderer::NoLabels; lm |= Renderer::StarLabels * gconf_client_get_bool(client, "/apps/celestia/labels/star", NULL); lm |= Renderer::PlanetLabels * gconf_client_get_bool(client, "/apps/celestia/labels/planet", NULL); lm |= Renderer::MoonLabels * gconf_client_get_bool(client, "/apps/celestia/labels/moon", NULL); lm |= Renderer::ConstellationLabels * gconf_client_get_bool(client, "/apps/celestia/labels/constellation", NULL); lm |= Renderer::GalaxyLabels * gconf_client_get_bool(client, "/apps/celestia/labels/galaxy", NULL); lm |= Renderer::AsteroidLabels * gconf_client_get_bool(client, "/apps/celestia/labels/asteroid", NULL); lm |= Renderer::SpacecraftLabels * gconf_client_get_bool(client, "/apps/celestia/labels/spacecraft", NULL); lm |= Renderer::LocationLabels * gconf_client_get_bool(client, "/apps/celestia/labels/location", NULL); lm |= Renderer::CometLabels * gconf_client_get_bool(client, "/apps/celestia/labels/comet", NULL); lm |= Renderer::NebulaLabels * gconf_client_get_bool(client, "/apps/celestia/labels/nebula", NULL); lm |= Renderer::OpenClusterLabels * gconf_client_get_bool(client, "/apps/celestia/labels/openCluster", NULL); lm |= Renderer::I18nConstellationLabels * gconf_client_get_bool(client, "/apps/celestia/labels/i18n", NULL); return lm;}/* HELPER: Sets one of the flags according to provided type, key, and value */static void gcSetFlag(int type, const char* name, gboolean value, GConfClient* client){ gchar key[60]; switch (type) { case Render: sprintf(key, "%s%s", "/apps/celestia/render/", name); break; case Orbit: sprintf(key, "%s%s", "/apps/celestia/orbits/", name); break; case Label: sprintf(key, "%s%s", "/apps/celestia/labels/", name); break; } gconf_client_set_bool(client, key, value, NULL);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?