G_Settings应用更改 [英] G_Settings apply changes

查看:111
本文介绍了G_Settings应用更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一些C编码,但无法永久存储g_settings!

Im doing some C coding but im unable to store g_settings permanently!

#include <stdlib.h>
#include <locale.h>


#include <gio/gio.h>
int main(int argc, char **argv)
{
  GSettings *settings;
  g_type_init();
  settings = g_settings_new ("org.nemo.desktop");
  printf("%s\n", g_settings_get_string(settings, "font"));
  g_settings_set (settings, "font", "s", "Arial");
  if (g_settings_get_has_unapplied (settings)) printf("X");
  printf("%s\n", g_settings_get_string(settings, "font"));
  return 0;
}

尝试使用Linux Mint 13 Cinnamon(路径等正确).

Trying on Linux Mint 13 Cinnamon (paths,etc. are correct).

推荐答案

哦,起初我误读了您的代码...如果您想确保所做的更改已写入磁盘,我相信您应该致电g_settings_sync ().显然,如果您不使用mainloop进行运行(如您的示例案例),则实际上需要这样做才能将所有内容存储在磁盘上.

Oh, I misread your code at first... I believe you should call g_settings_sync () if you want to ensure your changes are written to disk. Apparently if you run without a mainloop (like in your example case) this is really required to get things on disk at all.

因此,要清楚一点:具有glib mainloop的普通应用程序将不需要(也不应该真正使用)同步调用.

So, just to be clear: a normal application with a glib mainloop will not need (and shouldn't really use) a sync-call.

这篇关于G_Settings应用更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆