gtk笔记-GKeyFile读取配置文件

self->priv->config = g_key_file_new();  

 

/*  g_get_user_config_dir() ==== ~/.config/  */

self->priv->config_file = g_build_filename(g_get_user_config_dir(),     //创建config文件
"virt-viewer", "settings", NULL);

 

/* config_file==== ~/virt-viewer/settings  */

g_key_file_load_from_file(self->priv->config, self->priv->config_file,
G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, &error);      //加载config文件

 

 /*这是写配置到config,若是string,g_key_file_set_string()/

g_key_file_set_boolean(self->priv->config,
"virt-viewer", "ask-quit", !dont_ask);

 

 /*获取ui类别下的toolbar字段的bool, 若是string,g_key_file_get_string()/

gboolean ask = g_key_file_get_boolean(self->priv->config,
"virt-viewer", "ask-quit", &error);

 

参考链接:

https://www.freedesktop.org/software/gstreamer-sdk/data/docs/2012.5/gobject/gobject-The-Base-Object-Type.html

http://web.mit.edu/ghudson/dev/nokrb/third/gtk2/docs/reference/gtk/html/GtkCheckButton.html

https://developer.gimp.org/api/2.0/gtk/GtkWindow.html#gtk-window-set-default-icon-name

https://developer.gnome.org/glib/stable/glib-Miscellaneous-Utility-Functions.html#g-build-filename

https://blog.csdn.net/FlayHigherGT/article/details/84026124

 

posted @ 2020-08-11 00:16  海里木有鱼  阅读(640)  评论(0编辑  收藏  举报