forked from enlightenment/efl
ecore_config uses eet for storage now... check the disk space savings:
-rw-r--r-- 1 raster raster 12288 Oct 19 15:29 config.db -rw-r--r-- 1 raster raster 687 Oct 19 15:29 config.eet also.. edb goes back to obscurity as a little/non use lib again :) SVN revision: 11902
This commit is contained in:
parent
8912db12ef
commit
e764a022e7
|
@ -546,23 +546,23 @@ AC_ARG_ENABLE(ecore-config,
|
|||
)
|
||||
|
||||
if test "x$have_ecore_config" = "xyes"; then
|
||||
AC_ARG_WITH(edb-config,
|
||||
[ --with-edb-config=EDB_CONFIG use edb-config specified ],
|
||||
AC_ARG_WITH(eet-config,
|
||||
[ --with-eet-config=EET_CONFIG use eet-config specified ],
|
||||
[
|
||||
PROG_EDB_CONFIG=$withval;
|
||||
echo "using "$PROG_EDB_CONFIG" for edb-config";
|
||||
PROG_EET_CONFIG=$withval;
|
||||
echo "using "$PROG_EET_CONFIG" for eet-config";
|
||||
],[
|
||||
PROG="edb-config";
|
||||
AC_PATH_PROG(PROG_EDB_CONFIG, $PROG, "", $PATH)
|
||||
PROG="eet-config";
|
||||
AC_PATH_PROG(PROG_EET_CONFIG, $PROG, "", $PATH)
|
||||
])
|
||||
if [ test -z "$EDB_CONFIG" ]; then EDB_CONFIG=$PROG_EDB_CONFIG; fi
|
||||
edb_cflags=`$EDB_CONFIG --cflags`
|
||||
edb_libs=`$EDB_CONFIG --libs`
|
||||
if [ test -z "$EET_CONFIG" ]; then EET_CONFIG=$PROG_EET_CONFIG; fi
|
||||
eet_cflags=`$EET_CONFIG --cflags`
|
||||
eet_libs=`$EET_CONFIG --libs`
|
||||
AM_CONDITIONAL(BUILD_ECORE_CONFIG, true)
|
||||
ecore_config_libs="-lecore_config";
|
||||
AC_DEFINE(BUILD_ECORE_CONFIG, 1, [Build Ecore_Config Module])
|
||||
AC_SUBST(edb_libs)
|
||||
AC_SUBST(edb_cflags)
|
||||
AC_SUBST(eet_libs)
|
||||
AC_SUBST(eet_cflags)
|
||||
else
|
||||
AM_CONDITIONAL(BUILD_ECORE_CONFIG, false)
|
||||
fi
|
||||
|
|
|
@ -46,7 +46,7 @@ while test $# -gt 0; do
|
|||
;;
|
||||
--libs)
|
||||
libdirs=-L@libdir@
|
||||
echo $libdirs -lecore @ecore_job_libs@ @ecore_x_libs@ @ecore_evas_libs@ @ecore_con_libs@ @ecore_ipc_libs@ @ecore_txt_libs@ @ecore_fb_libs@ @ecore_config_libs@ @edb_libs@ -lm
|
||||
echo $libdirs -lecore @ecore_job_libs@ @ecore_x_libs@ @ecore_evas_libs@ @ecore_con_libs@ @ecore_ipc_libs@ @ecore_txt_libs@ @ecore_fb_libs@ @ecore_config_libs@ @eet_libs@ -lm
|
||||
;;
|
||||
*)
|
||||
echo "${usage}" 1>&2
|
||||
|
|
|
@ -60,7 +60,7 @@ INCLUDES = \
|
|||
-I$(top_srcdir)/src/lib/ecore_config \
|
||||
@evas_cflags@ \
|
||||
@x_cflags@ \
|
||||
@edb_cflags@
|
||||
@eet_cflags@
|
||||
|
||||
bin_PROGRAMS = \
|
||||
ecore_test \
|
||||
|
|
|
@ -7,7 +7,7 @@ INCLUDES = \
|
|||
-I$(top_builddir)/src/lib/ecore \
|
||||
-I$(top_builddir)/src/lib/ecore_ipc \
|
||||
-I$(top_builddir)/ \
|
||||
@evas_cflags@ @edb_cflags@
|
||||
@evas_cflags@ @eet_cflags@
|
||||
|
||||
CLEANFILES = $(DB)
|
||||
|
||||
|
@ -19,19 +19,19 @@ ecore_config_ipc_ecore_la_LDFLAGS = -no-undefined -module \
|
|||
|
||||
if BUILD_ECORE_CONFIG
|
||||
|
||||
DB = system.db
|
||||
$(DB): Makefile
|
||||
edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/theme/name str "winter"
|
||||
edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/font/path str "$(pkgdatadir)/data/fonts"
|
||||
edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/browser str `which firefox 2>/dev/null || which phoenix 2>/dev/null || which mozilla 2>/dev/null || which opera 2>/dev/null || which konqueror 2>/dev/null || which epiphany 2>/dev/null`
|
||||
edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/email str `which thunderbird 2>/dev/null || which mozilla 2>/dev/null || which kmail 2>/dev/null || which sylpheed 2>/dev/null || which evolution 2>/dev/null`
|
||||
#DB = system.db
|
||||
#$(DB): Makefile
|
||||
# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/theme/name str "winter"
|
||||
# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/font/path str "$(pkgdatadir)/data/fonts"
|
||||
# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/browser str `which firefox 2>/dev/null || which phoenix 2>/dev/null || which mozilla 2>/dev/null || which opera 2>/dev/null || which konqueror 2>/dev/null || which epiphany 2>/dev/null`
|
||||
# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/email str `which thunderbird 2>/dev/null || which mozilla 2>/dev/null || which kmail 2>/dev/null || which sylpheed 2>/dev/null || which evolution 2>/dev/null`
|
||||
|
||||
lib_LTLIBRARIES = libecore_config.la ecore_config_ipc_ecore.la
|
||||
include_HEADERS = \
|
||||
Ecore_Config.h
|
||||
|
||||
config_DATA = $(DB)
|
||||
configdir = $(pkgdatadir)
|
||||
#config_DATA = $(DB)
|
||||
#configdir = $(pkgdatadir)
|
||||
|
||||
libecore_config_la_SOURCES = \
|
||||
ecore_config.c \
|
||||
|
@ -39,11 +39,12 @@ ecore_config_ipc_main.c \
|
|||
ecore_config_util.c \
|
||||
ecore_config_storage.c \
|
||||
ecore_config_extra.c \
|
||||
ecore_config_db.c \
|
||||
ecore_config_private.h
|
||||
|
||||
libecore_config_la_LIBADD = \
|
||||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
@edb_libs@ \
|
||||
@eet_libs@ \
|
||||
@evas_libs@
|
||||
|
||||
libecore_config_la_DEPENDENCIES = \
|
||||
|
@ -60,7 +61,7 @@ ecore_config_ipc_ecore_la_LIBADD = \
|
|||
$(top_builddir)/src/lib/ecore/libecore.la \
|
||||
$(top_builddir)/src/lib/ecore_ipc/libecore_ipc.la \
|
||||
libecore_config.la \
|
||||
@edb_libs@ \
|
||||
@eet_libs@ \
|
||||
@evas_libs@
|
||||
|
||||
endif
|
||||
|
|
|
@ -1561,9 +1561,9 @@ _ecore_config_system_load(void)
|
|||
{ /* debug-only ### FIXME */
|
||||
if ((buf = malloc(PATH_MAX * sizeof(char))))
|
||||
{
|
||||
snprintf(buf, PATH_MAX, "%s/.e/config.db", p);
|
||||
snprintf(buf, PATH_MAX, "%s/.e/config.eet", p);
|
||||
if (ecore_config_file_load(buf) != 0)
|
||||
if (ecore_config_file_load(PACKAGE_DATA_DIR "/system.db") != 0)
|
||||
if (ecore_config_file_load(PACKAGE_DATA_DIR "/system.eet") != 0)
|
||||
return ECORE_CONFIG_ERR_NOFILE;
|
||||
sys = __ecore_config_bundle_local->data;
|
||||
while (sys)
|
||||
|
|
|
@ -0,0 +1,304 @@
|
|||
#include "Ecore_Config.h"
|
||||
#include "ecore_config_private.h"
|
||||
#include <Eet.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct _Ecore_Config_DB_File
|
||||
{
|
||||
Eet_File *ef;
|
||||
};
|
||||
|
||||
Ecore_Config_DB_File *
|
||||
_ecore_config_db_open_read(char *file)
|
||||
{
|
||||
Eet_File *ef;
|
||||
Ecore_Config_DB_File *db;
|
||||
|
||||
eet_init();
|
||||
db = malloc(sizeof(Ecore_Config_DB_File));
|
||||
if (!db) return NULL;
|
||||
ef = eet_open(file, EET_FILE_MODE_READ);
|
||||
if (!ef)
|
||||
{
|
||||
free(db);
|
||||
return NULL;
|
||||
}
|
||||
db->ef = ef;
|
||||
return db;
|
||||
}
|
||||
|
||||
Ecore_Config_DB_File *
|
||||
_ecore_config_db_open_write(char *file)
|
||||
{
|
||||
Eet_File *ef;
|
||||
Ecore_Config_DB_File *db;
|
||||
|
||||
eet_init();
|
||||
db = malloc(sizeof(Ecore_Config_DB_File));
|
||||
if (!db) return NULL;
|
||||
ef = eet_open(file, EET_FILE_MODE_WRITE);
|
||||
if (!ef)
|
||||
{
|
||||
free(db);
|
||||
return NULL;
|
||||
}
|
||||
db->ef = ef;
|
||||
return db;
|
||||
}
|
||||
|
||||
void
|
||||
_ecore_config_db_close(Ecore_Config_DB_File *db)
|
||||
{
|
||||
eet_close(db->ef);
|
||||
free(db);
|
||||
eet_shutdown();
|
||||
}
|
||||
|
||||
char **
|
||||
_ecore_config_db_keys_get(Ecore_Config_DB_File *db, int *num_ret)
|
||||
{
|
||||
char **keys;
|
||||
int key_count;
|
||||
int i;
|
||||
|
||||
keys = eet_list(db->ef, "*", &key_count);
|
||||
if (!keys)
|
||||
{
|
||||
*num_ret = 0;
|
||||
return NULL;
|
||||
}
|
||||
/* make keys freeable - this is safe to do */
|
||||
for (i = 0; i < key_count; i++) keys[i] = strdup(keys[i]);
|
||||
*num_ret = key_count;
|
||||
return keys;
|
||||
}
|
||||
|
||||
char *
|
||||
_ecore_config_db_key_type_get(Ecore_Config_DB_File *db, char *key)
|
||||
{
|
||||
char *data;
|
||||
int size;
|
||||
|
||||
data = eet_read(db->ef, key, &size);
|
||||
if (data)
|
||||
{
|
||||
if (size <= 2)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
if (data[size - 1] != 0)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
_ecore_config_db_key_int_get(Ecore_Config_DB_File *db, char *key, int *dest)
|
||||
{
|
||||
char *data;
|
||||
int size;
|
||||
|
||||
data = eet_read(db->ef, key, &size);
|
||||
if (data)
|
||||
{
|
||||
int l;
|
||||
|
||||
if (size <= 2)
|
||||
{
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
if (data[size - 1] != 0)
|
||||
{
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
/* "type" NIL 1242 NIL */
|
||||
l = strlen(data);
|
||||
if (l >= (size - 1))
|
||||
{
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
*dest = atoi(data + l + 1);
|
||||
free(data);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_ecore_config_db_key_float_get(Ecore_Config_DB_File *db, char *key, double *dest)
|
||||
{
|
||||
char *data;
|
||||
int size;
|
||||
|
||||
data = eet_read(db->ef, key, &size);
|
||||
if (data)
|
||||
{
|
||||
int l;
|
||||
|
||||
if (size <= 2)
|
||||
{
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
if (data[size - 1] != 0)
|
||||
{
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
/* "type" NIL "1242.4234" NIL */
|
||||
l = strlen(data);
|
||||
if (l >= (size - 1))
|
||||
{
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
*dest = atof(data + l + 1);
|
||||
free(data);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
_ecore_config_db_key_str_get(Ecore_Config_DB_File *db, char *key)
|
||||
{
|
||||
char *data;
|
||||
int size;
|
||||
|
||||
data = eet_read(db->ef, key, &size);
|
||||
if (data)
|
||||
{
|
||||
int l;
|
||||
char *s;
|
||||
|
||||
if (size <= 2)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
if (data[size - 1] != 0)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
/* "type" NIL "string goes here" NIL */
|
||||
l = strlen(data);
|
||||
if (l >= (size - 1))
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
s = strdup(data + l + 1);
|
||||
free(data);
|
||||
return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
_ecore_config_db_key_data_get(Ecore_Config_DB_File *db, char *key, int *size_ret)
|
||||
{
|
||||
char *data;
|
||||
int size;
|
||||
|
||||
data = eet_read(db->ef, key, &size);
|
||||
if (data)
|
||||
{
|
||||
int l;
|
||||
char *dat;
|
||||
|
||||
if (size <= 2)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
if (data[size - 1] != 0)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
/* "type" NIL data_goes_here NIL */
|
||||
l = strlen(data);
|
||||
if (l >= (size - 1))
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
dat = malloc(size - (l + 2));
|
||||
memcpy(dat, data + l + 1, size - (l + 2));
|
||||
free(data);
|
||||
*size_ret = size - (l + 2);
|
||||
return dat;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_ecore_config_db_key_int_set(Ecore_Config_DB_File *db, char *key, int val)
|
||||
{
|
||||
char buf[256];
|
||||
int num;
|
||||
|
||||
num = snprintf(buf, sizeof(buf), "%s %i ", "int", val);
|
||||
buf[3] = 0;
|
||||
buf[num - 1] = 0;
|
||||
eet_write(db->ef, key, buf, num, 1);
|
||||
}
|
||||
|
||||
void
|
||||
_ecore_config_db_key_float_set(Ecore_Config_DB_File *db, char *key, double val)
|
||||
{
|
||||
char buf[256];
|
||||
int num;
|
||||
|
||||
num = snprintf(buf, sizeof(buf), "%s %f ", "float", val);
|
||||
buf[5] = 0;
|
||||
buf[num - 1] = 0;
|
||||
eet_write(db->ef, key, buf, num, 1);
|
||||
}
|
||||
|
||||
void
|
||||
_ecore_config_db_key_str_set(Ecore_Config_DB_File *db, char *key, char *str)
|
||||
{
|
||||
char *buf;
|
||||
int num;
|
||||
|
||||
num = 3 + 1 + strlen(str) + 1;
|
||||
buf = malloc(num);
|
||||
if (!buf) return;
|
||||
strcpy(buf, "str");
|
||||
strcpy(buf + 4, str);
|
||||
eet_write(db->ef, key, buf, num, 1);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
_ecore_config_db_key_data_set(Ecore_Config_DB_File *db, char *key, void *data, int data_size)
|
||||
{
|
||||
char *buf;
|
||||
int num;
|
||||
|
||||
num = 3 + 1 + data_size + 1;
|
||||
buf = malloc(num);
|
||||
if (!buf) return;
|
||||
strcpy(buf, "data");
|
||||
memcpy(buf + 5, data, data_size);
|
||||
buf[num - 1] = 0;
|
||||
eet_write(db->ef, key, buf, num, 1);
|
||||
free(buf);
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
/* by Azundris, with thanks to Corey Donohoe <atmos@atmos.org> */
|
||||
|
||||
#include "ecore_config_ipc.h"
|
||||
#include "ecore_config_util.h"
|
||||
|
||||
#include "ecore_config_private.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -18,8 +16,6 @@
|
|||
#include <Ecore.h>
|
||||
#include <Ecore_Ipc.h>
|
||||
|
||||
#include <Edb.h>
|
||||
|
||||
#include "Ecore_Config.h"
|
||||
#include "config.h"
|
||||
|
||||
|
@ -51,68 +47,74 @@ _ecore_config_ipc_ecore_string_get(char **m, char **r)
|
|||
char *
|
||||
_ecore_config_ipc_global_prop_list(Ecore_Config_Server * srv, const long serial)
|
||||
{
|
||||
E_DB_File *db;
|
||||
char **keys;
|
||||
int key_count, x;
|
||||
estring *s;
|
||||
int f;
|
||||
char *buf, *p, *type, *data;
|
||||
Ecore_Config_DB_File *db;
|
||||
char **keys;
|
||||
int key_count, x;
|
||||
estring *s;
|
||||
int f;
|
||||
char buf[PATH_MAX], *p, *type, *data;
|
||||
|
||||
db = NULL;
|
||||
buf = NULL;
|
||||
s = estring_new(8192);
|
||||
f = 0;
|
||||
if ((p = getenv("HOME")))
|
||||
{ /* debug-only ### FIXME */
|
||||
if ((buf = malloc(PATH_MAX * sizeof(char))))
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/.e/config.eet", p);
|
||||
if (!(db = _ecore_config_db_open_read(buf)))
|
||||
{
|
||||
snprintf(buf, PATH_MAX, "%s/.e/config.db", p);
|
||||
db = e_db_open_read(buf);
|
||||
if (!(db = e_db_open_read(buf)))
|
||||
if (!(db = e_db_open_read(buf = PACKAGE_DATA_DIR "/system.db")))
|
||||
return NULL;
|
||||
strcpy(buf, PACKAGE_DATA_DIR"/system.eet");
|
||||
if (!(db = _ecore_config_db_open_read(buf)))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
keys = e_db_dump_key_list(buf, &key_count);
|
||||
free(buf);
|
||||
|
||||
for (x = 0; x < key_count; x++)
|
||||
if (!db) return NULL;
|
||||
key_count = 0;
|
||||
keys = _ecore_config_db_keys_get(db, &key_count);
|
||||
if (keys)
|
||||
{
|
||||
type = e_db_type_get(db, keys[x]);
|
||||
if (!type)
|
||||
type = "?";
|
||||
|
||||
if (!strcmp(type, "int"))
|
||||
estring_appendf(s, "%s%s: integer", f ? "\n" : "", keys[x]);
|
||||
else if (!strcmp(type, "float"))
|
||||
estring_appendf(s, "%s%s: float", f ? "\n" : "", keys[x]);
|
||||
else if (!strcmp(type, "str"))
|
||||
for (x = 0; x < key_count; x++)
|
||||
{
|
||||
data = e_db_str_get(db, keys[x]);
|
||||
if (data)
|
||||
type = _ecore_config_db_key_type_get(db, keys[x]);
|
||||
if (!type) type = "?";
|
||||
if (!strcmp(type, "int"))
|
||||
estring_appendf(s, "%s%s: integer", f ? "\n" : "", keys[x]);
|
||||
else if (!strcmp(type, "float"))
|
||||
estring_appendf(s, "%s%s: float", f ? "\n" : "", keys[x]);
|
||||
else if (!strcmp(type, "str"))
|
||||
{
|
||||
if (ecore_config_type_guess(keys[x], data) == PT_RGB)
|
||||
estring_appendf(s, "%s%s: colour", f ? "\n" : "", keys[x]);
|
||||
data = _ecore_config_db_key_str_get(db, keys[x]);
|
||||
if (data)
|
||||
{
|
||||
if (ecore_config_type_guess(keys[x], data) == PT_RGB)
|
||||
estring_appendf(s, "%s%s: colour", f ? "\n" : "", keys[x]);
|
||||
else
|
||||
estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]);
|
||||
free(data);
|
||||
}
|
||||
else
|
||||
estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]);
|
||||
free(data);
|
||||
{
|
||||
estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]);
|
||||
estring_appendf(s, "%s%s: unknown", f ? "\n" : "", keys[x]);
|
||||
continue;
|
||||
}
|
||||
if (type) free(type);
|
||||
f = 1;
|
||||
}
|
||||
else
|
||||
estring_appendf(s, "%s%s: unknown", f ? "\n" : "", keys[x]);
|
||||
|
||||
if (type)
|
||||
free(type);
|
||||
f = 1;
|
||||
}
|
||||
e_db_close(db);
|
||||
free(keys);
|
||||
|
||||
_ecore_config_db_close(db);
|
||||
if (keys)
|
||||
{
|
||||
for (x = 0; x < key_count; x++)
|
||||
{
|
||||
free(keys[x]);
|
||||
}
|
||||
free(keys);
|
||||
}
|
||||
|
||||
return estring_disown(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,20 @@ extern int DEBUG;
|
|||
# define D(fmt,args...) do { if(DEBUG>=0) fprintf(stderr,fmt,## args); } while(0);
|
||||
# define E(lvl,args...) do { if(DEBUG>=(lvl)) fprintf(stderr,## args); } while(0)
|
||||
|
||||
typedef struct _Ecore_Config_DB_File Ecore_Config_DB_File;
|
||||
|
||||
|
||||
|
||||
|
||||
Ecore_Config_DB_File *_ecore_config_db_open_read(char *file);
|
||||
Ecore_Config_DB_File *_ecore_config_db_open_write(char *file);
|
||||
void _ecore_config_db_close(Ecore_Config_DB_File *db);
|
||||
char **_ecore_config_db_keys_get(Ecore_Config_DB_File *db, int *num_ret);
|
||||
char *_ecore_config_db_key_type_get(Ecore_Config_DB_File *db, char *key);
|
||||
int _ecore_config_db_key_int_get(Ecore_Config_DB_File *db, char *key, int *dest);
|
||||
int _ecore_config_db_key_float_get(Ecore_Config_DB_File *db, char *key, double *dest);
|
||||
char *_ecore_config_db_key_str_get(Ecore_Config_DB_File *db, char *key);
|
||||
void *_ecore_config_db_key_data_get(Ecore_Config_DB_File *db, char *key, int *size_ret);
|
||||
void _ecore_config_db_key_int_set(Ecore_Config_DB_File *db, char *key, int val);
|
||||
void _ecore_config_db_key_float_set(Ecore_Config_DB_File *db, char *key, double val);
|
||||
void _ecore_config_db_key_str_set(Ecore_Config_DB_File *db, char *key, char *str);
|
||||
void _ecore_config_db_key_data_set(Ecore_Config_DB_File *db, char *key, void *data, int data_size);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#include <Edb.h>
|
||||
#include "Ecore_Config.h"
|
||||
|
||||
#include "ecore_config_private.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -24,7 +22,7 @@ ecore_config_load(void)
|
|||
{
|
||||
char file[PATH_MAX];
|
||||
|
||||
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db", getenv("HOME"),
|
||||
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.eet", getenv("HOME"),
|
||||
__ecore_config_app_name);
|
||||
return ecore_config_file_load(file);
|
||||
}
|
||||
|
@ -41,7 +39,7 @@ ecore_config_save(void)
|
|||
{
|
||||
char file[PATH_MAX];
|
||||
|
||||
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db", getenv("HOME"),
|
||||
snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.eet", getenv("HOME"),
|
||||
__ecore_config_app_name);
|
||||
return ecore_config_file_save(file);
|
||||
}
|
||||
|
@ -56,103 +54,110 @@ ecore_config_save(void)
|
|||
int
|
||||
ecore_config_file_load(char *file)
|
||||
{
|
||||
E_DB_File *db;
|
||||
char **keys;
|
||||
int key_count;
|
||||
int x, pt;
|
||||
int itmp;
|
||||
float ftmp;
|
||||
char *type;
|
||||
char *data;
|
||||
Ecore_Config_DB_File *db;
|
||||
char **keys;
|
||||
int key_count;
|
||||
int x, pt;
|
||||
int itmp;
|
||||
double ftmp;
|
||||
char *type;
|
||||
char *data;
|
||||
|
||||
db = NULL;
|
||||
type = NULL;
|
||||
data = NULL;
|
||||
|
||||
db = e_db_open_read(file);
|
||||
db = _ecore_config_db_open_read(file);
|
||||
if (!db)
|
||||
{
|
||||
E(0, "Cannot open database from file %s!\n", file);
|
||||
return ECORE_CONFIG_ERR_NODATA;
|
||||
}
|
||||
|
||||
keys = e_db_dump_key_list(file, &key_count);
|
||||
for (x = 0; x < key_count; x++)
|
||||
key_count = 0;
|
||||
keys = _ecore_config_db_keys_get(db, &key_count);
|
||||
printf("keys = %p, %i\n", keys, key_count);
|
||||
if (keys)
|
||||
{
|
||||
|
||||
type = e_db_type_get(db, keys[x]);
|
||||
if (!type)
|
||||
type = "?";
|
||||
|
||||
if (!strcmp(type, "int"))
|
||||
for (x = 0; x < key_count; x++)
|
||||
{
|
||||
if (e_db_int_get(db, keys[x], &itmp))
|
||||
type = _ecore_config_db_key_type_get(db, keys[x]);
|
||||
printf("%s == %s\n", keys[x], type);
|
||||
if (!type) type = "?";
|
||||
if (!strcmp(type, "int"))
|
||||
{
|
||||
Ecore_Config_Prop *p;
|
||||
|
||||
pt = PT_INT;
|
||||
if ((p = ecore_config_get(keys[x]))) pt = p->type;
|
||||
switch (pt)
|
||||
if (_ecore_config_db_key_int_get(db, keys[x], &itmp))
|
||||
{
|
||||
case PT_BLN:
|
||||
ecore_config_boolean_set(keys[x], itmp);
|
||||
break;
|
||||
default:
|
||||
ecore_config_int_set(keys[x], itmp);
|
||||
break;
|
||||
Ecore_Config_Prop *p;
|
||||
|
||||
pt = PT_INT;
|
||||
if ((p = ecore_config_get(keys[x]))) pt = p->type;
|
||||
switch (pt)
|
||||
{
|
||||
case PT_BLN:
|
||||
ecore_config_boolean_set(keys[x], itmp);
|
||||
break;
|
||||
default:
|
||||
ecore_config_int_set(keys[x], itmp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
E(0, "Could not read key %s!\n", keys[x]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type, "float"))
|
||||
{
|
||||
if (_ecore_config_db_key_float_get(db, keys[x], &ftmp))
|
||||
{
|
||||
ecore_config_float_set(keys[x], ftmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
E(0, "Could not read key %s!\n", keys[x]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type, "str"))
|
||||
{
|
||||
data = _ecore_config_db_key_str_get(db, keys[x]);
|
||||
if (data)
|
||||
{
|
||||
pt = ecore_config_type_guess(keys[x], data);
|
||||
switch (pt)
|
||||
{
|
||||
case PT_RGB:
|
||||
ecore_config_argb_set(keys[x], data);
|
||||
break;
|
||||
case PT_THM:
|
||||
ecore_config_theme_set(keys[x], data);
|
||||
break;
|
||||
default:
|
||||
ecore_config_string_set(keys[x], data);
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
E(0, "Could not read key %s!\n", keys[x]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
E(0, "Could not read key %s!\n", keys[x]);
|
||||
E(1, "Unexpected type: %s\n", type);
|
||||
continue;
|
||||
}
|
||||
if (type) free(type);
|
||||
}
|
||||
else if (!strcmp(type, "float"))
|
||||
{
|
||||
if (e_db_float_get(db, keys[x], &ftmp))
|
||||
{
|
||||
ecore_config_float_set(keys[x], ftmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
E(0, "Could not read key %s!\n", keys[x]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type, "str"))
|
||||
{
|
||||
data = e_db_str_get(db, keys[x]);
|
||||
if (data)
|
||||
{
|
||||
pt = ecore_config_type_guess(keys[x], data);
|
||||
switch (pt)
|
||||
{
|
||||
case PT_RGB:
|
||||
ecore_config_argb_set(keys[x], data);
|
||||
break;
|
||||
case PT_THM:
|
||||
ecore_config_theme_set(keys[x], data);
|
||||
break;
|
||||
default:
|
||||
ecore_config_string_set(keys[x], data);
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
E(0, "Could not read key %s!\n", keys[x]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
E(1, "Unexpected type: %s\n", type);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type)
|
||||
free(type);
|
||||
}
|
||||
e_db_close(db);
|
||||
free(keys);
|
||||
_ecore_config_db_close(db);
|
||||
if (keys)
|
||||
{
|
||||
for (x = 0; x < key_count; x++)
|
||||
{
|
||||
free(keys[x]);
|
||||
}
|
||||
free(keys);
|
||||
}
|
||||
return ECORE_CONFIG_ERR_SUCC;
|
||||
}
|
||||
|
||||
|
@ -188,10 +193,10 @@ _ecore_config_recurse_mkdir(char *file)
|
|||
int
|
||||
ecore_config_file_save(char *file)
|
||||
{
|
||||
Ecore_Config_Prop *next;
|
||||
E_DB_File *db;
|
||||
struct stat status;
|
||||
char *tmp;
|
||||
Ecore_Config_Prop *next;
|
||||
Ecore_Config_DB_File *db;
|
||||
struct stat status;
|
||||
char *tmp;
|
||||
|
||||
next = __ecore_config_bundle_local->data;
|
||||
db = NULL;
|
||||
|
@ -200,7 +205,7 @@ ecore_config_file_save(char *file)
|
|||
if (stat(file, &status))
|
||||
_ecore_config_recurse_mkdir(file);
|
||||
|
||||
db = e_db_open(file);
|
||||
db = _ecore_config_db_open_write(file);
|
||||
if (!db)
|
||||
{
|
||||
E(0, "Cannot open database from file %s!\n", file);
|
||||
|
@ -209,24 +214,25 @@ ecore_config_file_save(char *file)
|
|||
|
||||
while (next)
|
||||
{
|
||||
/* let the config_db deal with this
|
||||
if (!(next->flags & PF_MODIFIED))
|
||||
{
|
||||
next = next->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
*/
|
||||
tmp = NULL;
|
||||
|
||||
switch (next->type)
|
||||
{
|
||||
case PT_INT:
|
||||
e_db_int_set(db, next->key, ecore_config_int_get(next->key));
|
||||
_ecore_config_db_key_int_set(db, next->key, ecore_config_int_get(next->key));
|
||||
break;
|
||||
case PT_BLN:
|
||||
e_db_int_set(db, next->key, ecore_config_boolean_get(next->key));
|
||||
_ecore_config_db_key_int_set(db, next->key, ecore_config_boolean_get(next->key));
|
||||
break;
|
||||
case PT_FLT:
|
||||
e_db_float_set(db, next->key, ecore_config_float_get(next->key));
|
||||
_ecore_config_db_key_float_set(db, next->key, ecore_config_float_get(next->key));
|
||||
break;
|
||||
case PT_RGB:
|
||||
tmp = ecore_config_argbstr_get(next->key);
|
||||
|
@ -243,14 +249,13 @@ ecore_config_file_save(char *file)
|
|||
}
|
||||
|
||||
if (tmp) {
|
||||
e_db_str_set(db, next->key, tmp);
|
||||
_ecore_config_db_key_str_set(db, next->key, tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
next = next->next;
|
||||
}
|
||||
|
||||
e_db_close(db);
|
||||
e_db_flush();
|
||||
_ecore_config_db_close(db);
|
||||
return ECORE_CONFIG_ERR_SUCC;
|
||||
}
|
||||
|
|
|
@ -819,6 +819,7 @@ void ecore_x_window_prop_name_class_set(Ecore_X_Window win, const ch
|
|||
void ecore_x_window_prop_name_class_get(Ecore_X_Window win, char **n, char **c);
|
||||
void ecore_x_window_prop_protocol_set(Ecore_X_Window win, Ecore_X_WM_Protocol protocol, int on);
|
||||
int ecore_x_window_prop_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol protocol);
|
||||
Ecore_X_WM_Protocol *ecore_x_window_prop_protocol_list_get(Ecore_X_Window win, int *num_ret);
|
||||
void ecore_x_window_prop_sticky_set(Ecore_X_Window win, int on);
|
||||
int ecore_x_window_prop_input_mode_set(Ecore_X_Window win, Ecore_X_Window_Input_Mode mode);
|
||||
void ecore_x_window_prop_min_size_set(Ecore_X_Window win, int w, int h);
|
||||
|
@ -921,8 +922,16 @@ void ecore_x_icccm_send_take_focus(Ecore_X_Window win);
|
|||
ecore_x_window_save_set_del(Ecore_X_Window win);
|
||||
Ecore_X_Window *
|
||||
ecore_x_window_children_get(Ecore_X_Window win, int *num);
|
||||
|
||||
|
||||
void
|
||||
ecore_x_window_synthetic_move_resize_send(Ecore_X_Window win, int x, int y, int w, int h);
|
||||
void
|
||||
ecore_x_window_basic_hints_get(Ecore_X_Window win,
|
||||
int *accepts_focus,
|
||||
Ecore_X_Window_State_Hint *initial_state,
|
||||
Ecore_X_Pixmap *icon_pixmap,
|
||||
Ecore_X_Pixmap *icon_mask,
|
||||
Ecore_X_Window *icon_window,
|
||||
Ecore_X_Window *window_group);
|
||||
|
||||
Ecore_X_Cursor
|
||||
ecore_x_cursor_new(Ecore_X_Window win, int *pixels, int w, int h, int hot_x, int hot_y);
|
||||
|
|
|
@ -1060,6 +1060,78 @@ ecore_x_window_children_get(Ecore_X_Window win, int *num)
|
|||
return windows;
|
||||
}
|
||||
|
||||
void
|
||||
ecore_x_window_synthetic_move_resize_send(Ecore_X_Window win, int x, int y, int w, int h)
|
||||
{
|
||||
XEvent ev;
|
||||
|
||||
ev.type = ConfigureNotify;
|
||||
ev.xconfigure.display = _ecore_x_disp;
|
||||
ev.xconfigure.event = win;
|
||||
ev.xconfigure.window = win;
|
||||
ev.xconfigure.x = x;
|
||||
ev.xconfigure.y = y;
|
||||
ev.xconfigure.width = w;
|
||||
ev.xconfigure.height = h;
|
||||
ev.xconfigure.border_width = 0;
|
||||
ev.xconfigure.above = win;
|
||||
ev.xconfigure.override_redirect = False;
|
||||
XSendEvent(_ecore_x_disp, win, False, StructureNotifyMask, &ev);
|
||||
}
|
||||
|
||||
void
|
||||
ecore_x_window_basic_hints_get(Ecore_X_Window win,
|
||||
int *accepts_focus,
|
||||
Ecore_X_Window_State_Hint *initial_state,
|
||||
Ecore_X_Pixmap *icon_pixmap,
|
||||
Ecore_X_Pixmap *icon_mask,
|
||||
Ecore_X_Window *icon_window,
|
||||
Ecore_X_Window *window_group)
|
||||
{
|
||||
XWMHints *hints;
|
||||
|
||||
hints = XGetWMHints(_ecore_x_disp, win);
|
||||
if (hints)
|
||||
{
|
||||
if ((hints->flags & InputHint) && (accepts_focus))
|
||||
{
|
||||
if (hints->input)
|
||||
*accepts_focus = 1;
|
||||
else
|
||||
*accepts_focus = 0;
|
||||
}
|
||||
if ((hints->flags & StateHint) && (initial_state))
|
||||
{
|
||||
if (hints->initial_state == WithdrawnState)
|
||||
*initial_state = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN;
|
||||
else if (hints->initial_state == NormalState)
|
||||
*initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL;
|
||||
else if (hints->initial_state == IconicState)
|
||||
*initial_state = ECORE_X_WINDOW_STATE_HINT_ICONIC;
|
||||
}
|
||||
if ((hints->flags & IconPixmapHint) && (icon_pixmap))
|
||||
{
|
||||
*icon_pixmap = hints->icon_pixmap;
|
||||
}
|
||||
if ((hints->flags & IconMaskHint) && (icon_mask))
|
||||
{
|
||||
*icon_mask = hints->icon_pixmap;
|
||||
}
|
||||
if ((hints->flags & IconWindowHint) && (icon_window))
|
||||
{
|
||||
*icon_window = hints->icon_window;
|
||||
}
|
||||
if ((hints->flags & WindowGroupHint) && (window_group))
|
||||
{
|
||||
*window_group = hints->window_group;
|
||||
}
|
||||
XFree(hints);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -194,13 +194,16 @@ ecore_x_window_prop_string_get(Ecore_X_Window win, Ecore_X_Atom type)
|
|||
s = XmbTextPropertyToTextList(_ecore_x_disp, &xtp, &list, &items);
|
||||
if ((s == Success) && (items > 0))
|
||||
{
|
||||
/* FIXME convert from xlib encoding to utf8 */
|
||||
str = strdup(*list);
|
||||
XFreeStringList(list);
|
||||
}
|
||||
else
|
||||
/* FIXME convert from xlib encoding to utf8 */
|
||||
str = strdup((char *)xtp.value);
|
||||
}
|
||||
else
|
||||
/* FIXME convert from xlib encoding to utf8 */
|
||||
str = strdup((char *)xtp.value);
|
||||
XFree(xtp.value);
|
||||
}
|
||||
|
@ -223,6 +226,7 @@ ecore_x_window_prop_title_set(Ecore_X_Window win, const char *t)
|
|||
list[0] = (char *) t;
|
||||
|
||||
/* Xlib may not like the UTF8 String */
|
||||
/* FIXME convert utf8 to whatever encoding xlib prefers */
|
||||
/* ecore_x_window_prop_string_set(win, _ecore_x_atom_wm_name, (char *)t); */
|
||||
if (XStringListToTextProperty(list, 1, &xprop))
|
||||
{
|
||||
|
@ -572,6 +576,43 @@ ecore_x_window_prop_protocol_isset(Ecore_X_Window win,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be documented.
|
||||
*
|
||||
* FIXME: To be fixed.
|
||||
*/
|
||||
Ecore_X_WM_Protocol *
|
||||
ecore_x_window_prop_protocol_list_get(Ecore_X_Window win, int *num_ret)
|
||||
{
|
||||
Atom *protos = NULL;
|
||||
int i, protos_count = 0;
|
||||
Ecore_X_WM_Protocol *prot_ret = NULL;
|
||||
|
||||
if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count))
|
||||
return NULL;
|
||||
|
||||
if ((!protos) || (protos_count <= 0)) return NULL;
|
||||
prot_ret = malloc(protos_count * sizeof(Ecore_X_WM_Protocol));
|
||||
if (!prot_ret)
|
||||
{
|
||||
XFree(protos);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < protos_count; i++)
|
||||
{
|
||||
Ecore_X_WM_Protocol j;
|
||||
|
||||
for (j = 0; j < ECORE_X_WM_PROTOCOL_NUM; j++)
|
||||
{
|
||||
if (_ecore_x_atoms_wm_protocols[i] == protos[j])
|
||||
prot_ret[i] = j;
|
||||
}
|
||||
}
|
||||
XFree(protos);
|
||||
*num_ret = protos_count;
|
||||
return prot_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be documented.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue