Eina_Bool language_next(Language_XML *xml) { Eina_List *p_list; Language_XML_Node *parent, *cur; if (!xml) { DBG("One of values is NULL, returning with error."); return EINA_FALSE; } if (xml->current) { cur = xml->current; parent = cur->parent; if (parent) { p_list = parent->children; p_list = eina_list_data_find_list(p_list, xml->current); p_list = eina_list_next( p_list ); if (!(xml->current = eina_list_data_get(p_list))) { xml->current = cur; return EINA_FALSE; } } else xml->current = EINA_FALSE; } return xml->current ? EINA_TRUE : EINA_FALSE; }
static void _cb_feed_down(void *data, void *data2) { E_Config_Dialog_Data *cfdata; News_Feed *f; News_Item *ni; News_Feed_Ref *ref; Eina_List *sel, *l, *lf; cfdata = data; ni = cfdata->ni; for (sel=eina_list_last(cfdata->ilist_selected_feeds_sel); sel; sel=eina_list_prev(sel)) { f = sel->data; ref = news_feed_ref_find(f, ni); if (!ref) return; l = eina_list_data_find_list(ni->config->feed_refs, ref); lf = eina_list_next(l); if (!lf) return; ni->config->feed_refs = eina_list_remove_list(ni->config->feed_refs, l); ni->config->feed_refs = eina_list_append_relative_list(ni->config->feed_refs, ref, lf); } news_item_refresh(ni, 1, 0, 0); news_config_dialog_item_content_refresh_selected_feeds(ni); }
/* * etox_line_minimize - reduce the number of bits on a line */ void etox_line_minimize(Etox_Line * line) { Evas_Object *bit, *last_bit = NULL; Eina_List *l; CHECK_PARAM_POINTER("line", line); l = line->bits; if (!l) return; last_bit = l->data; l = l->next; while (l) { bit = l->data; /* * Attempt to merge the bits if possible, remove the second * one if successful. */ if (etox_style_merge(last_bit, bit)) { line->bits = eina_list_remove(line->bits, bit); l = eina_list_data_find_list(line->bits, last_bit); l = l->next; } else { last_bit = bit; l = l->next; } } }
EOLIAN static void _elm_flipselector_item_elm_widget_item_part_text_set(Eo *eo_item, Elm_Flipselector_Item_Data *item, const char *part, const char *label) { Eina_List *l; if (!label) return; if (part && strcmp(part, "default")) return; ELM_FLIPSELECTOR_DATA_GET(WIDGET(item), sd); if (!sd->items) return; l = eina_list_data_find_list(sd->items, eo_item); if (!l) return; eina_stringshare_del(item->label); item->label = eina_stringshare_add_length(label, sd->max_len); if (strlen(label) > strlen(elm_object_item_text_get(DATA_GET(sd->sentinel)))) sd->sentinel = l; if (sd->current == l) { _update_view(WIDGET(item)); elm_layout_sizing_eval(WIDGET(item)); } }
void etox_line_split(Etox_Line *line, Evas_Object *bit, int index) { Eina_List *ll; Etox_Line *newline; Evas_Object *split = NULL; ll = eina_list_data_find_list(line->bits, bit); /* * add the newline after the current one */ newline = etox_line_new(line->flags | ETOX_LINE_WRAPPED); newline->et = line->et; line->et->lines = eina_list_append_relative(line->et->lines, newline, line); /* * If the bit starts on the boundary, simply move it to the next line. */ if (index > 0) { if (index < etox_style_length(bit)) { /* * FIXME: There appears to be a problem here where the widths * of the split bits do not add up to the width of the original * bit! It is noticeable when the first split bit ends with * a space. Is it counted in the middle of a bit, but not at * the end? This causes a problem where the width of a line * does not match the sum of its bits and then etox_line_wrap * tries to wrap a line that does not have a bit on the edge. */ split = etox_split_bit(line, bit, index); } ll = ll->next; } /* * Move the remaining bits to the new line */ while (ll) { /* * Immediately move to the next object, as the node in the * list pointed to by ll will get removed. */ bit = ll->data; ll = ll->next; etox_line_remove(line, bit); etox_line_append(newline, bit); } }
void etox_line_unwrap(Etox *et, Etox_Line *line) { Eina_List *l, *prevline; Evas_Object *marker; if (!et->lines) return; prevline = eina_list_data_find_list(et->lines, line); l = prevline->next; while (l) { Eina_List *ll; line = l->data; if (!(line->flags & ETOX_LINE_WRAPPED)) break; /* remove any wrap marker bits */ ll = line->bits; while (ll) { int t; marker = ll->data; ll = ll->next; t = etox_style_get_type(marker); if (t == ETOX_BIT_TYPE_WRAP_MARKER) { line->bits = eina_list_remove(line->bits, marker); evas_object_del(marker); } } /* remove the line from the list */ et->lines = eina_list_remove(et->lines, line); /* merge the two lines */ etox_line_merge_append(prevline->data, line); etox_line_free(line); l = prevline->next; } // etox_line_minimize(line); }
void language_xml_clear(Language_XML *xml) { Language_XML_Node *n_cur; if ((!xml) || (!xml->current)) { DBG("One of values is NULL, returning with error."); return; } xml->current = xml->top; n_cur = xml->current; if (!n_cur) { DBG("One of values is NULL, returning with error."); return; } n_cur = n_cur->parent; if (n_cur) { Language_XML_Node *c_parent = n_cur; Eina_List *c_list = c_parent->children; void *data; c_list = eina_list_data_find_list(c_list, xml->current); EINA_LIST_FREE(c_list, data) E_FREE(data); if (!(n_cur = eina_list_data_get(c_list))) if (!(n_cur = eina_list_last(c_list))) n_cur = c_parent; } else { xml->top = NULL; void *data; if (xml->current) { eina_hash_free(xml->current->attributes); EINA_LIST_FREE(xml->current->children, data) E_FREE(data); E_FREE(xml->current); } } xml->current = n_cur; }
EAPI void efreet_icon_extension_add(const char *ext) { Eina_List *l; EINA_SAFETY_ON_NULL_RETURN(ext); ext = eina_stringshare_add(ext); if ((l = eina_list_data_find_list(efreet_icon_extensions, ext))) { efreet_icon_extensions = eina_list_promote_list(efreet_icon_extensions, l); eina_stringshare_del(ext); } else efreet_icon_extensions = eina_list_prepend(efreet_icon_extensions, ext); }
/* Move to right is basically the same as move to left of (num+1) */ static int border_move_to_right(E_Border *bd, int times) { Eina_List *n, *p; void *data; int c; if (!bd || !_G.tinfo) return 0; if (!(n = eina_list_data_find_list(_G.tinfo->client_list, bd))) return 0; if (!(p = n->next)) return 0; data = n->data; for (c = 0; c < (times - 1); c++) if (!(p = p->next)) return 0; _G.tinfo->client_list = eina_list_remove_list(_G.tinfo->client_list, n); _G.tinfo->client_list = eina_list_append_relative_list(_G.tinfo->client_list, data, p); return 1; }
int main(int argc, char **argv) { (void)argc; (void)argv; Eina_List *list = NULL, *r_list; Eina_List *l; Eina_Iterator *itr; void *list_data; eina_init(); list = eina_list_append(list, "caprica"); list = eina_list_append(list, "sagitarius"); list = eina_list_append(list, "aerilon"); list = eina_list_append(list, "gemenon"); list = eina_list_promote_list(list, eina_list_nth_list(list, 2)); list = eina_list_demote_list(list, eina_list_nth_list(list, 2)); list = eina_list_remove(list, "sagitarius"); l = eina_list_data_find_list(list, "aerilon"); eina_list_data_set(l, "aquarius"); printf("size: %d\n", eina_list_count(list)); r_list = eina_list_reverse_clone(list); itr = eina_list_iterator_new(r_list); EINA_ITERATOR_FOREACH(itr, list_data) printf("%s\n", (char*)list_data); eina_iterator_free(itr); eina_list_free(list); eina_list_free(r_list); eina_shutdown(); return 0; }
static Evry_Item_App * _item_exe_add(Plugin *p, const char *exe, int match) { Evry_Item_App *app = NULL; if ((app = eina_hash_find(p->added, exe))) { if (eina_list_data_find_list(p->base.items, app)) return app; } if (!app) { app = _item_new(p, ecore_file_file_get(exe), exe); app->file = eina_stringshare_ref(EVRY_ITEM(app)->id); } EVRY_ITEM(app)->fuzzy_match = match; EVRY_PLUGIN_ITEM_APPEND(p, app); return app; }
void etox_line_apply_context(Etox_Line *line, Etox_Context *context, Evas_Object *start, Evas_Object *end) { #ifdef DEBUG printf("etox_line_apply_context() - called\n"); fflush(stdout); #endif Eina_List *l, *ls = NULL, *le = NULL; ls = eina_list_data_find_list(line->bits, start); le = eina_list_data_find_list(line->bits, end); #ifdef DEBUG printf("etox_line_apply_context() - found start and end bits\n"); fflush(stdout); #endif /* make sure start and end exist and are in line->bits */ if ( !ls ) ls = line->bits; if ( !le ) le = eina_list_last(line->bits); for (l = ls; l; l = l->next) { Evas_Object *bit; bit = l->data; if (!l->prev && line->flags & ETOX_LINE_WRAPPED) { #ifdef DEBUG printf("etox_line_apply_context() - first bit of line. skipping obstacles...\n"); fflush(stdout); #endif /* go past any obstacles */ while (etox_style_fixed(bit)) { /* if there are only obstacles on the line (can this happen?) */ if (!l->next) return; l = l->next; bit = l->data; } #ifdef DEBUG printf("etox_line_apply_context() - applying context to marker bit\n"); fflush(stdout); #endif etox_style_set_text(bit, context->marker.text); etox_style_set_style(bit, context->marker.style); evas_object_color_set(bit, context->marker.r, context->marker.g, context->marker.b, context->marker.a); } else { #ifdef DEBUG printf("etox_line_apply_context() - applying context to bit\n"); fflush(stdout); #endif etox_style_set_style(bit, context->style); evas_object_color_set(bit, context->r, context->g, context->b, context->a); etox_style_set_font(bit, context->font, context->font_size); } if (l == le) break; } #ifdef DEBUG printf("etox_line_apply_context() - done\n"); fflush(stdout); #endif }
int etox_line_wrap(Etox *et, Etox_Line *line) { Eina_List *ll; Evas_Object *bit = NULL, *marker, *split_bit = NULL; Evas_Coord x, w, y, h; int index = -1, ok = 0; char *tmp; #ifdef DEBUG printf("etox_line_wrap() - trying to wrap line:\n"); etox_line_print_bits(line); #endif ok= 1; for (ll = line->bits; ll && ok; ll = ll->next) { bit = ll->data; tmp = etox_style_get_text(bit); evas_object_geometry_get(bit, &x, &y, &w, &h); /* if we are down to 1 character... or 1 char +space - abort */ if ( (strlen(tmp) <= 1) || ((strlen(tmp) == 2) && (tmp[1] == ' ')) ) { if (w > et->w) { ok = 0; #ifdef DEBUG printf("etox_line_wrap() - WARNING: Could not wrap line - etox too small!!\n"); #endif } } FREE(tmp); /* Find the bit that is on the border (right edje of the etox) */ if (x + w > et->x + et->w) { split_bit = bit; break; } } if (!ok) { return -1; } if (!split_bit) { #ifdef DEBUG printf("etox_line_wrap() - WARNING: Could not find the bit to split. Line " "width is probably wrong.\n"); #endif return -1; } /* get the index of the character on the edge */ bit = split_bit; if (bit) index = etox_style_text_at_position(bit, et->x + et->w, y + (h / 2), NULL, NULL, NULL, NULL); if (index == -1) { #ifdef DEBUG printf("etox_line_wrap() - WARNING: Could not find the character within the " "bit to split on. bit geometry is probably wrong?.\n"); #endif return -1; } /* Adjust the index to find the actual character we want to wrap. Invalid * wrap locations: * - index 0 of the first bit * - index 0 of the second bit if this is a wrapped line */ if (index > 0 || (!(bit == line->bits->data) && !(line->flags & ETOX_LINE_WRAPPED && bit == line->bits->next->data))) { char *tmp; tmp = etox_style_get_text(bit); /* If word wrap is on, back up to some whitespace */ if (et->flags & ETOX_BREAK_WORDS) { Evas_Object *original_bit = bit; int space_index = index; int done = 0; int found_space = 0; /* Back up until we find the proper word wrap index/bit */ while (!done) { /* If this is a space, we're done! */ if (isspace(tmp[space_index])) { found_space = 1; done = 1; } /* If this is the beginning of the bit and it is not the * first bit, back up into the previous bit */ else if (space_index == 0 && bit != line->bits->data) { ll = ll->prev; bit = ll->data; FREE(tmp); tmp = etox_style_get_text(bit); space_index = strlen(tmp) - 1; if (space_index < 0) space_index = 0; } /* If we're at the beginning of the line - give up! */ else if (space_index == 0) { done = 1; /* Point to the original bit */ bit = original_bit; FREE(tmp); tmp = etox_style_get_text(bit); #ifdef DEBUG printf("etox_line_wrap() - WARNING: Could not word wrap line - " "reverting to soft wrap.\n"); #endif } /* If this is not the beginning of the bit, back up */ else if (space_index > 0) { space_index--; } } /* If a space was found, then use it, otherwise revert to simple soft wrap and wrap at the character on the edge */ if (found_space) { index = space_index; } } /* don't start a new line with a space */ while (index < strlen(tmp) && isspace(tmp[index])) index++; FREE(tmp); } /* Wrap if we've found a reasonable position. Invalid wrap locations: * - index 0 of the first bit * - index 0 of the second bit if this is a wrapped line */ if (index > 0 || (!(bit == line->bits->data) && !(line->flags & ETOX_LINE_WRAPPED && bit == line->bits->next->data))) { #ifdef DEBUG char *tmp = etox_style_get_text(bit); printf("etox_line_wrap() - going to split line at index %d of bit:" "(%s)\n", index, tmp); FREE(tmp); #endif etox_line_split(line, bit, index); ll = eina_list_data_find_list(et->lines, line); ll = ll->next; /* create a marker bit. */ marker = etox_style_new(et->evas, et->context->marker.text, et->context->marker.style); etox_style_set_type(marker, ETOX_BIT_TYPE_WRAP_MARKER); evas_object_smart_member_add(marker, et->smart_obj); evas_object_color_set(marker, et->context->marker.r, et->context->marker.g, et->context->marker.b, et->context->marker.a); evas_object_clip_set(marker, et->clip); etox_style_set_font(marker, et->context->font, et->context->font_size); evas_object_show(marker); if (et->context->marker.placement == ETOX_MARKER_BEGINNING) etox_line_prepend(ll->data, marker); else etox_line_append(line, marker); } else index = -1; #ifdef DEBUG printf("etox_line_wrap() - done\n"); #endif return index; }