Enlightenment CVS committal Author : doursse Project : e17 Module : proto
Dir : e17/proto/epdf/src/bin Modified Files: epdf_etk_test.c epdf_evas_test.c epdf_ewl_test.c Log Message: big fat api breaking, plus a bug fixed for some pdf files without target in their index (maybe also a poppler bug) =================================================================== RCS file: /cvs/e/e17/proto/epdf/src/bin/epdf_etk_test.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- epdf_etk_test.c 15 Feb 2006 21:45:08 -0000 1.1 +++ epdf_etk_test.c 17 Apr 2006 18:06:10 -0000 1.2 @@ -13,35 +13,33 @@ void _tree_fill (Etk_Pdf *pdf, Etk_Tree *tree, Etk_Tree_Col *col, Etk_Tree_Row *row, Ecore_List *items) { - Etk_Tree_Row *prow; - Evas_Poppler_Index_Item *item; + Etk_Tree_Row *prow; + Epdf_Index_Item *item; if (!items) return; ecore_list_goto_first (items); - while ((item = ecore_list_next (items))) - { - char *buf; - Ecore_List *c; - int *num; - - buf = strdup (evas_poppler_index_item_title_get (item)); - if (!row) - prow = etk_tree_append (tree, col, buf, NULL); - else - prow = etk_tree_append_to_row (row, col, buf, NULL); + while ((item = ecore_list_next (items))) { + char *buf; + Ecore_List *c; + int *num; + + buf = strdup (epdf_index_item_title_get (item)); + if (!row) + prow = etk_tree_append (tree, col, buf, NULL); + else + prow = etk_tree_append_to_row (row, col, buf, NULL); - num = (int *)malloc (sizeof (int)); - *num = evas_poppler_index_item_page_get (etk_pdf_pdf_document_get (pdf), item); - etk_tree_row_data_set (prow, num); - free (buf); - c = evas_poppler_index_item_children_get (item); - if (c) - { - _tree_fill (pdf, tree, col, prow, c); - } + num = (int *)malloc (sizeof (int)); + *num = epdf_index_item_page_get (etk_pdf_pdf_document_get (pdf), item); + etk_tree_row_data_set (prow, num); + free (buf); + c = epdf_index_item_children_get (item); + if (c) { + _tree_fill (pdf, tree, col, prow, c); } + } } int @@ -55,29 +53,27 @@ Etk_Tree_Col *col; Etk_Tree_Row *row; Ecore_List *index; - Evas_Poppler_Document *document; + Epdf_Document *document; int page_count; int i; etk_init (); - if (argc == 1) - { - printf ("Usage: %s pdf_file\n", argv[0]); - etk_main_quit (); - return -1; - } + if (argc == 1) { + printf ("Usage: %s pdf_file\n", argv[0]); + etk_main_quit (); + return -1; + } /* We open the pdf file */ pdf = etk_pdf_new (); etk_pdf_file_set (ETK_PDF (pdf), argv[1]); document = ETK_PDF (pdf)->pdf_document; - if (!document) - { - printf ("The file %s can't be opened\n", argv[1]); - etk_main_quit (); - return -1; - } + if (!document) { + printf ("The file %s can't be opened\n", argv[1]); + etk_main_quit (); + return -1; + } index = etk_pdf_pdf_index_get (ETK_PDF (pdf)); @@ -90,25 +86,24 @@ etk_container_add (ETK_CONTAINER (window), table); etk_widget_show (table); - if (index) - { - tree = etk_tree_new (); - etk_tree_headers_visible_set (ETK_TREE (tree), ETK_FALSE); - etk_widget_size_request_set (tree, 60, -1); - etk_tree_mode_set (ETK_TREE(tree), ETK_TREE_MODE_TREE); - col = etk_tree_col_new (ETK_TREE(tree), "", - etk_tree_model_text_new (ETK_TREE (tree)), - 60); - etk_tree_build (ETK_TREE (tree)); - etk_tree_freeze (ETK_TREE (tree)); - _tree_fill (ETK_PDF (pdf), ETK_TREE (tree), col, NULL, index); - etk_tree_thaw (ETK_TREE (tree)); - evas_poppler_index_delete (index); - etk_signal_connect ("row_selected", ETK_OBJECT (tree), - ETK_CALLBACK(_change_page_cb), pdf); - etk_table_attach_defaults (ETK_TABLE (table), tree, 0, 0, 0, 0); - etk_widget_show (tree); - } + if (index) { + tree = etk_tree_new (); + etk_tree_headers_visible_set (ETK_TREE (tree), ETK_FALSE); + etk_widget_size_request_set (tree, 60, -1); + etk_tree_mode_set (ETK_TREE(tree), ETK_TREE_MODE_TREE); + col = etk_tree_col_new (ETK_TREE(tree), "", + etk_tree_model_text_new (ETK_TREE (tree)), + 60); + etk_tree_build (ETK_TREE (tree)); + etk_tree_freeze (ETK_TREE (tree)); + _tree_fill (ETK_PDF (pdf), ETK_TREE (tree), col, NULL, index); + etk_tree_thaw (ETK_TREE (tree)); + epdf_index_delete (index); + etk_signal_connect ("row_selected", ETK_OBJECT (tree), + ETK_CALLBACK(_change_page_cb), pdf); + etk_table_attach_defaults (ETK_TABLE (table), tree, 0, 0, 0, 0); + etk_widget_show (tree); + } list = etk_tree_new (); etk_tree_headers_visible_set (ETK_TREE (list), FALSE); @@ -127,17 +122,16 @@ 60); etk_tree_build (ETK_TREE (list)); - page_count = evas_poppler_document_page_count_get (ETK_PDF (pdf)->pdf_document); + page_count = epdf_document_page_count_get (ETK_PDF (pdf)->pdf_document); etk_tree_freeze (ETK_TREE (list)); - for (i = 0; i < page_count; i++) - { - int *num; - - row = etk_tree_append (ETK_TREE (list), col, i + 1, NULL); - num = (int *)malloc (sizeof (int)); - *num = i; - etk_tree_row_data_set (row, num); - } + for (i = 0; i < page_count; i++) { + int *num; + + row = etk_tree_append (ETK_TREE (list), col, i + 1, NULL); + num = (int *)malloc (sizeof (int)); + *num = i; + etk_tree_row_data_set (row, num); + } etk_tree_thaw (ETK_TREE (list)); etk_table_attach_defaults (ETK_TABLE (table), pdf, 1, 1, 0, 1); =================================================================== RCS file: /cvs/e/e17/proto/epdf/src/bin/epdf_evas_test.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- epdf_evas_test.c 16 Apr 2006 21:48:04 -0000 1.4 +++ epdf_evas_test.c 17 Apr 2006 18:06:10 -0000 1.5 @@ -9,7 +9,7 @@ #include "Epdf.h" static void -document_info_print (Evas_Poppler_Document *document, Evas_Poppler_Page *page); +document_info_print (Epdf_Document *document, Epdf_Page *page); static void app_resize(Ecore_Evas *ee); static int app_signal_exit(void *data, int ev_type, void *ev); @@ -18,36 +18,35 @@ int main (int argc, char *argv[]) { - Ecore_Evas *ee; - Evas *evas; - Evas_Object *o; - Evas_Poppler_Document *document; - Evas_Poppler_Page *page; - int page_number; + Ecore_Evas *ee; + Evas *evas; + Evas_Object *o; + Epdf_Document *document; + Epdf_Page *page; + int page_number; if (argc < 3) { printf ("\nUsage: %s filename page_number\n\n", argv[0]); exit (-1); } - document = evas_poppler_document_new (argv[1]); - if (!document) - { - printf ("Bad pdf file\n"); - exit (-1); - } + document = epdf_document_new (argv[1]); + if (!document) { + printf ("Bad pdf file\n"); + exit (-1); + } sscanf (argv[2], "%d", &page_number); - if (page_number >= evas_poppler_document_page_count_get (document)) { + if (page_number >= epdf_document_page_count_get (document)) { printf ("Page number exceeds the page count of the PDF document\n"); - evas_poppler_document_delete (document); + epdf_document_delete (document); exit (-1); } - page = evas_poppler_document_page_get (document, page_number); + page = epdf_document_page_get (document, page_number); if (!page) { printf ("Bad page\n"); - evas_poppler_document_delete (document); + epdf_document_delete (document); exit (-1); } @@ -58,36 +57,37 @@ evas_shutdown (); return -1; } + if (!ecore_evas_init()) { evas_shutdown (); ecore_shutdown (); return -1; } - ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 600, 850); + ee = ecore_evas_software_x11_new (NULL, 0, 0, 0, 600, 850); ecore_event_handler_add (ECORE_EVENT_SIGNAL_EXIT, app_signal_exit, NULL); - ecore_evas_callback_delete_request_set(ee, app_delete_request); - ecore_evas_title_set(ee, "Evas Pdf Test"); - ecore_evas_name_class_set(ee, "evas_pdf_test", "test_evas_pdf"); - ecore_evas_callback_resize_set(ee, app_resize); - ecore_evas_show(ee); - - evas = ecore_evas_get(ee); + ecore_evas_callback_delete_request_set (ee, app_delete_request); + ecore_evas_title_set (ee, "Evas Pdf Test"); + ecore_evas_name_class_set (ee, "evas_pdf_test", "test_evas_pdf"); + ecore_evas_callback_resize_set (ee, app_resize); + ecore_evas_show (ee); + + evas = ecore_evas_get (ee); o = evas_object_image_add (evas); - evas_object_move(o, 0, 0); - evas_poppler_page_render (page, o, - EVAS_POPPLER_PAGE_ORIENTATION_PORTRAIT, - 0, 0, -1, -1, - 1.0, 1.0); - evas_object_show(o); - ecore_evas_resize (ee, evas_poppler_page_width_get (page), evas_poppler_page_height_get (page)); + evas_object_move (o, 0, 0); + epdf_page_render (page, o, + EPDF_PAGE_ORIENTATION_PORTRAIT, + 0, 0, -1, -1, + 1.0, 1.0); + evas_object_show (o); + ecore_evas_resize (ee, epdf_page_width_get (page), epdf_page_height_get (page)); ecore_main_loop_begin (); - evas_poppler_page_delete (page); - evas_poppler_document_delete (document); - + epdf_page_delete (page); + epdf_document_delete (document); + ecore_evas_shutdown (); ecore_shutdown (); evas_shutdown (); @@ -95,13 +95,13 @@ return 0; } -static void display_index (Evas_Poppler_Document *document, Ecore_List *children, int n) +static void display_index (Epdf_Document *document, Ecore_List *children, int n) { - Evas_Poppler_Index_Item *item; + Epdf_Index_Item *item; if (!children) return; - + ecore_list_goto_first (children); while ((item = ecore_list_next (children))) { char *buf; @@ -112,75 +112,75 @@ buf = (char *)malloc (sizeof (char) * 2 * n + 1); memset (buf, ' ', 2 * n); buf[2 * n] = '\0'; - page = evas_poppler_index_item_page_get (document, item); + 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, evas_poppler_index_item_title_get (item), buf2); + printf ("%s%s (%s)\n", buf, epdf_index_item_title_get (item), buf2); free (buf); - c = evas_poppler_index_item_children_get (item); + c = epdf_index_item_children_get (item); if (c) display_index (document, c, n + 1); } } static void -document_info_print (Evas_Poppler_Document *document, Evas_Poppler_Page *page) +document_info_print (Epdf_Document *document, Epdf_Page *page) { - Ecore_List *fonts; - Ecore_List *index; - Evas_Poppler_Font_Info *font; - char *title; - char *author; - char *subject; - char *keywords; - char *creator; - char *producer; - const char *linearized; - char *creation_date; - char *mod_date; - const char *page_mode; - const char *page_layout; + Ecore_List *fonts; + Ecore_List *index; + Epdf_Font_Info *font; + char *title; + char *author; + char *subject; + char *keywords; + char *creator; + char *producer; + const char *linearized; + char *creation_date; + char *mod_date; + const char *page_mode; + const char *page_layout; printf ("\n"); - printf (" Poppler version....: %s\n", evas_poppler_version_get ()); + printf (" Poppler version....: %s\n", epdf_poppler_version_get ()); printf ("\n"); - + printf (" Document Metadata:\n"); printf ("\n"); - title = evas_poppler_document_title_get (document); + title = epdf_document_title_get (document); if (!title) title = strdup ("(none)"); - author = evas_poppler_document_author_get (document); + author = epdf_document_author_get (document); if (!author) author = strdup ("(none)"); - subject = evas_poppler_document_subject_get (document); + subject = epdf_document_subject_get (document); if (!subject) subject = strdup ("(none)"); - keywords = evas_poppler_document_keywords_get (document); + keywords = epdf_document_keywords_get (document); if (!keywords) keywords = strdup ("(none)"); - creator = evas_poppler_document_creator_get (document); + creator = epdf_document_creator_get (document); if (!creator) creator = strdup ("(none)"); - producer = evas_poppler_document_producer_get (document); + producer = epdf_document_producer_get (document); if (!producer) producer = strdup ("(none)"); - linearized = evas_poppler_document_linearized_get (document); - creation_date = evas_poppler_document_creation_date_get (document); + linearized = epdf_document_linearized_get (document); + creation_date = epdf_document_creation_date_get (document); if (!creation_date) creation_date = strdup ("(none)"); - mod_date = evas_poppler_document_mod_date_get (document); + mod_date = epdf_document_mod_date_get (document); if (!mod_date) mod_date = strdup ("(none)"); - page_mode = evas_poppler_document_page_mode_string_get (document); - page_layout = evas_poppler_document_page_layout_string_get (document); + page_mode = epdf_document_page_mode_string_get (document); + page_layout = epdf_document_page_layout_string_get (document); - printf (" File name..........: %s\n", evas_poppler_document_filename_get (document)); + printf (" File name..........: %s\n", epdf_document_filename_get (document)); printf (" Title..............: %s\n", title); - printf (" Format.............: PDF-%.1f\n", evas_poppler_document_pdf_version_get (document)); + printf (" Format.............: PDF-%.1f\n", epdf_document_pdf_version_get (document)); printf (" Author.............: %s\n", author); printf (" Subject............: %s\n", subject); printf (" Keywords...........: %s\n", keywords); @@ -193,27 +193,27 @@ printf (" Modification date..: %s\n", mod_date); printf ("\n"); - + printf (" Document Properties:\n"); printf ("\n"); - printf (" Page count.........: %d\n", evas_poppler_document_page_count_get (document)); + printf (" Page count.........: %d\n", epdf_document_page_count_get (document)); printf ("\n"); printf (" Fonts:\n"); printf ("\n"); - fonts = evas_poppler_document_fonts_get (document); + fonts = epdf_document_fonts_get (document); ecore_list_goto_first (fonts); while ((font = ecore_list_next (fonts))) { - printf (" %s (", evas_poppler_font_info_font_name_get (font)); - printf ("%s, ", evas_poppler_font_info_font_path_get (font)); - printf ("%s, ", evas_poppler_font_info_type_name_get (font)); - if (!evas_poppler_font_info_is_embedded_get (font)) + printf (" %s (", epdf_font_info_font_name_get (font)); + printf ("%s, ", epdf_font_info_font_path_get (font)); + printf ("%s, ", epdf_font_info_type_name_get (font)); + if (!epdf_font_info_is_embedded_get (font)) printf ("not "); printf ("embedded, "); - if (!evas_poppler_font_info_is_subset_get (font)) + if (!epdf_font_info_is_subset_get (font)) printf ("not "); printf ("subset)\n"); } @@ -223,12 +223,12 @@ printf (" Page Properties:\n"); printf ("\n"); - printf (" Number.............: %d\n", evas_poppler_page_number_get (page)); - printf (" Size (pixels)......: %d x %d\n", evas_poppler_page_width_get (page), evas_poppler_page_height_get (page)); - printf (" Orientation........: %s\n", evas_poppler_page_orientation_name_get (page)); + printf (" Number.............: %d\n", epdf_page_number_get (page)); + printf (" Size (pixels)......: %d x %d\n", epdf_page_width_get (page), epdf_page_height_get (page)); + printf (" Orientation........: %s\n", epdf_page_orientation_name_get (page)); printf ("\n"); - + if (title) free (title); if (author) @@ -247,9 +247,9 @@ if (mod_date) free (mod_date); - index = evas_poppler_index_new (document); + index = epdf_index_new (document); display_index (document, index, 0); - evas_poppler_index_delete (index); + epdf_index_delete (index); } static void @@ -257,7 +257,7 @@ { Evas_Coord w, h; Evas *evas; - + evas = ecore_evas_get(ee); evas_output_viewport_get(evas, NULL, NULL, &w, &h); /* bg_resize(w, h); */ =================================================================== RCS file: /cvs/e/e17/proto/epdf/src/bin/epdf_ewl_test.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- epdf_ewl_test.c 15 Feb 2006 21:45:08 -0000 1.1 +++ epdf_ewl_test.c 17 Apr 2006 18:06:10 -0000 1.2 @@ -13,78 +13,73 @@ void _tree_fill (Ewl_Widget *pdf, Ewl_Tree *tree, Ewl_Row *row, Ecore_List *items) { - Ewl_Widget *prow; - Evas_Poppler_Index_Item *item; + Ewl_Widget *prow; + Epdf_Index_Item *item; if (!items) return; ecore_list_goto_first (items); - while ((item = ecore_list_next (items))) - { - int page; - int *num; - char *buf; - Ecore_List *c; - - buf = strdup (evas_poppler_index_item_title_get (item)); - prow = ewl_tree_text_row_add (tree, row, - &buf); - page = evas_poppler_index_item_page_get (ewl_pdf_pdf_document_get (EWL_PDF (pdf)), item); - if (page >= 0) - { - num = (int *)malloc (sizeof (int)); - *num = page; - ewl_widget_data_set (prow, "row-number", num); - ewl_callback_append (EWL_WIDGET (prow), - EWL_CALLBACK_CLICKED, - EWL_CALLBACK_FUNCTION (_change_page_cb), - pdf); - } - free (buf); - c = evas_poppler_index_item_children_get (item); - if (c) - { - _tree_fill (pdf, tree, EWL_ROW (prow), c); - } + while ((item = ecore_list_next (items))) { + int page; + int *num; + char *buf; + Ecore_List *c; + + buf = strdup (epdf_index_item_title_get (item)); + prow = ewl_tree_text_row_add (tree, row, + &buf); + page = epdf_index_item_page_get (ewl_pdf_pdf_document_get (EWL_PDF (pdf)), item); + if (page >= 0) { + num = (int *)malloc (sizeof (int)); + *num = page; + ewl_widget_data_set (prow, "row-number", num); + ewl_callback_append (EWL_WIDGET (prow), + EWL_CALLBACK_CLICKED, + EWL_CALLBACK_FUNCTION (_change_page_cb), + pdf); } + free (buf); + c = epdf_index_item_children_get (item); + if (c) { + _tree_fill (pdf, tree, EWL_ROW (prow), c); + } + } } int main (int argc, char *argv[]) { - Ewl_Widget *window; - Ewl_Widget *table; - Ewl_Widget *list; - Ewl_Widget *tree; - Ewl_Widget *pdf; - Ewl_Widget *row; - Ecore_List *index; - Evas_Poppler_Document *document; - int page_count; - int i; + Ewl_Widget *window; + Ewl_Widget *table; + Ewl_Widget *list; + Ewl_Widget *tree; + Ewl_Widget *pdf; + Ewl_Widget *row; + Ecore_List *index; + Epdf_Document *document; + int page_count; + int i; ewl_init (&argc, (char **)argv); - if (argc == 1) - { - printf ("Usage: %s pdf_file\n", argv[0]); - ewl_main_quit (); - return -1; - } + if (argc == 1) { + printf ("Usage: %s pdf_file\n", argv[0]); + ewl_main_quit (); + return -1; + } /* We open the pdf file */ pdf = ewl_pdf_new (); ewl_pdf_file_set (EWL_PDF (pdf), argv[1]); document = EWL_PDF (pdf)->pdf_document; - if (!document) - { - printf ("The file %s can't be opened\n", argv[1]); - ewl_main_quit (); - return -1; - } + if (!document) { + printf ("The file %s can't be opened\n", argv[1]); + ewl_main_quit (); + return -1; + } - index = evas_poppler_index_new (document); + index = epdf_index_new (document); window = ewl_window_new (); ewl_window_title_set (EWL_WINDOW (window), "Ewl Pdf Test Application"); @@ -96,15 +91,14 @@ ewl_container_child_append (EWL_CONTAINER (window), table); ewl_widget_show (table); - if (index) - { - tree = ewl_tree_new (1); - ewl_tree_headers_visible_set (EWL_TREE (tree), FALSE); - ewl_table_add (EWL_TABLE (table), tree, 1, 1, 1, 1); - _tree_fill (pdf, EWL_TREE (tree), NULL, index); - evas_poppler_index_delete (index); - ewl_widget_show (tree); - } + if (index) { + tree = ewl_tree_new (1); + ewl_tree_headers_visible_set (EWL_TREE (tree), FALSE); + ewl_table_add (EWL_TABLE (table), tree, 1, 1, 1, 1); + _tree_fill (pdf, EWL_TREE (tree), NULL, index); + epdf_index_delete (index); + ewl_widget_show (tree); + } list = ewl_tree_new (1); ewl_tree_headers_visible_set (EWL_TREE (list), FALSE); @@ -117,24 +111,23 @@ ewl_table_add (EWL_TABLE (table), pdf, 2, 2, 1, 2); ewl_widget_show (pdf); - page_count = evas_poppler_document_page_count_get (document); - for (i = 0; i < page_count; i++) - { - char row_text[64]; - char *txt; - int *num; - - txt = row_text; - snprintf (row_text, 64, "%d", i + 1); - row = ewl_tree_text_row_add (EWL_TREE (list), NULL, &txt); - num = (int *)malloc (sizeof (int)); - *num = i; - ewl_widget_data_set (row, "row-number", num); - ewl_callback_append (EWL_WIDGET (row), - EWL_CALLBACK_CLICKED, - EWL_CALLBACK_FUNCTION (_change_page_cb), - pdf); - } + page_count = epdf_document_page_count_get (document); + for (i = 0; i < page_count; i++) { + char row_text[64]; + char *txt; + int *num; + + txt = row_text; + snprintf (row_text, 64, "%d", i + 1); + row = ewl_tree_text_row_add (EWL_TREE (list), NULL, &txt); + num = (int *)malloc (sizeof (int)); + *num = i; + ewl_widget_data_set (row, "row-number", num); + ewl_callback_append (EWL_WIDGET (row), + EWL_CALLBACK_CLICKED, + EWL_CALLBACK_FUNCTION (_change_page_cb), + pdf); + } ewl_widget_show (window); @@ -157,9 +150,8 @@ row_number = *(int *)ewl_widget_data_get (widget, "row-number"); pdf = EWL_PDF (user_data); - if (row_number != ewl_pdf_page_get (pdf)) - { - ewl_pdf_page_set (pdf, row_number); - ewl_callback_call (EWL_WIDGET (pdf), EWL_CALLBACK_REVEAL); - } + if (row_number != ewl_pdf_page_get (pdf)) { + ewl_pdf_page_set (pdf, row_number); + ewl_callback_call (EWL_WIDGET (pdf), EWL_CALLBACK_REVEAL); + } } ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs