本文整理汇总了C++中g_key_file_to_data函数的典型用法代码示例。如果您正苦于以下问题:C++ g_key_file_to_data函数的具体用法?C++ g_key_file_to_data怎么用?C++ g_key_file_to_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了g_key_file_to_data函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: remmina_pref_clear_recent
void
remmina_pref_clear_recent (void)
{
GKeyFile *gkeyfile;
gchar **keys;
gint i;
gchar *content;
gsize length;
gkeyfile = g_key_file_new ();
g_key_file_load_from_file (gkeyfile, remmina_pref_file, G_KEY_FILE_NONE, NULL);
keys = g_key_file_get_keys (gkeyfile, "remmina_pref", NULL, NULL);
if (keys)
{
for (i = 0; keys[i]; i++)
{
if (strncmp (keys[i], "recent_", 7) == 0)
{
g_key_file_set_string (gkeyfile, "remmina_pref", keys[i], "");
}
}
g_strfreev (keys);
}
content = g_key_file_to_data (gkeyfile, &length, NULL);
g_file_set_contents (remmina_pref_file, content, length, NULL);
g_key_file_free (gkeyfile);
g_free (content);
}
开发者ID:awakecoding,项目名称:Remmina,代码行数:31,代码来源:remminapref.c
示例2: storage_sync
void storage_sync(const char *imsi, const char *store, GKeyFile *keyfile)
{
char *path;
char *data;
gsize length = 0;
if (imsi)
path = g_strdup_printf(STORAGEDIR "/%s/%s", imsi, store);
else
path = g_strdup_printf(STORAGEDIR "/%s", store);
if (path == NULL)
return;
if (create_dirs(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
g_free(path);
return;
}
data = g_key_file_to_data(keyfile, &length, NULL);
g_file_set_contents(path, data, length, NULL);
g_free(data);
g_free(path);
}
开发者ID:yongsu,项目名称:oFono,代码行数:26,代码来源:storage.c
示例3: config_write
void config_write()
{
assert(m_config_file != NULL);
GKeyFile * kf = g_key_file_new();
g_key_file_set_integer(kf, "StatusIcon", "stepsize", m_stepsize);
g_key_file_set_boolean(kf, "StatusIcon", "lmb_slider", m_lmb_slider);
g_key_file_set_boolean(kf, "StatusIcon", "mmb_mute", m_mmb_mute);
g_key_file_set_boolean(kf, "StatusIcon", "use_horizontal_slider", m_use_horizontal_slider);
g_key_file_set_boolean(kf, "StatusIcon", "show_sound_level", m_show_sound_level);
g_key_file_set_boolean(kf, "Hotkeys", "up_enabled", m_hotkey_up_enabled);
g_key_file_set_boolean(kf, "Hotkeys", "down_enabled", m_hotkey_down_enabled);
g_key_file_set_boolean(kf, "Hotkeys", "mute_enabled", m_hotkey_mute_enabled);
if(m_helper_program)
g_key_file_set_value(kf, "StatusIcon", "onclick", m_helper_program);
if(m_theme)
g_key_file_set_value(kf, "StatusIcon", "theme", m_theme);
if(m_card)
g_key_file_set_value(kf, "Alsa", "card", m_card);
if(m_channel)
g_key_file_set_value(kf, "Alsa", "channel", m_channel);
if(m_hotkey_up)
g_key_file_set_value(kf, "Hotkeys", "up", m_hotkey_up);
if(m_hotkey_down)
g_key_file_set_value(kf, "Hotkeys", "down", m_hotkey_down);
if(m_hotkey_mute)
g_key_file_set_value(kf, "Hotkeys", "mute", m_hotkey_mute);
gsize length;
gchar * data = g_key_file_to_data(kf, &length, NULL);
g_file_set_contents(m_config_file, data, -1, NULL);
g_free(data);
g_key_file_free(kf);
}
开发者ID:sfate,项目名称:volumeicon,代码行数:34,代码来源:config.c
示例4: encodeGKeyFile
static void encodeGKeyFile(ArgumentEncoder* encoder, GKeyFile* keyFile)
{
gsize dataSize;
GOwnPtr<char> data(g_key_file_to_data(keyFile, &dataSize, 0));
DataReference dataReference(reinterpret_cast<uint8_t*>(data.get()), dataSize);
encoder->encode(dataReference);
}
开发者ID:CannedFish,项目名称:deepin-webkit,代码行数:7,代码来源:ArgumentCodersGtk.cpp
示例5: save_greeter_settings
static void save_greeter_settings (void)
{
char *str, *tfname;
char buffer[256];
GKeyFile *kf;
gsize len;
gint handle;
// read in data from file to a key file
kf = g_key_file_new ();
if (!g_key_file_load_from_file (kf, GREETER_CONFIG_FILE, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL))
return;
// update changed values in the key file
sprintf (buffer, "%s", gdk_color_to_string (&desktop_colour));
g_key_file_set_string (kf, "greeter", "desktop_bg", buffer);
g_key_file_set_string (kf, "greeter", "wallpaper", desktop_picture);
g_key_file_set_string (kf, "greeter", "wallpaper_mode", desktop_mode);
g_key_file_set_string (kf, "greeter", "gtk-font-name", desktop_font);
g_key_file_set_string (kf, "greeter", "gtk-theme-name", "PiX");
g_key_file_set_string (kf, "greeter", "gtk-icon-theme-name", "PiX");
// write the modified key file out to a temp file
str = g_key_file_to_data (kf, &len, NULL);
handle = g_file_open_tmp ("XXXXXX", &tfname, NULL);
write (handle, str, len);
close (handle);
g_free (str);
// copy the temp file to the correct place with sudo
sprintf (buffer, "sudo cp %s %s", tfname, GREETER_CONFIG_FILE);
system (buffer);
}
开发者ID:l10n-tw,项目名称:pipanel,代码行数:33,代码来源:pipanel.c
示例6: cid_write_keys_to_file
void
cid_write_keys_to_file (GKeyFile *pKeyFile, const gchar *cConfFilePath)
{
cid_debug ("%s (%s)", __func__, cConfFilePath);
GError *erreur = NULL;
gchar *cDirectory = g_path_get_dirname (cConfFilePath);
if (! g_file_test (cDirectory, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE))
{
g_mkdir_with_parents (cDirectory, 7*8*8+7*8+5);
}
g_free (cDirectory);
gsize length;
gchar *cNewConfFilePath = g_key_file_to_data (pKeyFile, &length, &erreur);
if (erreur != NULL)
{
cid_warning ("Error while fetching data : %s", erreur->message);
g_error_free (erreur);
return ;
}
g_file_set_contents (cConfFilePath, cNewConfFilePath, length, &erreur);
if (erreur != NULL)
{
cid_warning ("Error while writing data : %s", erreur->message);
g_error_free (erreur);
return ;
}
}
开发者ID:ziirish,项目名称:Conky-Images-Display,代码行数:31,代码来源:cid-config.c
示例7: prefsToData
static gchar *
prefsToData (PrettyPrintingOptions* ppo,
gsize* size,
GError** error)
{
GKeyFile *kf;
gchar *contents;
kf = g_key_file_new ();
g_key_file_set_string (kf, "pretty-printer", "newLineChars", ppo->newLineChars);
g_key_file_set_integer (kf, "pretty-printer", "indentChar", (int)ppo->indentChar);
g_key_file_set_integer (kf, "pretty-printer", "indentLength", ppo->indentLength);
g_key_file_set_boolean (kf, "pretty-printer", "oneLineText", ppo->oneLineText);
g_key_file_set_boolean (kf, "pretty-printer", "inlineText", ppo->inlineText);
g_key_file_set_boolean (kf, "pretty-printer", "oneLineComment", ppo->oneLineComment);
g_key_file_set_boolean (kf, "pretty-printer", "inlineComment", ppo->inlineComment);
g_key_file_set_boolean (kf, "pretty-printer", "oneLineCdata", ppo->oneLineCdata);
g_key_file_set_boolean (kf, "pretty-printer", "inlineCdata", ppo->inlineCdata);
g_key_file_set_boolean (kf, "pretty-printer", "emptyNodeStripping", ppo->emptyNodeStripping);
g_key_file_set_boolean (kf, "pretty-printer", "emptyNodeStrippingSpace", ppo->emptyNodeStrippingSpace);
g_key_file_set_boolean (kf, "pretty-printer", "forceEmptyNodeSplit", ppo->forceEmptyNodeSplit);
g_key_file_set_boolean (kf, "pretty-printer", "trimLeadingWhites", ppo->trimLeadingWhites);
g_key_file_set_boolean (kf, "pretty-printer", "trimTrailingWhites", ppo->trimTrailingWhites);
g_key_file_set_boolean (kf, "pretty-printer", "alignComment", ppo->alignComment);
g_key_file_set_boolean (kf, "pretty-printer", "alignText", ppo->alignText);
g_key_file_set_boolean (kf, "pretty-printer", "alignCdata", ppo->alignCdata);
contents = g_key_file_to_data (kf, size, error);
g_key_file_free (kf);
return contents;
}
开发者ID:DaveMDS,项目名称:geany-plugins,代码行数:32,代码来源:ConfigUI.c
示例8: _gtk_print_save_custom_papers
void
_gtk_print_save_custom_papers (GtkListStore *store)
{
GtkTreeModel *model = GTK_TREE_MODEL (store);
GtkTreeIter iter;
GKeyFile *keyfile;
gchar *filename, *data;
gsize len;
gint i = 0;
keyfile = g_key_file_new ();
if (gtk_tree_model_get_iter_first (model, &iter))
{
do
{
GtkPageSetup *page_setup;
gchar group[32];
g_snprintf (group, sizeof (group), "Paper%u", i);
gtk_tree_model_get (model, &iter, 0, &page_setup, -1);
gtk_page_setup_to_key_file (page_setup, keyfile, group);
++i;
} while (gtk_tree_model_iter_next (model, &iter));
}
filename = custom_paper_get_filename ();
data = g_key_file_to_data (keyfile, &len, NULL);
g_file_set_contents (filename, data, len, NULL);
g_free (data);
g_free (filename);
}
开发者ID:Pfiver,项目名称:gtk,代码行数:35,代码来源:gtkcustompaperunixdialog.c
示例9: SaveConfig
bool SaveConfig( const char file[], const Config *cfg )
{
FILE* fp;
GKeyFile *keyfile;
gchar *str;
gsize len;
bool succ;
succ = false;
keyfile = g_key_file_new();
g_key_file_set_value( keyfile, kMainSec, kAdapterKey, cfg->adapter );
g_key_file_set_integer( keyfile, kMainSec, kPortKey, cfg->dst_port );
g_key_file_set_integer( keyfile, kMainSec, kFilterKey, cfg->filter );
g_key_file_set_value( keyfile, kMainSec, kFilterWordsKey, cfg->filterwords );
g_key_file_set_integer( keyfile, kMainSec, kFilterIdURLKey, cfg->filteridurl );
g_key_file_set_integer( keyfile, kMainSec, kCheckUpdateKey, cfg->checkupdate );
str = g_key_file_to_data( keyfile, &len, NULL );
fp = fopen( file, "w" );
if( fp != NULL )
{
fwrite( str, len, 1, fp );
succ = true;
fclose( fp );
}//end if
g_free( str );
g_key_file_free( keyfile );
return succ;
}//end SaveConfig
开发者ID:ciakpey,项目名称:MediaSniffer,代码行数:34,代码来源:config.cpp
示例10: save_settings
static void save_settings(void)
{
GKeyFile *config = g_key_file_new();
gchar *data;
gchar *config_dir = g_path_get_dirname(config_file);
g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
g_key_file_set_boolean(config, "geanyprj", "display_sidebar", display_sidebar);
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("Plugin configuration directory could not be created."));
}
else
{
/* write config to file */
data = g_key_file_to_data(config, NULL, NULL);
utils_write_file(config_file, data);
g_free(data);
}
g_free(config_dir);
g_key_file_free(config);
}
开发者ID:Solgrid,项目名称:geany-plugins,代码行数:25,代码来源:geanyprj.c
示例11: serialize_cache
static gboolean
serialize_cache (MuContacts *self)
{
gchar *data;
gsize len;
gboolean rv;
g_hash_table_foreach (self->_hash, (GHFunc) each_keyval, self);
/* Note: err arg is unused */
data = g_key_file_to_data (self->_ccache, &len, NULL);
if (len) {
GError *err;
err = NULL;
rv = g_file_set_contents (self->_path, data, len, &err);
if (!rv) {
g_warning ("failed to serialize cache to %s: %s",
self->_path, err->message);
g_error_free (err);
}
g_free (data);
}
return rv;
}
开发者ID:Neil-Smithline,项目名称:mu,代码行数:25,代码来源:mu-contacts.c
示例12: config_save
static gboolean
config_save (TrackerConfigFile *file)
{
GError *error = NULL;
gchar *filename;
gchar *data;
gsize size;
if (!file->key_file) {
g_critical ("Could not save config, GKeyFile was NULL, has the config been loaded?");
return FALSE;
}
#ifdef CONFIG_ENABLE_TRACE
g_message ("Setting details to GKeyFile object...");
#endif /* CONFIG_ENABLE_TRACE */
/* FIXME: Get to GKeyFile from object properties */
#ifdef CONFIG_ENABLE_TRACE
g_message ("Saving config to disk...");
#endif /* CONFIG_ENABLE_TRACE */
/* Do the actual saving to disk now */
data = g_key_file_to_data (file->key_file, &size, &error);
if (error) {
g_warning ("Could not get config data to write to file, %s",
error->message);
g_error_free (error);
return FALSE;
}
filename = g_file_get_path (file->file);
g_file_set_contents (filename, data, size, &error);
g_free (data);
if (error) {
g_warning ("Could not write %" G_GSIZE_FORMAT " bytes to file '%s', %s",
size,
filename,
error->message);
g_free (filename);
g_error_free (error);
return FALSE;
}
#ifdef CONFIG_ENABLE_TRACE
g_message ("Wrote config to '%s' (%" G_GSIZE_FORMAT " bytes)",
filename,
size);
#endif /* CONFIG_ENABLE_TRACE */
g_free (filename);
return TRUE;
}
开发者ID:Pelagicore,项目名称:tracker-ivi,代码行数:60,代码来源:tracker-config-file.c
示例13: WritePrivateProfileString
/**
* Write a key to blow.ini
* @param [in] section configuration section
* @param [in] key configuration key
* @param [in] value value to write
* @param [in] filepath file path to blow.ini
* @return 1 if everything is ok -1 if not
*
* Example Usage:
* @code
* // Set the plain_prefix variable as "+zbr "
* WritePrivateProfileString("FiSH", "plain_prefix", "+zbr ", iniPath);
* @endcode
*/
int WritePrivateProfileString(const char *section, const char *key, const char *value, const char *filepath)
{
GKeyFile *key_file;
GError *error = NULL;
FILE *outfile = NULL;
gsize length = 0;
gchar *config = NULL;
key_file = g_key_file_new();
(void) g_key_file_load_from_file(key_file, filepath, G_KEY_FILE_NONE, NULL);
g_key_file_set_string(key_file, section, key, value);
// Get the content of the config to a string...
config = g_key_file_to_data(key_file, &length, &error);
if (error == NULL) { // If everything is ok...
outfile = fopen(filepath, "w");
if (outfile != NULL) {
(void) fwrite(config, sizeof(gchar), (size_t) length, outfile);
(void) fclose(outfile);
}
}
g_free(config);
g_key_file_free(key_file);
if ((error != NULL) || (outfile == NULL)) {
return -1;
}
return 1;
}
开发者ID:hugopeixoto,项目名称:FiSH-irssi,代码行数:46,代码来源:cfgopts.c
示例14: write_proximity_config
static void write_proximity_config(struct btd_device *device, const char *alert,
const char *level)
{
char *filename;
GKeyFile *key_file;
char *data;
gsize length = 0;
filename = btd_device_get_storage_path(device, "proximity");
key_file = g_key_file_new();
g_key_file_load_from_file(key_file, filename, 0, NULL);
if (level)
g_key_file_set_string(key_file, alert, "Level", level);
else
g_key_file_remove_group(key_file, alert, NULL);
data = g_key_file_to_data(key_file, &length, NULL);
if (length > 0) {
create_file(filename, S_IRUSR | S_IWUSR);
g_file_set_contents(filename, data, length, NULL);
}
g_free(data);
g_free(filename);
g_key_file_free(key_file);
}
开发者ID:alvarofagner,项目名称:bluez,代码行数:28,代码来源:monitor.c
示例15: ol_config_save
void ol_config_save (OlConfig *config)
{
OlConfigPrivate *priv = OL_CONFIG_GET_PRIVATE (config);
gsize len;
char *file_content = g_key_file_to_data (priv->config, &len, NULL);
g_file_set_contents (ol_config_get_path (), file_content, len, NULL);
}
开发者ID:AhmadMAlam,项目名称:osd-lyrics,代码行数:7,代码来源:ol_config.c
示例16: save_password_file
static gboolean
save_password_file (TrackerPasswordProviderKeyfile *kf,
GError **error)
{
TrackerPasswordProviderKeyfilePrivate *priv;
gchar *filename;
gchar *directory;
gchar *data;
gsize size;
directory = config_dir_ensure_exists_and_return (error);
if (!directory) {
return FALSE;
}
filename = g_build_filename (directory, KEYFILE_FILENAME, NULL);
g_free (directory);
priv = TRACKER_PASSWORD_PROVIDER_KEYFILE_GET_PRIVATE (kf);
data = g_key_file_to_data (priv->password_file, &size, NULL);
g_file_set_contents (filename, data, size, error);
g_free (data);
g_free (filename);
return *error == NULL ? TRUE : FALSE;
}
开发者ID:Pelagicore,项目名称:tracker-ivi,代码行数:28,代码来源:tracker-password-provider-keyfile.c
示例17: g_key_file_save_to_file
/* Custom function to save the keyfile to disk. If the file does not exist,
it will be created */
gboolean g_key_file_save_to_file(GKeyFile *kf, const gchar *file)
{
GError *error = NULL;
gsize length, nr;
char *data = g_key_file_to_data(kf, &length, &error);
GIOChannel *gio;
if (!data)
return FALSE;
gio = g_io_channel_new_file(file, "w+", &error);
if (!gio) {
GMAMEUI_DEBUG ("Could not save key file %s: %s", file, error->message);
g_error_free (error);
error = NULL;
g_free(data);
return FALSE;
}
g_io_channel_write_chars(gio, data, length, &nr, &error);
g_free(data);
g_io_channel_unref(gio);
return TRUE;
}
开发者ID:davewongillies,项目名称:gmameui,代码行数:32,代码来源:io.c
示例18: ep_key_file_save
static void
ep_key_file_save (void)
{
gchar *contents;
gchar *filename;
gchar *pathname;
gsize length = 0;
GError *error = NULL;
if (!check_key_file (G_STRFUNC))
return;
filename = ep_key_file_get_filename ();
contents = g_key_file_to_data (key_file, &length, &error);
pathname = g_path_get_dirname (filename);
if (!error) {
g_mkdir_with_parents (pathname, 0700);
g_file_set_contents (filename, contents, length, &error);
}
g_free (pathname);
if (error != NULL) {
g_warning ("%s: %s", filename, error->message);
g_error_free (error);
}
g_free (contents);
g_free (filename);
}
开发者ID:gcampax,项目名称:evolution-data-server,代码行数:31,代码来源:e-passwords-win32.c
示例19: create_custom_theme
void
create_custom_theme (const char *parent)
{
GKeyFile *keyfile;
char *data;
char *path;
/* Create the custom directory */
path = custom_theme_dir_path (NULL);
g_mkdir_with_parents (path, 0755);
g_free (path);
/* Set the data for index.theme */
keyfile = g_key_file_new ();
g_key_file_set_string (keyfile, "Sound Theme", "Name", _("Custom"));
g_key_file_set_string (keyfile, "Sound Theme", "Inherits", parent);
g_key_file_set_string (keyfile, "Sound Theme", "Directories", ".");
data = g_key_file_to_data (keyfile, NULL, NULL);
g_key_file_free (keyfile);
/* Save the index.theme */
path = custom_theme_dir_path ("index.theme");
g_file_set_contents (path, data, -1, NULL);
g_free (path);
g_free (data);
custom_theme_update_time ();
}
开发者ID:ChrisCummins,项目名称:gnome-control-center,代码行数:28,代码来源:sound-theme-file-utils.c
示例20: save_preset_file
bool_t save_preset_file (EqualizerPreset * preset, const char * filename)
{
GKeyFile *rcfile;
int i;
char *data;
gsize len;
GError *error = NULL;
rcfile = g_key_file_new();
g_key_file_set_double(rcfile, "Equalizer preset", "Preamp", preset->preamp);
for (i = 0; i < 10; i++) {
char tmp[7];
g_snprintf(tmp, sizeof(tmp), "Band%d", i);
g_key_file_set_double(rcfile, "Equalizer preset", tmp,
preset->bands[i]);
}
data = g_key_file_to_data(rcfile, &len, &error);
bool_t success = FALSE;
VFSFile * file = vfs_fopen (filename, "w");
if (file == NULL)
goto DONE;
if (vfs_fwrite (data, 1, strlen (data), file) == strlen (data))
success = TRUE;
vfs_fclose (file);
DONE:
g_free(data);
g_key_file_free(rcfile);
return success;
}
开发者ID:Falcon-peregrinus,项目名称:mlplayer,代码行数:34,代码来源:equalizer_preset.c
注:本文中的g_key_file_to_data函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论