Java教程

gtk笔记-GKeyFile读取配置文件

本文主要是介绍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

 

这篇关于gtk笔记-GKeyFile读取配置文件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!