本文整理汇总了C++中g_key_file_set_string函数的典型用法代码示例。如果您正苦于以下问题:C++ g_key_file_set_string函数的具体用法?C++ g_key_file_set_string怎么用?C++ g_key_file_set_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了g_key_file_set_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: handle_wcs_data
static int handle_wcs_data(const uint8_t *tlv_msg, int length)
{
struct wifi_sc *wsc = NULL;
GKeyFile *keyfile = NULL;
int ret = -EINVAL;
wsc = decode_from_tlv(tlv_msg, length);
if (!wsc)
return -EINVAL;
if (!wsc->ssid)
goto out;
keyfile = g_key_file_new();
if (!keyfile) {
ret = -ENOMEM;
goto out;
}
g_key_file_set_string(keyfile, NEARD_SERVICE_GROUP,
SERVICE_KEY_TYPE, "wifi");
g_key_file_set_string(keyfile, NEARD_SERVICE_GROUP,
SERVICE_KEY_SSID, wsc->ssid);
g_key_file_set_boolean(keyfile, NEARD_SERVICE_GROUP,
SERVICE_KEY_HIDDEN, TRUE);
if (wsc->passphrase)
g_key_file_set_string(keyfile, NEARD_SERVICE_GROUP,
SERVICE_KEY_PASSPHRASE, wsc->passphrase);
ret = connman_config_provision_mutable_service(keyfile);
out:
g_key_file_unref(keyfile);
free_wifi_sc(wsc);
return ret;
}
开发者ID:drgogeta86,项目名称:connman,代码行数:37,代码来源:neard.c
示例2: sat_pref_layout_ok
/** User pressed OK. Any changes should be stored in config. */
void sat_pref_layout_ok(GKeyFile * cfg)
{
if (dirty)
{
/* we have new settings */
if (cfg != NULL)
{
g_key_file_set_string(cfg,
MOD_CFG_GLOBAL_SECTION,
MOD_CFG_GRID,
gtk_entry_get_text(GTK_ENTRY(gridstr)));
}
else
{
sat_cfg_set_str(SAT_CFG_STR_MODULE_GRID,
gtk_entry_get_text(GTK_ENTRY(gridstr)));
sat_cfg_set_bool(SAT_CFG_BOOL_MAIN_WIN_POS,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(mwin)));
sat_cfg_set_bool(SAT_CFG_BOOL_MOD_WIN_POS,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(mod)));
sat_cfg_set_bool(SAT_CFG_BOOL_MOD_STATE,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(state)));
}
}
else if (reset)
{
/* we have to reset the values to global or default settings */
if (cfg == NULL)
{
/* layout */
sat_cfg_reset_str(SAT_CFG_STR_MODULE_GRID);
/* window placement */
sat_cfg_reset_bool(SAT_CFG_BOOL_MAIN_WIN_POS);
sat_cfg_reset_bool(SAT_CFG_BOOL_MOD_WIN_POS);
sat_cfg_reset_bool(SAT_CFG_BOOL_MOD_STATE);
}
else
{
g_key_file_remove_key((GKeyFile *) (cfg),
MOD_CFG_GLOBAL_SECTION, MOD_CFG_GRID, NULL);
}
}
dirty = FALSE;
reset = FALSE;
}
开发者ID:bastla,项目名称:gpredict,代码行数:50,代码来源:sat-pref-layout.c
示例3: save_state
static gboolean
save_state (time_t mtime,
gchar **converted)
{
gchar *filename;
GKeyFile *keyfile;
gchar *str;
GError *error;
gboolean result;
/* Make sure the state directory exists */
if (g_mkdir_with_parents (g_get_user_data_dir (), 0755))
{
g_printerr ("Failed to create directory %s: %s\n",
g_get_user_data_dir (), g_strerror (errno));
return FALSE;
}
filename = g_build_filename (g_get_user_data_dir (), "mateconf-gsettings-data-convert", NULL);
keyfile = g_key_file_new ();
str = g_strdup_printf ("%ld", mtime);
g_key_file_set_string (keyfile,
"State", "timestamp", str);
g_free (str);
g_key_file_set_string_list (keyfile,
"State", "converted",
(const gchar * const *)converted, g_strv_length (converted));
str = g_key_file_to_data (keyfile, NULL, NULL);
g_key_file_free (keyfile);
error = NULL;
if (!g_file_set_contents (filename, str, -1, &error))
{
g_printerr ("%s\n", error->message);
g_error_free (error);
result = FALSE;
}
else
result = TRUE;
g_free (filename);
g_free (str);
return result;
}
开发者ID:fatman2021,项目名称:mate-conf,代码行数:49,代码来源:mateconf-gsettings-data-convert.c
示例4: gnc_save_all_state
/** Save all persistent program state to disk. This function finds the
* name of the "new" state file associated with a specific book guid.
* It saves some top level data, then iterates through the list of
* open windows calling a helper function to save each window.
*
* @note The name of the state file is based on the name of the data
* file, not the path name of the data file. If there are multiple
* data files with the same name, the state files will be suffixed
* with a number. E.G. test_account, test_account_2, test_account_3,
* etc.
*
* @param session The QofSession whose state should be saved.
*
* @param unused */
static void
gnc_save_all_state (gpointer session, gpointer unused)
{
QofBook *book;
gchar guid_string[GUID_ENCODING_LENGTH+1];
const GncGUID *guid;
GKeyFile *keyfile = NULL;
keyfile = gnc_state_get_current ();
if (keyfile)
{
/* Remove existing Window and Page groups from the keyfile
* They will be regenerated.
*/
gsize num_groups, curr;
gchar **groups = g_key_file_get_groups (keyfile, &num_groups);
for (curr=0; curr < num_groups; curr++)
{
if (g_str_has_prefix (groups[curr], "Window ") ||
g_str_has_prefix (groups[curr], "Page "))
{
DEBUG ("Removing state group %s", groups[curr]);
g_key_file_remove_group (keyfile, groups[curr], NULL);
}
}
g_strfreev (groups);
}
/* Store the book's GncGUID in the top level group */
book = qof_session_get_book(session);
guid = qof_entity_get_guid(QOF_INSTANCE(book));
guid_to_string_buff(guid, guid_string);
g_key_file_set_string(keyfile, STATE_FILE_TOP, STATE_FILE_BOOK_GUID,
guid_string);
gnc_main_window_save_all_windows(keyfile);
#ifdef DEBUG
/* Debugging: dump a copy to the trace log */
{
gchar *file_data;
gsize file_length;
file_data = g_key_file_to_data(keyfile, &file_length, NULL);
DEBUG("=== File Data Written===\n%s\n=== File End ===\n", file_data);
g_free(file_data);
}
#endif
LEAVE("");
}
开发者ID:Gnucash,项目名称:gnucash,代码行数:63,代码来源:top-level.c
示例5: hlfs_get_inode_info_setup
static void
hlfs_get_inode_info_setup(Fixture *fixture, const void *data) {
const char *test_dir = (const char *)data;
g_print("test env dir is %s\n", test_dir);
char *fs_dir = g_build_filename(test_dir, "testfs", NULL);
// g_assert(g_mkdir(fs_dir, 0700) == 0);
char *uri = g_malloc0(128);
g_assert(uri != NULL);
snprintf(uri, 128, "%s%s", "local://", fs_dir);
// char *uri = g_build_path(tmp, fs_dir, NULL);
g_print("uri is %s\n", uri);
pid_t status;
const char cmd[256];
memset((char *) cmd, 0, 256);
sprintf((char *) cmd, "%s %s %s %s %d %s %d %s %d", "../mkfs.hlfs",
"-u", uri,
"-b", 8192,
"-s", 67108864,
"-m", 1024);
g_message("cmd is [%s]", cmd);
status = system(cmd);
#if 0
GKeyFile *sb_keyfile = g_key_file_new();
g_key_file_set_string(sb_keyfile, "METADATA", "uri", uri);
g_key_file_set_integer(sb_keyfile, "METADATA", "block_size", 8196);
g_key_file_set_integer(sb_keyfile, "METADATA", "segment_size", 67108864);
g_key_file_set_integer(sb_keyfile, "METADATA", "max_fs_size", 671088640);
gchar *content = g_key_file_to_data(sb_keyfile, NULL, NULL);
char *sb_file_path = g_build_filename(fs_dir, "superblock", NULL);
g_print("sb file path is %s\n", sb_file_path);
GError *error = NULL;
if (TRUE != g_file_set_contents(sb_file_path, content, strlen(content) + 1, &error)) {
g_print("error msg is %s", error->message);
error = NULL;
}
#endif
fixture->uri = uri;
g_print("fixture->uri is %s\n", fixture->uri);
fixture->ctrl = init_hlfs(fixture->uri);
g_assert(fixture->ctrl != NULL);
int ret = hlfs_open(fixture->ctrl, 1);
g_assert(ret == 0);
take_snapshot(fixture, data);
test_hlfs_find_inode_before_time(fixture, data);
// g_key_file_free(sb_keyfile);
// g_free(sb_file_path);
g_free(fs_dir);
return ;
}
开发者ID:baibaibai,项目名称:hlfs,代码行数:49,代码来源:test_hlfs_get_inode_info.c
示例6: goa_utils_keyfile_set_string
void
goa_utils_keyfile_set_string (GoaAccount *account, const gchar *key, const gchar *value)
{
GError *error;
GKeyFile *key_file;
gchar *contents;
gchar *group;
gchar *path;
gsize length;
contents = NULL;
path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ());
group = g_strdup_printf ("Account %s", goa_account_get_id (account));
key_file = g_key_file_new ();
error = NULL;
if (!g_key_file_load_from_file (key_file,
path,
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
&error))
{
g_warning ("Error loading keyfile %s: %s (%s, %d)",
path,
error->message,
g_quark_to_string (error->domain),
error->code);
g_error_free (error);
goto out;
}
g_key_file_set_string (key_file, group, key, value);
contents = g_key_file_to_data (key_file, &length, NULL);
error = NULL;
if (!g_file_set_contents (path, contents, length, &error))
{
g_prefix_error (&error, "Error writing key-value-file %s: ", path);
g_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code);
g_error_free (error);
goto out;
}
out:
g_free (contents);
g_key_file_free (key_file);
g_free (group);
g_free (path);
}
开发者ID:abprime,项目名称:gnome-online-accounts,代码行数:49,代码来源:goautils.c
示例7: mc_config_set_string
void
mc_config_set_string (const mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * value)
{
gchar *buffer;
if (!mc_config || !group || !param || !value)
return;
buffer = mc_config_normalize_before_save (value);
g_key_file_set_string (mc_config->handle, group, param, buffer);
g_free (buffer);
}
开发者ID:MidnightCommander,项目名称:mc,代码行数:15,代码来源:set.c
示例8: on_save_preferences
static void
on_save_preferences (Viewer *viewer, GKeyFile *keyfile, void *user_data)
{
RendererCamThumb *self = user_data;
GPtrArray *keys = gu_hash_table_get_keys(self->cam_handlers);
for (int k = 0; k < g_ptr_array_size(keys); k++) {
char *key = g_ptr_array_index(keys, k);
cam_renderer_t *cr = g_hash_table_lookup(self->cam_handlers, key);
char str[80];
sprintf (str, "%d %d", cr->render_place, cr->expanded);
g_key_file_set_string (keyfile, RENDERER_NAME, key, str);
}
}
开发者ID:BIANZiyang,项目名称:3PRE,代码行数:15,代码来源:renderer_cam_thumb.c
示例9: add_remote_to_keyfile
static gboolean
add_remote_to_keyfile (GKeyFile *new_keyfile,
const char *key,
const char *url,
GPtrArray *branches,
GError **error)
{
gboolean ret = FALSE;
char **iter;
g_key_file_set_string (new_keyfile, key, "url", url);
for (iter = opt_set; iter && *iter; iter++)
{
const char *keyvalue = *iter;
gs_free char *subkey = NULL;
gs_free char *subvalue = NULL;
if (!parse_keyvalue (keyvalue, &subkey, &subvalue, error))
goto out;
g_key_file_set_string (new_keyfile, key, subkey, subvalue);
}
if (branches->len > 0)
g_key_file_set_string_list (new_keyfile, key, "branches",
(const char *const *)branches->pdata,
branches->len);
if (opt_no_gpg_verify)
g_key_file_set_boolean (new_keyfile, key, "gpg-verify", FALSE);
ret = TRUE;
out:
return ret;
}
开发者ID:aloverso,项目名称:ostree-1,代码行数:36,代码来源:ot-builtin-remote.c
示例10: keystore_store_key
/**
* Sets a key in the key store file.
*/
bool keystore_store_key(const char *nick, const char *key) {
const char *password;
char *encrypted;
char *wrapped;
bool ok = false;
GKeyFile *keyfile = getConfigFile();
// Remove old key
delete_nick(keyfile, nick);
// Add new key
password = get_keystore_password();
if (password) {
// Encrypt the password
encrypted = fish_encrypt(password, strlen(password), key);
if (!encrypted) goto end;
// Prepend "+OK "
wrapped = g_strconcat("+OK ", encrypted, NULL);
g_free(encrypted);
// Store encrypted in file
g_key_file_set_string(keyfile, nick, "key", wrapped);
free(wrapped);
} else {
// Store unencrypted in file
g_key_file_set_string(keyfile, nick, "key", key);
}
// Save key store file
ok = save_keystore(keyfile);
end:
g_key_file_free(keyfile);
return ok;
}
开发者ID:94m3k1n9,项目名称:hexchat,代码行数:39,代码来源:keystore.c
示例11: create_conf_file
/* create basic conffile with sensible defaults */
static void create_conf_file(void)
{
GKeyFile *settingsfile;
gchar *keyfile;
mkdir(CONFIG_FILE_DIR, 0755);
settingsfile = g_key_file_new();
g_key_file_set_string(settingsfile, MODE_SETTING_ENTRY, MODE_SETTING_KEY, MODE_DEVELOPER );
keyfile = g_key_file_to_data (settingsfile, NULL, NULL);
if(g_file_set_contents(FS_MOUNT_CONFIG_FILE, keyfile, -1, NULL) == 0)
log_debug("Conffile creation failed. Continuing without configuration!\n");
g_key_file_free(settingsfile);
}
开发者ID:d0b3rm4n,项目名称:usb-moded,代码行数:16,代码来源:usb_moded-config.c
示例12: policy_allowed_bearers
static void policy_allowed_bearers(const char *allowed_bearers)
{
struct passwd *pwd;
uid_t uid;
char *pathname;
GKeyFile *keyfile;
LOG("update to '%s'", allowed_bearers);
uid = getuid();
pwd = getpwuid(uid);
g_assert(pwd);
keyfile = g_key_file_new();
g_key_file_set_string(keyfile, "policy_foo", "uid", pwd->pw_name);
g_key_file_set_string(keyfile, "policy_foo", "AllowedBearers",
allowed_bearers);
pathname = g_strdup_printf("%s/foo.policy", POLICYDIR);
policy_save(keyfile, pathname);
g_free(pathname);
g_key_file_unref(keyfile);
}
开发者ID:hmallat,项目名称:connman,代码行数:24,代码来源:session-test.c
示例13: cairo_dock_add_remove_element_to_key
void cairo_dock_add_remove_element_to_key (const gchar *cConfFilePath, const gchar *cGroupName, const gchar *cKeyName, gchar *cElementName, gboolean bAdd)
{
GKeyFile *pKeyFile = cairo_dock_open_key_file (cConfFilePath);
if (pKeyFile == NULL)
return ;
gchar *cElementList = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL), *cNewElementList = NULL;
if (cElementList != NULL && *cElementList == '\0')
{
g_free (cElementList);
cElementList= NULL;
}
if (bAdd)
{
//g_print ("on rajoute %s\n", cElementName);
if (cElementList != NULL)
cNewElementList = g_strdup_printf ("%s;%s", cElementList, cElementName);
else
cNewElementList = g_strdup (cElementName);
}
else
{
//g_print ("on enleve %s\n", cElementName);
gchar *str = g_strstr_len (cElementList, strlen (cElementList), cElementName);
g_return_if_fail (str != NULL);
if (str == cElementList)
{
if (str[strlen (cElementName)] == '\0')
cNewElementList = g_strdup ("");
else
cNewElementList = g_strdup (str + strlen (cElementName) + 1);
}
else
{
*(str-1) = '\0';
if (str[strlen (cElementName)] == '\0')
cNewElementList = g_strdup (cElementList);
else
cNewElementList = g_strdup_printf ("%s;%s", cElementList, str + strlen (cElementName) + 1);
}
}
g_key_file_set_string (pKeyFile, cGroupName, cKeyName, cNewElementList);
cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath);
g_free (cElementList);
g_free (cNewElementList);
g_key_file_free (pKeyFile);
}
开发者ID:BackupTheBerlios,项目名称:cairo-dock-svn,代码行数:48,代码来源:cairo-dock-keyfile-utilities.c
示例14: anjuta_session_set_string
/**
* anjuta_session_set_string:
* @session: an #AnjutaSession object
* @section: Section.
* @key: Key name.
* @value: Key value
*
* Set a string @value to @key in given @section.
*/
void
anjuta_session_set_string (AnjutaSession *session, const gchar *section,
const gchar *key, const gchar *value)
{
g_return_if_fail (ANJUTA_IS_SESSION (session));
g_return_if_fail (section != NULL);
g_return_if_fail (key != NULL);
if (!value)
{
g_key_file_remove_key (session->priv->key_file, section, key, NULL);
return;
}
g_key_file_set_string (session->priv->key_file, section, key, value);
}
开发者ID:GNOME,项目名称:anjuta,代码行数:25,代码来源:anjuta-session.c
示例15: gather_unlock_options
/**
* builder: the gtk builder object
* dialog: The dialog to extract the data from
*
* Gets the unlocking settings and stores them in output_data
*
**/
static void
gather_unlock_options (GtkBuilder *builder, GtkDialog *dialog)
{
GcrUnlockOptionsWidget *unlock;
const gchar *choice;
unlock = g_object_get_data (G_OBJECT (dialog), "unlock-options-widget");
choice = gcr_unlock_options_widget_get_choice (unlock);
if (choice) {
g_key_file_set_integer (output_data, "unlock-options", "ttl",
gcr_unlock_options_widget_get_ttl (unlock));
g_key_file_set_string (output_data, "unlock-options", "choice", choice);
}
}
开发者ID:bhull2010,项目名称:mate-keyring,代码行数:23,代码来源:gku-prompt-tool.c
示例16: remmina_pref_set_value
void
remmina_pref_set_value (const gchar *key, const gchar *value)
{
GKeyFile *gkeyfile;
gchar *content;
gsize length;
gkeyfile = g_key_file_new ();
g_key_file_load_from_file (gkeyfile, remmina_pref_file, G_KEY_FILE_NONE, NULL);
g_key_file_set_string (gkeyfile, "remmina_pref", key, value);
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,代码行数:16,代码来源:remminapref.c
示例17: set_network_setting
/*
* @param config : the key to be set
* @param setting : The value to be set
*/
set_config_result_t set_network_setting(const char *config, const char *setting)
{
GKeyFile *settingsfile;
gboolean test = FALSE;
gchar *keyfile;
if(!strcmp(config, NETWORK_IP_KEY) || !strcmp(config, NETWORK_GATEWAY_KEY))
if(validate_ip(setting) != 0)
return SET_CONFIG_ERROR;
settingsfile = g_key_file_new();
test = g_key_file_load_from_file(settingsfile, FS_MOUNT_CONFIG_FILE, G_KEY_FILE_NONE, NULL);
if(!strcmp(config, NETWORK_IP_KEY) || !strcmp(config, NETWORK_INTERFACE_KEY) || !strcmp(config, NETWORK_GATEWAY_KEY))
{
set_config_result_t ret = SET_CONFIG_ERROR;
if (test)
{
if(config_value_changed(settingsfile, NETWORK_ENTRY, config, setting))
{
g_key_file_free(settingsfile);
return SET_CONFIG_UNCHANGED;
}
}
else
{
log_debug("No conffile. Creating.\n");
create_conf_file();
}
g_key_file_set_string(settingsfile, NETWORK_ENTRY, config, setting);
keyfile = g_key_file_to_data (settingsfile, NULL, NULL);
/* free the settingsfile before writing things out to be sure
the contents will be correctly written to file afterwards.
Just a precaution. */
g_key_file_free(settingsfile);
if (g_file_set_contents(FS_MOUNT_CONFIG_FILE, keyfile, -1, NULL))
ret = SET_CONFIG_UPDATED;
free(keyfile);
return ret;
}
else
{
g_key_file_free(settingsfile);
return SET_CONFIG_ERROR;
}
}
开发者ID:merlin1991,项目名称:usb-moded,代码行数:51,代码来源:usb_moded-config.c
示例18: save_config
static void
save_config( GKeyFile *file )
{
GKeyFile *config = pgm_main_window_get_config();
g_key_file_set_boolean( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"AutoIndent",
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( auto_indent ) ) );
g_key_file_set_boolean( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"IndentOnTab",
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( indent_on_tab ) ) );
g_key_file_set_boolean( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"ShowLineNumbers",
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( show_line_numbers ) ) );
g_key_file_set_boolean( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"SmartHomeEnd",
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( smart_home_end ) ) );
g_key_file_set_boolean( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"InsertSpacesInsteadOfTab",
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( insert_spaces_instead_of_tabs ) ) );
g_key_file_set_boolean( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"HighlightCurrentLine",
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( highlight_current_line ) ) );
g_key_file_set_integer( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"IndentWidth",
gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( indent_width_editor ) ) );
g_key_file_set_integer( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"TabWidth",
gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( tab_width_editor ) ) );
g_key_file_set_string( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"Font",
gtk_font_button_get_font_name( GTK_FONT_BUTTON( font_editor ) ) );
g_key_file_set_integer( config,
PGM_SQL_EDITOR_CONFIG_GROUP,
"DrawSpaces",
gtk_combo_box_get_active( GTK_COMBO_BOX( draw_spaces_editor ) ) );
pgm_sql_editor_reload_config();
}
开发者ID:Torvus,项目名称:pgmanager,代码行数:47,代码来源:pgmsqleditorpreference.c
示例19: save_settings
void save_settings(Preferences *pref)
{
gchar *path;
gchar *dir;
GKeyFile* key;
GError *err = NULL;
gchar *data;
gsize data_len = 0;
GtkWidget *dialog;
path = get_config_path();
dir = g_dirname(path);
key = g_key_file_new();
g_key_file_load_from_file(key, path, G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
g_key_file_set_integer(key, "core", "backend", pref->backend);
g_key_file_set_string(key, "core", "download_dir", pref->download_dir);
g_key_file_set_integer(key, "core", "max_concurrent_downloads", pref->max_concurrent_downloads);
g_key_file_set_boolean(key, "core", "use_schedule", pref->use_schedule);
g_key_file_set_integer(key, "core", "start_time_hour", pref->start_time_hour);
g_key_file_set_integer(key, "core", "start_time_minute", pref->start_time_minute);
g_key_file_set_integer(key, "core", "end_time_hour", pref->end_time_hour);
g_key_file_set_integer(key, "core", "end_time_minute", pref->end_time_minute);
data = g_key_file_to_data(key, &data_len, &err);
if (err) {
dialog = gtk_message_dialog_new (GTK_WINDOW(g_GAria2),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Error: %s", err->message);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_error_free(err);
}
if (!g_file_test(dir, G_FILE_TEST_EXISTS)) {
g_mkdir_with_parents(dir, 0700);
}
g_file_set_contents(path, data, data_len, NULL);
g_free(data);
g_free(path);
g_free(dir);
g_key_file_free(key);
}
开发者ID:BackupTheBerlios,项目名称:garia2,代码行数:47,代码来源:preference.c
示例20: _accounts_rename
static gboolean
_accounts_rename(const char * const account_name, const char * const new_name)
{
if (g_key_file_has_group(accounts, new_name)) {
return FALSE;
}
if (!g_key_file_has_group(accounts, account_name)) {
return FALSE;
}
g_key_file_set_boolean(accounts, new_name, "enabled",
g_key_file_get_boolean(accounts, account_name, "enabled", NULL));
g_key_file_set_integer(accounts, new_name, "priority.online",
g_key_file_get_integer(accounts, account_name, "priority.online", NULL));
g_key_file_set_integer(accounts, new_name, "priority.chat",
g_key_file_get_integer(accounts, account_name, "priority.chat", NULL));
g_key_file_set_integer(accounts, new_name, "priority.away",
g_key_file_get_integer(accounts, account_name, "priority.away", NULL));
g_key_file_set_integer(accounts, new_name, "priority.xa",
g_key_file_get_integer(accounts, account_name, "priority.xa", NULL));
g_key_file_set_integer(accounts, new_name, "priority.dnd",
g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL));
// copy other string properties
int i;
for (i = 0; i < ARRAY_SIZE(string_keys); i++) {
char *value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL);
if (value != NULL) {
g_key_file_set_string(accounts, new_name, string_keys[i], value);
g_free(value);
}
}
g_key_file_remove_group(accounts, account_name, NULL);
_save_accounts();
autocomplete_remove(all_ac, account_name);
autocomplete_add(all_ac, new_name);
if (g_key_file_get_boolean(accounts, new_name, "enabled", NULL)) {
autocomplete_remove(enabled_ac, account_name);
autocomplete_add(enabled_ac, new_name);
}
return TRUE;
}
开发者ID:NYAMNYAM3,项目名称:profanity,代码行数:47,代码来源:accounts.c
注:本文中的g_key_file_set_string函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论