diff options
author | Evgeny Stambulchik <fnevgeny@gmail.com> | 2019-06-20 00:07:07 +0300 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2019-08-21 17:10:07 +0200 |
commit | 2f55f4cc10cc7544b1c564ef28f84d470b2dbe05 (patch) | |
tree | 86577097048e6238de5cf2e7136f29e8de24971c | |
parent | c6dbde146a47e2c899b57923b370470eddeb90f7 (diff) |
Implement missing Movie API's in the Glib bindings
-rw-r--r-- | glib/demo/utils.c | 11 | ||||
-rw-r--r-- | glib/poppler-movie.cc | 104 | ||||
-rw-r--r-- | glib/poppler-movie.h | 17 |
3 files changed, 131 insertions, 1 deletions
diff --git a/glib/demo/utils.c b/glib/demo/utils.c index 38bde147..40f541f7 100644 --- a/glib/demo/utils.c +++ b/glib/demo/utils.c @@ -564,6 +564,7 @@ pgd_movie_view_set_movie (GtkWidget *movie_view, GtkWidget *button; GEnumValue *enum_value; gint row = 0; + PopplerMovieTime start, duration; table = gtk_bin_get_child (GTK_BIN (movie_view)); if (table) { @@ -590,7 +591,15 @@ pgd_movie_view_set_movie (GtkWidget *movie_view, pgd_table_add_property (GTK_GRID (table), "<b>Need Poster:</b>", poppler_movie_need_poster (movie) ? "Yes" : "No", &row); pgd_table_add_property (GTK_GRID (table), "<b>Show Controls:</b>", poppler_movie_show_controls (movie) ? "Yes" : "No", &row); enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_MOVIE_PLAY_MODE), poppler_movie_get_play_mode (movie)); - pgd_table_add_property (GTK_GRID (table), "<b>Play mode:</b>", enum_value->value_name, &row); + pgd_table_add_property (GTK_GRID (table), "<b>Play Mode:</b>", enum_value->value_name, &row); + pgd_table_add_property (GTK_GRID (table), "<b>Synchronous Play:</b>", poppler_movie_synchronous_play (movie) ? "Yes" : "No", &row); + pgd_table_add_property (GTK_GRID (table), "<b>Volume:</b>", g_strdup_printf("%i", poppler_movie_get_volume (movie)), &row); + pgd_table_add_property (GTK_GRID (table), "<b>Rate:</b>", g_strdup_printf("%g", poppler_movie_get_rate (movie)), &row); + start = poppler_movie_get_start (movie); + pgd_table_add_property (GTK_GRID (table), "<b>Start:</b>", g_strdup_printf("%lu/%i s", start.units, start.units_per_second), &row); + duration = poppler_movie_get_duration (movie); + pgd_table_add_property (GTK_GRID (table), "<b>Duration:</b>", g_strdup_printf("%lu/%i s", duration.units, duration.units_per_second), &row); + pgd_table_add_property (GTK_GRID (table), "<b>Rotation Angle:</b>", g_strdup_printf("%u", poppler_movie_get_rotation_angle (movie)), &row); button = gtk_button_new_with_mnemonic ("_Play"); g_signal_connect (button, "clicked", diff --git a/glib/poppler-movie.cc b/glib/poppler-movie.cc index 999d1c40..f505ce07 100644 --- a/glib/poppler-movie.cc +++ b/glib/poppler-movie.cc @@ -38,6 +38,12 @@ struct _PopplerMovie gboolean need_poster; gboolean show_controls; PopplerMoviePlayMode mode; + gboolean synchronous_play; + gint volume; + gdouble rate; + PopplerMovieTime start; + PopplerMovieTime duration; + gushort rotation_angle; }; struct _PopplerMovieClass @@ -105,6 +111,20 @@ _poppler_movie_new (const Movie *poppler_movie) break; } + movie->synchronous_play = poppler_movie->getActivationParameters()->synchronousPlay; + + movie->volume = poppler_movie->getActivationParameters()->volume; + + movie->rate = poppler_movie->getActivationParameters()->rate; + + movie->start.units = poppler_movie->getActivationParameters()->start.units; + movie->start.units_per_second = poppler_movie->getActivationParameters()->start.units_per_second; + + movie->duration.units = poppler_movie->getActivationParameters()->duration.units; + movie->duration.units_per_second = poppler_movie->getActivationParameters()->duration.units_per_second; + + movie->rotation_angle = poppler_movie->getRotationAngle(); + return movie; } @@ -182,3 +202,87 @@ poppler_movie_get_play_mode (PopplerMovie *poppler_movie) return poppler_movie->mode; } + +/** + * poppler_movie_synchronous_play: + * @poppler_movie: a #PopplerMovie + * + * Returns whether the user must wait for the movie to be finished before + * the PDF viewer accepts any interactive action + * + * Return value: %TRUE if yes, %FALSE otherwise + */ +gboolean +poppler_movie_synchronous_play (PopplerMovie *poppler_movie) +{ + g_return_val_if_fail (POPPLER_IS_MOVIE (poppler_movie), FALSE); + + return poppler_movie->synchronous_play; +} + +/** + * poppler_movie_get_volume: + * @poppler_movie: a #PopplerMovie + * + * Returns the playback audio volume + * + * Return value: volume setting for the movie (0 - 100) + */ +gint +poppler_movie_get_volume (PopplerMovie *poppler_movie) +{ + g_return_val_if_fail (POPPLER_IS_MOVIE (poppler_movie), 0); + + return poppler_movie->volume; +} + +/** + * poppler_movie_get_rate: + * @poppler_movie: a #PopplerMovie + * + * Returns the relative speed of the movie + * + * Return value: the relative speed of the movie (1 means no change) + */ +gdouble +poppler_movie_get_rate (PopplerMovie *poppler_movie) +{ + g_return_val_if_fail (POPPLER_IS_MOVIE (poppler_movie), 0); + + return poppler_movie->rate; +} + +/** + * poppler_movie_get_rotation_angle: + * @poppler_movie: a #PopplerMovie + * + * Returns the rotation angle + * + * Return value: the number of degrees the movie should be rotated (positive, + * multiples of 90: 0, 90, 180, 270) + */ +gushort +poppler_movie_get_rotation_angle (PopplerMovie *poppler_movie) +{ + g_return_val_if_fail (POPPLER_IS_MOVIE (poppler_movie), 0); + + return poppler_movie->rotation_angle; +} + +const static PopplerMovieTime time0 = {0, 0}; + +PopplerMovieTime +poppler_movie_get_start (PopplerMovie *poppler_movie) +{ + g_return_val_if_fail (POPPLER_IS_MOVIE (poppler_movie), time0); + + return poppler_movie->start; +} + +PopplerMovieTime +poppler_movie_get_duration (PopplerMovie *poppler_movie) +{ + g_return_val_if_fail (POPPLER_IS_MOVIE (poppler_movie), time0); + + return poppler_movie->duration; +} diff --git a/glib/poppler-movie.h b/glib/poppler-movie.h index 02c07650..0cb7bb20 100644 --- a/glib/poppler-movie.h +++ b/glib/poppler-movie.h @@ -51,6 +51,11 @@ typedef enum POPPLER_MOVIE_PLAY_MODE_PALINDROME } PopplerMoviePlayMode; +typedef struct { + gulong units; + gint units_per_second; +} PopplerMovieTime; + POPPLER_PUBLIC GType poppler_movie_get_type (void) G_GNUC_CONST; POPPLER_PUBLIC @@ -61,6 +66,18 @@ POPPLER_PUBLIC gboolean poppler_movie_show_controls (PopplerMovie *poppler_movie); POPPLER_PUBLIC PopplerMoviePlayMode poppler_movie_get_play_mode (PopplerMovie *poppler_movie); +POPPLER_PUBLIC +gboolean poppler_movie_synchronous_play (PopplerMovie *poppler_movie); +POPPLER_PUBLIC +gint poppler_movie_get_volume (PopplerMovie *poppler_movie); +POPPLER_PUBLIC +gdouble poppler_movie_get_rate (PopplerMovie *poppler_movie); +POPPLER_PUBLIC +gushort poppler_movie_get_rotation_angle (PopplerMovie *poppler_movie); +POPPLER_PUBLIC +PopplerMovieTime poppler_movie_get_start (PopplerMovie *poppler_movie); +POPPLER_PUBLIC +PopplerMovieTime poppler_movie_get_duration (PopplerMovie *poppler_movie); G_END_DECLS |