example fixes

SVN revision: 19560
This commit is contained in:
Carsten Haitzler 2006-01-06 15:32:46 +00:00
parent 5ba10bb385
commit e886d21d78
4 changed files with 35 additions and 20 deletions

View File

@ -12,7 +12,9 @@ CON_EXAMPLES = con_server_example con_client_example
endif
if BUILD_ECORE_CONFIG
CONFIG_EXAMPLES = config_basic_example
CONFIG_EXAMPLES = \
config_basic_example \
config_listener_example
endif
if BUILD_ECORE_X
@ -58,6 +60,11 @@ config_basic_example_LDADD = $(top_builddir)/src/lib/ecore/libecore.la \
$(top_builddir)/src/lib/ecore_config/libecore_config.la \
$(top_builddir)/src/lib/ecore_ipc/libecore_ipc.la \
$(top_builddir)/src/lib/ecore_con/libecore_con.la
config_listener_example_SOURCES = config_listener_example.c
config_listener_example_LDADD = $(top_builddir)/src/lib/ecore/libecore.la \
$(top_builddir)/src/lib/ecore_config/libecore_config.la \
$(top_builddir)/src/lib/ecore_ipc/libecore_ipc.la \
$(top_builddir)/src/lib/ecore_con/libecore_con.la
endif
if BUILD_ECORE_X

View File

@ -5,11 +5,11 @@
#include <string.h>
#include <Ecore_Config.h>
#define INT_VAL_KEY "int_val"
#define FLT_VAL_KEY "flt_val"
#define STR_VAL_KEY "str_val"
#define RGB_VAL_KEY "rgb_val"
#define THM_VAL_KEY "thm_val"
#define INT_VAL_KEY "/example/integer"
#define FLT_VAL_KEY "/example/float"
#define STR_VAL_KEY "/example/string"
#define RGB_VAL_KEY "/example/colour"
#define THM_VAL_KEY "/example/theme"
long int_val;
float flt_val;
@ -21,7 +21,7 @@ void set_defaults (void) {
ecore_config_int_default(INT_VAL_KEY, 0);
ecore_config_float_default(FLT_VAL_KEY, 0.0);
ecore_config_string_default(STR_VAL_KEY, "test1");
ecore_config_rgb_default(RGB_VAL_KEY, "#000000");
ecore_config_argb_default(RGB_VAL_KEY, "#FF000000");
ecore_config_theme_default(THM_VAL_KEY, "default");
}
@ -34,7 +34,7 @@ void get_settings (void) {
int_val = ecore_config_int_get(INT_VAL_KEY);
flt_val = ecore_config_float_get(FLT_VAL_KEY);
str_val = ecore_config_string_get(STR_VAL_KEY);
rgb_val = ecore_config_rgbstr_get(RGB_VAL_KEY);
rgb_val = ecore_config_argbstr_get(RGB_VAL_KEY);
thm_val = ecore_config_theme_get(THM_VAL_KEY);
}
@ -46,18 +46,20 @@ void change_settings(void) {
} else {
str_val[4] += 1;
}
if('9' == rgb_val[1]) {
rgb_val[1] = '\0';
rgb_val[3] = '\0';
rgb_val[5] = '\0';
if('9' == rgb_val[3]) {
rgb_val[3] = '0';
rgb_val[5] = '0';
rgb_val[7] = '0';
} else {
rgb_val[1] += 1;
rgb_val[3] += 1;
rgb_val[5] += 1;
rgb_val[7] += 1;
}
if(!strcmp(thm_val, "default")) {
if(thm_val) free(thm_val);
thm_val = strdup("winter");
} else {
if(thm_val) free(thm_val);
thm_val = strdup("default");
}
}
@ -66,17 +68,17 @@ void save_settings (void) {
ecore_config_int_set(INT_VAL_KEY, int_val);
ecore_config_float_set(FLT_VAL_KEY, flt_val);
ecore_config_string_set(STR_VAL_KEY, str_val);
ecore_config_rgb_set(RGB_VAL_KEY, rgb_val);
ecore_config_argb_set(RGB_VAL_KEY, rgb_val);
ecore_config_theme_set(THM_VAL_KEY, thm_val);
ecore_config_save();
}
void dump_settings (void) {
printf(" Int Value: %li\n", int_val);
printf(" Float Value: %f\n", flt_val);
printf(" String Value: %s\n", str_val);
printf(" RGB Value: %s\n", rgb_val);
printf(" Theme Value: %s\n", thm_val);
printf(" Float Value: %f\n", flt_val);
printf(" String Value: %s\n", str_val);
printf(" RGB Value: %s\n", rgb_val);
printf(" Theme Value: %s\n", thm_val);
}
int main (int argc, char **argv) {
@ -88,6 +90,9 @@ int main (int argc, char **argv) {
printf("--- Values to be Saved ---\n");
dump_settings();
save_settings();
if(str_val) free(str_val);
if(rgb_val) free(rgb_val);
if(thm_val) free(thm_val);
ecore_config_shutdown();
return 0;
}

View File

@ -5,7 +5,7 @@
#include <Ecore.h>
#include <Ecore_Config.h>
#define INT_PROPERTY_KEY "int_val"
#define INT_PROPERTY_KEY "/example/integer"
#define CALLBACK_NAME "change listener"
int change_listener (const char *key, const Ecore_Config_Type type,

View File

@ -18,11 +18,14 @@ int main (int argc, char *argv[]) {
char *last = "last";
list = ecore_list_new();
ecore_list_append(list, last); // Insert
ecore_list_prepend(list, first); // Add to front
ecore_list_goto_index(list, 2);
ecore_list_goto_index(list, 1); // counted from 0
ecore_list_insert(list, second); // Insert before item at index 2
print_list(list);
ecore_list_destroy(list);
return 0;
}