static void _tree_fill (Etk_Pdf *pdf, Etk_Tree *tree, Etk_Tree_Col *col, Etk_Tree_Row *row, Ecore_List *items) { Etk_Tree_Row *prow; Epdf_Index_Item *item; if (!items) return; ecore_list_first_goto (items); while ((item = ecore_list_next (items))) { char *buf; Ecore_List *c; int *num; buf = strdup (epdf_index_item_title_get (item)); prow = etk_tree_row_append (tree, row, col, buf, NULL); num = (int *)malloc (sizeof (int)); *num = epdf_index_item_page_get (etk_pdf_pdf_document_get (pdf), item); etk_tree_row_data_set_full (prow, num, free); free (buf); c = epdf_index_item_children_get (item); if (c) { _tree_fill (pdf, tree, col, prow, c); } } }
static void display_index (Epdf_Document *document, Eina_List *children, int n) { Epdf_Index_Item *item; Eina_List *l; if (!children) return; EINA_LIST_FOREACH(children, l, item) { char *buf; char buf2[64]; int page; Eina_List *c; buf = (char *)malloc (sizeof (char) * 2 * n + 1); memset (buf, ' ', 2 * n); buf[2 * n] = '\0'; page = epdf_index_item_page_get (document, item); if (page == -1) snprintf (buf2, 64, "no dest. page"); else snprintf (buf2, 64, "page %d", page); printf ("%s%s (%s)\n", buf, epdf_index_item_title_get (item), buf2); free (buf); c = epdf_index_item_children_get (item); if (c) display_index (document, c, n + 1); }
void TOCDialog(Evas *e, Evas_Object *obj,Ecore_List *list) { int numchoices=ecore_list_count(list); char **initchoices; //char **values; initchoices=(char **)malloc(sizeof(char*)*numchoices); //values=(char **)malloc(sizeof(char*)*numchoices); ecore_list_first_goto(list); int i; for(i=0;i<numchoices;i++) { asprintf(&(initchoices[i]),"%d. %s",(i%8+1),epdf_index_item_title_get((Epdf_Index_Item *)ecore_list_next(list))); } Evas_Object *tocchoicebox=init_choicebox(e,(const char**)initchoices,NULL, numchoices, toc_choicehandler, "Table of Contents",obj,(void *)list, true); for(i=0;i<numchoices;i++) { free(initchoices[i]); } //free(values); free(initchoices); int x,y,w,h; evas_object_geometry_get(tocchoicebox,&x,&y,&w,&h); evas_object_move(tocchoicebox,(int)(((double)get_win_width()-w)/2.0),(int)(((double)get_win_height()-h)/2.0)); }