Enlightenment CVS committal
Author : codewarrior
Project : e17
Module : proto
Dir : e17/proto/exhibit/src/bin
Modified Files:
exhibit.h exhibit_comment.c exhibit_main.c exhibit_options.c
exhibit_options.h exhibit_tab.c
Log Message:
- config subsystem
- more bug fixes for comments / tabs
===================================================================
RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- exhibit.h 29 Jul 2006 15:18:13 -0000 1.19
+++ exhibit.h 29 Jul 2006 19:50:04 -0000 1.20
@@ -1,6 +1,7 @@
#ifndef _EX_H
#define _EX_H
+#include <Eet.h>
#include <Evas.h>
#include <Ecore.h>
#include <Ecore_X.h>
@@ -38,6 +39,7 @@
typedef struct _Ex_Tab Ex_Tab;
typedef struct _Ex_Thumb Ex_Thumb;
typedef struct _Ex_Filedialog Ex_Filedialog;
+typedef struct _Ex_Config_Version Ex_Config_Version;
typedef enum _Ex_Images
{
@@ -60,13 +62,10 @@
double sharpen_thresh;
double brighten_thresh;
- double slide_interval;
-
- int comments_visible;
-
- int im_view;
-
- int default_sort;
+ double slide_interval;
+ int comments_visible;
+ int default_view;
+ int default_sort;
};
struct _Ex_Tab
@@ -138,7 +137,8 @@
Evas_List *tabs;
Ex_Tab *cur_tab;
- Ex_Options *options;
+ Ex_Options *options;
+ Ex_Config_Version *version;
struct {
int down;
@@ -168,6 +168,13 @@
Etk_Widget *filechooser;
Etk_Widget *entry;
Etk_Image *im;
+};
+
+struct _Ex_Config_Version
+{
+ int major;
+ int minor;
+ int patch;
};
#define WINDOW_TITLE "Exhibit"
===================================================================
RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_comment.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- exhibit_comment.c 29 Jul 2006 15:18:13 -0000 1.7
+++ exhibit_comment.c 29 Jul 2006 19:50:04 -0000 1.8
@@ -102,6 +102,8 @@
comment, ETK_TRUE);
return;
}
+
etk_textblock_text_set(ETK_TEXT_VIEW(e->cur_tab->comment.textview)->textblock,
+ "", ETK_TRUE);
}
void
===================================================================
RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_main.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -3 -r1.52 -r1.53
--- exhibit_main.c 29 Jul 2006 15:18:13 -0000 1.52
+++ exhibit_main.c 29 Jul 2006 19:50:04 -0000 1.53
@@ -4,6 +4,7 @@
extern pid_t pid;
extern Evas_List *thumb_list;
+Exhibit *e;
Ecore_Evas *ee_buf;
Evas *evas_buf;
Evas_List *event_handlers;
@@ -37,7 +38,6 @@
}
}
-
void
_ex_main_button_zoom_in_cb(Etk_Object *obj, void *data)
{
@@ -257,9 +257,9 @@
etk_image_set_from_file(ETK_IMAGE(e->cur_tab->image), image);
/* Use selected option for default view */
- if (e->options->im_view == EX_IMAGE_ONE_TO_ONE)
+ if (e->options->default_view == EX_IMAGE_ONE_TO_ONE)
_ex_main_button_zoom_one_to_one_cb(NULL, e);
- else if (e->options->im_view == EX_IMAGE_FIT_TO_WINDOW)
+ else if (e->options->default_view == EX_IMAGE_FIT_TO_WINDOW)
_ex_main_button_fit_to_window_cb(NULL, e);
else
{
@@ -283,6 +283,9 @@
etk_range_value_set(hs, (double)w/2);
etk_range_value_set(vs, (double)h/2);
+
+ if(e->cur_tab->comment.visible)
+ _ex_comment_load(e);
}
void
@@ -767,8 +770,31 @@
{
/* adding first "real" tab, copy existing tab, and create new one */
e->notebook = etk_notebook_new();
- etk_paned_child2_set(ETK_PANED(e->hpaned), e->notebook, ETK_TRUE);
- etk_notebook_page_append(ETK_NOTEBOOK(e->notebook),
_ex_file_get(e->cur_tab->dir), e->cur_tab->scrolled_view);
+ etk_paned_child2_set(ETK_PANED(e->hpaned), e->notebook, ETK_TRUE);
+
+ if(e->cur_tab->fit_window)
+ {
+ if(e->cur_tab->comment.visible)
+ etk_notebook_page_append(ETK_NOTEBOOK(e->notebook),
+ _ex_file_get(e->cur_tab->dir),
+ e->cur_tab->comment.vbox);
+ else
+ etk_notebook_page_append(ETK_NOTEBOOK(e->notebook),
+ _ex_file_get(e->cur_tab->dir),
+ e->cur_tab->alignment);
+ }
+ else
+ {
+ if(e->cur_tab->comment.visible)
+ etk_notebook_page_append(ETK_NOTEBOOK(e->notebook),
+ _ex_file_get(e->cur_tab->dir),
+ e->cur_tab->comment.vbox);
+ else
+ etk_notebook_page_append(ETK_NOTEBOOK(e->notebook),
+ _ex_file_get(e->cur_tab->dir),
+ e->cur_tab->scrolled_view);
+ }
+
etk_signal_connect("current_page_changed", ETK_OBJECT(e->notebook),
ETK_CALLBACK(_ex_main_window_tab_toggled_cb), e);
etk_widget_show(ETK_WIDGET(e->notebook));
}
@@ -830,7 +856,6 @@
void
_ex_main_window_show(char *dir)
{
- Exhibit *e;
Ex_Tab *tab;
const char *file;
char *homedir;
@@ -846,7 +871,7 @@
e->options = _ex_options_new();
/* Now load saved options */
- e->options = _ex_options_load(e->options);
+ _ex_options_load(e);
homedir = getenv("HOME");
if (!homedir)
@@ -1101,6 +1126,9 @@
};
ecore_file_init();
+ if(!_ex_options_init())
+ printf("WARNING: Exhibit could not set up its options files!\n"
+ " You will not be able to save your preferences.\n");
event_handlers = evas_list_append(event_handlers,
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
_ex_thumb_exe_exit,
@@ -1113,6 +1141,8 @@
_ex_main_window_show(NULL);
etk_main();
+ _ex_options_save(e);
+ _ex_options_shutdown();
ecore_file_shutdown();
etk_shutdown();
===================================================================
RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_options.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- exhibit_options.c 28 Jul 2006 16:04:47 -0000 1.3
+++ exhibit_options.c 29 Jul 2006 19:50:04 -0000 1.4
@@ -1,32 +1,178 @@
#include "exhibit.h"
+#define NEWD(str, typ) \
+ eet_data_descriptor_new(str, sizeof(typ), \
+ (void *(*) (void *))evas_list_next, \
+ (void *(*) (void *, void *))evas_list_append, \
+ (void *(*) (void *))evas_list_data, \
+ (void *(*) (void *))evas_list_free, \
+ (void (*) (void *, int (*) (void *, const char
*, void *, void *), void *))evas_hash_foreach, \
+ (void *(*) (void *, const char *, void
*))evas_hash_add, \
+ (void (*) (void *))evas_hash_free)
+
+#define FREED(eed) \
+ if (eed) \
+ { \
+ eet_data_descriptor_free((eed)); \
+ (eed) = NULL; \
+ }
+
+#define CFG_OPTIONS_NEWI(str, it, type)
EET_DATA_DESCRIPTOR_ADD_BASIC(_ex_config_options_edd, Ex_Options, str, it, type)
+
+#define VER_NEWI(str, it, type)
EET_DATA_DESCRIPTOR_ADD_BASIC(_ex_config_version_edd, Ex_Config_Version, str,
it, type)
+
+static Eet_Data_Descriptor *_ex_config_options_edd = NULL;
+static Eet_Data_Descriptor *_ex_config_version_edd = NULL;
+
+
+int
+_ex_options_init()
+{
+ char *home;
+ char buf[PATH_MAX];
+
+ home = getenv("HOME");
+ if(!home)
+ {
+ printf("Cant find home directory!\n");
+ return 0;
+ }
+
+ /* make sure ~/.e exists and is a dir */
+ snprintf(buf, sizeof(buf), "%s/.e", home);
+ if(!ecore_file_is_dir(buf))
+ {
+ if(ecore_file_exists(buf))
+ {
+ printf("Cant create config path!\n");
+ return 0;
+ }
+
+ if(!ecore_file_mkdir(buf))
+ {
+ printf("Cant create config path!");
+ return 0;
+ }
+ }
+
+ /* make sure ~/.e/exhibit exists and is a dir */
+ snprintf(buf, sizeof(buf), "%s/.e/exhibit", home);
+ if(!ecore_file_is_dir(buf))
+ {
+ if(ecore_file_exists(buf))
+ {
+ printf("Cant create config path!");
+ return 0;
+ }
+
+ if(!ecore_file_mkdir(buf))
+ {
+ printf("Cant create config path!");
+ return 0;
+ }
+ }
+
+ _ex_config_options_edd = NEWD("Ex_Options", Ex_Options);
+ CFG_OPTIONS_NEWI("a1", app1, EET_T_STRING);
+ CFG_OPTIONS_NEWI("a2", app2, EET_T_STRING);
+ CFG_OPTIONS_NEWI("a3", app3, EET_T_STRING);
+ CFG_OPTIONS_NEWI("a4", app4, EET_T_STRING);
+ CFG_OPTIONS_NEWI("fp", fav_path, EET_T_STRING);
+ CFG_OPTIONS_NEWI("bt", blur_thresh, EET_T_DOUBLE);
+ CFG_OPTIONS_NEWI("st", sharpen_thresh, EET_T_DOUBLE);
+ CFG_OPTIONS_NEWI("rt", brighten_thresh, EET_T_DOUBLE);
+ CFG_OPTIONS_NEWI("lt", slide_interval, EET_T_DOUBLE);
+ CFG_OPTIONS_NEWI("cv", comments_visible, EET_T_INT);
+ CFG_OPTIONS_NEWI("dv", default_view, EET_T_INT);
+
+ _ex_config_version_edd = NEWD("Ex_Config_Version", Ex_Config_Version);
+ VER_NEWI("mj", major, EET_T_INT);
+ VER_NEWI("mn", minor, EET_T_INT);
+ VER_NEWI("pa", patch, EET_T_INT);
+
+ return 1;
+}
+
+int
+_ex_options_shutdown()
+{
+ FREED(_ex_config_options_edd);
+ FREED(_ex_config_version_edd);
+ return 1;
+}
+
+Ex_Config_Version *
+_ex_options_version_parse(char *version)
+{
+ Ex_Config_Version *v;
+ int res;
+
+ v = calloc(1, sizeof(Ex_Config_Version));
+ res = sscanf(version, "%d.%d.%d", &v->major, &v->minor, &v->patch);
+
+ if(res < 3)
+ return NULL;
+
+ return v;
+}
+
+/*
+ * Compare 2 versions, return 1 if v1 > v2
+ * return 0 if v1 == v2
+ * return -1 if v1 < v2
+ */
+int
+_ex_options_version_compare(Ex_Config_Version *v1, Ex_Config_Version *v2)
+{
+ if(v1->major > v2->major)
+ return 1;
+ else if (v1->major < v2->major)
+ return -1;
+
+ if(v1->minor > v2->minor)
+ return 1;
+ else if (v1->minor < v2->minor)
+ return -1;
+
+ if(v1->patch > v2->patch)
+ return 1;
+ else if (v1->patch < v2->patch)
+ return -1;
+
+ return 0;
+}
+
Ex_Options *
_ex_options_new()
{
Ex_Options *o;
- o = calloc(1, sizeof(Ex_Options));
- o = _ex_options_default(o);
-
+ o = calloc(1, sizeof(Ex_Options));
return o;
}
-Ex_Options *
-_ex_options_default(Ex_Options *o)
-{
- o->app1 = NULL;
- o->app2 = NULL;
- o->app3 = NULL;
- o->app4 = NULL;
- o->fav_path = NULL;
- o->blur_thresh = EX_DEFAULT_BLUR_THRESH;
- o->sharpen_thresh = EX_DEFAULT_SHARPEN_THRESH;
- o->brighten_thresh = EX_DEFAULT_BRIGHTEN_THRESH;
- o->slide_interval = EX_DEFAULT_SLIDE_INTERVAL;
- o->comments_visible = EX_DEFAULT_COMMENTS_VISIBLE;
- o->im_view = EX_IMAGE_ONE_TO_ONE;
+void
+_ex_options_default(Exhibit *e)
+{
+ if(!e->options)
+ e->options = _ex_options_new();
- return o;
+ /* TODO: free values before allocating if e->options != NULL */
+
+ e->options->app1 = NULL;
+ e->options->app2 = NULL;
+ e->options->app3 = NULL;
+ e->options->app4 = NULL;
+ e->options->fav_path = NULL;
+ e->options->blur_thresh = EX_DEFAULT_BLUR_THRESH;
+ e->options->sharpen_thresh = EX_DEFAULT_SHARPEN_THRESH;
+ e->options->brighten_thresh = EX_DEFAULT_BRIGHTEN_THRESH;
+ e->options->slide_interval = EX_DEFAULT_SLIDE_INTERVAL;
+ e->options->comments_visible = EX_DEFAULT_COMMENTS_VISIBLE;
+ e->options->default_view = EX_IMAGE_ONE_TO_ONE;
+ e->options->default_sort = 0; /* TODO: enumerate sort types */
+
+ e->version = _ex_options_version_parse(VERSION);
}
void
@@ -40,21 +186,92 @@
E_FREE(e->options);
}
-void
+int
_ex_options_save(Exhibit *e)
{
- /* TODO
- * Save options to .eet */
+ Eet_File *ef;
+ char buf[PATH_MAX];
+ char *home;
+ int ret;
+
+ home = getenv("HOME");
+ if(!home)
+ return 0;
+
+ snprintf(buf, sizeof(buf), "%s/.e/exhibit/config.eet", home);
+
+ ef = eet_open(buf, EET_FILE_MODE_WRITE);
+ if(!ef)
+ return 0;
+
+ ret = eet_data_write(ef, _ex_config_version_edd, "config/version",
e->version, 1);
+ if(!ret)
+ printf("Problem saving config!\n");
+
+ ret = eet_data_write(ef, _ex_config_options_edd, "config/options",
e->options, 1);
+ if(!ret)
+ printf("Problem saving config/options!");
+
+ eet_close(ef);
+ return ret;
}
-Ex_Options *
-_ex_options_load(Ex_Options *o)
+int
+_ex_options_load(Exhibit *e)
{
-
- /* TODO
- * Load options from .eet */
+ Eet_File *ef;
+ char buf[PATH_MAX];
+ char *home;
- return o;
+ home = getenv("HOME");
+ if(!home)
+ {
+ _ex_options_default(e);
+ return 0;
+ }
+
+ snprintf(buf, sizeof(buf), "%s/.e/exhibit/config.eet", home);
+
+ if(!ecore_file_exists(buf) || ecore_file_size(buf) == 0)
+ {
+ /* no saved config */
+ _ex_options_default(e);
+ return 0;
+ }
+
+ ef = eet_open(buf, EET_FILE_MODE_READ);
+ if(!ef)
+ {
+ printf("Cant open configuration file! Using program defaults.\n");
+ return 0;
+ }
+
+ E_FREE(e->version);
+ e->version = eet_data_read(ef, _ex_config_version_edd, "config/version");
+ if(!e->version)
+ {
+ printf("Incompatible configuration file! Creating new one.\n");
+ eet_close(ef);
+ _ex_options_default(e);
+ return 0;
+ }
+ else
+ {
+ Ex_Config_Version *v;
+
+ v = _ex_options_version_parse(VERSION);
+ if(_ex_options_version_compare(v, e->version) != 0)
+ {
+ printf("Your version / configuration of E-Stickies is not
valid!\n");
+ _ex_options_default(e);
+ return 0;
+ }
+ }
+
+ e->options = eet_data_read(ef, _ex_config_options_edd, "config/options");
+
+ eet_close(ef);
+ return 1;
}
void
===================================================================
RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_options.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- exhibit_options.h 28 Jul 2006 16:04:47 -0000 1.2
+++ exhibit_options.h 29 Jul 2006 19:50:04 -0000 1.3
@@ -1,11 +1,13 @@
#ifndef _EX_OPTIONS_H
#define _EX_OPTIONS_H
+int _ex_options_init();
+int _ex_options_shutdown();
Ex_Options *_ex_options_new();
-Ex_Options *_ex_options_default(Ex_Options *o);
+void _ex_options_default(Exhibit *o);
void _ex_options_free(Exhibit *e);
-void _ex_options_save(Exhibit *e);
-Ex_Options *_ex_options_load(Ex_Options *e);
+int _ex_options_save(Exhibit *e);
+int _ex_options_load(Exhibit *e);
void _ex_options_window_show(Exhibit *e);
Etk_Bool _ex_options_window_delete_cb(void *data);
===================================================================
RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_tab.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- exhibit_tab.c 29 Jul 2006 02:49:24 -0000 1.14
+++ exhibit_tab.c 29 Jul 2006 19:50:04 -0000 1.15
@@ -84,7 +84,9 @@
{
chdir(tab->cur_path);
- if(tab->fit_window)
+ if(tab->comment.visible)
+ etk_notebook_page_child_set(ETK_NOTEBOOK(tab->e->notebook), tab->num,
tab->comment.vbox);
+ else if(tab->fit_window)
etk_notebook_page_child_set(ETK_NOTEBOOK(tab->e->notebook), tab->num,
tab->alignment);
etk_table_attach(ETK_TABLE(tab->e->table), tab->dtree,
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs