static void xv_doc_build_index(GtkTreeModel* model, GtkTreeIter* parent, PopplerIndexIter* index_iter) { do { GtkTreeIter tree_iter; PopplerIndexIter *child; PopplerAction *action; gboolean expand; gchar *markup; action = poppler_index_iter_get_action(index_iter); expand = poppler_index_iter_is_open(index_iter); if(!action) { continue; } markup = g_markup_escape_text(action->any.title, -1); gtk_tree_store_append(GTK_TREE_STORE(model), &tree_iter, parent); gtk_tree_store_set(GTK_TREE_STORE(model), &tree_iter, 0, markup, 1, action, -1); g_object_weak_ref(G_OBJECT(model), (GWeakNotify) poppler_action_free, action); g_free(markup); child = poppler_index_iter_get_child(index_iter); if(child) { xv_doc_build_index(model, &tree_iter, child); } poppler_index_iter_free(child); } while(poppler_index_iter_next(index_iter)); }
static VALUE rg_next(VALUE self) { if (poppler_index_iter_next(RVAL2POPPLERINDEXITER(self))) { return Qtrue; } else { rb_ivar_set(self, id_valid, Qfalse); return Qfalse; } }
static VALUE rg_each(VALUE self) { PopplerIndexIter *iter; CHECK_IITER_IS_VALID(self); iter = RVAL2POPPLERINDEXITER(self); do { rb_yield(self); } while (poppler_index_iter_next(iter)); rb_ivar_set(self, id_valid, Qfalse); return self; }
static void collect_action (PopplerIndexIter *iter) { do { PopplerAction *action; PopplerIndexIter *child; action = poppler_index_iter_get_action (iter); actual_action_types = g_list_append (actual_action_types, GUINT_TO_POINTER (action->type)); poppler_action_free (action); child = poppler_index_iter_get_child (iter); if (child) collect_action (child); poppler_index_iter_free (child); } while (poppler_index_iter_next (iter)); }
static void read_toc (PopplerIndexIter *index, GString **toc) { if (!index) { return; } if (!*toc) { *toc = g_string_new (""); } do { PopplerAction *action; PopplerIndexIter *iter; action = poppler_index_iter_get_action (index); if (!action) { continue; } switch (action->type) { case POPPLER_ACTION_GOTO_DEST: { PopplerActionGotoDest *ag = (PopplerActionGotoDest *)action; PopplerDest *agd = ag->dest; if (!tracker_is_empty_string (ag->title)) { g_string_append_printf (*toc, "%s ", ag->title); } if (!tracker_is_empty_string (agd->named_dest)) { g_string_append_printf (*toc, "%s ", agd->named_dest); } break; } case POPPLER_ACTION_LAUNCH: { PopplerActionLaunch *al = (PopplerActionLaunch *)action; if (!tracker_is_empty_string (al->title)) { g_string_append_printf (*toc, "%s ", al->title); } if (!tracker_is_empty_string (al->file_name)) { g_string_append_printf (*toc, "%s ", al->file_name); } if (!tracker_is_empty_string (al->params)) { g_string_append_printf (*toc, "%s ", al->params); } break; } case POPPLER_ACTION_URI: { PopplerActionUri *au = (PopplerActionUri *)action; if (!tracker_is_empty_string (au->uri)) { g_string_append_printf (*toc, "%s ", au->uri); } break; } case POPPLER_ACTION_NAMED: { PopplerActionNamed *an = (PopplerActionNamed *)action; if (!tracker_is_empty_string (an->title)) { g_string_append_printf (*toc, "%s, ", an->title); } if (!tracker_is_empty_string (an->named_dest)) { g_string_append_printf (*toc, "%s ", an->named_dest); } break; } case POPPLER_ACTION_MOVIE: { PopplerActionMovie *am = (PopplerActionMovie *)action; if (!tracker_is_empty_string (am->title)) { g_string_append_printf (*toc, "%s ", am->title); } break; } case POPPLER_ACTION_NONE: case POPPLER_ACTION_UNKNOWN: case POPPLER_ACTION_GOTO_REMOTE: case POPPLER_ACTION_RENDITION: case POPPLER_ACTION_OCG_STATE: case POPPLER_ACTION_JAVASCRIPT: /* Do nothing */ break; } poppler_action_free (action); iter = poppler_index_iter_get_child (index); read_toc (iter, toc); } while (poppler_index_iter_next (index)); poppler_index_iter_free (index); }