Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_password.c ewl_password.h ewl_progressbar.c 
        ewl_progressbar.h 


Log Message:
- formatting/type checking

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_password.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_password.c      5 Oct 2005 22:45:57 -0000       1.6
+++ ewl_password.c      25 Oct 2005 02:03:46 -0000      1.7
@@ -8,17 +8,21 @@
  * @return Returns a new password widget on success, NULL on failure.
  * @brief Allocate and initialize a new password widget
  */
-Ewl_Widget     *ewl_password_new(void)
+Ewl_Widget *
+ewl_password_new(void)
 {
-       Ewl_Password      *e;
+       Ewl_Password *e;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
 
        e = NEW(Ewl_Password, 1);
        if (!e)
-               return NULL;
+               DRETURN_PTR(NULL, DLEVEL_STABLE);
 
-       ewl_password_init(e);
+       if (!ewl_password_init(e)) {
+               ewl_widget_destroy(EWL_WIDGET(e));
+               e = NULL;
+       }
 
        DRETURN_PTR(EWL_WIDGET(e), DLEVEL_STABLE);
 }
@@ -30,16 +34,19 @@
  *
  * Initializes the password widget @a e to it's default values and callbacks.
  */
-void ewl_password_init(Ewl_Password * e)
+int
+ewl_password_init(Ewl_Password *e)
 {
-       Ewl_Widget     *w;
+       Ewl_Widget *w;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("e", e);
+       DCHECK_PARAM_PTR_RET("e", e, FALSE);
 
        w = EWL_WIDGET(e);
 
-       ewl_entry_init(EWL_ENTRY(w));
+       if (!ewl_entry_init(EWL_ENTRY(w)))
+               DRETURN_INT(FALSE, DLEVEL_STABLE);
+
        ewl_widget_inherit(w, "password");
        e->obscure = '*';
 
@@ -51,10 +58,10 @@
        ewl_callback_del(w, EWL_CALLBACK_MOUSE_MOVE, ewl_entry_cb_mouse_move);
        ewl_callback_append(w, EWL_CALLBACK_KEY_DOWN, ewl_password_key_down_cb,
                            NULL);
-       ewl_callback_append(w, EWL_CALLBACK_DESTROY, ewl_password_destroy,
+       ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_password_destroy,
                            NULL);
 
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       DRETURN_INT(TRUE, DLEVEL_STABLE);
 }
 
 /**
@@ -65,13 +72,15 @@
  *
  * Change the text of the password widget @a e to the string @a t.
  */
-void ewl_password_text_set(Ewl_Password * e, char *t)
+void
+ewl_password_text_set(Ewl_Password *e, char *t)
 {
        char *vis = NULL;
        int len;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("e", e);
+       DCHECK_TYPE("e", e, "password");
 
        /*
         * Zero this out just in case a segv occurs (by the end
@@ -100,12 +109,14 @@
  * @return Returns the password text on success, NULL on failure.
  * @brief Get the text from an password widget
  */
-char           *ewl_password_text_get(Ewl_Password * e)
+char *
+ewl_password_text_get(Ewl_Password *e)
 {
-       Ewl_Widget     *w;
+       Ewl_Widget *w;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("e", e, NULL);
+       DCHECK_TYPE_RET("e", e, "password", NULL);
 
        w = EWL_WIDGET(e);
 
@@ -118,10 +129,12 @@
  * @return Returns the character value of the obscuring character.
  * @brief Retrieves the character used to obscure the text for a password.
  */
-char ewl_password_obscure_get(Ewl_Password * e)
+char
+ewl_password_obscure_get(Ewl_Password *e)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("e", e, 0);
+       DCHECK_TYPE_RET("e", e, "password", 0);
 
        DRETURN_INT(e->obscure, DLEVEL_STABLE);
 }
@@ -132,29 +145,31 @@
  * @return Returns no value.
  * @brief Sets the character used to obscure the text for a password.
  */
-void ewl_password_obscure_set(Ewl_Password * e, char o)
+void
+ewl_password_obscure_set(Ewl_Password *e, char o)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("e", e);
+       DCHECK_TYPE("e", e, "password");
 
        e->obscure = o;
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void ewl_password_text_insert(Ewl_Password * e, char *s)
+void
+ewl_password_text_insert(Ewl_Password *e, char *s)
 {
-       char           *s2, *s3;
-       int             l = 0, l2 = 0;
+       char *s2, *s3;
+       int l = 0, l2 = 0;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("e", e);
+       DCHECK_TYPE("e", e, "password");
 
        s2 = ewl_password_text_get(e);
-       if (s)
-               l = strlen(s);
-       if (s2)
-               l2 = strlen(s2);
+       if (s) l = strlen(s);
+       if (s2) l2 = strlen(s2);
 
        s3 = NEW(char, l + l2 + 1);
        if (!s3) {
@@ -163,10 +178,8 @@
        }
 
        s3[0] = 0;
-       if (s2)
-               strcat(s3, s2);
-       if (s)
-               strcat(s3, s);
+       if (s2) strcat(s3, s2);
+       if (s) strcat(s3, s);
 
        ewl_password_text_set(e, s3);
 
@@ -179,8 +192,9 @@
 /*
  * Handle key events to modify the text of the password widget.
  */
-void ewl_password_key_down_cb(Ewl_Widget * w, void *ev_data,
-                                       void *user_data __UNUSED__)
+void
+ewl_password_key_down_cb(Ewl_Widget *w, void *ev_data,
+                               void *user_data __UNUSED__)
 {
        int len;
        char *tmp;
@@ -189,6 +203,7 @@
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
+       DCHECK_TYPE("w", w, "widget");
 
        e = EWL_PASSWORD(w);
        ev = ev_data;
@@ -217,13 +232,17 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void ewl_password_destroy(Ewl_Widget * w, void *ev_data __UNUSED__,
-                                       void *user_data __UNUSED__)
+void
+ewl_password_destroy(Ewl_Widget *w, void *ev_data __UNUSED__,
+                               void *user_data __UNUSED__)
 {
-       Ewl_Password *p = EWL_PASSWORD(w);
+       Ewl_Password *p;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("w", w);
+       DCHECK_TYPE("w", w, "widget");
 
+       p = EWL_PASSWORD(w);
        if (p->real_text) {
                ZERO(p->real_text, char, strlen(p->real_text));
                FREE(p->real_text);
@@ -231,3 +250,4 @@
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_password.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_password.h      5 Oct 2005 22:45:57 -0000       1.3
+++ ewl_password.h      25 Oct 2005 02:03:46 -0000      1.4
@@ -36,23 +36,24 @@
        char       obscure; /**< Character displayed for password characters */
 };
 
-Ewl_Widget     *ewl_password_new();
-void            ewl_password_init(Ewl_Password * e);
-void            ewl_password_text_set(Ewl_Password * e, char *t);
-char           *ewl_password_text_get(Ewl_Password * e);
-void            ewl_password_obscure_set(Ewl_Password * e, char o);
-char            ewl_password_obscure_get(Ewl_Password * e);
+Ewl_Widget     *ewl_password_new(void);
+int             ewl_password_init(Ewl_Password *e);
+void            ewl_password_text_set(Ewl_Password *e, char *t);
+char           *ewl_password_text_get(Ewl_Password *e);
+void            ewl_password_obscure_set(Ewl_Password *e, char o);
+char            ewl_password_obscure_get(Ewl_Password *e);
 
-void ewl_password_text_insert(Ewl_Password * e, char *s);
+void            ewl_password_text_insert(Ewl_Password *e, char *s);
 
 /*
  * Internally used callbacks, override at your own risk.
  */
-void ewl_password_key_down_cb(Ewl_Widget * w, void *ev_data, void *user_data);
-void ewl_password_destroy(Ewl_Widget * w, void *ev_data, void *user_data);
+void ewl_password_key_down_cb(Ewl_Widget *w, void *ev_data, void *user_data);
+void ewl_password_destroy(Ewl_Widget *w, void *ev_data, void *user_data);
 
 /**
  * @}
  */
 
 #endif                         /* __EWL_PASSWORD_H__ */
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_progressbar.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_progressbar.c   3 Oct 2005 06:43:07 -0000       1.4
+++ ewl_progressbar.c   25 Oct 2005 02:03:46 -0000      1.5
@@ -9,7 +9,8 @@
  * @return Returns NULL on failure, or a pointer to the new progressbar on 
success.
  * @brief Allocate and initialize a new progressbar
  */
-Ewl_Widget *ewl_progressbar_new() 
+Ewl_Widget *
+ewl_progressbar_new(void) 
 {
        Ewl_Progressbar *p;
 
@@ -19,7 +20,10 @@
        if (!p)
                DRETURN_PTR(NULL, DLEVEL_STABLE);
 
-       ewl_progressbar_init(p);
+       if (!ewl_progressbar_init(p)) {
+               ewl_widget_destroy(EWL_WIDGET(p));
+               p = NULL;
+       }
        
        DRETURN_PTR(EWL_WIDGET(p), DLEVEL_STABLE);
 }
@@ -29,9 +33,10 @@
  * @return Returns TRUE on success, FALSE on failure.
  * @brief Initialize the progressbar to some sane starting values
  */
-int ewl_progressbar_init(Ewl_Progressbar * p)
+int
+ewl_progressbar_init(Ewl_Progressbar *p)
 {
-       Ewl_Widget     *w;
+       Ewl_Widget *w;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("p", p, FALSE);
@@ -62,8 +67,7 @@
 
        p->label = ewl_text_new();
        ewl_text_text_set(EWL_TEXT(p->label), NULL);
-       ewl_object_alignment_set(EWL_OBJECT(p->label),
-                       EWL_FLAG_ALIGN_CENTER);
+       ewl_object_alignment_set(EWL_OBJECT(p->label), EWL_FLAG_ALIGN_CENTER);
        ewl_container_child_append(EWL_CONTAINER(p), p->label);
        ewl_widget_show(p->label);
 
@@ -84,21 +88,21 @@
  * @return Returns no value.
  * @brief Set the value of the progressbars location
  */
-void ewl_progressbar_value_set(Ewl_Progressbar * p, double v)
+void
+ewl_progressbar_value_set(Ewl_Progressbar *p, double v)
 {
        char c[10];
        
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("p", p);
+       DCHECK_TYPE("p", p, "progressbar");
 
        if (v == p->value)
                DRETURN(DLEVEL_STABLE);
 
-       if (v < 0)
-               v = 0;
+       if (v < 0) v = 0;
 
        p->value = v;
-
        if (p->auto_label) {
                /* 
                 * Do a precentage calculation as a default label.
@@ -119,10 +123,12 @@
  * @return Returns 0 on failure, the value of the progressbars location on 
success.
  * @brief Retrieve the current value of the progressbars
  */ 
-double ewl_progressbar_value_get(Ewl_Progressbar * p)
+double
+ewl_progressbar_value_get(Ewl_Progressbar *p)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("p", p, -1);
+       DCHECK_TYPE_RET("p", p, "progressbar", -1);
 
        DRETURN_FLOAT(p->value, DLEVEL_STABLE);
 }
@@ -133,10 +139,12 @@
  * @return Returns no value.
  * @brief Set the range of the progressbar. Cannot be less then 1.
  */    
-void ewl_progressbar_range_set (Ewl_Progressbar * p, double r)
+void
+ewl_progressbar_range_set(Ewl_Progressbar *p, double r)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("p", p);
+       DCHECK_TYPE("p", p, "progressbar");
 
        if (r == p->range)
                DRETURN(DLEVEL_STABLE);
@@ -157,25 +165,28 @@
  * @return Returns 0 on failure, the value of the progressbars location on 
success.
  * @brief Retrieve the current range of the progressbars (default 100)
  */
-double ewl_progressbar_range_get (Ewl_Progressbar * p)
+double
+ewl_progressbar_range_get(Ewl_Progressbar *p)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("p", p, -1);
+       DCHECK_TYPE_RET("p", p, "progressbar", -1);
        
        DRETURN_FLOAT(p->range, DLEVEL_STABLE);
 }
 
-
 /**
  * @param p: the progressbars whose text will be changed
  * @param label: the new label
  * @return Returns no value
  * @brief Sets the given text on the progressbar
  */
-void ewl_progressbar_label_set (Ewl_Progressbar * p, char *label)
+void
+ewl_progressbar_label_set(Ewl_Progressbar *p, char *label)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("p", p);
+       DCHECK_TYPE("p", p, "progressbar");
 
        p->auto_label = FALSE;
        
@@ -191,12 +202,14 @@
  * @return Returns no value
  * @brief Sets the given format string on the progressbar (%lf of %lf beers)
  */
-void ewl_progressbar_custom_label_set (Ewl_Progressbar * p, char 
*format_string)
+void
+ewl_progressbar_custom_label_set(Ewl_Progressbar *p, char *format_string)
 {
        char label[PATH_MAX];
        
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("p", p);
+       DCHECK_TYPE("p", p, "progressbar");
 
        p->auto_label = FALSE;
 
@@ -213,9 +226,12 @@
  * @return Returns no value
  * @brief Hides the given progressbars label
  */
-void ewl_progressbar_label_hide (Ewl_Progressbar * p) {
+void
+ewl_progressbar_label_hide(Ewl_Progressbar *p) 
+{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("p", p);
+       DCHECK_TYPE("p", p, "progressbar");
        
        p->auto_label = FALSE;
        ewl_text_text_set(EWL_TEXT(p->label), "");
@@ -228,31 +244,34 @@
  * @return Returns no value
  * @brief Shows the given progressbars label
  */
-void ewl_progressbar_label_show (Ewl_Progressbar * p) {
+void
+ewl_progressbar_label_show (Ewl_Progressbar *p) 
+{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("p", p);
+       DCHECK_TYPE("p", p, "progressbar");
 
        p->auto_label = TRUE;
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-
 /*
  * On a configure event we need to adjust the progressbar to fit into it's new
  * coords and position as well as move the bar to the correct size and
  * position.
  */
 void
-ewl_progressbar_configure_cb(Ewl_Widget * w, void *ev_data __UNUSED__,
+ewl_progressbar_configure_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
                                                void *user_data __UNUSED__)
 {
        Ewl_Progressbar *p;
-       int             dx, dy;
-       int             dw, dh;
+       int dx, dy;
+       int dw, dh;
        
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
+       DCHECK_TYPE("w", w, "widget");
 
        p = EWL_PROGRESSBAR(w);
 
@@ -269,17 +288,18 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-
-static void ewl_progressbar_child_handle(Ewl_Container *c,
-                                       Ewl_Widget *w __UNUSED__)
+static void
+ewl_progressbar_child_handle(Ewl_Container *c,
+                               Ewl_Widget *w __UNUSED__)
 {
        Ewl_Progressbar *p;
        double value;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("c", c);
+       DCHECK_TYPE("c", c, "container");
 
        p = EWL_PROGRESSBAR(c);
-
        value = p->value / p->range;
 
        if (value < 0.01)
@@ -294,9 +314,14 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void ewl_progressbar_child_show_cb(Ewl_Container *c, Ewl_Widget *w)
+void
+ewl_progressbar_child_show_cb(Ewl_Container *c, Ewl_Widget *w)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("c", c);
+       DCHECK_PARAM_PTR("w", w);
+       DCHECK_TYPE("c", c, "container");
+       DCHECK_TYPE("w", w, "widget");
 
        ewl_progressbar_child_handle(c, w);
        
@@ -309,6 +334,10 @@
                                Ewl_Orientation o __UNUSED__)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("c", c);
+       DCHECK_PARAM_PTR("w", w);
+       DCHECK_TYPE("c", c, "container");
+       DCHECK_TYPE("w", w, "widget");
 
        ewl_progressbar_child_handle(c, w);
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_progressbar.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_progressbar.h   3 Oct 2005 06:43:07 -0000       1.4
+++ ewl_progressbar.h   25 Oct 2005 02:03:46 -0000      1.5
@@ -34,35 +34,35 @@
  */
 struct Ewl_Progressbar
 {
-       Ewl_Container   container;  /**< Inherit from Ewl_Container */
+       Ewl_Container    container;  /**< Inherit from Ewl_Container */
        Ewl_Widget      *bar;       /**< The moving bar on top */
        Ewl_Widget      *label;     /**< text label on the bar */
-       double          value;      /**< current value of the progressbar */
-       double          range;      /**< the maximum range of the progressbar */
-       int             auto_label;  /**< flag if user is setting label or not 
*/
+       double           value;      /**< current value of the progressbar */
+       double           range;      /**< the maximum range of the progressbar 
*/
+       int              auto_label;  /**< flag if user is setting label or not 
*/
 };
 
 
 Ewl_Widget     *ewl_progressbar_new(void);
-int             ewl_progressbar_init (Ewl_Progressbar * p);
+int             ewl_progressbar_init(Ewl_Progressbar *p);
 
-void            ewl_progressbar_value_set (Ewl_Progressbar * p, double v);
-double                  ewl_progressbar_value_get (Ewl_Progressbar * p);
+void            ewl_progressbar_value_set(Ewl_Progressbar *p, double v);
+double                  ewl_progressbar_value_get(Ewl_Progressbar *p);
 
-void            ewl_progressbar_range_set (Ewl_Progressbar * p, double r);
-double                  ewl_progressbar_range_get (Ewl_Progressbar * p);
+void            ewl_progressbar_range_set(Ewl_Progressbar *p, double r);
+double                  ewl_progressbar_range_get(Ewl_Progressbar *p);
 
-void            ewl_progressbar_label_set (Ewl_Progressbar * p, char *label);
-void            ewl_progressbar_custom_label_set (Ewl_Progressbar * p, 
+void            ewl_progressbar_label_set(Ewl_Progressbar *p, char *label);
+void            ewl_progressbar_custom_label_set(Ewl_Progressbar *p, 
                                                        char *format_string);
 
-void            ewl_progressbar_label_show (Ewl_Progressbar * p);
-void            ewl_progressbar_label_hide (Ewl_Progressbar * p);
+void            ewl_progressbar_label_show(Ewl_Progressbar *p);
+void            ewl_progressbar_label_hide(Ewl_Progressbar *p);
 
 /*
  * Internally used callbacks, override at your own risk.
  */
-void ewl_progressbar_configure_cb(Ewl_Widget * w, void *ev_data,
+void ewl_progressbar_configure_cb(Ewl_Widget *w, void *ev_data,
                                  void *user_data);
 void ewl_progressbar_child_show_cb(Ewl_Container *c, Ewl_Widget *w);
 void ewl_progressbar_child_resize_cb(Ewl_Container *c, Ewl_Widget *w, int size,




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to