Пример #1
0
/* Write the project settings as well as the project session files into its configuration files.
 * emit_signal defines whether the project-save signal should be emitted. When write_config()
 * is called while closing a project, this is used to skip emitting the signal because
 * project-close will be emitted afterwards.
 * Returns: TRUE if project file was written successfully. */
static gboolean write_config(gboolean emit_signal)
{
	GeanyProject *p;
	GKeyFile *config;
	gchar *filename;
	gchar *data;
	gboolean ret = FALSE;

	g_return_val_if_fail(app->project != NULL, FALSE);

	p = app->project;

	config = g_key_file_new();
	/* try to load an existing config to keep manually added comments */
	filename = utils_get_locale_from_utf8(p->file_name);
	g_key_file_load_from_file(config, filename, G_KEY_FILE_NONE, NULL);

	stash_group_save_to_key_file(indent_group, config);

	g_key_file_set_string(config, "project", "name", p->name);
	g_key_file_set_string(config, "project", "base_path", p->base_path);

	if (p->description)
		g_key_file_set_string(config, "project", "description", p->description);
	if (p->file_patterns)
		g_key_file_set_string_list(config, "project", "file_patterns",
			(const gchar**) p->file_patterns, g_strv_length(p->file_patterns));

	g_key_file_set_integer(config, "long line marker", "long_line_behaviour", p->long_line_behaviour);
	g_key_file_set_integer(config, "long line marker", "long_line_column", p->long_line_column);

	/* store the session files into the project too */
	if (project_prefs.project_session)
		configuration_save_session_files(config);
	build_save_menu(config, (gpointer)p, GEANY_BCS_PROJ);
	if (emit_signal)
	{
		g_signal_emit_by_name(geany_object, "project-save", config);
	}
	/* write the file */
	data = g_key_file_to_data(config, NULL, NULL);
	ret = (utils_write_file(filename, data) == 0);

	g_free(data);
	g_free(filename);
	g_key_file_free(config);

	return ret;
}
Пример #2
0
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 ;
}
Пример #3
0
void
ccnet_session_save_config (CcnetSession *session)
{
    GError *error = NULL;
    char *str;
    FILE *fp;

    ccnet_message ("[Session] Saving configure file\n");
    if (session->saving_pub) {
        /* only update timestamp when pubinfo changes */
        save_pubinfo (session);
        session->saving_pub = 0;
    }

    g_key_file_set_string (session->keyf, "General", "NAME",
                           session->base.name);
    g_key_file_set_string (session->keyf, "General", "ID", 
                           session->base.id);
    g_key_file_set_string (session->keyf, "General", "USER_NAME", 
                           session->base.user_name);
#ifdef CCNET_SERVER
    g_key_file_set_string (session->keyf, "General", "SERVICE_URL",
                           session->base.service_url?session->base.service_url:"");
#endif
    g_key_file_set_integer (session->keyf, "Network", "PORT",
                            session->base.public_port);

    g_key_file_set_integer (session->keyf, "Client", "PORT", session->local_port);

    str = g_key_file_to_data (session->keyf, NULL, &error);
    if (error) {
        ccnet_warning ("Can't save unauth peer info: %s\n",
                       error->message);
        return;
    }

    if ((fp = g_fopen (session->config_file, "wb")) == NULL) {
        ccnet_warning ("Can't save session conf: %s\n", strerror(errno));
        g_free (str);
        return;
    }

    fputs (str, fp);
    fclose (fp);

    g_free (str);
    return;
}
/** Save enough information about this owner tree page that it can
 *  be recreated next time the user starts gnucash.
 *
 *  @param plugin_page The page to save.
 *
 *  @param key_file A pointer to the GKeyFile data structure where the
 *  page information should be written.
 *
 *  @param group_name The group name to use when saving data. */
static void
gnc_plugin_page_owner_tree_save_page (GncPluginPage *plugin_page,
                                      GKeyFile *key_file,
                                      const gchar *group_name)
{
    GncPluginPageOwnerTree *owner_page;
    GncPluginPageOwnerTreePrivate *priv;

    g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
    g_return_if_fail (key_file != NULL);
    g_return_if_fail (group_name != NULL);

    ENTER("page %p, key_file %p, group_name %s", plugin_page, key_file,
          group_name);

    owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(plugin_page);
    priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);

    g_key_file_set_integer(key_file, group_name, OWNER_TYPE_LABEL,
                           priv->owner_type);

    gnc_tree_view_owner_save(GNC_TREE_VIEW_OWNER(priv->tree_view),
                             &priv->fd, key_file, group_name);
    LEAVE(" ");
}
Пример #5
0
static void mame_gui_prefs_save_int (MameGuiPrefs *pr, GParamSpec *param, gpointer user_data)
{
	gchar *key;
	gint value;

	g_return_if_fail (pr->priv->prefs_ini_file != NULL);
	g_return_if_fail (pr->priv->filename != NULL);
	
	key = g_strdup (g_param_spec_get_name (param));
	
	g_return_if_fail (key != NULL);	
	
	g_object_get (pr, key, &value, NULL);
	
	GMAMEUI_DEBUG ("Saving %s - setting integer value %s with value %d",
		       pr->priv->filename, key, value);

	/* Set the value and save the file */
	g_key_file_set_integer (pr->priv->prefs_ini_file, "Preferences", key, value);
	g_key_file_save_to_file (pr->priv->prefs_ini_file, pr->priv->filename);
	
	g_free (key);
	
	/* FIXME TODO Preferences is a temporary group name - need to find a way to
	   add more groups */
}
Пример #6
0
static gboolean recent_program_save(GKeyFile *config, const char *section,
	RecentProgram *recent)
{
	g_key_file_set_string(config, section, "name", recent->name);
	g_key_file_set_integer(config, section, "id", recent->id);
	return TRUE;
}
Пример #7
0
void appconfig_write_file() {
    GKeyFile *keyfile = g_key_file_new();

    g_key_file_load_from_file(keyfile, config_filename, G_KEY_FILE_KEEP_COMMENTS, NULL);

    ConfigOption *option = config_options;
    for (option=config_options; option->key; option++) {
        switch (option->type) {
            case INTEGER:
                g_key_file_set_integer(keyfile, "wavbreaker", option->key,
                        config_option_get_integer(option));
                break;
            case BOOLEAN:
                g_key_file_set_boolean(keyfile, "wavbreaker", option->key,
                        config_option_get_integer(option));
                break;
            case STRING:
                g_key_file_set_string(keyfile, "wavbreaker", option->key,
                        config_option_get_string(option));
                break;
            default:
                g_warning("Invalid option type: %d\n", option->type);
                break;
        }
    }

    if (!g_key_file_save_to_file(keyfile, config_filename, NULL)) {
        g_warning("Could not save settings");
    }

    g_key_file_free(keyfile);
}
Пример #8
0
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);
}
Пример #9
0
void sat_cfg_set_int(sat_cfg_int_e param, gint value)
{
    if (param < SAT_CFG_INT_NUM)
    {
        if (config == NULL)
        {
            sat_log_log (SAT_LOG_LEVEL_ERROR,
                         _("%s: Module not initialised\n"),
                         __func__);
        }
        else
        {
            g_key_file_set_integer (config,
                                    sat_cfg_int[param].group,
                                    sat_cfg_int[param].key,
                                    value);
        }

    }
    else
    {
        sat_log_log (SAT_LOG_LEVEL_ERROR,
                     _("%s: Unknown INT param index (%d)\n"),
                     __func__, param);
    }
}
Пример #10
0
PluginInfoCache::PluginInfoCache()
    : m_cacheFile(g_key_file_new())
    , m_readOnlyMode(false)
{
    GUniquePtr<char> cacheDirectory(g_build_filename(g_get_user_cache_dir(), "webkitgtk", nullptr));
    if (WebCore::makeAllDirectories(cacheDirectory.get())) {
        m_cachePath.reset(g_build_filename(cacheDirectory.get(), "plugins", nullptr));
        g_key_file_load_from_file(m_cacheFile.get(), m_cachePath.get(), G_KEY_FILE_NONE, nullptr);
    }

    if (g_key_file_has_group(m_cacheFile.get(), "schema")) {
        unsigned schemaVersion = static_cast<unsigned>(g_key_file_get_integer(m_cacheFile.get(), "schema", "version", nullptr));
        if (schemaVersion < gSchemaVersion) {
            // Cache file using an old schema, create a new empty file.
            m_cacheFile.reset(g_key_file_new());
        } else if (schemaVersion > gSchemaVersion) {
            // Cache file using a newer schema, use the cache in read only mode.
            m_readOnlyMode = true;
        } else {
            // Same schema version, we don't need to update it.
            return;
        }
    }

    g_key_file_set_integer(m_cacheFile.get(), "schema", "version", static_cast<unsigned>(gSchemaVersion));
}
Пример #11
0
void
prefs_set_max_log_size(gint value)
{
    log_maxsize = value;
    g_key_file_set_integer(prefs, PREF_GROUP_LOGGING, "maxsize", value);
    _save_prefs();
}
Пример #12
0
void
propono_cache_prefs_set_integer (const gchar *group, const gchar *key, gint value)
{
    g_return_if_fail (keyfile != NULL);

    g_key_file_set_integer (keyfile, group, key, value);
}
Пример #13
0
void test_setinteger()
{
	GKeyFile *keyfile;
	gint *value;
	gsize n = 2;
	
	gint list[2] = {111,222};
	
	const gchar *data = 
	    "[1]\n"
	    "key1=123\n"
	    "key2=456\n";

	keyfile = load_data (data, 0);
	
	check_integer_value (keyfile, "1", "key1", 123);
	g_key_file_set_integer(keyfile,"1","key1",789);
	check_integer_value (keyfile, "1", "key1", 789);
	
	g_key_file_set_integer_list(keyfile,"1","key1",list,2);
	
	value = g_key_file_get_integer_list(keyfile, "1", "key1",&n, NULL);
	
	g_assert(value[0] == 111);
	g_assert(value[1] == 222);
	
}
Пример #14
0
PluginInfoCache::PluginInfoCache()
    : m_cacheFile(g_key_file_new())
    , m_saveToFileIdle(RunLoop::main(), this, &PluginInfoCache::saveToFile)
    , m_readOnlyMode(false)
{
    m_saveToFileIdle.setPriority(G_PRIORITY_DEFAULT_IDLE);

    GUniquePtr<char> cacheDirectory(g_build_filename(g_get_user_cache_dir(), "webkitgtk", nullptr));
    if (WebCore::makeAllDirectories(cacheDirectory.get())) {
        // Delete old cache file.
        GUniquePtr<char> oldCachePath(g_build_filename(cacheDirectory.get(), "plugins", nullptr));
        WebCore::deleteFile(WebCore::filenameToString(oldCachePath.get()));

        m_cachePath.reset(g_build_filename(cacheDirectory.get(), cacheFilenameForCurrentDisplay(), nullptr));
        g_key_file_load_from_file(m_cacheFile.get(), m_cachePath.get(), G_KEY_FILE_NONE, nullptr);
    }

    if (g_key_file_has_group(m_cacheFile.get(), "schema")) {
        unsigned schemaVersion = static_cast<unsigned>(g_key_file_get_integer(m_cacheFile.get(), "schema", "version", nullptr));
        if (schemaVersion < gSchemaVersion) {
            // Cache file using an old schema, create a new empty file.
            m_cacheFile.reset(g_key_file_new());
        } else if (schemaVersion > gSchemaVersion) {
            // Cache file using a newer schema, use the cache in read only mode.
            m_readOnlyMode = true;
        } else {
            // Same schema version, we don't need to update it.
            return;
        }
    }

    g_key_file_set_integer(m_cacheFile.get(), "schema", "version", static_cast<unsigned>(gSchemaVersion));
}
Пример #15
0
/* Sort changed callback */
static void
gnc_split_reg2_sort_changed_cb (GtkTreeSortable *sortable, gpointer user_data)
{
    GNCSplitReg2 *gsr = user_data;
    GncTreeViewSplitReg *view;
    GncTreeModelSplitReg *model;
    GtkSortType   type;
    gint          sortcol;
    gint          sort_depth;
    const gchar  *state_section;
    GKeyFile *state_file = gnc_state_get_current();

    gtk_tree_sortable_get_sort_column_id (sortable, &sortcol, &type);
    ENTER("sortcol is %d", sortcol);

    view = gnc_ledger_display2_get_split_view_register (gsr->ledger);
    model = gnc_ledger_display2_get_split_model_register (gsr->ledger);

    sort_depth = gnc_tree_view_reg_get_selected_row_depth (view);
    if (sort_depth != 0)
        model->sort_depth = sort_depth;

    model->sort_col = sortcol;
    model->sort_direction = type;

    /* Save the sort depth state */
    state_section = gnc_tree_view_get_state_section (GNC_TREE_VIEW (view));
    g_key_file_set_integer (state_file, state_section, "sort_depth", model->sort_depth);

    LEAVE("m_sort_col %d, m_sort_direction is %d  m_sort_depth is %d", model->sort_col, model->sort_direction, model->sort_depth);

    if (sortcol != -1)
        gnc_ledger_display2_refresh (gsr->ledger);
}
Пример #16
0
void rclib_settings_set_integer(const gchar *group_name,
    const gchar *key, gint value)
{
    settings_dirty = TRUE;
    if(settings_keyfile==NULL) return;
    g_key_file_set_integer(settings_keyfile, group_name, key, value);
}
Пример #17
0
void
libbalsa_conf_set_int_(const char *path, int value, gboolean priv)
{
    g_key_file_set_integer(LBC_KEY_FILE(priv), lbc_groups->data, path,
                           value);
    LBC_CHANGED(priv);
}
Пример #18
0
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_integer(config, "geniuspaste", "website", website_selected);
    g_key_file_set_boolean(config, "geniuspaste", "open_browser", check_button_is_checked);
    g_key_file_set_string(config, "geniuspaste", "author_name", author_name);

    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
    {
        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);
}
Пример #19
0
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;
}
Пример #20
0
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();
}
Пример #21
0
void
accounts_set_priority_dnd(const char *const account_name, const gint value)
{
    if (accounts_account_exists(account_name)) {
        g_key_file_set_integer(accounts, account_name, "priority.dnd", value);
        _save_accounts();
    }
}
Пример #22
0
void
accounts_set_port(const char *const account_name, const int value)
{
    if (value != 0) {
        g_key_file_set_integer(accounts, account_name, "port", value);
        _save_accounts();
    }
}
void cd_mail_create_mh_params( GKeyFile *pKeyFile, gchar *pMailAccountName )
{
	g_key_file_set_string (pKeyFile, pMailAccountName, "type", "mh");
	g_key_file_set_comment (pKeyFile, pMailAccountName, "type", ">0 ", NULL);

	g_key_file_set_integer (pKeyFile, pMailAccountName, "timeout mn", 10);
	g_key_file_set_comment (pKeyFile, pMailAccountName, "timeout mn", "I0[1;30] timeout:\n{In minutes.}", NULL);
}
Пример #24
0
static void persistent_state_to_keyfile(const GAPersistentState *pstate,
                                        GKeyFile *keyfile)
{
    g_assert(pstate);
    g_assert(keyfile);

    g_key_file_set_integer(keyfile, "global", "fd_counter", pstate->fd_counter);
}
Пример #25
0
static void
_accounts_set_priority_online(const char * const account_name, const gint value)
{
    if (accounts_account_exists(account_name)) {
        g_key_file_set_integer(accounts, account_name, "priority.online", value);
        _save_accounts();
    }
}
Пример #26
0
void
mc_config_set_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int value)
{
    if (!mc_config || !group || !param)
        return;

    g_key_file_set_integer (mc_config->handle, group, param, value);
}
Пример #27
0
void
maki_instance_config_set_integer (makiInstance* inst, gchar const* group, gchar const* key, gint value)
{
	g_mutex_lock(inst->mutex.config);
	g_key_file_set_integer(inst->key_file, group, key, value);
	maki_instance_config_save(inst);
	g_mutex_unlock(inst->mutex.config);
}
Пример #28
0
gboolean desmume_config_update_keys(GKeyFile *keyfile)
{
    for(int i = 0; i < NB_KEYS; i++) {
        g_key_file_set_integer(keyfile, "KEYS", key_names[i], keyboard_cfg[i]);
    }

    return desmume_config_write_file(keyfile);
}
Пример #29
0
/*
 * save all settings as a resource file "print-settings"
 * and as an image parasite
 */
void
print_settings_save (PrintData *data)
{
  GKeyFile *key_file = print_settings_key_file_from_settings (data);

  /* image setup */
  if (gimp_image_is_valid (data->image_id))
    {
      g_key_file_set_integer (key_file, "image-setup",
                              "unit", data->unit);
      g_key_file_set_double  (key_file, "image-setup",
                              "x-resolution", data->xres);
      g_key_file_set_double  (key_file, "image-setup",
                              "y-resolution", data->yres);
      g_key_file_set_double  (key_file, "image-setup",
                              "x-offset", data->offset_x);
      g_key_file_set_double  (key_file, "image-setup",
                              "y-offset", data->offset_y);
      g_key_file_set_integer (key_file, "image-setup",
                              "center-mode", data->center);
      g_key_file_set_boolean (key_file, "image-setup",
                              "use-full-page", data->use_full_page);
      g_key_file_set_boolean (key_file, "image-setup",
                              "crop-marks", data->draw_crop_marks);

      print_utils_key_file_save_as_parasite (key_file,
                                             data->image_id,
                                             PRINT_SETTINGS_NAME);
    }

  /* some settings shouldn't be made persistent on a global level,
   * so they are only stored in the image, not in the rcfile
   */

  g_key_file_remove_key (key_file, "image-setup", "x-resolution", NULL);
  g_key_file_remove_key (key_file, "image-setup", "y-resolution", NULL);
  g_key_file_remove_key (key_file, "image-setup", "x-offset", NULL);
  g_key_file_remove_key (key_file, "image-setup", "y-offset", NULL);

  g_key_file_remove_key (key_file, PRINT_SETTINGS_NAME, "n-copies", NULL);

  print_utils_key_file_save_as_rcfile (key_file, PRINT_SETTINGS_NAME);

  g_key_file_free (key_file);
}
Пример #30
0
gboolean script_list_save(GtkListStore* script_list, GError** error)
{
	gboolean ret = FALSE;
	GtkTreeModel* model = GTK_TREE_MODEL(script_list);
	GKeyFile* keyfile = g_key_file_new();

	GtkTreeIter iter;
	gboolean valid = gtk_tree_model_get_iter_first(model, &iter);
	while (valid) {
		gchar* name;
		gchar* description;
		gchar* command;
		gint interval;
		gboolean enabled;
		enum script_event blink_on;
		enum script_event notify_on;

		gtk_tree_model_get(model, &iter,
			COLUMN_NAME, &name,
			COLUMN_DESCRIPTION, &description,
			COLUMN_COMMAND, &command,
			COLUMN_INTERVAL, &interval,
			COLUMN_ENABLED, &enabled,
			COLUMN_BLINK_ON, &blink_on,
			COLUMN_NOTIFY_ON, &notify_on,
			-1);

		g_key_file_set_string(keyfile, name, "description", description);
		g_key_file_set_string(keyfile, name, "command", command);
		g_key_file_set_integer(keyfile, name, "interval", interval);
		g_key_file_set_boolean(keyfile, name, "enabled", enabled);
		g_assert(blink_on < EVENT_COUNT);
		g_key_file_set_string(keyfile, name, "blink_on", event_str[blink_on]);
		g_assert(notify_on < EVENT_COUNT);
		g_key_file_set_string(keyfile, name, "notify_on", event_str[notify_on]);

		valid = gtk_tree_model_iter_next(model, &iter);
	}

	gsize length;
	gchar* data = g_key_file_to_data(keyfile, &length, error);

	if (data) {
		gchar* nall_dir = g_build_path("/", g_get_home_dir(), ".nall", NULL);
		g_mkdir_with_parents(nall_dir, 0755);

		gchar* cfgfile = g_build_path("/", nall_dir, "nall.ini", NULL);
		ret = g_file_set_contents(cfgfile, data, length, error);

		g_free(cfgfile);
		g_free(nall_dir);
		g_free(data);
	}

	g_key_file_free(keyfile);
	return ret;
}