【发布时间】:2014-04-02 13:37:59
【问题描述】:
我正在使用 MonoDevelop 开发一个 ubuntu 统一应用程序。
如何使用 C# 读取 dconf 设置?
我可以使用 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。你说的对。如here 所述:“大多数应用程序不想直接与 dconf 交互,而是与 GSettings 交互。”
-
如果有影响,您可以使用
GLib.Settings类(类似于 GSettings API),它是 GTK#3 中gio-sharp.dll的一部分。 GTK#3 为我打破了一些东西,这就是为什么我会坚持你的 hack。