Enlightenment CVS committal

Author  : ningerso
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_window.c ewl_window.h 


Log Message:
Update window title, name and class accessors to avoid string duplication.
Remove default title, name and class values.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_window.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -3 -r1.86 -r1.87
--- ewl_window.c        6 Dec 2007 07:07:12 -0000       1.86
+++ ewl_window.c        19 Dec 2007 16:15:31 -0000      1.87
@@ -53,9 +53,11 @@
        ewl_widget_appearance_set(EWL_WIDGET(w), EWL_WINDOW_TYPE);
        ewl_widget_inherit(EWL_WIDGET(w), EWL_WINDOW_TYPE);
        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_FILL);
+       /*
        w->title = strdup("EWL");
        w->name = strdup("EWL");
        w->classname  = strdup("EWL");
+       */
 
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_REALIZE,
                             ewl_window_cb_realize, NULL);
@@ -120,7 +122,7 @@
        DCHECK_PARAM_PTR(win);
        DCHECK_TYPE(win, EWL_WINDOW_TYPE);
 
-       if ((!title) || (strcmp(win->title, title))) {
+       if ((!title) || (!win->title) || (strcmp(win->title, title))) {
                IF_FREE(win->title);
                win->title = (title ? strdup(title) : strdup(""));
        }
@@ -135,16 +137,17 @@
  * @return Returns a pointer to a new copy of the title, NULL on failure.
  * @brief Retrieve the title of the specified window
  *
- * The returned title should be freed.
+ * The returned title should not be freed, and should be copied immediately if
+ * needed for extended use.
  */
-char *
+const char *
 ewl_window_title_get(Ewl_Window *win)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(win, NULL);
        DCHECK_TYPE_RET(win, EWL_WINDOW_TYPE, NULL);
 
-       DRETURN_PTR(strdup(win->title), DLEVEL_STABLE);
+       DRETURN_PTR(win->title, DLEVEL_STABLE);
 }
 
 /**
@@ -163,7 +166,7 @@
        DCHECK_PARAM_PTR(win);
        DCHECK_TYPE(win, EWL_WINDOW_TYPE);
 
-       if ((!name) || (strcmp(win->name, name))) {
+       if ((!name) || (!win->name) || (strcmp(win->name, name))) {
                IF_FREE(win->name);
                win->name = (name ? strdup(name) : strdup(""));
        }
@@ -178,16 +181,17 @@
  * @return Returns a pointer to a new copy of the name, NULL on failure.
  * @brief Retrieve the name of the specified window
  *
- * The returned name should be freed.
+ * The returned name should not be freed, and should be copied immediately if
+ * needed for extended use.
  */
-char *
+const char *
 ewl_window_name_get(Ewl_Window *win)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(win, NULL);
        DCHECK_TYPE_RET(win, EWL_WINDOW_TYPE, NULL);
 
-       DRETURN_PTR(strdup(win->name), DLEVEL_STABLE);
+       DRETURN_PTR(win->name, DLEVEL_STABLE);
 }
 
 /**
@@ -223,16 +227,17 @@
  * @return Returns a pointer to a new copy of the class, NULL on failure.
  * @brief Retrieve the class of the specified window
  *
- * The returned class should be freed.
+ * The returned class should not be freed, and should be copied immediately if
+ * needed for extended use.
  */
-char *
+const char *
 ewl_window_class_get(Ewl_Window *win)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(win, NULL);
        DCHECK_TYPE_RET(win, EWL_WINDOW_TYPE, NULL);
 
-       DRETURN_PTR(strdup(win->classname), DLEVEL_STABLE);
+       DRETURN_PTR(win->classname, DLEVEL_STABLE);
 }
 
 /**
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_window.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- ewl_window.h        6 Dec 2007 07:07:12 -0000       1.40
+++ ewl_window.h        19 Dec 2007 16:15:31 -0000      1.41
@@ -77,11 +77,11 @@
 int             ewl_window_init(Ewl_Window *win);
 Ewl_Window     *ewl_window_window_find(void *window);
 void            ewl_window_title_set(Ewl_Window *win, const char *title);
-char           *ewl_window_title_get(Ewl_Window *win);
+const char     *ewl_window_title_get(Ewl_Window *win);
 void            ewl_window_name_set(Ewl_Window *win, const char *name);
-char           *ewl_window_name_get(Ewl_Window *win);
+const char     *ewl_window_name_get(Ewl_Window *win);
 void            ewl_window_class_set(Ewl_Window *win, const char *classname);
-char           *ewl_window_class_get(Ewl_Window *win);
+const char     *ewl_window_class_get(Ewl_Window *win);
 void            ewl_window_borderless_set(Ewl_Window *win);
 void            ewl_window_dialog_set(Ewl_Window *win, int dialog);
 int             ewl_window_dialog_get(Ewl_Window *win);



-------------------------------------------------------------------------
SF.Net email is sponsored by:
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