Enlightenment CVS committal Author : ningerso Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_dnd.c ewl_dnd.h ewl_iconbox.c Log Message: Removal of unused type lookup code. Fix generation of type arrays on _get. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_dnd.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- ewl_dnd.c 30 Sep 2006 00:45:48 -0000 1.26 +++ ewl_dnd.c 13 Oct 2006 01:50:44 -0000 1.27 @@ -31,9 +31,8 @@ Ecore_Event_Handler *ewl_dnd_mouse_up_handler; Ecore_Event_Handler *ewl_dnd_mouse_move_handler; -char *ewl_dnd_drop_types[] = { "text/uri-list", "text/plain", NULL }; - static char *ewl_dnd_types_encode(const char **types); +static char **ewl_dnd_types_decode(const char *types); static char * ewl_dnd_type_stpcpy(char *dst, const char *src); static int ewl_dnd_types_encoded_contains(char *types, char *type); @@ -180,18 +179,17 @@ * @return Returns a NULL terminated array of mimetypes widget provides for DND * @brief: Gets the mimetypes the designated widget can provide for DND */ -const char ** +char ** ewl_dnd_provided_types_get(Ewl_Widget *w) { - const char **types; + const char *types; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("w", w, NULL); DCHECK_TYPE_RET("w", w, EWL_WIDGET_TYPE, NULL); types = ecore_hash_get(ewl_dnd_provided_hash, w); - - DRETURN_PTR(types, DLEVEL_STABLE); + DRETURN_PTR(ewl_dnd_types_decode(types), DLEVEL_STABLE); } /** @@ -269,7 +267,7 @@ const char ** ewl_dnd_accepted_types_get(Ewl_Widget *w) { - const char **types; + const char *types; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("w", w, NULL); @@ -277,40 +275,11 @@ types = ecore_hash_get(ewl_dnd_provided_hash, w); - DRETURN_PTR(types, DLEVEL_STABLE); + DRETURN_PTR(ewl_dnd_types_decode(types), DLEVEL_STABLE); } /** - * @param widget: The widget to get the types for - * @return Returns the Ewl_Dnd_Types for the given widget - * @brief Get the Ewl_Dnd_Types for the given widget - */ -Ewl_Dnd_Types * -ewl_dnd_types_for_widget_get(Ewl_Widget *widget) -{ - Ewl_Widget *parent = NULL; - - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("widget", widget, NULL); - DCHECK_TYPE_RET("widget", widget, EWL_WIDGET_TYPE, NULL); - - /* We need to get the top-level window widget. Note - * that we assume here that a widget is - * a) Parented, and - * b) It's top-level parent is a window */ - parent = widget->parent; - while (parent && parent->parent) - parent = parent->parent; - - /* Now check if this obj we found is a window */ - if (parent && ewl_widget_type_is(parent, "embed")) - DRETURN_PTR(&(EWL_EMBED(parent)->dnd_types), DLEVEL_STABLE); - - DRETURN_PTR(NULL, DLEVEL_STABLE); -} - -/** * @param w: The widget to start dragging * @return Returns no value * @brief Tells the widget to start dragging @@ -381,33 +350,14 @@ ecore_x_mwm_borderless_set(ewl_dnd_evas_win, 1); /* Start the drag operation */ - ecore_x_dnd_types_set(ewl_dnd_drag_win, ewl_dnd_drop_types, 1); + ecore_x_dnd_types_set(ewl_dnd_drag_win, ewl_dnd_provided_types_get(w), + 1); ecore_x_dnd_begin(ewl_dnd_drag_win, NULL, 0); DLEAVE_FUNCTION(DLEVEL_STABLE); } /** - * @param type: The type to check for - * @return Returns TRUE if the given type is supported, FALSE otherwise - * @brief Checks if the given type @a type is supported - */ -int -ewl_dnd_type_supported(char *type) -{ - char **check; - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("type", type, FALSE); - - for (check = ewl_dnd_drop_types; *check; check++) { - if (!strcmp(type, *check)) - DRETURN_INT(TRUE, DLEVEL_STABLE); - } - - DRETURN_INT(FALSE, DLEVEL_STABLE); -} - -/** * @return Returns no value * @brief Disables DND */ @@ -517,6 +467,35 @@ *tmptype = '\0'; DRETURN_PTR(type, DLEVEL_STABLE); +} + +static char ** +ewl_dnd_types_decode(const char *types) +{ + int count; + const char *tmp; + char **list; + + DENTER_FUNCTION(DLEVEL_STABLE); + + if (!types) + DRETURN_PTR(types, DLEVEL_STABLE); + + /* + * Short lists so iterate over multiple times rather than incur + * allocation overhead. + */ + for (tmp = types, count = 0; *tmp; tmp++, count++) { + while (*tmp) tmp++; + } + + list = calloc(count + 1, sizeof(char *)); + for (tmp = types, count = 0; *tmp; tmp++, count++) { + list[count] = strdup(tmp); + while (*tmp) tmp++; + } + + DRETURN_PTR(list, DLEVEL_STABLE); } static char * =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_dnd.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- ewl_dnd.h 8 Sep 2006 01:05:17 -0000 1.16 +++ ewl_dnd.h 13 Oct 2006 01:50:44 -0000 1.17 @@ -23,12 +23,10 @@ int ewl_dnd_status_get(void); void ewl_dnd_position_windows_set(Ewl_Widget *w); -Ewl_Dnd_Types *ewl_dnd_types_for_widget_get(Ewl_Widget *widget); -int ewl_dnd_type_supported(char *type); void ewl_dnd_provided_types_set(Ewl_Widget *w, const char **types); int ewl_dnd_provided_types_contains(Ewl_Widget *w, char *type); -const char **ewl_dnd_provided_types_get(Ewl_Widget *w); +char **ewl_dnd_provided_types_get(Ewl_Widget *w); void ewl_dnd_accepted_types_set(Ewl_Widget *w, const char **types); int ewl_dnd_accepted_types_contains(Ewl_Widget *w, char *type); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_iconbox.c,v retrieving revision 1.119 retrieving revision 1.120 diff -u -3 -r1.119 -r1.120 --- ewl_iconbox.c 30 Sep 2006 18:41:01 -0000 1.119 +++ ewl_iconbox.c 13 Oct 2006 01:50:44 -0000 1.120 @@ -1203,7 +1203,6 @@ int ibx, iby, px, py, fw, fh; Ewl_Iconbox *ib; Ewl_Iconbox_Icon *list_item; - Ewl_Dnd_Types *types; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("user_data", user_data); @@ -1220,14 +1219,6 @@ fw= ewl_object_preferred_w_get(EWL_OBJECT(list_item->image)); fh= ewl_object_preferred_h_get(EWL_OBJECT(list_item->image)); - - /* Get types */ - if ((types = ewl_dnd_types_for_widget_get(EWL_WIDGET(ib)))) { - /*printf("We have %d types!\n", types->num_types); - if (types->num_types > 0) { - printf("First type is '%s'\n", types->types[0]); - }*/ - } DLEAVE_FUNCTION(DLEVEL_STABLE); } ------------------------------------------------------------------------- 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