Use the newer libSystem Config API to load and save preferences
This commit is contained in:
parent
2e32d7a948
commit
c20d211b73
|
@ -51,7 +51,6 @@ static char const _license[] =
|
|||
#define _(string) gettext(string)
|
||||
#define N_(string) (string)
|
||||
|
||||
#define COMMON_CONFIG_FILENAME
|
||||
#define COMMON_DND
|
||||
#define COMMON_EXEC
|
||||
#define COMMON_GET_ABSOLUTE_PATH
|
||||
|
@ -815,18 +814,15 @@ static void _error_response(gpointer data)
|
|||
/* browser_config_load */
|
||||
int browser_config_load(Browser * browser)
|
||||
{
|
||||
String * filename;
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
String * p = NULL;
|
||||
#endif
|
||||
|
||||
if(browser->config == NULL)
|
||||
return 0; /* XXX ignore error */
|
||||
if((filename = _common_config_filename(BROWSER_CONFIG_FILE)) == NULL)
|
||||
return -1;
|
||||
if(config_load(browser->config, filename) != 0)
|
||||
if(config_load_preferences(browser->config, "DeforaOS/" VENDOR, PACKAGE,
|
||||
BROWSER_CONFIG_FILE) != 0)
|
||||
browser_error(NULL, error_get(NULL), 1);
|
||||
string_delete(filename);
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
/* XXX deserves a rework (enum) */
|
||||
if(_config_load_string(browser->config, "default_view", &p) == 0
|
||||
|
@ -859,15 +855,12 @@ int browser_config_load(Browser * browser)
|
|||
int browser_config_save(Browser * browser)
|
||||
{
|
||||
int ret = 0;
|
||||
String * filename;
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
char * str[BV_COUNT] = { "details", "icons", "list", "thumbnails" };
|
||||
#endif
|
||||
|
||||
if(browser->config == NULL)
|
||||
return 0; /* XXX ignore error */
|
||||
if((filename = _common_config_filename(BROWSER_CONFIG_FILE)) == NULL)
|
||||
return 1;
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
/* XXX deserves a rework (enum) */
|
||||
if(browser->prefs.default_view >= BV_FIRST
|
||||
|
@ -884,8 +877,9 @@ int browser_config_save(Browser * browser)
|
|||
ret |= _config_save_boolean(browser->config, "show_hidden_files",
|
||||
browser->prefs.show_hidden_files);
|
||||
if(ret == 0)
|
||||
ret |= config_save(browser->config, filename);
|
||||
string_delete(filename);
|
||||
ret |= config_save_preferences_user(browser->config,
|
||||
"DeforaOS/" VENDOR, PACKAGE,
|
||||
BROWSER_CONFIG_FILE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2527,18 +2521,16 @@ static int _browser_config_set(Browser * browser, char const * section,
|
|||
{
|
||||
int ret;
|
||||
String * s = NULL;
|
||||
String * filename;
|
||||
|
||||
if(section != NULL && (s = string_new_append("plugin::", section, NULL))
|
||||
== NULL)
|
||||
return -browser_error(NULL, error_get(NULL), 1);
|
||||
if((ret = config_set(browser->config, s, variable, value)) == 0
|
||||
&& (filename = _common_config_filename(
|
||||
BROWSER_CONFIG_FILE)) != NULL)
|
||||
if((ret = config_set(browser->config, s, variable, value)) == 0)
|
||||
{
|
||||
if(config_save(browser->config, filename) != 0)
|
||||
if(config_save_preferences_user(browser->config,
|
||||
"DeforaOS/" VENDOR, PACKAGE,
|
||||
BROWSER_CONFIG_FILE) != 0)
|
||||
browser_error(NULL, error_get(NULL), 1);
|
||||
string_delete(filename);
|
||||
}
|
||||
string_delete(s);
|
||||
return ret;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
/* Browser */
|
||||
/* defaults */
|
||||
# define BROWSER_CONFIG_FILE ".browser"
|
||||
# define BROWSER_CONFIG_FILE "Browser.conf"
|
||||
# define BROWSER_ICON_WRAP_WIDTH 96
|
||||
# define BROWSER_LIST_WRAP_WIDTH 118
|
||||
# define BROWSER_THUMBNAIL_WRAP_WIDTH 112
|
||||
|
|
16
src/common.c
16
src/common.c
|
@ -39,10 +39,6 @@
|
|||
|
||||
|
||||
/* prototypes */
|
||||
#ifdef COMMON_CONFIG_FILENAME
|
||||
static String * _common_config_filename(String const * name);
|
||||
#endif
|
||||
|
||||
#ifdef COMMON_DND
|
||||
static int _common_drag_data_received(GdkDragContext * context,
|
||||
GtkSelectionData * seldata, char const * dest);
|
||||
|
@ -66,18 +62,6 @@ static int _common_symlink(GtkWidget * window, char const * cur);
|
|||
|
||||
|
||||
/* functions */
|
||||
#ifdef COMMON_CONFIG_FILENAME
|
||||
static String * _common_config_filename(String const * name)
|
||||
{
|
||||
char const * homedir;
|
||||
|
||||
if((homedir = getenv("HOME")) == NULL)
|
||||
homedir = g_get_home_dir();
|
||||
return string_new_append(homedir, "/", name, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef COMMON_DND
|
||||
/* common_drag_data_received */
|
||||
static int _common_drag_data_received(GdkDragContext * context,
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#define N_(string) (string)
|
||||
|
||||
#define COMMON_GET_ABSOLUTE_PATH
|
||||
#define COMMON_CONFIG_FILENAME
|
||||
#include "common.c"
|
||||
|
||||
/* constants */
|
||||
|
@ -236,13 +235,13 @@ static int _new_load(Properties * properties, char const * plugin)
|
|||
size_t i;
|
||||
int cnt = 0;
|
||||
|
||||
p = _common_config_filename(BROWSER_CONFIG_FILE);
|
||||
if((properties->config = config_new()) != NULL
|
||||
&& config_load(properties->config, p) == 0
|
||||
&& config_load_preferences(properties->config,
|
||||
"DeforaOS/" VENDOR, PACKAGE,
|
||||
BROWSER_CONFIG_FILE) == 0
|
||||
&& (plugins = config_get(properties->config, NULL,
|
||||
"properties")) == NULL)
|
||||
plugins = "properties,preview";
|
||||
string_delete(p);
|
||||
if(plugin != NULL)
|
||||
{
|
||||
if(_properties_load(properties, plugin) == 0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user