1
我正在使用MonoDevelop開發ubuntu統一應用程序。如何使用C#讀取dconf設置
我如何讀取dconf使用C#設置?
我可以使用C#訪問GSettings嗎?
我真正需要的是關鍵/org/gnome/desktop/interface/font-name
的價值。
更新
我的快速破解如下:
private string GetFontName()
{
string font = "Ubuntu 11";
Process p = new Process {
StartInfo = new ProcessStartInfo {
FileName = "gsettings",
Arguments = "get org.gnome.desktop.interface font-name",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
p.Start();
while (!p.StandardOutput.EndOfStream)
font = p.StandardOutput.ReadLine();
p.WaitForExit();
return font.Trim(new char[]{'\''});
}
你不應該綁定到GSettings呢? – rene
@rene。你是對的。正如[此處](https://wiki.gnome.org/Projects/dconf)所述:「**大多數應用程序不會直接與dconf連接,而是與GSettings。**」 – sergej
如果它有所作爲,您可以使用GTK#3中'gio-sharp.dll'的一部分'GLib.Settings'類(類似於GSettings API)。 GTK#3爲我打破了東西,這就是爲什麼我會堅持你的破解。 – EvilTak