Enlightenment CVS committal

Author  : pfritz
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        Ewl.h Makefile.am ewl_entry.c ewl_entry.h ewl_text.c 
        ewl_text.h 


Log Message:
*API BREAK*
replace ewl_password by ewl_text_obscure_set()

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Ewl.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- Ewl.h       27 Feb 2008 03:52:45 -0000      1.36
+++ Ewl.h       4 Apr 2008 00:25:49 -0000       1.37
@@ -46,7 +46,6 @@
 
 #include <ewl_colorpicker.h>
 #include <ewl_colordialog.h>
-#include <ewl_password.h>
 #include <ewl_range.h>
 #include <ewl_seeker.h>
 #include <ewl_scrollbar.h>
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Makefile.am,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -3 -r1.61 -r1.62
--- Makefile.am 14 Dec 2007 08:44:26 -0000      1.61
+++ Makefile.am 4 Apr 2008 00:25:49 -0000       1.62
@@ -70,7 +70,6 @@
        ewl_object.h \
        ewl_overlay.h \
        ewl_paned.h \
-       ewl_password.h \
        ewl_popup.h \
        ewl_progressbar.h \
        ewl_radiobutton.h \
@@ -154,7 +153,6 @@
        ewl_object.c \
        ewl_overlay.c \
        ewl_paned.c \
-       ewl_password.c \
        ewl_popup.c \
        ewl_progressbar.c \
        ewl_radiobutton.c \
@@ -196,6 +194,7 @@
 
 libewl_la_LIBADD = $(GCOV_LIBS) @EMOTION_LIBS@ @EPSILON_LIBS@ @EFREET_LIBS@ 
@EDJE_LIBS@ @ECORE_LIBS@ @EVAS_LIBS@ -lm
 libewl_la_LDFLAGS = @create_shared_lib@ -version-info @INTERFACE_VERSION@
+libewl_la_LIBTOOLFLAGS =
 
 clean-local:
        @rm -f *.gcno
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_entry.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -3 -r1.82 -r1.83
--- ewl_entry.c 6 Jan 2008 19:17:12 -0000       1.82
+++ ewl_entry.c 4 Apr 2008 00:25:49 -0000       1.83
@@ -111,6 +111,27 @@
 }
 
 /**
+ * @return Returns a new password widget on success, NULL on failure.
+ * @brief Allocate and initialize a new password widget
+ *
+ * A password widget is an entry with a set obscure character. The default is a
+ * star (*)
+ */
+Ewl_Widget *
+ewl_password_new(void)
+{
+       Ewl_Widget *e;
+       
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       e = ewl_entry_new();
+       ewl_widget_appearance_set(e, "password/"EWL_ENTRY_TYPE);
+       ewl_text_obscure_set(EWL_TEXT(e), "*");
+       
+       DRETURN_PTR(e, DLEVEL_STABLE);
+}
+
+/**
  * @param e: The Ewl_Entry to initialize
  * @return Returns TRUE on success or FALSE on failure
  * @brief Initializes an Ewl_Entry widget to default values
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_entry.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- ewl_entry.h 6 Jan 2008 19:17:12 -0000       1.31
+++ ewl_entry.h 4 Apr 2008 00:25:49 -0000       1.32
@@ -66,6 +66,7 @@
 };
 
 Ewl_Widget     *ewl_entry_new(void);
+Ewl_Widget     *ewl_password_new(void);
 int             ewl_entry_init(Ewl_Entry *e);
 
 void            ewl_entry_multiline_set(Ewl_Entry *e, unsigned int multiline);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.c,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -3 -r1.190 -r1.191
--- ewl_text.c  6 Dec 2007 13:31:17 -0000       1.190
+++ ewl_text.c  4 Apr 2008 00:25:50 -0000       1.191
@@ -744,6 +744,59 @@
 }
 
 /**
+ * @param e: the text to set the obscuring character
+ * @param o: the character to obscure the password characters. This need to be
+ *           a string, because UTF-8 characters can be longer then one byte.
+ *           If it is not a valid UTF-8 character it will fallback to an
+ *           asterix (*). NULL will turn the option off and let the text widget
+ *           return to the normal text view.
+ * @return Returns no value.
+ * @brief Sets the character used to obscure the text for a password. Every
+ * character will be replaced by this character on the output.
+ */
+void
+ewl_text_obscure_set(Ewl_Text *t, const char *o)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR(t);
+       DCHECK_TYPE(t, EWL_TEXT_TYPE);
+
+       /* free the old character */
+       IF_FREE(t->obscure);
+
+       /* do some checking */
+       if (ewl_text_char_utf8_is(o)) {
+               size_t len;
+
+               len = EWL_TEXT_CHAR_BYTE_LEN(o);
+               t->obscure = NEW(char, len + 1);
+               memcpy(t->obscure, o, len);
+               t->obscure[len] = 0;
+       }
+       else
+               t->obscure = strdup("*");
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param t: the text to retrieve the obscuring character
+ * @return Returns the character value of the obscuring character. This is
+ *         a null-terminated string containing an UTF-8 character or NULL
+ *         if the text isn't set to obscure the text.
+ * @brief Retrieves the character used to obscure the text for a password.
+ */
+const char *
+ewl_text_obscure_get(Ewl_Text *t)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET(t, 0);
+       DCHECK_TYPE_RET(t, EWL_TEXT_TYPE, 0);
+
+       DRETURN_INT(t->obscure, DLEVEL_STABLE);
+}
+
+/**
  * @param t: The text to set the selectable value of
  * @param selectable: The selectable value to set
  * @return Returns no value
@@ -2948,15 +3001,36 @@
        if (node->tx != ewl_text_default_context)
                evas_textblock_cursor_format_append(cursor, node->tx->format);
 
-       ptr = t->text + byte_idx;
-       tmp = *(ptr + node->byte_len);
-       if (strlen(ptr) < node->byte_len)
-               DWARNING("Byte length of node %u overruns actual text %d",
-                               node->byte_len, (int)strlen(ptr));
-       *(ptr + node->byte_len) = '\0';
+       if (!t->obscure)
+       {
+               ptr = t->text + byte_idx;
+               tmp = *(ptr + node->byte_len);
+               if (strlen(ptr) < node->byte_len)
+                       DWARNING("Byte length of node %u overruns actual"
+                                " text %d", node->byte_len, (int)strlen(ptr));
+               *(ptr + node->byte_len) = '\0';
 
-       ewl_text_plaintext_parse(t->textblock, ptr);
-       *(ptr + node->byte_len) = tmp;
+               ewl_text_plaintext_parse(t->textblock, ptr);
+               *(ptr + node->byte_len) = tmp;
+       }
+       else
+       {
+               char *otxt;
+               size_t len;
+
+               int i;
+
+               len = strlen(t->obscure);
+               otxt = alloca(len * node->char_len + 1);
+               ptr = otxt;
+               for (i = 0; i < node->char_len; i++)
+               {
+                       memcpy(ptr, t->obscure, len);
+                       ptr += len;
+               }
+               *ptr = '\0';
+               ewl_text_plaintext_parse(t->textblock, otxt);
+       }
 
        evas_textblock_cursor_format_append(cursor, "-");
 
@@ -3334,6 +3408,7 @@
 
        t = EWL_TEXT(w);
 
+       IF_FREE(t->obscure);
        /* Note, we don't explictly destroy the triggers or the selection
         * because they will be cleared, because they are children of the
         * text widget itself */
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -3 -r1.61 -r1.62
--- ewl_text.h  11 Nov 2007 06:07:46 -0000      1.61
+++ ewl_text.h  4 Apr 2008 00:25:50 -0000       1.62
@@ -71,7 +71,8 @@
        void *textblock;          /**< The Evas_Object_Textblock */
 
        char *text;               /**< The text itself */
-
+       char *obscure;            /**< The utf8 character to be displayed
+                                      instead of the real text */
        struct
        {
                unsigned int chars;     /**< Number of characters in the text */
@@ -131,6 +132,8 @@
 void            ewl_text_text_insert(Ewl_Text *t, const char *text,
                                                unsigned int char_idx);
 void            ewl_text_text_delete(Ewl_Text *t, unsigned int length);
+
+void            ewl_text_obscure_set(Ewl_Text *t, const char *utf8_character);
 
 void            ewl_text_selectable_set(Ewl_Text *t, unsigned int selectable);
 unsigned int    ewl_text_selectable_get(Ewl_Text *t);



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to