Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        Ewl.h Makefile.am ewl_filelist.c ewl_filelist.h 
        ewl_filelist_column.c ewl_filelist_icon.c ewl_misc.c 
        ewl_text.c ewl_text.h 
Added Files:
        ewl_io_manager.c ewl_io_manager.h 


Log Message:
- start of an io manager for ewl. this will handle reading in things like
  files and parsing them into the correct format for the ewl_text.

  - works on a plugin system so plugins can be written outside the ewl_tree
    and just put in the plugin directory

  - this is just the base, not all functions are complete yet (it can read
    in text/plain files tho, heh)

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Ewl.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- Ewl.h       12 Sep 2006 05:07:12 -0000      1.11
+++ Ewl.h       14 Sep 2006 05:35:38 -0000      1.12
@@ -282,6 +282,8 @@
 #include <ewl_config.h>
 #include <ewl_theme.h>
 
+#include <ewl_io_manager.h>
+
 #include <ewl_label.h>
 #include <ewl_button.h>
 #include <ewl_floater.h>
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Makefile.am,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -3 -r1.34 -r1.35
--- Makefile.am 12 Sep 2006 05:07:12 -0000      1.34
+++ Makefile.am 14 Sep 2006 05:35:38 -0000      1.35
@@ -48,6 +48,7 @@
        ewl_icon.h \
        ewl_icon_theme.h \
        ewl_iconbox.h \
+       ewl_io_manager.h \
        ewl_image.h \
        ewl_imenu.h \
        ewl_list.h \
@@ -125,6 +126,7 @@
        ewl_icon.c \
        ewl_icon_theme.c \
        ewl_iconbox.c \
+       ewl_io_manager.c \
        ewl_image.c \
        ewl_list.c \
        ewl_media.c \
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- ewl_filelist.c      6 Sep 2006 15:16:11 -0000       1.18
+++ ewl_filelist.c      14 Sep 2006 05:35:38 -0000      1.19
@@ -3,9 +3,6 @@
 #include "ewl_macros.h"
 #include "ewl_private.h"
 
-static Ecore_Hash *ewl_filelist_ext_icon = NULL;
-
-static int ewl_filelist_strcasecompare(const void *key1, const void *key2);
 static void ewl_filelist_signal_between(Ewl_Filelist *fl, Ewl_Container *c,
                                                int add, const char *signal, 
                                                int a_idx, Ewl_Widget *a, 
@@ -21,32 +18,6 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("fl", fl, FALSE);
 
-       if (!ewl_filelist_ext_icon)
-       {
-               ewl_filelist_ext_icon = ecore_hash_new(ecore_str_hash, 
-                                                       
ewl_filelist_strcasecompare);
-
-               ecore_hash_set(ewl_filelist_ext_icon, ".png", 
EWL_ICON_IMAGE_X_GENERIC);
-               ecore_hash_set(ewl_filelist_ext_icon, ".jpg", 
EWL_ICON_IMAGE_X_GENERIC);
-               ecore_hash_set(ewl_filelist_ext_icon, ".gif", 
EWL_ICON_IMAGE_X_GENERIC);
-
-               ecore_hash_set(ewl_filelist_ext_icon, ".wmv", 
EWL_ICON_VIDEO_X_GENERIC);
-               ecore_hash_set(ewl_filelist_ext_icon, ".mpg", 
EWL_ICON_VIDEO_X_GENERIC);
-               ecore_hash_set(ewl_filelist_ext_icon, ".mpeg", 
EWL_ICON_VIDEO_X_GENERIC);
-               ecore_hash_set(ewl_filelist_ext_icon, ".avi", 
EWL_ICON_VIDEO_X_GENERIC);
-               ecore_hash_set(ewl_filelist_ext_icon, ".mov", 
EWL_ICON_VIDEO_X_GENERIC);
-               ecore_hash_set(ewl_filelist_ext_icon, ".asf", 
EWL_ICON_VIDEO_X_GENERIC);
-
-               ecore_hash_set(ewl_filelist_ext_icon, ".mp3", 
EWL_ICON_AUDIO_X_GENERIC);
-
-               ecore_hash_set(ewl_filelist_ext_icon, ".html", 
EWL_ICON_TEXT_HTML);
-               ecore_hash_set(ewl_filelist_ext_icon, ".htm", 
EWL_ICON_TEXT_HTML);
-
-               ecore_hash_set(ewl_filelist_ext_icon, ".pl", 
EWL_ICON_TEXT_X_SCRIPT);
-               ecore_hash_set(ewl_filelist_ext_icon, ".sh", 
EWL_ICON_TEXT_X_SCRIPT);
-               ecore_hash_set(ewl_filelist_ext_icon, ".ksh", 
EWL_ICON_TEXT_X_SCRIPT);
-       }
-
        if (!ewl_box_init(EWL_BOX(fl)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);
 
@@ -634,10 +605,11 @@
        DRETURN_INT(fl->scroll_flags.h, DLEVEL_STABLE);
 }
 
-char *
+const char *
 ewl_filelist_stock_icon_get(Ewl_Filelist *fl, const char *path)
 {
-       char *ret = NULL, *ptr = NULL;
+       const char *ret = NULL;
+       char *ptr = NULL;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("fl", fl, NULL);
@@ -648,7 +620,7 @@
                DRETURN_PTR(EWL_ICON_FOLDER, DLEVEL_STABLE);
 
        ptr = strrchr(path, '.');
-       ret = ecore_hash_get(ewl_filelist_ext_icon, ptr);
+       ret = ewl_io_manager_extension_icon_name_get(ptr);
        if (ret) DRETURN_PTR(ret, DLEVEL_STABLE);
 
        if (ecore_file_can_exec(path))
@@ -1079,23 +1051,4 @@
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
-
-static int
-ewl_filelist_strcasecompare(const void *key1, const void *key2)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-
-       if (!key1 || !key2)
-       {
-               DRETURN_INT(ecore_direct_compare(key1, key2), DLEVEL_STABLE);
-       }
-       else if (key1 == key2)
-       {
-               DRETURN_INT(0, DLEVEL_STABLE);
-       }
-
-       DRETURN_INT(strcasecmp((const char *)key1, 
-                               (const char *)key2), DLEVEL_STABLE);
-}
-
 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- ewl_filelist.h      6 Sep 2006 15:16:11 -0000       1.10
+++ ewl_filelist.h      14 Sep 2006 05:35:38 -0000      1.11
@@ -119,7 +119,7 @@
                                                Ewl_Scrollpane_Flags h);
 Ewl_Scrollpane_Flags ewl_filelist_hscroll_flag_get(Ewl_Filelist *fl);
 
-char           *ewl_filelist_stock_icon_get(Ewl_Filelist *fl, const char 
*path);
+const char     *ewl_filelist_stock_icon_get(Ewl_Filelist *fl, const char 
*path);
 
 char           *ewl_filelist_expand_path(Ewl_Filelist *fl, const char *dir);
 void            ewl_filelist_directory_read(Ewl_Filelist *fl, 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist_column.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_filelist_column.c       6 Sep 2006 15:35:01 -0000       1.16
+++ ewl_filelist_column.c       14 Sep 2006 05:35:38 -0000      1.17
@@ -433,8 +433,8 @@
 {
        Ewl_Filelist_Column *list;
        Ewl_Widget *icon;
-       char *stock, path[PATH_MAX];
-       const char *img;
+       const char *stock, *img;
+       char path[PATH_MAX];
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("fl", fl);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist_icon.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- ewl_filelist_icon.c 6 Sep 2006 15:35:01 -0000       1.10
+++ ewl_filelist_icon.c 14 Sep 2006 05:35:38 -0000      1.11
@@ -242,8 +242,8 @@
 {
        Ewl_Filelist_Icon *list;
        Ewl_Widget *icon;
-       char *stock, path[PATH_MAX];
-       const char *img;
+       const char *img, *stock;
+       char path[PATH_MAX];
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("fl", fl);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_misc.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -3 -r1.64 -r1.65
--- ewl_misc.c  16 Aug 2006 15:04:50 -0000      1.64
+++ ewl_misc.c  14 Sep 2006 05:35:38 -0000      1.65
@@ -148,6 +148,12 @@
                DRETURN_INT(--ewl_init_count, DLEVEL_STABLE);
        }
 
+       if (!ewl_io_manager_init()) {
+               DERROR("Could not init io manager data.\n");
+               ewl_shutdown();
+               DRETURN_INT(--ewl_init_count, DLEVEL_STABLE);
+       }
+
        ewl_init_parse_options(argc, argv);
 
        /* we create the engine we will be working with here so that it is
@@ -285,6 +291,7 @@
        ewl_engines_shutdown();
        ewl_config_shutdown();
        ewl_dnd_shutdown();
+       ewl_io_manager_shutdown();
 
        /*
         * Free internal accounting lists.
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -3 -r1.126 -r1.127
--- ewl_text.c  11 Sep 2006 04:21:42 -0000      1.126
+++ ewl_text.c  14 Sep 2006 05:35:38 -0000      1.127
@@ -24,7 +24,6 @@
                        unsigned int context_mask, Ewl_Text_Context *tx_change);
 static Ewl_Text_Context *ewl_text_context_find(Ewl_Text_Context *tx,
                        unsigned int context_mask, Ewl_Text_Context *tx_change);
-static Ewl_Text_Context *ewl_text_context_default_create(Ewl_Text *t);
 
 static void ewl_text_display(Ewl_Text *t);
 static void ewl_text_plaintext_parse(Evas_Object *tb, char *txt);
@@ -41,6 +40,7 @@
 static void ewl_text_tree_node_delete(Ewl_Text *t, Ewl_Text_Tree *tree);
 
 static void ewl_text_tree_shrink(Ewl_Text_Tree *tree);
+static void ewl_tree_gather_leaves(Ewl_Text_Tree *tree, Ecore_List *list);
 static void ewl_text_format_get(Ewl_Text_Context *ctx);
 static char *ewl_text_color_string_get(int r, int g, int b, int a);
 static Evas_Textblock_Cursor *ewl_text_textblock_cursor_position(Ewl_Text *t, 
@@ -2247,6 +2247,93 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/**
+ * @param text: The text to serialize
+ * @return Returns an array of nodes that defines the tree
+ * @brief This will return the array of nodes that make up the
+ * formatting for the tree
+ */
+Ecore_List *
+ewl_text_serialize(Ewl_Text *t)
+{
+       Ecore_List *list = NULL;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("t", t, NULL);
+       DCHECK_TYPE_RET("t", t, EWL_TEXT_TYPE, NULL);
+
+       list = ecore_list_new();
+       ewl_tree_gather_leaves(t->formatting.tree, list);
+
+       DRETURN_PTR(list, DLEVEL_STABLE);
+}
+
+/**
+ * @param text: The tree to build
+ * @param nodes: The array of nodes to use in the tree
+ * @param text: The text to set in the tree
+ * @return Returns no value
+ * @brief Builds the tree formatting from the given array of nodes
+ */
+void
+ewl_text_deserialize(Ewl_Text *t, Ecore_List *nodes, const char *text)
+{
+       Ewl_Text_Tree *node = NULL;
+       unsigned int extend = 0, byte_len = 0, byte_idx = 0;
+       unsigned int char_len = 0, char_idx = 0;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("t", t);
+       DCHECK_PARAM_PTR("nodes", nodes);
+       DCHECK_PARAM_PTR("text", text);
+
+       ewl_text_clear(t);
+
+       /* make sure we have room for the text */
+       byte_len = strlen(text);
+       extend = EWL_TEXT_EXTEND_VAL;
+       if (extend < byte_len) extend += byte_len;
+       t->text = realloc(t->text, extend * sizeof(char));
+
+       /* copy the text */
+       memcpy(t->text, text, byte_len);
+
+       ewl_text_byte_to_char(t, 0, byte_len, NULL, &char_len);
+       t->formatting.tree->length.bytes = byte_len;
+       t->formatting.tree->length.chars = char_len;
+
+       ecore_list_goto_first(nodes);
+       while ((node = ecore_list_remove_first(nodes)))
+       {
+               char_idx = 0;
+               char_len = 0;
+
+               ewl_text_byte_to_char(t, byte_idx, node->length.bytes, 
+                                               &char_idx, &char_len);
+
+               ewl_text_tree_context_apply(t, 
+                               EWL_TEXT_CONTEXT_MASK_FONT |
+                               EWL_TEXT_CONTEXT_MASK_SIZE |
+                               EWL_TEXT_CONTEXT_MASK_STYLES |
+                               EWL_TEXT_CONTEXT_MASK_ALIGN |
+                               EWL_TEXT_CONTEXT_MASK_WRAP |
+                               EWL_TEXT_CONTEXT_MASK_COLOR |
+                               EWL_TEXT_CONTEXT_MASK_BG_COLOR |
+                               EWL_TEXT_CONTEXT_MASK_GLOW_COLOR |
+                               EWL_TEXT_CONTEXT_MASK_OUTLINE_COLOR |
+                               EWL_TEXT_CONTEXT_MASK_SHADOW_COLOR |
+                               EWL_TEXT_CONTEXT_MASK_STRIKETHROUGH_COLOR |
+                               EWL_TEXT_CONTEXT_MASK_UNDERLINE_COLOR |
+                               EWL_TEXT_CONTEXT_MASK_DOUBLE_UNDERLINE_COLOR,
+                               node->tx, char_idx, char_len);
+
+               byte_idx += node->length.bytes;
+               ewl_text_tree_free(node);
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
 /* This will determine the number of bytes to get to char_pos in the text
  * and, if needed will get the number of bytes between char_pos and 
  * char_pos + char_len */
@@ -4327,7 +4414,7 @@
        DRETURN_PTR(tx, DLEVEL_STABLE);
 }
 
-static Ewl_Text_Context *
+Ewl_Text_Context *
 ewl_text_context_default_create(Ewl_Text *t)
 {
        Ewl_Text_Context *tx = NULL, *tmp;
@@ -5708,6 +5795,29 @@
                        char_idx += child->length.chars;
                        byte_idx += child->length.bytes;
                }
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/* gather all of the leaf nodes of the tree into an array */
+static void
+ewl_tree_gather_leaves(Ewl_Text_Tree *tree, Ecore_List *list)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("tree", tree);
+       DCHECK_PARAM_PTR("list", list);
+
+       if (tree->tx)
+               ecore_list_append(list, tree);
+
+       else
+       {
+               Ewl_Text_Tree *child;
+
+               ecore_list_goto_first(tree->children);
+               while ((child = ecore_list_next(tree->children)))
+                       ewl_tree_gather_leaves(child, list);
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -3 -r1.43 -r1.44
--- ewl_text.h  9 Sep 2006 18:06:59 -0000       1.43
+++ ewl_text.h  14 Sep 2006 05:35:38 -0000      1.44
@@ -254,6 +254,9 @@
                                                        unsigned int *b, 
unsigned int *a,
                                                        unsigned int char_idx);
 
+Ecore_List     *ewl_text_serialize(Ewl_Text *t);
+void            ewl_text_deserialize(Ewl_Text *t, Ecore_List *nodes, const 
char *text);
+
 /**
  * Inherits from Ewl_Widget and extends to provide a trigger for the text
  * widget
@@ -355,6 +358,7 @@
 void ewl_text_context_shutdown(void);
 
 Ewl_Text_Context *ewl_text_context_new(void);
+Ewl_Text_Context *ewl_text_context_default_create(Ewl_Text *t);
 
 void ewl_text_context_acquire(Ewl_Text_Context *tx);
 void ewl_text_context_release(Ewl_Text_Context *tx);



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to