static void pgd_annot_view_set_annot_movie (GtkWidget *table, PopplerAnnotMovie *annot, gint *row) { GtkWidget *movie_view; gchar *text; text = poppler_annot_movie_get_title (annot); pgd_table_add_property (GTK_GRID (table), "<b>Movie Title:</b>", text, row); g_free (text); movie_view = pgd_movie_view_new (); pgd_movie_view_set_movie (movie_view, poppler_annot_movie_get_movie (annot)); pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Movie:</b>", movie_view, row); gtk_widget_show (movie_view); }
void pgd_action_view_set_action (GtkWidget *action_view, PopplerAction *action) { GtkWidget *alignment; GtkWidget *table; gint row = 0; alignment = gtk_bin_get_child (GTK_BIN (action_view)); if (alignment) { gtk_container_remove (GTK_CONTAINER (action_view), alignment); } alignment = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 12, 5); gtk_container_add (GTK_CONTAINER (action_view), alignment); gtk_widget_show (alignment); if (!action) return; table = gtk_grid_new (); gtk_grid_set_column_spacing (GTK_GRID (table), 6); gtk_grid_set_row_spacing (GTK_GRID (table), 6); pgd_table_add_property (GTK_GRID (table), "<b>Title:</b>", action->any.title, &row); switch (action->type) { case POPPLER_ACTION_UNKNOWN: pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Unknown", &row); break; case POPPLER_ACTION_NONE: pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "None", &row); break; case POPPLER_ACTION_GOTO_DEST: pgd_action_view_add_destination (action_view, GTK_GRID (table), action->goto_dest.dest, FALSE, &row); break; case POPPLER_ACTION_GOTO_REMOTE: pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Remote Destination", &row); pgd_table_add_property (GTK_GRID (table), "<b>Filename:</b>", action->goto_remote.file_name, &row); pgd_action_view_add_destination (action_view, GTK_GRID (table), action->goto_remote.dest, TRUE, &row); break; case POPPLER_ACTION_LAUNCH: pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Launch", &row); pgd_table_add_property (GTK_GRID (table), "<b>Filename:</b>", action->launch.file_name, &row); pgd_table_add_property (GTK_GRID (table), "<b>Params:</b>", action->launch.params, &row); break; case POPPLER_ACTION_URI: pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "External URI", &row); pgd_table_add_property (GTK_GRID (table), "<b>URI</b>", action->uri.uri, &row); break; case POPPLER_ACTION_NAMED: pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Named Action", &row); pgd_table_add_property (GTK_GRID (table), "<b>Name:</b>", action->named.named_dest, &row); break; case POPPLER_ACTION_MOVIE: { GtkWidget *movie_view = pgd_movie_view_new (); pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Movie", &row); pgd_table_add_property (GTK_GRID (table), "<b>Operation:</b>", get_movie_op (action->movie.operation), &row); pgd_movie_view_set_movie (movie_view, action->movie.movie); pgd_table_add_property_with_custom_widget (GTK_GRID (table), "<b>Movie:</b>", movie_view, &row); } break; case POPPLER_ACTION_RENDITION: { gchar *text; pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "Rendition", &row); text = g_strdup_printf ("%d", action->rendition.op); pgd_table_add_property (GTK_GRID (table), "<b>Operation:</b>", text, &row); g_free (text); if (action->rendition.media) { gboolean embedded = poppler_media_is_embedded (action->rendition.media); GtkWidget *button; pgd_table_add_property (GTK_GRID (table), "<b>Embedded:</b>", embedded ? "Yes": "No", &row); if (embedded) { const gchar *mime_type = poppler_media_get_mime_type (action->rendition.media); pgd_table_add_property (GTK_GRID (table), "<b>Mime type:</b>", mime_type ? mime_type : "", &row); } else { pgd_table_add_property (GTK_GRID (table), "<b>Filename:</b>", poppler_media_get_filename (action->rendition.media), &row); } button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY); g_signal_connect (button, "clicked", G_CALLBACK (pgd_action_view_play_rendition), action->rendition.media); pgd_table_add_property_with_custom_widget (GTK_GRID (table), NULL, button, &row); gtk_widget_show (button); } } break; case POPPLER_ACTION_OCG_STATE: { GList *l; GtkWidget *button; pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "OCGState", &row); for (l = action->ocg_state.state_list; l; l = g_list_next (l)) { PopplerActionLayer *action_layer = (PopplerActionLayer *)l->data; gchar *text; gint n_layers = g_list_length (action_layer->layers); switch (action_layer->action) { case POPPLER_ACTION_LAYER_ON: text = g_strdup_printf ("%d layers On", n_layers); break; case POPPLER_ACTION_LAYER_OFF: text = g_strdup_printf ("%d layers Off", n_layers); break; case POPPLER_ACTION_LAYER_TOGGLE: text = g_strdup_printf ("%d layers Toggle", n_layers); break; } pgd_table_add_property (GTK_GRID (table), "<b>Action:</b>", text, &row); g_free (text); } button = gtk_button_new_with_label ("Do action"); g_signal_connect (button, "clicked", G_CALLBACK (pgd_action_view_do_action_layer), action->ocg_state.state_list); pgd_table_add_property_with_custom_widget (GTK_GRID (table), NULL, button, &row); gtk_widget_show (button); } break; case POPPLER_ACTION_JAVASCRIPT: { GtkTextBuffer *buffer; GtkWidget *textview; GtkWidget *swindow; pgd_table_add_property (GTK_GRID (table), "<b>Type:</b>", "JavaScript", &row); buffer = gtk_text_buffer_new (NULL); if (action->javascript.script) gtk_text_buffer_set_text (buffer, action->javascript.script, -1); textview = gtk_text_view_new_with_buffer (buffer); gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE); g_object_unref (buffer); swindow = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (swindow), textview); gtk_widget_show (textview); pgd_table_add_property_with_custom_widget (GTK_GRID (table), NULL, swindow, &row); gtk_widget_show (swindow); } break; default: g_assert_not_reached (); } gtk_container_add (GTK_CONTAINER (alignment), table); gtk_widget_show (table); }