/* movie.c generated by valac 0.56.17, the Vala compiler
 * generated from movie.vala, do not modify */

#include <glib.h>
#include <glib-object.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>
#include <gst/gst.h>
#include <poppler.h>
#include <gee.h>
#include <float.h>
#include <math.h>
#include <gio/gio.h>
#include <glib/gstdio.h>
#include <unistd.h>
#include <cairo-gobject.h>
#include <gst/video/video.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define PDFPC_TYPE_PIPELINE_ERROR (pdfpc_pipeline_error_get_type ())

#define PDFPC_TYPE_VIDEO_CONF (pdfpc_video_conf_get_type ())
#define PDFPC_VIDEO_CONF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_VIDEO_CONF, pdfpcVideoConf))
#define PDFPC_VIDEO_CONF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_VIDEO_CONF, pdfpcVideoConfClass))
#define PDFPC_IS_VIDEO_CONF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_VIDEO_CONF))
#define PDFPC_IS_VIDEO_CONF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_VIDEO_CONF))
#define PDFPC_VIDEO_CONF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_VIDEO_CONF, pdfpcVideoConfClass))

typedef struct _pdfpcVideoConf pdfpcVideoConf;
typedef struct _pdfpcVideoConfClass pdfpcVideoConfClass;
typedef struct _pdfpcVideoConfPrivate pdfpcVideoConfPrivate;

#define PDFPC_WINDOW_TYPE_FULLSCREEN (pdfpc_window_fullscreen_get_type ())
#define PDFPC_WINDOW_FULLSCREEN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_WINDOW_TYPE_FULLSCREEN, pdfpcWindowFullscreen))
#define PDFPC_WINDOW_FULLSCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_WINDOW_TYPE_FULLSCREEN, pdfpcWindowFullscreenClass))
#define PDFPC_WINDOW_IS_FULLSCREEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_WINDOW_TYPE_FULLSCREEN))
#define PDFPC_WINDOW_IS_FULLSCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_WINDOW_TYPE_FULLSCREEN))
#define PDFPC_WINDOW_FULLSCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_WINDOW_TYPE_FULLSCREEN, pdfpcWindowFullscreenClass))

typedef struct _pdfpcWindowFullscreen pdfpcWindowFullscreen;
typedef struct _pdfpcWindowFullscreenClass pdfpcWindowFullscreenClass;

#define PDFPC_WINDOW_TYPE_CONTROLLABLE_WINDOW (pdfpc_window_controllable_window_get_type ())
#define PDFPC_WINDOW_CONTROLLABLE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_WINDOW_TYPE_CONTROLLABLE_WINDOW, pdfpcWindowControllableWindow))
#define PDFPC_WINDOW_CONTROLLABLE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_WINDOW_TYPE_CONTROLLABLE_WINDOW, pdfpcWindowControllableWindowClass))
#define PDFPC_WINDOW_IS_CONTROLLABLE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_WINDOW_TYPE_CONTROLLABLE_WINDOW))
#define PDFPC_WINDOW_IS_CONTROLLABLE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_WINDOW_TYPE_CONTROLLABLE_WINDOW))
#define PDFPC_WINDOW_CONTROLLABLE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_WINDOW_TYPE_CONTROLLABLE_WINDOW, pdfpcWindowControllableWindowClass))

typedef struct _pdfpcWindowControllableWindow pdfpcWindowControllableWindow;
typedef struct _pdfpcWindowControllableWindowClass pdfpcWindowControllableWindowClass;
enum  {
	PDFPC_VIDEO_CONF_0_PROPERTY,
	PDFPC_VIDEO_CONF_DISPLAY_NUM_PROPERTY,
	PDFPC_VIDEO_CONF_RECT_PROPERTY,
	PDFPC_VIDEO_CONF_WINDOW_PROPERTY,
	PDFPC_VIDEO_CONF_NUM_PROPERTIES
};
static GParamSpec* pdfpc_video_conf_properties[PDFPC_VIDEO_CONF_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define PDFPC_TYPE_PLAYBACK_OPTIONS (pdfpc_playback_options_get_type ())
typedef struct _pdfpcPlaybackOptions pdfpcPlaybackOptions;
#define _g_free0(var) (var = (g_free (var), NULL))

#define PDFPC_TYPE_ACTION_MAPPING (pdfpc_action_mapping_get_type ())
#define PDFPC_ACTION_MAPPING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_ACTION_MAPPING, pdfpcActionMapping))
#define PDFPC_ACTION_MAPPING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_ACTION_MAPPING, pdfpcActionMappingClass))
#define PDFPC_IS_ACTION_MAPPING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_ACTION_MAPPING))
#define PDFPC_IS_ACTION_MAPPING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_ACTION_MAPPING))
#define PDFPC_ACTION_MAPPING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_ACTION_MAPPING, pdfpcActionMappingClass))

typedef struct _pdfpcActionMapping pdfpcActionMapping;
typedef struct _pdfpcActionMappingClass pdfpcActionMappingClass;
typedef struct _pdfpcActionMappingPrivate pdfpcActionMappingPrivate;

#define PDFPC_TYPE_PRESENTATION_CONTROLLER (pdfpc_presentation_controller_get_type ())
#define PDFPC_PRESENTATION_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_PRESENTATION_CONTROLLER, pdfpcPresentationController))
#define PDFPC_PRESENTATION_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_PRESENTATION_CONTROLLER, pdfpcPresentationControllerClass))
#define PDFPC_IS_PRESENTATION_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_PRESENTATION_CONTROLLER))
#define PDFPC_IS_PRESENTATION_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_PRESENTATION_CONTROLLER))
#define PDFPC_PRESENTATION_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_PRESENTATION_CONTROLLER, pdfpcPresentationControllerClass))

typedef struct _pdfpcPresentationController pdfpcPresentationController;
typedef struct _pdfpcPresentationControllerClass pdfpcPresentationControllerClass;
typedef enum  {
	PDFPC_ACTION_MAPPING_ACTION_TYPE_LINK,
	PDFPC_ACTION_MAPPING_ACTION_TYPE_MOVIE
} pdfpcActionMappingActionType;

#define PDFPC_ACTION_MAPPING_TYPE_ACTION_TYPE (pdfpc_action_mapping_action_type_get_type ())

#define PDFPC_TYPE_CONTROLLED_MOVIE (pdfpc_controlled_movie_get_type ())
#define PDFPC_CONTROLLED_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_CONTROLLED_MOVIE, pdfpcControlledMovie))
#define PDFPC_CONTROLLED_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_CONTROLLED_MOVIE, pdfpcControlledMovieClass))
#define PDFPC_IS_CONTROLLED_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_CONTROLLED_MOVIE))
#define PDFPC_IS_CONTROLLED_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_CONTROLLED_MOVIE))
#define PDFPC_CONTROLLED_MOVIE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_CONTROLLED_MOVIE, pdfpcControlledMovieClass))

typedef struct _pdfpcControlledMovie pdfpcControlledMovie;
typedef struct _pdfpcControlledMovieClass pdfpcControlledMovieClass;
typedef struct _pdfpcControlledMoviePrivate pdfpcControlledMoviePrivate;
enum  {
	PDFPC_CONTROLLED_MOVIE_0_PROPERTY,
	PDFPC_CONTROLLED_MOVIE_FILENAME_PROPERTY,
	PDFPC_CONTROLLED_MOVIE_NUM_PROPERTIES
};
static GParamSpec* pdfpc_controlled_movie_properties[PDFPC_CONTROLLED_MOVIE_NUM_PROPERTIES];
#define __vala_PopplerAction_free0(var) ((var == NULL) ? NULL : (var = (_vala_PopplerAction_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define PDFPC_VIEW_TYPE_VIDEO (pdfpc_view_video_get_type ())
#define PDFPC_VIEW_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_VIEW_TYPE_VIDEO, pdfpcViewVideo))
#define PDFPC_VIEW_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_VIEW_TYPE_VIDEO, pdfpcViewVideoClass))
#define PDFPC_VIEW_IS_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_VIEW_TYPE_VIDEO))
#define PDFPC_VIEW_IS_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_VIEW_TYPE_VIDEO))
#define PDFPC_VIEW_VIDEO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_VIEW_TYPE_VIDEO, pdfpcViewVideoClass))

typedef struct _pdfpcViewVideo pdfpcViewVideo;
typedef struct _pdfpcViewVideoClass pdfpcViewVideoClass;
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
#define __vala_GstVideoInfo_free0(var) ((var == NULL) ? NULL : (var = (_vala_GstVideoInfo_free (var), NULL)))
#define _cairo_font_options_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_font_options_destroy (var), NULL)))
typedef struct _Block1Data Block1Data;

/**
     * An error in constructing a gstreamer pipeline.
     */
typedef enum  {
	PDFPC_PIPELINE_ERROR_ElementConstruction,
	PDFPC_PIPELINE_ERROR_Linking
} pdfpcPipelineError;
#define PDFPC_PIPELINE_ERROR pdfpc_pipeline_error_quark ()

struct _pdfpcVideoConf {
	GObject parent_instance;
	pdfpcVideoConfPrivate * priv;
};

struct _pdfpcVideoConfClass {
	GObjectClass parent_class;
};

struct _pdfpcVideoConfPrivate {
	gint _display_num;
	GdkRectangle _rect;
	pdfpcWindowControllableWindow* _window;
};

struct _pdfpcPlaybackOptions {
	gboolean autostart;
	gboolean loop;
	gboolean noprogress;
	gboolean noaudio;
	gboolean poster;
	gint starttime;
	gint stoptime;
};

struct _pdfpcActionMapping {
	GObject parent_instance;
	pdfpcActionMappingPrivate * priv;
	pdfpcActionMappingActionType type;
	PopplerRectangle area;
	pdfpcPresentationController* controller;
};

struct _pdfpcActionMappingClass {
	GObjectClass parent_class;
	void (*init) (pdfpcActionMapping* self, PopplerRectangle* area, pdfpcPresentationController* controller);
	pdfpcActionMapping* (*new_from_link_mapping) (pdfpcActionMapping* self, PopplerLinkMapping* mapping, pdfpcPresentationController* controller);
	pdfpcActionMapping* (*new_from_annot_mapping) (pdfpcActionMapping* self, PopplerAnnotMapping* mapping, pdfpcPresentationController* controller);
	void (*on_mouse_enter) (pdfpcActionMapping* self, GtkWidget* widget, GdkEventMotion* event);
	void (*on_mouse_leave) (pdfpcActionMapping* self, GtkWidget* widget, GdkEventMotion* event);
	gboolean (*on_button_press) (pdfpcActionMapping* self, GtkWidget* widget, GdkEventButton* event);
	gboolean (*on_button_release) (pdfpcActionMapping* self, GtkWidget* widget, GdkEventButton* event);
	gboolean (*on_mouse_move) (pdfpcActionMapping* self, GtkWidget* widget, GdkEventMotion* event);
	gboolean (*is_sensitive) (pdfpcActionMapping* self);
	void (*on_freeze) (pdfpcActionMapping* self, gboolean frozen);
	void (*deactivate) (pdfpcActionMapping* self);
};

struct _pdfpcControlledMovie {
	pdfpcActionMapping parent_instance;
	pdfpcControlledMoviePrivate * priv;
	GstElement* pipeline;
	GeeList* sinks;
	gboolean shown;
	GdkCursor* pause_cursor;
	GdkCursor* play_cursor;
	GdkCursor* drag_cursor;
	gboolean eos;
	gchar* temp;
	GdkRectangle rect;
	gint video_w;
	gint video_h;
	gdouble scalex;
	gdouble scaley;
	gint64 duration;
	gdouble seek_bar_fontsize;
	gdouble seek_bar_height;
	gdouble seek_bar_padding;
	gboolean in_seek_bar;
	gboolean mouse_drag;
	gboolean drag_was_playing;
	gint64 paused_at;
	pdfpcPlaybackOptions options;
};

struct _pdfpcControlledMovieClass {
	pdfpcActionMappingClass parent_class;
	void (*stop) (pdfpcControlledMovie* self);
};

struct _pdfpcControlledMoviePrivate {
	gchar* _filename;
};

struct _Block1Data {
	int _ref_count_;
	pdfpcControlledMovie* self;
	pdfpcVideoConf* conf;
	GtkWidget* video_area;
	pdfpcViewVideo* video_surface;
};

static gint pdfpcVideoConf_private_offset;
static gpointer pdfpc_video_conf_parent_class = NULL;
static gint pdfpcControlledMovie_private_offset;
static gpointer pdfpc_controlled_movie_parent_class = NULL;
VALA_EXTERN gboolean pdfpc_options_auto_srt;

VALA_EXTERN GQuark pdfpc_pipeline_error_quark (void);
VALA_EXTERN GType pdfpc_pipeline_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType pdfpc_video_conf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcVideoConf, g_object_unref)
VALA_EXTERN GType pdfpc_window_fullscreen_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcWindowFullscreen, g_object_unref)
VALA_EXTERN GType pdfpc_window_controllable_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcWindowControllableWindow, g_object_unref)
VALA_EXTERN pdfpcVideoConf* pdfpc_video_conf_new (void);
VALA_EXTERN pdfpcVideoConf* pdfpc_video_conf_construct (GType object_type);
VALA_EXTERN gint pdfpc_video_conf_get_display_num (pdfpcVideoConf* self);
VALA_EXTERN void pdfpc_video_conf_set_display_num (pdfpcVideoConf* self,
                                       gint value);
VALA_EXTERN void pdfpc_video_conf_get_rect (pdfpcVideoConf* self,
                                GdkRectangle * result);
VALA_EXTERN void pdfpc_video_conf_set_rect (pdfpcVideoConf* self,
                                GdkRectangle * value);
static gboolean _cairo_rectangle_int_equal (const cairo_rectangle_int_t * s1,
                                     const cairo_rectangle_int_t * s2);
VALA_EXTERN pdfpcWindowControllableWindow* pdfpc_video_conf_get_window (pdfpcVideoConf* self);
VALA_EXTERN void pdfpc_video_conf_set_window (pdfpcVideoConf* self,
                                  pdfpcWindowControllableWindow* value);
static void pdfpc_video_conf_finalize (GObject * obj);
static GType pdfpc_video_conf_get_type_once (void);
static void _vala_pdfpc_video_conf_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_pdfpc_video_conf_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);
VALA_EXTERN GType pdfpc_playback_options_get_type (void) G_GNUC_CONST ;
VALA_EXTERN pdfpcPlaybackOptions* pdfpc_playback_options_dup (const pdfpcPlaybackOptions* self);
VALA_EXTERN void pdfpc_playback_options_free (pdfpcPlaybackOptions* self);
VALA_EXTERN GstElement* pdfpc_gst_element_make (const gchar* factoryname,
                                    const gchar* name,
                                    GError** error);
VALA_EXTERN GType pdfpc_action_mapping_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcActionMapping, g_object_unref)
VALA_EXTERN GType pdfpc_presentation_controller_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcPresentationController, g_object_unref)
VALA_EXTERN GType pdfpc_action_mapping_action_type_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType pdfpc_controlled_movie_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcControlledMovie, g_object_unref)
VALA_EXTERN pdfpcActionMapping* pdfpc_action_mapping_new_from_link_mapping (pdfpcActionMapping* self,
                                                                PopplerLinkMapping* mapping,
                                                                pdfpcPresentationController* controller);
VALA_EXTERN pdfpcActionMapping* pdfpc_action_mapping_new_from_annot_mapping (pdfpcActionMapping* self,
                                                                 PopplerAnnotMapping* mapping,
                                                                 pdfpcPresentationController* controller);
VALA_EXTERN void pdfpc_action_mapping_deactivate (pdfpcActionMapping* self);
VALA_EXTERN gboolean pdfpc_action_mapping_on_button_press (pdfpcActionMapping* self,
                                               GtkWidget* widget,
                                               GdkEventButton* event);
VALA_EXTERN gboolean pdfpc_action_mapping_on_button_release (pdfpcActionMapping* self,
                                                 GtkWidget* widget,
                                                 GdkEventButton* event);
VALA_EXTERN void pdfpc_action_mapping_on_mouse_leave (pdfpcActionMapping* self,
                                          GtkWidget* widget,
                                          GdkEventMotion* event);
VALA_EXTERN void pdfpc_action_mapping_on_freeze (pdfpcActionMapping* self,
                                     gboolean frozen);
VALA_EXTERN gboolean pdfpc_action_mapping_on_mouse_move (pdfpcActionMapping* self,
                                             GtkWidget* widget,
                                             GdkEventMotion* event);
VALA_EXTERN void pdfpc_controlled_movie_stop (pdfpcControlledMovie* self);
VALA_EXTERN void pdfpc_controlled_movie_init_movie2 (pdfpcControlledMovie* self,
                                         pdfpcControlledMovie* movie,
                                         const gchar* uri,
                                         const gchar* suburi);
VALA_EXTERN void pdfpc_controlled_movie_establish_pipeline (pdfpcControlledMovie* self,
                                                const gchar* uri,
                                                const gchar* suburi);
VALA_EXTERN void pdfpc_controlled_movie_play (pdfpcControlledMovie* self);
VALA_EXTERN void pdfpc_controlled_movie_hide (pdfpcControlledMovie* self);
VALA_EXTERN void pdfpc_controlled_movie_init_movie (pdfpcControlledMovie* self,
                                        pdfpcControlledMovie* movie,
                                        PopplerRectangle* area,
                                        pdfpcPresentationController* controller,
                                        const gchar* uri,
                                        const gchar* suburi,
                                        pdfpcPlaybackOptions* options,
                                        gboolean temp);
VALA_EXTERN void pdfpc_action_mapping_init (pdfpcActionMapping* self,
                                PopplerRectangle* area,
                                pdfpcPresentationController* controller);
static pdfpcActionMapping* pdfpc_controlled_movie_real_new_from_link_mapping (pdfpcActionMapping* base,
                                                                       PopplerLinkMapping* mapping,
                                                                       pdfpcPresentationController* controller);
static gboolean _vala_string_array_contains (gchar* * stack,
                                      gssize stack_length,
                                      const gchar* needle);
VALA_EXTERN gchar* pdfpc_controlled_movie_filename_to_uri (pdfpcControlledMovie* self,
                                               const gchar* location,
                                               const gchar* pdf_fname);
VALA_EXTERN gchar* pdfpc_presentation_controller_get_pdf_fname (pdfpcPresentationController* self);
static pdfpcActionMapping* pdfpc_controlled_movie_real_new_from_annot_mapping (pdfpcActionMapping* base,
                                                                        PopplerAnnotMapping* mapping,
                                                                        pdfpcPresentationController* controller);
static PopplerAction* _vala_PopplerAction_copy (PopplerAction* self);
static void _vala_PopplerAction_free (PopplerAction* self);
VALA_EXTERN void pdfpc_controlled_movie_set_filename (pdfpcControlledMovie* self,
                                          const gchar* value);
static void pdfpc_controlled_movie_real_deactivate (pdfpcActionMapping* base);
VALA_EXTERN GType pdfpc_view_video_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcViewVideo, g_object_unref)
VALA_EXTERN void pdfpc_view_video_remove_video (pdfpcViewVideo* self,
                                    GtkWidget* video);
static void pdfpc_controlled_movie_update_cursor (pdfpcControlledMovie* self,
                                           GdkWindow* window);
static gboolean pdfpc_controlled_movie_real_on_button_press (pdfpcActionMapping* base,
                                                      GtkWidget* widget,
                                                      GdkEventButton* event);
static void pdfpc_controlled_movie_set_mouse_in (pdfpcControlledMovie* self,
                                          gdouble x,
                                          gdouble y);
VALA_EXTERN void pdfpc_controlled_movie_toggle_play (pdfpcControlledMovie* self);
VALA_EXTERN void pdfpc_controlled_movie_pause (pdfpcControlledMovie* self);
VALA_EXTERN gint64 pdfpc_controlled_movie_mouse_seek (pdfpcControlledMovie* self,
                                          gdouble x,
                                          gdouble y);
static gboolean pdfpc_controlled_movie_real_on_button_release (pdfpcActionMapping* base,
                                                        GtkWidget* widget,
                                                        GdkEventButton* event);
VALA_EXTERN GdkCursor* pdfpc_controlled_movie_load_cursor (pdfpcControlledMovie* self,
                                               GdkDisplay* display,
                                               const gchar* filename);
VALA_EXTERN cairo_surface_t* pdfpc_renderer_image_render (const gchar* filename,
                                              gint width,
                                              gint height);
VALA_EXTERN void pdfpc_controlled_movie_refresh (pdfpcControlledMovie* self);
static void pdfpc_controlled_movie_real_on_mouse_leave (pdfpcActionMapping* base,
                                                 GtkWidget* widget,
                                                 GdkEventMotion* event);
static void pdfpc_controlled_movie_real_on_freeze (pdfpcActionMapping* base,
                                            gboolean frozen);
VALA_EXTERN void pdfpc_controlled_movie_on_draw (pdfpcControlledMovie* self,
                                     GstElement* overlay,
                                     cairo_t* cr,
                                     guint64 timestamp,
                                     guint64 duration);
VALA_EXTERN void pdfpc_controlled_movie_draw_seek_bar (pdfpcControlledMovie* self,
                                           cairo_t* cr,
                                           guint64 timestamp);
static gboolean ____lambda6_ (pdfpcControlledMovie* self);
static gboolean _____lambda6__gsource_func (gpointer self);
VALA_EXTERN void pdfpc_controlled_movie_on_gst_message (pdfpcControlledMovie* self,
                                            GstMessage* message);
static gboolean pdfpc_controlled_movie_real_on_mouse_move (pdfpcActionMapping* base,
                                                    GtkWidget* widget,
                                                    GdkEventMotion* event);
VALA_EXTERN void pdfpc_controlled_movie_on_prepare (pdfpcControlledMovie* self,
                                        GstElement* overlay,
                                        GstCaps* caps);
static void _vala_GstVideoInfo_free (GstVideoInfo* self);
VALA_EXTERN void pdfpc_controlled_movie_show (pdfpcControlledMovie* self);
VALA_EXTERN void pdfpc_presentation_controller_overlay_pos (pdfpcPresentationController* self,
                                                gint n,
                                                PopplerRectangle* area,
                                                GdkRectangle* rect,
                                                pdfpcWindowControllableWindow** window);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
VALA_EXTERN gboolean pdfpc_window_controllable_window_get_interactive (pdfpcWindowControllableWindow* self);
VALA_EXTERN GstElement* pdfpc_controlled_movie_add_video_control (pdfpcControlledMovie* self,
                                                      GstElement* source,
                                                      GstBin* bin,
                                                      GdkRectangle* rect);
VALA_EXTERN gboolean pdfpc_presentation_controller_get_frozen (pdfpcPresentationController* self);
VALA_EXTERN pdfpcViewVideo* pdfpc_window_controllable_window_get_video_surface (pdfpcWindowControllableWindow* self);
VALA_EXTERN void pdfpc_view_video_add_video (pdfpcViewVideo* self,
                                 GtkWidget* video,
                                 GdkRectangle* position);
static void ____lambda7_ (Block1Data* _data1_,
                   GtkAllocation* a);
VALA_EXTERN void pdfpc_view_video_resize_video (pdfpcViewVideo* self,
                                    GtkWidget* video,
                                    GdkRectangle* position);
static void _____lambda7__gtk_widget_size_allocate (GtkWidget* _sender,
                                             GtkAllocation* allocation,
                                             gpointer self);
static void _pdfpc_controlled_movie_on_gst_message_gst_bus_message (GstBus* _sender,
                                                             GstMessage* message,
                                                             gpointer self);
static void _pdfpc_controlled_movie_on_draw_dynamic_draw0_ (GstElement* _sender,
                                                     cairo_t* cr,
                                                     guint64 timestamp,
                                                     guint64 duration,
                                                     gpointer self);
static void _pdfpc_controlled_movie_on_prepare_dynamic_caps_changed1_ (GstElement* _sender,
                                                                GstCaps* caps,
                                                                gpointer self);
VALA_EXTERN void pdfpc_controlled_movie_rewind (pdfpcControlledMovie* self);
static void pdfpc_controlled_movie_real_stop (pdfpcControlledMovie* self);
VALA_EXTERN pdfpcControlledMovie* pdfpc_controlled_movie_new (void);
VALA_EXTERN pdfpcControlledMovie* pdfpc_controlled_movie_construct (GType object_type);
VALA_EXTERN pdfpcActionMapping* pdfpc_action_mapping_construct (GType object_type);
VALA_EXTERN const gchar* pdfpc_controlled_movie_get_filename (pdfpcControlledMovie* self);
static GObject * pdfpc_controlled_movie_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void pdfpc_controlled_movie_finalize (GObject * obj);
static GType pdfpc_controlled_movie_get_type_once (void);
static void _vala_pdfpc_controlled_movie_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_pdfpc_controlled_movie_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

GQuark
pdfpc_pipeline_error_quark (void)
{
	return g_quark_from_static_string ("pdfpc-pipeline-error-quark");
}

static GType
pdfpc_pipeline_error_get_type_once (void)
{
	static const GEnumValue values[] = {{PDFPC_PIPELINE_ERROR_ElementConstruction, "PDFPC_PIPELINE_ERROR_ElementConstruction", "elementconstruction"}, {PDFPC_PIPELINE_ERROR_Linking, "PDFPC_PIPELINE_ERROR_Linking", "linking"}, {0, NULL, NULL}};
	GType pdfpc_pipeline_error_type_id;
	pdfpc_pipeline_error_type_id = g_enum_register_static ("pdfpcPipelineError", values);
	return pdfpc_pipeline_error_type_id;
}

GType
pdfpc_pipeline_error_get_type (void)
{
	static volatile gsize pdfpc_pipeline_error_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_pipeline_error_type_id__once)) {
		GType pdfpc_pipeline_error_type_id;
		pdfpc_pipeline_error_type_id = pdfpc_pipeline_error_get_type_once ();
		g_once_init_leave (&pdfpc_pipeline_error_type_id__once, pdfpc_pipeline_error_type_id);
	}
	return pdfpc_pipeline_error_type_id__once;
}

static inline gpointer
pdfpc_video_conf_get_instance_private (pdfpcVideoConf* self)
{
	return G_STRUCT_MEMBER_P (self, pdfpcVideoConf_private_offset);
}

pdfpcVideoConf*
pdfpc_video_conf_construct (GType object_type)
{
	pdfpcVideoConf * self = NULL;
	self = (pdfpcVideoConf*) g_object_new (object_type, NULL);
	return self;
}

pdfpcVideoConf*
pdfpc_video_conf_new (void)
{
	return pdfpc_video_conf_construct (PDFPC_TYPE_VIDEO_CONF);
}

gint
pdfpc_video_conf_get_display_num (pdfpcVideoConf* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_display_num;
	return result;
}

void
pdfpc_video_conf_set_display_num (pdfpcVideoConf* self,
                                  gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = pdfpc_video_conf_get_display_num (self);
	if (old_value != value) {
		self->priv->_display_num = value;
		g_object_notify_by_pspec ((GObject *) self, pdfpc_video_conf_properties[PDFPC_VIDEO_CONF_DISPLAY_NUM_PROPERTY]);
	}
}

void
pdfpc_video_conf_get_rect (pdfpcVideoConf* self,
                           GdkRectangle * result)
{
	GdkRectangle _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_rect;
	*result = _tmp0_;
	return;
}

static gboolean
_cairo_rectangle_int_equal (const cairo_rectangle_int_t * s1,
                            const cairo_rectangle_int_t * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (s1->x != s2->x) {
		return FALSE;
	}
	if (s1->y != s2->y) {
		return FALSE;
	}
	if (s1->width != s2->width) {
		return FALSE;
	}
	if (s1->height != s2->height) {
		return FALSE;
	}
	return TRUE;
}

void
pdfpc_video_conf_set_rect (pdfpcVideoConf* self,
                           GdkRectangle * value)
{
	GdkRectangle old_value;
	g_return_if_fail (self != NULL);
	pdfpc_video_conf_get_rect (self, &old_value);
	if (_cairo_rectangle_int_equal (value, &old_value) != TRUE) {
		GdkRectangle _tmp0_;
		_tmp0_ = *value;
		self->priv->_rect = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, pdfpc_video_conf_properties[PDFPC_VIDEO_CONF_RECT_PROPERTY]);
	}
}

pdfpcWindowControllableWindow*
pdfpc_video_conf_get_window (pdfpcVideoConf* self)
{
	pdfpcWindowControllableWindow* result;
	pdfpcWindowControllableWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

void
pdfpc_video_conf_set_window (pdfpcVideoConf* self,
                             pdfpcWindowControllableWindow* value)
{
	pdfpcWindowControllableWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = pdfpc_video_conf_get_window (self);
	if (old_value != value) {
		pdfpcWindowControllableWindow* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_window);
		self->priv->_window = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, pdfpc_video_conf_properties[PDFPC_VIDEO_CONF_WINDOW_PROPERTY]);
	}
}

static void
pdfpc_video_conf_class_init (pdfpcVideoConfClass * klass,
                             gpointer klass_data)
{
	pdfpc_video_conf_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &pdfpcVideoConf_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_pdfpc_video_conf_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_pdfpc_video_conf_set_property;
	G_OBJECT_CLASS (klass)->finalize = pdfpc_video_conf_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_VIDEO_CONF_DISPLAY_NUM_PROPERTY, pdfpc_video_conf_properties[PDFPC_VIDEO_CONF_DISPLAY_NUM_PROPERTY] = g_param_spec_int ("display-num", "display-num", "display-num", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_VIDEO_CONF_RECT_PROPERTY, pdfpc_video_conf_properties[PDFPC_VIDEO_CONF_RECT_PROPERTY] = g_param_spec_boxed ("rect", "rect", "rect", gdk_rectangle_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_VIDEO_CONF_WINDOW_PROPERTY, pdfpc_video_conf_properties[PDFPC_VIDEO_CONF_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", PDFPC_WINDOW_TYPE_CONTROLLABLE_WINDOW, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
pdfpc_video_conf_instance_init (pdfpcVideoConf * self,
                                gpointer klass)
{
	self->priv = pdfpc_video_conf_get_instance_private (self);
}

static void
pdfpc_video_conf_finalize (GObject * obj)
{
	pdfpcVideoConf * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_TYPE_VIDEO_CONF, pdfpcVideoConf);
	_g_object_unref0 (self->priv->_window);
	G_OBJECT_CLASS (pdfpc_video_conf_parent_class)->finalize (obj);
}

/**
     * Datatype to hold video configuration (like size, pos, parent window)
     */
static GType
pdfpc_video_conf_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcVideoConfClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_video_conf_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcVideoConf), 0, (GInstanceInitFunc) pdfpc_video_conf_instance_init, NULL };
	GType pdfpc_video_conf_type_id;
	pdfpc_video_conf_type_id = g_type_register_static (G_TYPE_OBJECT, "pdfpcVideoConf", &g_define_type_info, 0);
	pdfpcVideoConf_private_offset = g_type_add_instance_private (pdfpc_video_conf_type_id, sizeof (pdfpcVideoConfPrivate));
	return pdfpc_video_conf_type_id;
}

GType
pdfpc_video_conf_get_type (void)
{
	static volatile gsize pdfpc_video_conf_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_video_conf_type_id__once)) {
		GType pdfpc_video_conf_type_id;
		pdfpc_video_conf_type_id = pdfpc_video_conf_get_type_once ();
		g_once_init_leave (&pdfpc_video_conf_type_id__once, pdfpc_video_conf_type_id);
	}
	return pdfpc_video_conf_type_id__once;
}

static void
_vala_pdfpc_video_conf_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	pdfpcVideoConf * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFPC_TYPE_VIDEO_CONF, pdfpcVideoConf);
	switch (property_id) {
		case PDFPC_VIDEO_CONF_DISPLAY_NUM_PROPERTY:
		g_value_set_int (value, pdfpc_video_conf_get_display_num (self));
		break;
		case PDFPC_VIDEO_CONF_RECT_PROPERTY:
		{
			GdkRectangle boxed;
			pdfpc_video_conf_get_rect (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		case PDFPC_VIDEO_CONF_WINDOW_PROPERTY:
		g_value_set_object (value, pdfpc_video_conf_get_window (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_pdfpc_video_conf_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	pdfpcVideoConf * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFPC_TYPE_VIDEO_CONF, pdfpcVideoConf);
	switch (property_id) {
		case PDFPC_VIDEO_CONF_DISPLAY_NUM_PROPERTY:
		pdfpc_video_conf_set_display_num (self, g_value_get_int (value));
		break;
		case PDFPC_VIDEO_CONF_RECT_PROPERTY:
		pdfpc_video_conf_set_rect (self, g_value_get_boxed (value));
		break;
		case PDFPC_VIDEO_CONF_WINDOW_PROPERTY:
		pdfpc_video_conf_set_window (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

pdfpcPlaybackOptions*
pdfpc_playback_options_dup (const pdfpcPlaybackOptions* self)
{
	pdfpcPlaybackOptions* dup;
	dup = g_new0 (pdfpcPlaybackOptions, 1);
	memcpy (dup, self, sizeof (pdfpcPlaybackOptions));
	return dup;
}

void
pdfpc_playback_options_free (pdfpcPlaybackOptions* self)
{
	g_free (self);
}

static GType
pdfpc_playback_options_get_type_once (void)
{
	GType pdfpc_playback_options_type_id;
	pdfpc_playback_options_type_id = g_boxed_type_register_static ("pdfpcPlaybackOptions", (GBoxedCopyFunc) pdfpc_playback_options_dup, (GBoxedFreeFunc) pdfpc_playback_options_free);
	return pdfpc_playback_options_type_id;
}

GType
pdfpc_playback_options_get_type (void)
{
	static volatile gsize pdfpc_playback_options_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_playback_options_type_id__once)) {
		GType pdfpc_playback_options_type_id;
		pdfpc_playback_options_type_id = pdfpc_playback_options_get_type_once ();
		g_once_init_leave (&pdfpc_playback_options_type_id__once, pdfpc_playback_options_type_id);
	}
	return pdfpc_playback_options_type_id__once;
}

/**
     * Make a non-NULL gstreamer element, or raise an error.
     */
static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

GstElement*
pdfpc_gst_element_make (const gchar* factoryname,
                        const gchar* name,
                        GError** error)
{
	GstElement* element = NULL;
	GstElement* _tmp0_;
	GstElement* _tmp1_;
	GError* _inner_error0_ = NULL;
	GstElement* result;
	g_return_val_if_fail (factoryname != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = gst_element_factory_make (factoryname, name);
	if (_tmp0_ != NULL) {
		g_object_ref_sink (_tmp0_);
	}
	element = _tmp0_;
	_tmp1_ = element;
	if (_tmp1_ == NULL) {
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		GError* _tmp6_;
		GError* _tmp7_;
		_tmp2_ = string_to_string (name);
		_tmp3_ = string_to_string (factoryname);
		_tmp4_ = g_strconcat ("Could not make element ", _tmp2_, " of type ", _tmp3_, ".", NULL);
		_tmp5_ = _tmp4_;
		_tmp6_ = g_error_new_literal (PDFPC_PIPELINE_ERROR, PDFPC_PIPELINE_ERROR_ElementConstruction, _tmp5_);
		_tmp7_ = _tmp6_;
		_g_free0 (_tmp5_);
		_inner_error0_ = _tmp7_;
		if (_inner_error0_->domain == PDFPC_PIPELINE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (element);
			return NULL;
		} else {
			_g_object_unref0 (element);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	result = element;
	return result;
}

static inline gpointer
pdfpc_controlled_movie_get_instance_private (pdfpcControlledMovie* self)
{
	return G_STRUCT_MEMBER_P (self, pdfpcControlledMovie_private_offset);
}

/**
         * Auxiliary part of init_movie() that can be called asynchronously
         * via GLib.Idle.add()
         */
void
pdfpc_controlled_movie_init_movie2 (pdfpcControlledMovie* self,
                                    pdfpcControlledMovie* movie,
                                    const gchar* uri,
                                    const gchar* suburi)
{
	GstElement* _tmp0_;
	GstElement* _tmp1_;
	GstElement* _tmp2_;
	GstElement* _tmp3_;
	pdfpcPlaybackOptions _tmp4_;
	pdfpcPlaybackOptions _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (movie != NULL);
	g_return_if_fail (uri != NULL);
	pdfpc_controlled_movie_establish_pipeline (movie, uri, suburi);
	_tmp0_ = movie->pipeline;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = movie->pipeline;
	gst_element_set_state (_tmp1_, GST_STATE_PAUSED);
	_tmp2_ = movie->pipeline;
	gst_element_get_state (_tmp2_, NULL, NULL, GST_CLOCK_TIME_NONE);
	_tmp3_ = movie->pipeline;
	_tmp4_ = movie->options;
	gst_element_seek_simple (_tmp3_, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, (gint64) (_tmp4_.starttime * GST_SECOND));
	_tmp5_ = movie->options;
	if (_tmp5_.autostart) {
		pdfpc_controlled_movie_play (movie);
	} else {
		pdfpcPlaybackOptions _tmp6_;
		_tmp6_ = movie->options;
		if (!_tmp6_.poster) {
			pdfpc_controlled_movie_hide (movie);
		}
	}
}

/**
         * Inits  the movie
         */
static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

void
pdfpc_controlled_movie_init_movie (pdfpcControlledMovie* self,
                                   pdfpcControlledMovie* movie,
                                   PopplerRectangle* area,
                                   pdfpcPresentationController* controller,
                                   const gchar* uri,
                                   const gchar* suburi,
                                   pdfpcPlaybackOptions* options,
                                   gboolean temp)
{
	PopplerRectangle _tmp0_;
	pdfpcPlaybackOptions _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (movie != NULL);
	g_return_if_fail (area != NULL);
	g_return_if_fail (controller != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (options != NULL);
	_tmp0_ = *area;
	pdfpc_action_mapping_init ((pdfpcActionMapping*) movie, &_tmp0_, controller);
	_tmp1_ = *options;
	movie->options = _tmp1_;
	if (temp) {
		gchar* _tmp3_;
		_tmp3_ = string_substring (uri, (glong) 7, (glong) -1);
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp3_;
	} else {
		gchar* _tmp4_;
		_tmp4_ = g_strdup ("");
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp4_;
	}
	_tmp5_ = g_strdup (_tmp2_);
	_g_free0 (movie->temp);
	movie->temp = _tmp5_;
	pdfpc_controlled_movie_init_movie2 (self, movie, uri, suburi);
	_g_free0 (_tmp2_);
}

/**
         * Create a new Movie from a link mapping, if the link of type "LAUNCH"
         * and points to a file that looks like a video file.  The video is
         * played back in the area of the hyperlink, which is probably not
         * conforming to the PDF spec, but it makes this an easy way to include
         * movies in presentations.  As a bonus, a query string on the video
         * filename can activate the autostart and loop properties.  (E.g., link
         * to movie.avi?autostart&loop to make movie.avi start playing with the
         * page is entered and loop back to the beginning when it reaches the
         * end.)
         */
static gboolean
_vala_string_array_contains (gchar* * stack,
                             gssize stack_length,
                             const gchar* needle)
{
	gssize i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static pdfpcActionMapping*
pdfpc_controlled_movie_real_new_from_link_mapping (pdfpcActionMapping* base,
                                                   PopplerLinkMapping* mapping,
                                                   pdfpcPresentationController* controller)
{
	pdfpcControlledMovie * self;
	PopplerAction* _tmp0_;
	gchar* file = NULL;
	PopplerAction* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** splitfile = NULL;
	const gchar* _tmp4_;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gint splitfile_length1;
	gint _splitfile_size_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* querystring = NULL;
	gchar* _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	gchar** queryarray = NULL;
	const gchar* _tmp15_;
	gchar** _tmp16_;
	gchar** _tmp17_;
	gint queryarray_length1;
	gint _queryarray_size_;
	gchar** _tmp18_;
	gint _tmp18__length1;
	gchar** _tmp19_;
	gint _tmp19__length1;
	gchar** _tmp20_;
	gint _tmp20__length1;
	gchar** _tmp21_;
	gint _tmp21__length1;
	gchar* srtfile = NULL;
	gchar** _tmp22_;
	gint _tmp22__length1;
	gchar* uri = NULL;
	const gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* suburi = NULL;
	const gchar* _tmp48_;
	gboolean uncertain = FALSE;
	gchar* ctype = NULL;
	const gchar* _tmp53_;
	gboolean _tmp54_ = FALSE;
	gchar* _tmp55_;
	gboolean _tmp56_ = FALSE;
	const gchar* _tmp57_;
	GType type = 0UL;
	pdfpcControlledMovie* new_obj = NULL;
	GObject* _tmp61_;
	GObject* _tmp62_;
	pdfpcControlledMovie* _tmp63_;
	PopplerRectangle _tmp64_;
	const gchar* _tmp65_;
	const gchar* _tmp66_;
	pdfpcPlaybackOptions _tmp67_;
	pdfpcActionMapping* result;
	self = (pdfpcControlledMovie*) base;
	g_return_val_if_fail (mapping != NULL, NULL);
	g_return_val_if_fail (controller != NULL, NULL);
	_tmp0_ = mapping->action;
	if (_tmp0_->type != POPPLER_ACTION_LAUNCH) {
		result = NULL;
		return result;
	}
	_tmp1_ = mapping->action;
	_tmp2_ = (*((PopplerActionLaunch*) _tmp1_)).file_name;
	_tmp3_ = g_strdup (_tmp2_);
	file = _tmp3_;
	_tmp4_ = file;
	_tmp6_ = _tmp5_ = g_strsplit (_tmp4_, "?", 2);
	splitfile = _tmp6_;
	splitfile_length1 = _vala_array_length (_tmp5_);
	_splitfile_size_ = splitfile_length1;
	_tmp7_ = splitfile;
	_tmp7__length1 = splitfile_length1;
	_tmp8_ = _tmp7_[0];
	_tmp9_ = g_strdup (_tmp8_);
	_g_free0 (file);
	file = _tmp9_;
	_tmp10_ = g_strdup ("");
	querystring = _tmp10_;
	_tmp11_ = splitfile;
	_tmp11__length1 = splitfile_length1;
	if (_tmp11__length1 == 2) {
		gchar** _tmp12_;
		gint _tmp12__length1;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		_tmp12_ = splitfile;
		_tmp12__length1 = splitfile_length1;
		_tmp13_ = _tmp12_[1];
		_tmp14_ = g_strdup (_tmp13_);
		_g_free0 (querystring);
		querystring = _tmp14_;
	}
	_tmp15_ = querystring;
	_tmp17_ = _tmp16_ = g_strsplit (_tmp15_, "&", 0);
	queryarray = _tmp17_;
	queryarray_length1 = _vala_array_length (_tmp16_);
	_queryarray_size_ = queryarray_length1;
	_tmp18_ = queryarray;
	_tmp18__length1 = queryarray_length1;
	self->options.autostart = _vala_string_array_contains (_tmp18_, _tmp18__length1, "autostart");
	_tmp19_ = queryarray;
	_tmp19__length1 = queryarray_length1;
	self->options.loop = _vala_string_array_contains (_tmp19_, _tmp19__length1, "loop");
	_tmp20_ = queryarray;
	_tmp20__length1 = queryarray_length1;
	self->options.noprogress = _vala_string_array_contains (_tmp20_, _tmp20__length1, "noprogress");
	_tmp21_ = queryarray;
	_tmp21__length1 = queryarray_length1;
	self->options.noaudio = _vala_string_array_contains (_tmp21_, _tmp21__length1, "noaudio");
	self->options.poster = FALSE;
	self->options.starttime = 0;
	self->options.stoptime = 0;
	srtfile = NULL;
	_tmp22_ = queryarray;
	_tmp22__length1 = queryarray_length1;
	{
		gchar** param_collection = NULL;
		gint param_collection_length1 = 0;
		gint _param_collection_size_ = 0;
		gint param_it = 0;
		param_collection = _tmp22_;
		param_collection_length1 = _tmp22__length1;
		for (param_it = 0; param_it < param_collection_length1; param_it = param_it + 1) {
			gchar* _tmp23_;
			gchar* param = NULL;
			_tmp23_ = g_strdup (param_collection[param_it]);
			param = _tmp23_;
			{
				const gchar* _tmp24_;
				const gchar* _tmp30_;
				const gchar* _tmp36_;
				_tmp24_ = param;
				if (g_str_has_prefix (_tmp24_, "start=")) {
					const gchar* _tmp25_;
					gchar** _tmp26_;
					gchar** _tmp27_;
					gchar** _tmp28_;
					gint _tmp28__length1;
					const gchar* _tmp29_;
					_tmp25_ = param;
					_tmp27_ = _tmp26_ = g_strsplit (_tmp25_, "=", 0);
					_tmp28_ = _tmp27_;
					_tmp28__length1 = _vala_array_length (_tmp26_);
					_tmp29_ = _tmp28_[1];
					self->options.starttime = atoi (_tmp29_);
					_tmp28_ = (_vala_array_free (_tmp28_, _tmp28__length1, (GDestroyNotify) g_free), NULL);
				}
				_tmp30_ = param;
				if (g_str_has_prefix (_tmp30_, "stop=")) {
					const gchar* _tmp31_;
					gchar** _tmp32_;
					gchar** _tmp33_;
					gchar** _tmp34_;
					gint _tmp34__length1;
					const gchar* _tmp35_;
					_tmp31_ = param;
					_tmp33_ = _tmp32_ = g_strsplit (_tmp31_, "=", 0);
					_tmp34_ = _tmp33_;
					_tmp34__length1 = _vala_array_length (_tmp32_);
					_tmp35_ = _tmp34_[1];
					self->options.stoptime = atoi (_tmp35_);
					_tmp34_ = (_vala_array_free (_tmp34_, _tmp34__length1, (GDestroyNotify) g_free), NULL);
				}
				_tmp36_ = param;
				if (g_str_has_prefix (_tmp36_, "srtfile=")) {
					const gchar* _tmp37_;
					gchar** _tmp38_;
					gchar** _tmp39_;
					gchar** _tmp40_;
					gint _tmp40__length1;
					const gchar* _tmp41_;
					gchar* _tmp42_;
					_tmp37_ = param;
					_tmp39_ = _tmp38_ = g_strsplit (_tmp37_, "=", 0);
					_tmp40_ = _tmp39_;
					_tmp40__length1 = _vala_array_length (_tmp38_);
					_tmp41_ = _tmp40_[1];
					_tmp42_ = g_strdup (_tmp41_);
					_g_free0 (srtfile);
					srtfile = _tmp42_;
					_tmp40_ = (_vala_array_free (_tmp40_, _tmp40__length1, (GDestroyNotify) g_free), NULL);
				}
				_g_free0 (param);
			}
		}
	}
	_tmp43_ = file;
	_tmp44_ = pdfpc_presentation_controller_get_pdf_fname (controller);
	_tmp45_ = _tmp44_;
	_tmp46_ = pdfpc_controlled_movie_filename_to_uri (self, _tmp43_, _tmp45_);
	_tmp47_ = _tmp46_;
	_g_free0 (_tmp45_);
	uri = _tmp47_;
	_tmp48_ = srtfile;
	if (_tmp48_ != NULL) {
		const gchar* _tmp49_;
		gchar* _tmp50_;
		gchar* _tmp51_;
		gchar* _tmp52_;
		_tmp49_ = srtfile;
		_tmp50_ = pdfpc_presentation_controller_get_pdf_fname (controller);
		_tmp51_ = _tmp50_;
		_tmp52_ = pdfpc_controlled_movie_filename_to_uri (self, _tmp49_, _tmp51_);
		_g_free0 (suburi);
		suburi = _tmp52_;
		_g_free0 (_tmp51_);
	} else {
		_g_free0 (suburi);
		suburi = NULL;
	}
	_tmp53_ = uri;
	_tmp55_ = g_content_type_guess (_tmp53_, NULL, (gsize) 0, &_tmp54_);
	uncertain = _tmp54_;
	ctype = _tmp55_;
	_tmp57_ = ctype;
	if (!string_contains (_tmp57_, "video")) {
		const gchar* _tmp58_;
		gchar* _tmp59_;
		gchar* _tmp60_;
		_tmp58_ = ctype;
		_tmp59_ = g_content_type_get_mime_type (_tmp58_);
		_tmp60_ = _tmp59_;
		_tmp56_ = !string_contains (_tmp60_, "video");
		_g_free0 (_tmp60_);
	} else {
		_tmp56_ = FALSE;
	}
	if (_tmp56_) {
		result = NULL;
		_g_free0 (ctype);
		_g_free0 (suburi);
		_g_free0 (uri);
		_g_free0 (srtfile);
		queryarray = (_vala_array_free (queryarray, queryarray_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (querystring);
		splitfile = (_vala_array_free (splitfile, splitfile_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (file);
		return result;
	}
	type = G_TYPE_FROM_INSTANCE (self);
	_tmp61_ = g_object_new (type, NULL);
	_tmp62_ = G_IS_INITIALLY_UNOWNED (_tmp61_) ? g_object_ref_sink (_tmp61_) : _tmp61_;
	new_obj = G_TYPE_CHECK_INSTANCE_CAST (_tmp62_, PDFPC_TYPE_CONTROLLED_MOVIE, pdfpcControlledMovie);
	_tmp63_ = new_obj;
	_tmp64_ = mapping->area;
	_tmp65_ = uri;
	_tmp66_ = suburi;
	_tmp67_ = self->options;
	pdfpc_controlled_movie_init_movie (self, _tmp63_, &_tmp64_, controller, _tmp65_, _tmp66_, &_tmp67_, FALSE);
	result = (pdfpcActionMapping*) new_obj;
	_g_free0 (ctype);
	_g_free0 (suburi);
	_g_free0 (uri);
	_g_free0 (srtfile);
	queryarray = (_vala_array_free (queryarray, queryarray_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (querystring);
	splitfile = (_vala_array_free (splitfile, splitfile_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (file);
	return result;
}

/**
         * Create a new Movie from an annotation mapping, if the annotation is a
         * screen annotation with a video file or a movie annotation.  Some
         * options to modify the behavior of the playback are not yet supported,
         * since they're missing from poppler.
         */
static PopplerAction*
_vala_PopplerAction_copy (PopplerAction* self)
{
	return g_boxed_copy (poppler_action_get_type (), self);
}

static gpointer
__vala_PopplerAction_copy0 (gpointer self)
{
	return self ? _vala_PopplerAction_copy (self) : NULL;
}

static void
_vala_PopplerAction_free (PopplerAction* self)
{
	g_boxed_free (poppler_action_get_type (), self);
}

static pdfpcActionMapping*
pdfpc_controlled_movie_real_new_from_annot_mapping (pdfpcActionMapping* base,
                                                    PopplerAnnotMapping* mapping,
                                                    pdfpcPresentationController* controller)
{
	pdfpcControlledMovie * self;
	PopplerAnnot* annot = NULL;
	PopplerAnnot* _tmp0_;
	PopplerAnnot* _tmp1_;
	gchar* uri = NULL;
	gchar* suburi = NULL;
	gboolean temp = FALSE;
	gchar* file = NULL;
	PopplerAnnot* _tmp2_;
	GType type = 0UL;
	pdfpcControlledMovie* new_obj = NULL;
	GObject* _tmp51_;
	GObject* _tmp52_;
	pdfpcControlledMovie* _tmp53_;
	const gchar* _tmp54_;
	pdfpcControlledMovie* _tmp55_;
	PopplerRectangle _tmp56_;
	const gchar* _tmp57_;
	const gchar* _tmp58_;
	pdfpcPlaybackOptions _tmp59_;
	GError* _inner_error0_ = NULL;
	pdfpcActionMapping* result;
	self = (pdfpcControlledMovie*) base;
	g_return_val_if_fail (mapping != NULL, NULL);
	g_return_val_if_fail (controller != NULL, NULL);
	_tmp0_ = mapping->annot;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	annot = _tmp1_;
	suburi = NULL;
	temp = FALSE;
	file = NULL;
	self->options.autostart = FALSE;
	self->options.loop = FALSE;
	self->options.noprogress = FALSE;
	self->options.noaudio = FALSE;
	self->options.poster = FALSE;
	self->options.starttime = 0;
	self->options.stoptime = 0;
	_tmp2_ = annot;
	switch (poppler_annot_get_annot_type (_tmp2_)) {
		case POPPLER_ANNOT_SCREEN:
		{
			PopplerAnnot* _tmp3_;
			gchar* _tmp4_;
			gchar* _tmp5_;
			gboolean _tmp6_;
			PopplerAction* action = NULL;
			PopplerAnnot* _tmp7_;
			PopplerAction* _tmp8_;
			PopplerAction* _tmp9_;
			PopplerMedia* movie = NULL;
			PopplerAction* _tmp10_;
			PopplerActionMovie _tmp11_;
			PopplerMovie* _tmp12_;
			PopplerMedia* _tmp13_;
			PopplerMedia* _tmp14_;
			_tmp3_ = annot;
			_tmp4_ = poppler_annot_get_contents (_tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = !string_contains (_tmp5_, "video");
			_g_free0 (_tmp5_);
			if (_tmp6_) {
				result = NULL;
				_g_free0 (file);
				_g_free0 (suburi);
				_g_free0 (uri);
				_g_object_unref0 (annot);
				return result;
			}
			_tmp7_ = annot;
			_tmp8_ = poppler_annot_screen_get_action (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, poppler_annot_screen_get_type (), PopplerAnnotScreen));
			_tmp9_ = __vala_PopplerAction_copy0 (_tmp8_);
			action = _tmp9_;
			_tmp10_ = action;
			_tmp11_ = _tmp10_->movie;
			_tmp12_ = _tmp11_.movie;
			_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, poppler_media_get_type (), PopplerMedia));
			movie = _tmp13_;
			_tmp14_ = movie;
			if (poppler_media_is_embedded (_tmp14_)) {
				gchar* tmp_fn = NULL;
				gint fh = 0;
				const gchar* _tmp24_;
				gchar* _tmp25_;
				{
					gint _tmp15_ = 0;
					gchar* _tmp16_ = NULL;
					gint _tmp17_;
					_tmp17_ = g_file_open_tmp ("pdfpc-XXXXXX", &_tmp16_, &_inner_error0_);
					_g_free0 (tmp_fn);
					tmp_fn = _tmp16_;
					_tmp15_ = _tmp17_;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						if (_inner_error0_->domain == G_FILE_ERROR) {
							goto __catch0_g_file_error;
						}
						_g_free0 (tmp_fn);
						_g_object_unref0 (movie);
						__vala_PopplerAction_free0 (action);
						_g_free0 (file);
						_g_free0 (suburi);
						_g_free0 (uri);
						_g_object_unref0 (annot);
						g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
						g_clear_error (&_inner_error0_);
						return NULL;
					}
					fh = _tmp15_;
				}
				goto __finally0;
				__catch0_g_file_error:
				{
					GError* e = NULL;
					GError* _tmp18_;
					const gchar* _tmp19_;
					e = _inner_error0_;
					_inner_error0_ = NULL;
					_tmp18_ = e;
					_tmp19_ = _tmp18_->message;
					g_printerr ("Could not create temp file: %s\n", _tmp19_);
					result = NULL;
					_g_error_free0 (e);
					_g_free0 (tmp_fn);
					_g_object_unref0 (movie);
					__vala_PopplerAction_free0 (action);
					_g_free0 (file);
					_g_free0 (suburi);
					_g_free0 (uri);
					_g_object_unref0 (annot);
					return result;
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_free0 (tmp_fn);
					_g_object_unref0 (movie);
					__vala_PopplerAction_free0 (action);
					_g_free0 (file);
					_g_free0 (suburi);
					_g_free0 (uri);
					_g_object_unref0 (annot);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return NULL;
				}
				close (fh);
				{
					PopplerMedia* _tmp20_;
					const gchar* _tmp21_;
					_tmp20_ = movie;
					_tmp21_ = tmp_fn;
					poppler_media_save (_tmp20_, _tmp21_, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch1_g_error;
					}
				}
				goto __finally1;
				__catch1_g_error:
				{
					GError* e = NULL;
					GError* _tmp22_;
					const gchar* _tmp23_;
					e = _inner_error0_;
					_inner_error0_ = NULL;
					_tmp22_ = e;
					_tmp23_ = _tmp22_->message;
					g_printerr ("Could not save temp file: %s\n", _tmp23_);
					result = NULL;
					_g_error_free0 (e);
					_g_free0 (tmp_fn);
					_g_object_unref0 (movie);
					__vala_PopplerAction_free0 (action);
					_g_free0 (file);
					_g_free0 (suburi);
					_g_free0 (uri);
					_g_object_unref0 (annot);
					return result;
				}
				__finally1:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_free0 (tmp_fn);
					_g_object_unref0 (movie);
					__vala_PopplerAction_free0 (action);
					_g_free0 (file);
					_g_free0 (suburi);
					_g_free0 (uri);
					_g_object_unref0 (annot);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return NULL;
				}
				_tmp24_ = tmp_fn;
				_tmp25_ = g_strconcat ("file://", _tmp24_, NULL);
				_g_free0 (uri);
				uri = _tmp25_;
				temp = TRUE;
				_g_free0 (tmp_fn);
			} else {
				PopplerMedia* _tmp26_;
				const gchar* _tmp27_;
				gchar* _tmp28_;
				const gchar* _tmp29_;
				const gchar* _tmp30_;
				gchar* _tmp31_;
				gchar* _tmp32_;
				gchar* _tmp33_;
				_tmp26_ = movie;
				_tmp27_ = poppler_media_get_filename (_tmp26_);
				_tmp28_ = g_strdup (_tmp27_);
				_g_free0 (file);
				file = _tmp28_;
				_tmp29_ = file;
				if (_tmp29_ == NULL) {
					g_printerr ("Movie not embedded and has no file name\n");
					result = NULL;
					_g_object_unref0 (movie);
					__vala_PopplerAction_free0 (action);
					_g_free0 (file);
					_g_free0 (suburi);
					_g_free0 (uri);
					_g_object_unref0 (annot);
					return result;
				}
				_tmp30_ = file;
				_tmp31_ = pdfpc_presentation_controller_get_pdf_fname (controller);
				_tmp32_ = _tmp31_;
				_tmp33_ = pdfpc_controlled_movie_filename_to_uri (self, _tmp30_, _tmp32_);
				_g_free0 (uri);
				uri = _tmp33_;
				_g_free0 (_tmp32_);
				temp = FALSE;
			}
			_g_object_unref0 (movie);
			__vala_PopplerAction_free0 (action);
			break;
		}
		case POPPLER_ANNOT_MOVIE:
		{
			PopplerMovie* movie = NULL;
			PopplerAnnot* _tmp34_;
			PopplerMovie* _tmp35_;
			PopplerMovie* _tmp36_;
			PopplerMovie* _tmp37_;
			const gchar* _tmp38_;
			gchar* _tmp39_;
			const gchar* _tmp40_;
			const gchar* _tmp41_;
			gchar* _tmp42_;
			gchar* _tmp43_;
			gchar* _tmp44_;
			PopplerMovie* _tmp45_;
			PopplerMovie* _tmp46_;
			PopplerMovie* _tmp47_;
			PopplerMovie* _tmp48_;
			gint duration = 0;
			PopplerMovie* _tmp49_;
			_tmp34_ = annot;
			_tmp35_ = poppler_annot_movie_get_movie (G_TYPE_CHECK_INSTANCE_CAST (_tmp34_, poppler_annot_movie_get_type (), PopplerAnnotMovie));
			_tmp36_ = _g_object_ref0 (_tmp35_);
			movie = _tmp36_;
			_tmp37_ = movie;
			_tmp38_ = poppler_movie_get_filename (_tmp37_);
			_tmp39_ = g_strdup (_tmp38_);
			_g_free0 (file);
			file = _tmp39_;
			_tmp40_ = file;
			if (_tmp40_ == NULL) {
				g_printerr ("Movie has no file name\n");
				result = NULL;
				_g_object_unref0 (movie);
				_g_free0 (file);
				_g_free0 (suburi);
				_g_free0 (uri);
				_g_object_unref0 (annot);
				return result;
			}
			_tmp41_ = file;
			_tmp42_ = pdfpc_presentation_controller_get_pdf_fname (controller);
			_tmp43_ = _tmp42_;
			_tmp44_ = pdfpc_controlled_movie_filename_to_uri (self, _tmp41_, _tmp43_);
			_g_free0 (uri);
			uri = _tmp44_;
			_g_free0 (_tmp43_);
			temp = FALSE;
			_tmp45_ = movie;
			self->options.poster = poppler_movie_need_poster (_tmp45_);
			_tmp46_ = movie;
			self->options.noprogress = !poppler_movie_show_controls (_tmp46_);
			_tmp47_ = movie;
			self->options.loop = poppler_movie_get_play_mode (_tmp47_) == POPPLER_MOVIE_PLAY_MODE_REPEAT;
			_tmp48_ = movie;
			self->options.starttime = (gint) (poppler_movie_get_start (_tmp48_) / 1000000000L);
			_tmp49_ = movie;
			duration = (gint) (poppler_movie_get_duration (_tmp49_) / 1000000000L);
			if (duration > 0) {
				pdfpcPlaybackOptions _tmp50_;
				_tmp50_ = self->options;
				self->options.stoptime = _tmp50_.starttime + duration;
			}
			_g_object_unref0 (movie);
			break;
		}
		default:
		{
			result = NULL;
			_g_free0 (file);
			_g_free0 (suburi);
			_g_free0 (uri);
			_g_object_unref0 (annot);
			return result;
		}
	}
	type = G_TYPE_FROM_INSTANCE (self);
	_tmp51_ = g_object_new (type, NULL);
	_tmp52_ = G_IS_INITIALLY_UNOWNED (_tmp51_) ? g_object_ref_sink (_tmp51_) : _tmp51_;
	new_obj = G_TYPE_CHECK_INSTANCE_CAST (_tmp52_, PDFPC_TYPE_CONTROLLED_MOVIE, pdfpcControlledMovie);
	_tmp53_ = new_obj;
	_tmp54_ = file;
	pdfpc_controlled_movie_set_filename (_tmp53_, _tmp54_);
	_tmp55_ = new_obj;
	_tmp56_ = mapping->area;
	_tmp57_ = uri;
	_tmp58_ = suburi;
	_tmp59_ = self->options;
	pdfpc_controlled_movie_init_movie (self, _tmp55_, &_tmp56_, controller, _tmp57_, _tmp58_, &_tmp59_, temp);
	result = (pdfpcActionMapping*) new_obj;
	_g_free0 (file);
	_g_free0 (suburi);
	_g_free0 (uri);
	_g_object_unref0 (annot);
	return result;
}

/**
         * When we leave the page, stop the movie and delete any temporary files.
         */
static void
pdfpc_controlled_movie_real_deactivate (pdfpcActionMapping* base)
{
	pdfpcControlledMovie * self;
	const gchar* _tmp0_;
	self = (pdfpcControlledMovie*) base;
	pdfpc_controlled_movie_stop (self);
	_tmp0_ = self->temp;
	if (g_strcmp0 (_tmp0_, "") != 0) {
		const gchar* _tmp1_;
		_tmp1_ = self->temp;
		if (g_unlink (_tmp1_) != 0) {
			const gchar* _tmp2_;
			_tmp2_ = self->temp;
			g_printerr ("Problem deleting temp file %s\n", _tmp2_);
		}
	}
	{
		GeeList* _sink_list = NULL;
		GeeList* _tmp3_;
		gint _sink_size = 0;
		GeeList* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		gint _sink_index = 0;
		_tmp3_ = self->sinks;
		_sink_list = _tmp3_;
		_tmp4_ = _sink_list;
		_tmp5_ = gee_collection_get_size ((GeeCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		_sink_size = _tmp6_;
		_sink_index = -1;
		while (TRUE) {
			gint _tmp7_;
			gint _tmp8_;
			GtkWidget* sink = NULL;
			GeeList* _tmp9_;
			gpointer _tmp10_;
			pdfpcViewVideo* parent = NULL;
			GtkWidget* _tmp11_;
			GtkContainer* _tmp12_;
			GtkContainer* _tmp13_;
			pdfpcViewVideo* _tmp14_;
			pdfpcViewVideo* _tmp15_;
			GtkWidget* _tmp16_;
			_sink_index = _sink_index + 1;
			_tmp7_ = _sink_index;
			_tmp8_ = _sink_size;
			if (!(_tmp7_ < _tmp8_)) {
				break;
			}
			_tmp9_ = _sink_list;
			_tmp10_ = gee_list_get (_tmp9_, _sink_index);
			sink = (GtkWidget*) _tmp10_;
			_tmp11_ = sink;
			_tmp12_ = gtk_widget_get_parent (_tmp11_);
			_tmp13_ = _tmp12_;
			_tmp14_ = _g_object_ref0 (PDFPC_VIEW_IS_VIDEO (_tmp13_) ? ((pdfpcViewVideo*) _tmp13_) : NULL);
			parent = _tmp14_;
			_tmp15_ = parent;
			_tmp16_ = sink;
			pdfpc_view_video_remove_video (_tmp15_, _tmp16_);
			_g_object_unref0 (parent);
			_g_object_unref0 (sink);
		}
	}
}

/**
         * Hide all video widegts (but receive events for them)
         */
void
pdfpc_controlled_movie_hide (pdfpcControlledMovie* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeList* _sink_list = NULL;
		GeeList* _tmp0_;
		gint _sink_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _sink_index = 0;
		_tmp0_ = self->sinks;
		_sink_list = _tmp0_;
		_tmp1_ = _sink_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_sink_size = _tmp3_;
		_sink_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			GtkWidget* sink = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			GtkWidget* _tmp8_;
			_sink_index = _sink_index + 1;
			_tmp4_ = _sink_index;
			_tmp5_ = _sink_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _sink_list;
			_tmp7_ = gee_list_get (_tmp6_, _sink_index);
			sink = (GtkWidget*) _tmp7_;
			_tmp8_ = sink;
			gtk_widget_set_opacity (_tmp8_, (gdouble) 0);
			_g_object_unref0 (sink);
		}
	}
	self->shown = FALSE;
}

static void
pdfpc_controlled_movie_update_cursor (pdfpcControlledMovie* self,
                                      GdkWindow* window)
{
	GdkCursor* cursor = NULL;
	GdkCursor* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	if (self->in_seek_bar) {
		GdkCursor* _tmp0_;
		GdkCursor* _tmp1_;
		_tmp0_ = self->drag_cursor;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_g_object_unref0 (cursor);
		cursor = _tmp1_;
	} else {
		if (self->paused_at >= ((gint64) 0)) {
			GdkCursor* _tmp2_;
			GdkCursor* _tmp3_;
			_tmp2_ = self->play_cursor;
			_tmp3_ = _g_object_ref0 (_tmp2_);
			_g_object_unref0 (cursor);
			cursor = _tmp3_;
		} else {
			GdkCursor* _tmp4_;
			GdkCursor* _tmp5_;
			_tmp4_ = self->pause_cursor;
			_tmp5_ = _g_object_ref0 (_tmp4_);
			_g_object_unref0 (cursor);
			cursor = _tmp5_;
		}
	}
	_tmp6_ = cursor;
	gdk_window_set_cursor (window, _tmp6_);
	_g_object_unref0 (cursor);
}

/**
         * If we click outside of the progress bar, toggle the playing state.
         * Inside the progress bar, pause or stop the timeout, and start the
         * drag state.
         */
static gboolean
pdfpc_controlled_movie_real_on_button_press (pdfpcActionMapping* base,
                                             GtkWidget* widget,
                                             GdkEventButton* event)
{
	pdfpcControlledMovie * self;
	GstElement* _tmp0_;
	GdkWindow* _tmp1_;
	gboolean result;
	self = (pdfpcControlledMovie*) base;
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->pipeline;
	if (_tmp0_ == NULL) {
		result = FALSE;
		return result;
	}
	_tmp1_ = event->window;
	pdfpc_controlled_movie_update_cursor (self, _tmp1_);
	pdfpc_controlled_movie_set_mouse_in (self, event->x, event->y);
	if (!self->in_seek_bar) {
		pdfpc_controlled_movie_toggle_play (self);
	} else {
		GstElement* _tmp2_;
		self->mouse_drag = TRUE;
		_tmp2_ = self->pipeline;
		self->drag_was_playing = _tmp2_->current_state == GST_STATE_PLAYING;
		pdfpc_controlled_movie_pause (self);
		pdfpc_controlled_movie_mouse_seek (self, event->x, event->y);
	}
	result = TRUE;
	return result;
}

/**
         * Stop the drag state and restart either playback or the timeout,
         * depending on the previous state.
         */
static gboolean
pdfpc_controlled_movie_real_on_button_release (pdfpcActionMapping* base,
                                               GtkWidget* widget,
                                               GdkEventButton* event)
{
	pdfpcControlledMovie * self;
	GdkWindow* _tmp0_;
	gboolean result;
	self = (pdfpcControlledMovie*) base;
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = event->window;
	pdfpc_controlled_movie_update_cursor (self, _tmp0_);
	pdfpc_controlled_movie_set_mouse_in (self, event->x, event->y);
	if (self->mouse_drag) {
		gint64 seek_time = 0LL;
		gboolean _tmp1_ = FALSE;
		seek_time = pdfpc_controlled_movie_mouse_seek (self, event->x, event->y);
		if (self->drag_was_playing) {
			_tmp1_ = TRUE;
		} else {
			_tmp1_ = self->eos;
		}
		if (_tmp1_) {
			self->eos = FALSE;
			pdfpc_controlled_movie_play (self);
		} else {
			GstElement* _tmp2_;
			_tmp2_ = self->pipeline;
			gst_element_seek_simple (_tmp2_, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, seek_time);
		}
	}
	self->mouse_drag = FALSE;
	result = TRUE;
	return result;
}

/**
         * Load a cursor
         */
GdkCursor*
pdfpc_controlled_movie_load_cursor (pdfpcControlledMovie* self,
                                    GdkDisplay* display,
                                    const gchar* filename)
{
	GdkCursor* cursor = NULL;
	gint size = 0;
	cairo_surface_t* surface = NULL;
	cairo_surface_t* _tmp0_;
	cairo_surface_t* _tmp1_;
	GdkCursor* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (display != NULL, NULL);
	g_return_val_if_fail (filename != NULL, NULL);
	size = 24;
	_tmp0_ = pdfpc_renderer_image_render (filename, size, size);
	surface = _tmp0_;
	_tmp1_ = surface;
	if (_tmp1_ != NULL) {
		cairo_surface_t* _tmp2_;
		GdkCursor* _tmp3_;
		_tmp2_ = surface;
		_tmp3_ = gdk_cursor_new_from_surface (display, _tmp2_, (gdouble) 0, (gdouble) 0);
		_g_object_unref0 (cursor);
		cursor = _tmp3_;
	} else {
		GdkCursor* _tmp4_;
		_tmp4_ = gdk_cursor_new_from_name (display, "default");
		_g_object_unref0 (cursor);
		cursor = _tmp4_;
	}
	result = cursor;
	_cairo_surface_destroy0 (surface);
	return result;
}

/**
         * Force refresh when not playing
         */
void
pdfpc_controlled_movie_refresh (pdfpcControlledMovie* self)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	if (self->paused_at >= ((gint64) 0)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->eos;
	}
	if (_tmp0_) {
		GstElement* _tmp1_;
		_tmp1_ = self->pipeline;
		gst_element_seek_simple (_tmp1_, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, self->paused_at);
	}
}

static void
pdfpc_controlled_movie_real_on_mouse_leave (pdfpcActionMapping* base,
                                            GtkWidget* widget,
                                            GdkEventMotion* event)
{
	pdfpcControlledMovie * self;
	self = (pdfpcControlledMovie*) base;
	g_return_if_fail (widget != NULL);
	g_return_if_fail (event != NULL);
	self->in_seek_bar = FALSE;
	self->mouse_drag = FALSE;
	pdfpc_controlled_movie_refresh (self);
}

static void
pdfpc_controlled_movie_real_on_freeze (pdfpcActionMapping* base,
                                       gboolean frozen)
{
	pdfpcControlledMovie * self;
	self = (pdfpcControlledMovie*) base;
	{
		GeeList* _sink_list = NULL;
		GeeList* _tmp0_;
		gint _sink_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _sink_index = 0;
		_tmp0_ = self->sinks;
		_sink_list = _tmp0_;
		_tmp1_ = _sink_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_sink_size = _tmp3_;
		_sink_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			GtkWidget* sink = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			gboolean sink_is_frozen = FALSE;
			GtkWidget* _tmp8_;
			gconstpointer _tmp9_;
			gboolean _tmp10_ = FALSE;
			_sink_index = _sink_index + 1;
			_tmp4_ = _sink_index;
			_tmp5_ = _sink_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _sink_list;
			_tmp7_ = gee_list_get (_tmp6_, _sink_index);
			sink = (GtkWidget*) _tmp7_;
			_tmp8_ = sink;
			_tmp9_ = g_object_get_data ((GObject*) _tmp8_, "pdfpc_frozen");
			sink_is_frozen = (gboolean) ((gintptr) _tmp9_);
			if (!frozen) {
				_tmp10_ = sink_is_frozen;
			} else {
				_tmp10_ = FALSE;
			}
			if (_tmp10_) {
				GtkWidget* _tmp11_;
				GtkWidget* _tmp12_;
				_tmp11_ = sink;
				gtk_widget_set_opacity (_tmp11_, (gdouble) 1);
				_tmp12_ = sink;
				g_object_set_data_full ((GObject*) _tmp12_, "pdfpc_frozen", (gpointer) ((gintptr) FALSE), NULL);
			}
			_g_object_unref0 (sink);
		}
	}
	return;
}

/**
         * Everytime we get a new frame, update the progress bar.
         */
static gboolean
____lambda6_ (pdfpcControlledMovie* self)
{
	GstElement* _tmp0_;
	pdfpcPlaybackOptions _tmp1_;
	gboolean result;
	_tmp0_ = self->pipeline;
	_tmp1_ = self->options;
	gst_element_seek_simple (_tmp0_, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, (gint64) (_tmp1_.starttime * GST_SECOND));
	result = FALSE;
	return result;
}

static gboolean
_____lambda6__gsource_func (gpointer self)
{
	gboolean result;
	result = ____lambda6_ ((pdfpcControlledMovie*) self);
	return result;
}

void
pdfpc_controlled_movie_on_draw (pdfpcControlledMovie* self,
                                GstElement* overlay,
                                cairo_t* cr,
                                guint64 timestamp,
                                guint64 duration)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	pdfpcPlaybackOptions _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (overlay != NULL);
	g_return_if_fail (cr != NULL);
	cairo_translate (cr, (gdouble) 0, (gdouble) self->video_h);
	cairo_scale (cr, self->scalex, -self->scaley);
	pdfpc_controlled_movie_draw_seek_bar (self, cr, timestamp);
	_tmp2_ = self->options;
	if (_tmp2_.stoptime != 0) {
		pdfpcPlaybackOptions _tmp3_;
		_tmp3_ = self->options;
		_tmp1_ = ((guint64) (_tmp3_.stoptime * GST_SECOND)) < timestamp;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		pdfpcPlaybackOptions _tmp4_;
		_tmp4_ = self->options;
		_tmp0_ = ((gdouble) timestamp) < ((_tmp4_.stoptime + 0.2) * GST_SECOND);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		pdfpcPlaybackOptions _tmp5_;
		_tmp5_ = self->options;
		if (_tmp5_.loop) {
			g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _____lambda6__gsource_func, g_object_ref (self), g_object_unref);
		} else {
			self->eos = TRUE;
			pdfpc_controlled_movie_pause (self);
		}
	}
}

/**
         * Handling of bus messages on the Gstreamer pipeline.
         */
void
pdfpc_controlled_movie_on_gst_message (pdfpcControlledMovie* self,
                                       GstMessage* message)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	switch (message->type) {
		case GST_MESSAGE_EOS:
		{
			pdfpcPlaybackOptions _tmp0_;
			_tmp0_ = self->options;
			if (_tmp0_.loop) {
				GstElement* _tmp1_;
				pdfpcPlaybackOptions _tmp2_;
				_tmp1_ = self->pipeline;
				_tmp2_ = self->options;
				gst_element_seek_simple (_tmp1_, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, (gint64) (_tmp2_.starttime * GST_SECOND));
			} else {
				self->eos = TRUE;
				pdfpc_controlled_movie_pause (self);
			}
			break;
		}
		case GST_MESSAGE_ERROR:
		{
			GError* err = NULL;
			gchar* debug_info = NULL;
			GError* _tmp3_ = NULL;
			gchar* _tmp4_ = NULL;
			GstObject* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			GError* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			gst_message_parse_error (message, &_tmp3_, &_tmp4_);
			_g_error_free0 (err);
			err = _tmp3_;
			_g_free0 (debug_info);
			debug_info = _tmp4_;
			_tmp5_ = message->src;
			_tmp6_ = gst_object_get_name (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = _tmp7_;
			_tmp9_ = err;
			_tmp10_ = _tmp9_->message;
			g_printerr ("Gstreamer error from element %s: %s\n", _tmp8_, _tmp10_);
			_g_free0 (_tmp8_);
			_tmp11_ = debug_info;
			if (_tmp11_ != NULL) {
				const gchar* _tmp12_;
				_tmp12_ = debug_info;
				g_printerr ("  (debugging info: %s)\n", _tmp12_);
			}
			_g_free0 (debug_info);
			_g_error_free0 (err);
			break;
		}
		default:
		{
			break;
		}
	}
}

/**
         * Seek if we're dragging the progress bar.
         */
static gboolean
pdfpc_controlled_movie_real_on_mouse_move (pdfpcActionMapping* base,
                                           GtkWidget* widget,
                                           GdkEventMotion* event)
{
	pdfpcControlledMovie * self;
	GdkWindow* _tmp0_;
	gboolean result;
	self = (pdfpcControlledMovie*) base;
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	pdfpc_controlled_movie_set_mouse_in (self, event->x, event->y);
	_tmp0_ = event->window;
	pdfpc_controlled_movie_update_cursor (self, _tmp0_);
	if (self->mouse_drag) {
		pdfpc_controlled_movie_mouse_seek (self, event->x, event->y);
	} else {
		pdfpc_controlled_movie_refresh (self);
	}
	result = FALSE;
	return result;
}

/**
         * When we find out the properties of the movie, we can work out how it
         * needs to be scaled to fit in the alloted area.  (This is only important
         * for the view with the controls.)
         */
static void
_vala_GstVideoInfo_free (GstVideoInfo* self)
{
	g_boxed_free (gst_video_info_get_type (), self);
}

void
pdfpc_controlled_movie_on_prepare (pdfpcControlledMovie* self,
                                   GstElement* overlay,
                                   GstCaps* caps)
{
	GstVideoInfo* info = NULL;
	GstVideoInfo* _tmp0_;
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_;
	gint64 _tmp3_ = 0LL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (overlay != NULL);
	g_return_if_fail (caps != NULL);
	_tmp0_ = gst_video_info_new ();
	info = _tmp0_;
	gst_video_info_from_caps (info, caps);
	self->video_w = info->width;
	self->video_h = info->height;
	_tmp1_ = self->rect;
	self->scalex = ((gdouble) self->video_w) / _tmp1_.width;
	_tmp2_ = self->rect;
	self->scaley = ((gdouble) self->video_h) / _tmp2_.height;
	self->seek_bar_height = (self->seek_bar_fontsize + (2 * self->seek_bar_padding)) / self->scaley;
	gst_element_query_duration (overlay, GST_FORMAT_TIME, &_tmp3_);
	self->duration = _tmp3_;
	__vala_GstVideoInfo_free0 (info);
}

/**
         * Show all video widgets except those created while the view was frozen
         */
void
pdfpc_controlled_movie_show (pdfpcControlledMovie* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeList* _sink_list = NULL;
		GeeList* _tmp0_;
		gint _sink_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _sink_index = 0;
		_tmp0_ = self->sinks;
		_sink_list = _tmp0_;
		_tmp1_ = _sink_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_sink_size = _tmp3_;
		_sink_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			GtkWidget* sink = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			gboolean sink_is_frozen = FALSE;
			GtkWidget* _tmp8_;
			gconstpointer _tmp9_;
			_sink_index = _sink_index + 1;
			_tmp4_ = _sink_index;
			_tmp5_ = _sink_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _sink_list;
			_tmp7_ = gee_list_get (_tmp6_, _sink_index);
			sink = (GtkWidget*) _tmp7_;
			_tmp8_ = sink;
			_tmp9_ = g_object_get_data ((GObject*) _tmp8_, "pdfpc_frozen");
			sink_is_frozen = (gboolean) ((gintptr) _tmp9_);
			if (!sink_is_frozen) {
				GtkWidget* _tmp10_;
				_tmp10_ = sink;
				gtk_widget_set_opacity (_tmp10_, (gdouble) 1);
			}
			_g_object_unref0 (sink);
		}
	}
	self->shown = TRUE;
}

void
pdfpc_controlled_movie_draw_seek_bar (pdfpcControlledMovie* self,
                                      cairo_t* cr,
                                      guint64 timestamp)
{
	gdouble start = 0.0;
	pdfpcPlaybackOptions _tmp0_;
	gdouble stop = 0.0;
	pdfpcPlaybackOptions _tmp1_;
	gboolean _tmp2_ = FALSE;
	pdfpcPlaybackOptions _tmp3_;
	gdouble start_bar = 0.0;
	GdkRectangle _tmp5_;
	gdouble stop_bar = 0.0;
	GdkRectangle _tmp6_;
	gdouble fraction = 0.0;
	gboolean _tmp7_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (cr != NULL);
	_tmp0_ = self->options;
	start = (((gdouble) _tmp0_.starttime) * GST_SECOND) / self->duration;
	_tmp1_ = self->options;
	stop = (((gdouble) _tmp1_.stoptime) * GST_SECOND) / self->duration;
	_tmp3_ = self->options;
	if (_tmp3_.starttime != 0) {
		pdfpcPlaybackOptions _tmp4_;
		_tmp4_ = self->options;
		_tmp2_ = _tmp4_.stoptime == 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		stop = 1.0;
	}
	_tmp5_ = self->rect;
	start_bar = start * _tmp5_.width;
	_tmp6_ = self->rect;
	stop_bar = stop * _tmp6_.width;
	fraction = ((gdouble) timestamp) / self->duration;
	if (self->in_seek_bar) {
		_tmp7_ = TRUE;
	} else {
		_tmp7_ = self->mouse_drag;
	}
	if (_tmp7_) {
		gdouble bar_end = 0.0;
		GdkRectangle _tmp8_;
		GdkRectangle _tmp9_;
		gint time_in_sec = 0;
		gchar* timestring = NULL;
		gchar* _tmp10_;
		gint dur_in_sec = 0;
		gchar* durstring = NULL;
		gchar* _tmp11_;
		cairo_text_extents_t te = {0};
		cairo_font_options_t* fo = NULL;
		cairo_font_options_t* _tmp12_;
		cairo_font_options_t* _tmp13_;
		cairo_font_options_t* _tmp14_;
		const gchar* _tmp15_;
		cairo_text_extents_t _tmp16_ = {0};
		cairo_text_extents_t _tmp17_;
		GdkRectangle _tmp18_;
		const gchar* _tmp23_;
		cairo_text_extents_t _tmp24_ = {0};
		cairo_text_extents_t _tmp25_;
		const gchar* _tmp29_;
		_tmp8_ = self->rect;
		bar_end = fraction * (_tmp8_.width - (2 * self->seek_bar_padding));
		_tmp9_ = self->rect;
		cairo_rectangle (cr, (gdouble) 0, (gdouble) 0, (gdouble) _tmp9_.width, self->seek_bar_height);
		cairo_set_source_rgba (cr, (gdouble) 0, (gdouble) 0, (gdouble) 0, 0.8);
		cairo_fill (cr);
		cairo_rectangle (cr, self->seek_bar_padding, self->seek_bar_padding, bar_end, self->seek_bar_height - 4);
		cairo_set_source_rgba (cr, (gdouble) 1, (gdouble) 1, (gdouble) 1, 0.8);
		cairo_fill (cr);
		cairo_rectangle (cr, start_bar, (gdouble) 0, stop_bar - start_bar, self->seek_bar_height);
		cairo_set_source_rgba (cr, (gdouble) 0, (gdouble) 1, (gdouble) 0, 0.5);
		cairo_fill (cr);
		time_in_sec = (gint) (timestamp / GST_SECOND);
		_tmp10_ = g_strdup_printf ("%i:%02i", time_in_sec / 60, time_in_sec % 60);
		timestring = _tmp10_;
		dur_in_sec = (gint) (self->duration / GST_SECOND);
		_tmp11_ = g_strdup_printf ("%i:%02i", dur_in_sec / 60, dur_in_sec % 60);
		durstring = _tmp11_;
		_tmp12_ = cairo_font_options_create ();
		fo = _tmp12_;
		_tmp13_ = fo;
		cairo_font_options_set_antialias (_tmp13_, CAIRO_ANTIALIAS_GRAY);
		_tmp14_ = fo;
		cairo_set_font_options (cr, _tmp14_);
		cairo_select_font_face (cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
		cairo_set_font_size (cr, self->seek_bar_height - (2 * self->seek_bar_padding));
		_tmp15_ = durstring;
		cairo_text_extents (cr, _tmp15_, &_tmp16_);
		te = _tmp16_;
		_tmp17_ = te;
		_tmp18_ = self->rect;
		if (((bar_end + _tmp17_.width) + (4 * self->seek_bar_padding)) < ((gdouble) _tmp18_.width)) {
			GdkRectangle _tmp19_;
			cairo_text_extents_t _tmp20_;
			cairo_text_extents_t _tmp21_;
			const gchar* _tmp22_;
			_tmp19_ = self->rect;
			_tmp20_ = te;
			_tmp21_ = te;
			cairo_move_to (cr, (_tmp19_.width - _tmp20_.width) - (2 * self->seek_bar_padding), (self->seek_bar_height / 2) - (_tmp21_.height / 2));
			cairo_set_source_rgba (cr, 0.8, 0.8, 0.8, (gdouble) 1);
			cairo_save (cr);
			cairo_scale (cr, (gdouble) 1, (gdouble) -1);
			_tmp22_ = durstring;
			cairo_show_text (cr, _tmp22_);
			cairo_restore (cr);
		}
		_tmp23_ = timestring;
		cairo_text_extents (cr, _tmp23_, &_tmp24_);
		te = _tmp24_;
		_tmp25_ = te;
		if (bar_end > _tmp25_.width) {
			cairo_text_extents_t _tmp26_;
			cairo_text_extents_t _tmp27_;
			_tmp26_ = te;
			_tmp27_ = te;
			cairo_move_to (cr, bar_end - _tmp26_.width, (self->seek_bar_height / 2) - (_tmp27_.height / 2));
			cairo_set_source_rgba (cr, (gdouble) 0, (gdouble) 0, (gdouble) 0, (gdouble) 1);
		} else {
			cairo_text_extents_t _tmp28_;
			_tmp28_ = te;
			cairo_move_to (cr, bar_end + (2 * self->seek_bar_padding), (self->seek_bar_height / 2) - (_tmp28_.height / 2));
			cairo_set_source_rgba (cr, 0.8, 0.8, 0.8, (gdouble) 1);
		}
		cairo_save (cr);
		cairo_scale (cr, (gdouble) 1, (gdouble) -1);
		_tmp29_ = timestring;
		cairo_show_text (cr, _tmp29_);
		cairo_restore (cr);
		_cairo_font_options_destroy0 (fo);
		_g_free0 (durstring);
		_g_free0 (timestring);
	} else {
		pdfpcPlaybackOptions _tmp30_;
		_tmp30_ = self->options;
		if (_tmp30_.noprogress == FALSE) {
			GdkRectangle _tmp31_;
			GdkRectangle _tmp32_;
			_tmp31_ = self->rect;
			cairo_rectangle (cr, (gdouble) 0, (gdouble) 0, (gdouble) _tmp31_.width, (gdouble) 4);
			cairo_set_source_rgba (cr, (gdouble) 0, (gdouble) 0, (gdouble) 0, 0.8);
			cairo_fill (cr);
			_tmp32_ = self->rect;
			cairo_rectangle (cr, (gdouble) 1, (gdouble) 1, fraction * (_tmp32_.width - 2), (gdouble) 2);
			cairo_set_source_rgba (cr, (gdouble) 1, (gdouble) 1, (gdouble) 1, 0.8);
			cairo_fill (cr);
			cairo_rectangle (cr, start_bar, (gdouble) 0, stop_bar - start_bar, (gdouble) 4);
			cairo_set_source_rgba (cr, (gdouble) 1, (gdouble) 1, (gdouble) 1, 0.5);
			cairo_fill (cr);
		}
	}
}

/**
         * Set up the gstreamer pipeline.
         */
static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		pdfpcControlledMovie* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->video_surface);
		_g_object_unref0 (_data1_->video_area);
		_g_object_unref0 (_data1_->conf);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
____lambda7_ (Block1Data* _data1_,
              GtkAllocation* a)
{
	pdfpcControlledMovie* self;
	GdkRectangle rect = {0};
	pdfpcWindowControllableWindow* window = NULL;
	pdfpcPresentationController* _tmp0_;
	pdfpcVideoConf* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	PopplerRectangle _tmp4_;
	GdkRectangle _tmp5_ = {0};
	pdfpcWindowControllableWindow* _tmp6_ = NULL;
	pdfpcVideoConf* _tmp7_;
	GdkRectangle _tmp8_;
	pdfpcWindowControllableWindow* _tmp9_;
	gboolean _tmp10_;
	gboolean _tmp11_;
	pdfpcViewVideo* _tmp15_;
	GtkWidget* _tmp16_;
	GdkRectangle _tmp17_;
	self = _data1_->self;
	g_return_if_fail (a != NULL);
	_tmp0_ = ((pdfpcActionMapping*) self)->controller;
	_tmp1_ = _data1_->conf;
	_tmp2_ = pdfpc_video_conf_get_display_num (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = ((pdfpcActionMapping*) self)->area;
	pdfpc_presentation_controller_overlay_pos (_tmp0_, _tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
	rect = _tmp5_;
	_g_object_unref0 (window);
	window = _tmp6_;
	_tmp7_ = _data1_->conf;
	_tmp8_ = rect;
	pdfpc_video_conf_set_rect (_tmp7_, &_tmp8_);
	_tmp9_ = window;
	_tmp10_ = pdfpc_window_controllable_window_get_interactive (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_) {
		GdkRectangle _tmp12_;
		GdkRectangle _tmp13_;
		GdkRectangle _tmp14_;
		_tmp12_ = rect;
		self->rect = _tmp12_;
		_tmp13_ = rect;
		self->scalex = ((gdouble) self->video_w) / _tmp13_.width;
		_tmp14_ = rect;
		self->scaley = ((gdouble) self->video_h) / _tmp14_.height;
		self->seek_bar_height = (self->seek_bar_fontsize + (2 * self->seek_bar_padding)) / self->scaley;
	}
	_tmp15_ = _data1_->video_surface;
	_tmp16_ = _data1_->video_area;
	_tmp17_ = rect;
	pdfpc_view_video_resize_video (_tmp15_, _tmp16_, &_tmp17_);
	_g_object_unref0 (window);
}

static void
_____lambda7__gtk_widget_size_allocate (GtkWidget* _sender,
                                        GtkAllocation* allocation,
                                        gpointer self)
{
	____lambda7_ (self, allocation);
}

static void
_pdfpc_controlled_movie_on_gst_message_gst_bus_message (GstBus* _sender,
                                                        GstMessage* message,
                                                        gpointer self)
{
	pdfpc_controlled_movie_on_gst_message ((pdfpcControlledMovie*) self, message);
}

void
pdfpc_controlled_movie_establish_pipeline (pdfpcControlledMovie* self,
                                           const gchar* uri,
                                           const gchar* suburi)
{
	GstBin* bin = NULL;
	GstBin* _tmp0_;
	GstElement* tee = NULL;
	GstElement* _tmp1_;
	GstBin* _tmp2_;
	GstElement* _tmp3_;
	GstBin* _tmp4_;
	GstElement* _tmp5_;
	GstPad* _tmp6_;
	GstPad* _tmp7_;
	GstGhostPad* _tmp8_;
	GstGhostPad* _tmp9_;
	gint n = 0;
	GeeList* video_confs = NULL;
	GeeArrayList* _tmp10_;
	GstElement* _tmp95_;
	GstElement* _tmp96_;
	gint subsize = 0;
	GstElement* _tmp101_;
	gchar* _tmp102_;
	gchar* _tmp103_;
	gchar* _tmp104_;
	gchar* _tmp105_;
	GstElement* _tmp106_;
	GstElement* _tmp107_;
	GstBin* _tmp108_;
	GstElement* _tmp109_;
	pdfpcPlaybackOptions _tmp110_;
	GstBus* bus = NULL;
	GstElement* _tmp111_;
	GstBus* _tmp112_;
	GstBus* _tmp113_;
	GstBus* _tmp114_;
	GstBin* _tmp115_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	_g_object_unref0 (self->pipeline);
	self->pipeline = NULL;
	_tmp0_ = (GstBin*) gst_bin_new ("bin");
	g_object_ref_sink (_tmp0_);
	bin = _tmp0_;
	_tmp1_ = gst_element_factory_make ("tee", "tee");
	if (_tmp1_ != NULL) {
		g_object_ref_sink (_tmp1_);
	}
	tee = _tmp1_;
	_tmp2_ = bin;
	_tmp3_ = tee;
	gst_bin_add_many (_tmp2_, _tmp3_, NULL);
	_tmp4_ = bin;
	_tmp5_ = tee;
	_tmp6_ = gst_element_get_static_pad (_tmp5_, "sink");
	_tmp7_ = _tmp6_;
	_tmp8_ = (GstGhostPad*) gst_ghost_pad_new ("sink", _tmp7_);
	g_object_ref_sink (_tmp8_);
	_tmp9_ = _tmp8_;
	gst_element_add_pad ((GstElement*) _tmp4_, (GstPad*) _tmp9_);
	_g_object_unref0 (_tmp9_);
	_g_object_unref0 (_tmp7_);
	n = 0;
	_tmp10_ = gee_array_list_new (PDFPC_TYPE_VIDEO_CONF, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	video_confs = (GeeList*) _tmp10_;
	while (TRUE) {
		GdkRectangle rect = {0};
		pdfpcWindowControllableWindow* window = NULL;
		pdfpcPresentationController* _tmp11_;
		PopplerRectangle _tmp12_;
		GdkRectangle _tmp13_ = {0};
		pdfpcWindowControllableWindow* _tmp14_ = NULL;
		pdfpcWindowControllableWindow* _tmp15_;
		pdfpcVideoConf* conf = NULL;
		GdkRectangle _tmp16_;
		pdfpcWindowControllableWindow* _tmp17_;
		pdfpcWindowControllableWindow* _tmp18_;
		pdfpcVideoConf* _tmp19_ = NULL;
		GeeList* _tmp20_;
		pdfpcVideoConf* _tmp21_;
		gint _tmp22_;
		_tmp11_ = ((pdfpcActionMapping*) self)->controller;
		_tmp12_ = ((pdfpcActionMapping*) self)->area;
		pdfpc_presentation_controller_overlay_pos (_tmp11_, n, &_tmp12_, &_tmp13_, &_tmp14_);
		rect = _tmp13_;
		_g_object_unref0 (window);
		window = _tmp14_;
		_tmp15_ = window;
		if (_tmp15_ == NULL) {
			_g_object_unref0 (window);
			break;
		}
		_tmp16_ = rect;
		_tmp17_ = window;
		_tmp18_ = _g_object_ref0 (_tmp17_);
		_tmp19_ = pdfpc_video_conf_new ();
		pdfpc_video_conf_set_display_num (_tmp19_, n);
		pdfpc_video_conf_set_rect (_tmp19_, &_tmp16_);
		pdfpc_video_conf_set_window (_tmp19_, _tmp18_);
		_g_object_unref0 (_tmp18_);
		conf = _tmp19_;
		_tmp20_ = video_confs;
		_tmp21_ = conf;
		gee_collection_add ((GeeCollection*) _tmp20_, _tmp21_);
		_tmp22_ = n;
		n = _tmp22_ + 1;
		_g_object_unref0 (conf);
		_g_object_unref0 (window);
	}
	n = 0;
	{
		GeeList* _conf_list = NULL;
		GeeList* _tmp23_;
		gint _conf_size = 0;
		GeeList* _tmp24_;
		gint _tmp25_;
		gint _tmp26_;
		gint _conf_index = 0;
		_tmp23_ = video_confs;
		_conf_list = _tmp23_;
		_tmp24_ = _conf_list;
		_tmp25_ = gee_collection_get_size ((GeeCollection*) _tmp24_);
		_tmp26_ = _tmp25_;
		_conf_size = _tmp26_;
		_conf_index = -1;
		while (TRUE) {
			Block1Data* _data1_;
			gint _tmp27_;
			gint _tmp28_;
			GeeList* _tmp29_;
			gpointer _tmp30_;
			GstElement* sink = NULL;
			GstElement* _tmp41_;
			GtkWidget* _tmp42_ = NULL;
			GstElement* queue = NULL;
			gchar* _tmp43_;
			gchar* _tmp44_;
			gchar* _tmp45_;
			gchar* _tmp46_;
			GstElement* _tmp47_;
			GstElement* _tmp48_;
			GstBin* _tmp49_;
			GstElement* _tmp50_;
			GstElement* _tmp51_;
			GstElement* _tmp52_;
			GstElement* _tmp53_;
			pdfpcVideoConf* _tmp54_;
			pdfpcWindowControllableWindow* _tmp55_;
			pdfpcWindowControllableWindow* _tmp56_;
			gboolean _tmp57_;
			gboolean _tmp58_;
			GstElement* _tmp69_;
			gboolean _tmp70_ = FALSE;
			pdfpcVideoConf* _tmp71_;
			pdfpcWindowControllableWindow* _tmp72_;
			pdfpcWindowControllableWindow* _tmp73_;
			gboolean _tmp74_;
			gboolean _tmp75_;
			pdfpcVideoConf* _tmp80_;
			pdfpcWindowControllableWindow* _tmp81_;
			pdfpcWindowControllableWindow* _tmp82_;
			pdfpcViewVideo* _tmp83_;
			pdfpcViewVideo* _tmp84_;
			pdfpcViewVideo* _tmp85_;
			pdfpcViewVideo* _tmp86_;
			GtkWidget* _tmp87_;
			pdfpcVideoConf* _tmp88_;
			GdkRectangle _tmp89_ = {0};
			GdkRectangle _tmp90_;
			pdfpcViewVideo* _tmp91_;
			GeeList* _tmp92_;
			GtkWidget* _tmp93_;
			gint _tmp94_;
			_data1_ = g_slice_new0 (Block1Data);
			_data1_->_ref_count_ = 1;
			_data1_->self = g_object_ref (self);
			_conf_index = _conf_index + 1;
			_tmp27_ = _conf_index;
			_tmp28_ = _conf_size;
			if (!(_tmp27_ < _tmp28_)) {
				block1_data_unref (_data1_);
				_data1_ = NULL;
				break;
			}
			_tmp29_ = _conf_list;
			_tmp30_ = gee_list_get (_tmp29_, _conf_index);
			_data1_->conf = (pdfpcVideoConf*) _tmp30_;
			{
				GstElement* _tmp31_ = NULL;
				gchar* _tmp32_;
				gchar* _tmp33_;
				gchar* _tmp34_;
				gchar* _tmp35_;
				GstElement* _tmp36_;
				GstElement* _tmp37_;
				GstElement* _tmp38_;
				_tmp32_ = g_strdup_printf ("%i", n);
				_tmp33_ = _tmp32_;
				_tmp34_ = g_strconcat ("sink", _tmp33_, NULL);
				_tmp35_ = _tmp34_;
				_tmp36_ = pdfpc_gst_element_make ("gtksink", _tmp35_, &_inner_error0_);
				_tmp37_ = _tmp36_;
				_g_free0 (_tmp35_);
				_g_free0 (_tmp33_);
				_tmp31_ = _tmp37_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					if (_inner_error0_->domain == PDFPC_PIPELINE_ERROR) {
						goto __catch0_pdfpc_pipeline_error;
					}
					_g_object_unref0 (sink);
					block1_data_unref (_data1_);
					_data1_ = NULL;
					_g_object_unref0 (video_confs);
					_g_object_unref0 (tee);
					_g_object_unref0 (bin);
					g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return;
				}
				_tmp38_ = _tmp31_;
				_tmp31_ = NULL;
				_g_object_unref0 (sink);
				sink = _tmp38_;
				_g_object_unref0 (_tmp31_);
			}
			goto __finally0;
			__catch0_pdfpc_pipeline_error:
			{
				GError* e = NULL;
				GError* _tmp39_;
				const gchar* _tmp40_;
				e = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp39_ = e;
				_tmp40_ = _tmp39_->message;
				g_printerr ("Error creating video sink: %s\n", _tmp40_);
				g_printerr ("Gstreamer installation may be incomplete.\n");
				_g_error_free0 (e);
				_g_object_unref0 (sink);
				block1_data_unref (_data1_);
				_data1_ = NULL;
				_g_object_unref0 (video_confs);
				_g_object_unref0 (tee);
				_g_object_unref0 (bin);
				return;
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (sink);
				block1_data_unref (_data1_);
				_data1_ = NULL;
				_g_object_unref0 (video_confs);
				_g_object_unref0 (tee);
				_g_object_unref0 (bin);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
			_tmp41_ = sink;
			g_object_get ((GObject*) _tmp41_, "widget", &_tmp42_, NULL);
			_g_object_unref0 (_data1_->video_area);
			_data1_->video_area = _tmp42_;
			_tmp43_ = g_strdup_printf ("%i", n);
			_tmp44_ = _tmp43_;
			_tmp45_ = g_strconcat ("queue", _tmp44_, NULL);
			_tmp46_ = _tmp45_;
			_tmp47_ = gst_element_factory_make ("queue", _tmp46_);
			if (_tmp47_ != NULL) {
				g_object_ref_sink (_tmp47_);
			}
			_tmp48_ = _tmp47_;
			_g_free0 (_tmp46_);
			_g_free0 (_tmp44_);
			queue = _tmp48_;
			_tmp49_ = bin;
			_tmp50_ = queue;
			_tmp51_ = sink;
			gst_bin_add_many (_tmp49_, _tmp50_, _tmp51_, NULL);
			_tmp52_ = tee;
			_tmp53_ = queue;
			gst_element_link (_tmp52_, _tmp53_);
			_tmp54_ = _data1_->conf;
			_tmp55_ = pdfpc_video_conf_get_window (_tmp54_);
			_tmp56_ = _tmp55_;
			_tmp57_ = pdfpc_window_controllable_window_get_interactive (_tmp56_);
			_tmp58_ = _tmp57_;
			if (_tmp58_) {
				GstElement* ad_element = NULL;
				GstElement* _tmp59_;
				GstBin* _tmp60_;
				pdfpcVideoConf* _tmp61_;
				GdkRectangle _tmp62_ = {0};
				GdkRectangle _tmp63_;
				GstElement* _tmp64_;
				GstElement* _tmp65_;
				GstElement* _tmp66_;
				_tmp59_ = queue;
				_tmp60_ = bin;
				_tmp61_ = _data1_->conf;
				pdfpc_video_conf_get_rect (_tmp61_, &_tmp62_);
				_tmp63_ = _tmp62_;
				_tmp64_ = pdfpc_controlled_movie_add_video_control (self, _tmp59_, _tmp60_, &_tmp63_);
				ad_element = _tmp64_;
				_tmp65_ = ad_element;
				_tmp66_ = sink;
				gst_element_link (_tmp65_, _tmp66_);
				_g_object_unref0 (ad_element);
			} else {
				GstElement* _tmp67_;
				GstElement* _tmp68_;
				_tmp67_ = queue;
				_tmp68_ = sink;
				gst_element_link (_tmp67_, _tmp68_);
			}
			_tmp69_ = sink;
			g_object_set ((GObject*) _tmp69_, "force_aspect_ratio", FALSE, NULL);
			_tmp71_ = _data1_->conf;
			_tmp72_ = pdfpc_video_conf_get_window (_tmp71_);
			_tmp73_ = _tmp72_;
			_tmp74_ = pdfpc_window_controllable_window_get_interactive (_tmp73_);
			_tmp75_ = _tmp74_;
			if (!_tmp75_) {
				pdfpcPresentationController* _tmp76_;
				gboolean _tmp77_;
				gboolean _tmp78_;
				_tmp76_ = ((pdfpcActionMapping*) self)->controller;
				_tmp77_ = pdfpc_presentation_controller_get_frozen (_tmp76_);
				_tmp78_ = _tmp77_;
				_tmp70_ = _tmp78_;
			} else {
				_tmp70_ = FALSE;
			}
			if (_tmp70_) {
				GtkWidget* _tmp79_;
				_tmp79_ = _data1_->video_area;
				g_object_set_data_full ((GObject*) _tmp79_, "pdfpc_frozen", (gpointer) ((gintptr) TRUE), NULL);
			}
			_tmp80_ = _data1_->conf;
			_tmp81_ = pdfpc_video_conf_get_window (_tmp80_);
			_tmp82_ = _tmp81_;
			_tmp83_ = pdfpc_window_controllable_window_get_video_surface (_tmp82_);
			_tmp84_ = _tmp83_;
			_tmp85_ = _g_object_ref0 (_tmp84_);
			_data1_->video_surface = _tmp85_;
			_tmp86_ = _data1_->video_surface;
			_tmp87_ = _data1_->video_area;
			_tmp88_ = _data1_->conf;
			pdfpc_video_conf_get_rect (_tmp88_, &_tmp89_);
			_tmp90_ = _tmp89_;
			pdfpc_view_video_add_video (_tmp86_, _tmp87_, &_tmp90_);
			_tmp91_ = _data1_->video_surface;
			g_signal_connect_data ((GtkWidget*) _tmp91_, "size-allocate", (GCallback) _____lambda7__gtk_widget_size_allocate, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
			_tmp92_ = self->sinks;
			_tmp93_ = _data1_->video_area;
			gee_collection_add ((GeeCollection*) _tmp92_, _tmp93_);
			_tmp94_ = n;
			n = _tmp94_ + 1;
			_g_object_unref0 (queue);
			_g_object_unref0 (sink);
			block1_data_unref (_data1_);
			_data1_ = NULL;
		}
	}
	_tmp95_ = gst_element_factory_make ("playbin", "playbin");
	if (_tmp95_ != NULL) {
		g_object_ref_sink (_tmp95_);
	}
	_g_object_unref0 (self->pipeline);
	self->pipeline = _tmp95_;
	_tmp96_ = self->pipeline;
	g_object_set ((GObject*) _tmp96_, "uri", uri, NULL);
	if (suburi != NULL) {
		GstElement* _tmp97_;
		_tmp97_ = self->pipeline;
		g_object_set ((GObject*) _tmp97_, "suburi", suburi, NULL);
	} else {
		if (pdfpc_options_auto_srt) {
			GstElement* _tmp98_;
			gchar* _tmp99_;
			gchar* _tmp100_;
			_tmp98_ = self->pipeline;
			_tmp99_ = g_strconcat (uri, ".srt", NULL);
			_tmp100_ = _tmp99_;
			g_object_set ((GObject*) _tmp98_, "suburi", _tmp100_, NULL);
			_g_free0 (_tmp100_);
		}
	}
	subsize = 18;
	_tmp101_ = self->pipeline;
	_tmp102_ = g_strdup_printf ("%i", subsize);
	_tmp103_ = _tmp102_;
	_tmp104_ = g_strconcat ("Sans, ", _tmp103_, NULL);
	_tmp105_ = _tmp104_;
	g_object_set ((GObject*) _tmp101_, "subtitle-font-desc", _tmp105_, NULL);
	_g_free0 (_tmp105_);
	_g_free0 (_tmp103_);
	_tmp106_ = self->pipeline;
	g_object_set ((GObject*) _tmp106_, "force_aspect_ratio", FALSE, NULL);
	_tmp107_ = self->pipeline;
	_tmp108_ = bin;
	g_object_set ((GObject*) _tmp107_, "video_sink", _tmp108_, NULL);
	_tmp109_ = self->pipeline;
	_tmp110_ = self->options;
	g_object_set ((GObject*) _tmp109_, "mute", _tmp110_.noaudio, NULL);
	_tmp111_ = self->pipeline;
	_tmp112_ = gst_element_get_bus (_tmp111_);
	bus = _tmp112_;
	_tmp113_ = bus;
	gst_bus_add_signal_watch_full (_tmp113_, G_PRIORITY_DEFAULT);
	_tmp114_ = bus;
	g_signal_connect_object (_tmp114_, "message", (GCallback) _pdfpc_controlled_movie_on_gst_message_gst_bus_message, self, 0);
	_tmp115_ = bin;
	gst_debug_bin_to_dot_file (_tmp115_, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline");
	_g_object_unref0 (bus);
	_g_object_unref0 (video_confs);
	_g_object_unref0 (tee);
	_g_object_unref0 (bin);
}

/**
         * Utility function for converting filenames to URI's. If file
         * is not an absolute path, use the PDF file location as a base
         * directory.
         */
gchar*
pdfpc_controlled_movie_filename_to_uri (pdfpcControlledMovie* self,
                                        const gchar* location,
                                        const gchar* pdf_fname)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	gchar* fullpath = NULL;
	GFile* fp = NULL;
	const gchar* _tmp8_;
	GFile* _tmp9_;
	GFile* _tmp10_;
	gchar* _tmp11_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (location != NULL, NULL);
	g_return_val_if_fail (pdf_fname != NULL, NULL);
	_tmp0_ = g_uri_parse_scheme (location);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_ != NULL;
	_g_free0 (_tmp1_);
	if (_tmp2_) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup (location);
		result = _tmp3_;
		return result;
	}
	if (g_path_is_absolute (location)) {
		gchar* _tmp4_;
		_tmp4_ = g_strdup (location);
		_g_free0 (fullpath);
		fullpath = _tmp4_;
	} else {
		gchar* dirname = NULL;
		gchar* _tmp5_;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp5_ = g_path_get_dirname (pdf_fname);
		dirname = _tmp5_;
		_tmp6_ = dirname;
		_tmp7_ = g_build_filename (_tmp6_, location, NULL);
		_g_free0 (fullpath);
		fullpath = _tmp7_;
		_g_free0 (dirname);
	}
	_tmp8_ = fullpath;
	_tmp9_ = g_file_new_for_path (_tmp8_);
	fp = _tmp9_;
	_tmp10_ = fp;
	_tmp11_ = g_file_get_uri (_tmp10_);
	result = _tmp11_;
	_g_object_unref0 (fp);
	_g_free0 (fullpath);
	return result;
}

/**
         * Hook up the elements to draw the controls to the first output leg.
         */
static void
_pdfpc_controlled_movie_on_draw_dynamic_draw0_ (GstElement* _sender,
                                                cairo_t* cr,
                                                guint64 timestamp,
                                                guint64 duration,
                                                gpointer self)
{
	pdfpc_controlled_movie_on_draw ((pdfpcControlledMovie*) self, _sender, cr, timestamp, duration);
}

static void
_pdfpc_controlled_movie_on_prepare_dynamic_caps_changed1_ (GstElement* _sender,
                                                           GstCaps* caps,
                                                           gpointer self)
{
	pdfpc_controlled_movie_on_prepare ((pdfpcControlledMovie*) self, _sender, caps);
}

GstElement*
pdfpc_controlled_movie_add_video_control (pdfpcControlledMovie* self,
                                          GstElement* source,
                                          GstBin* bin,
                                          GdkRectangle* rect)
{
	GstElement* overlay = NULL;
	GstElement* adaptor = NULL;
	GdkRectangle _tmp14_;
	GstElement* _tmp15_;
	GstElement* _tmp16_;
	GError* _inner_error0_ = NULL;
	GstElement* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (source != NULL, NULL);
	g_return_val_if_fail (bin != NULL, NULL);
	g_return_val_if_fail (rect != NULL, NULL);
	{
		GstElement* _tmp0_ = NULL;
		GstElement* _tmp1_;
		GstElement* _tmp2_;
		GstElement* _tmp3_ = NULL;
		GstElement* _tmp4_;
		GstElement* _tmp5_;
		GstElement* _tmp6_;
		GstElement* _tmp7_;
		GstElement* _tmp8_;
		GstElement* _tmp9_;
		_tmp1_ = pdfpc_gst_element_make ("videoconvert", "converter", &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == PDFPC_PIPELINE_ERROR) {
				goto __catch0_pdfpc_pipeline_error;
			}
			_g_object_unref0 (adaptor);
			_g_object_unref0 (overlay);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (adaptor);
		adaptor = _tmp2_;
		_tmp4_ = pdfpc_gst_element_make ("cairooverlay", "controls", &_inner_error0_);
		_tmp3_ = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp0_);
			if (_inner_error0_->domain == PDFPC_PIPELINE_ERROR) {
				goto __catch0_pdfpc_pipeline_error;
			}
			_g_object_unref0 (adaptor);
			_g_object_unref0 (overlay);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp5_ = _tmp3_;
		_tmp3_ = NULL;
		_g_object_unref0 (overlay);
		overlay = _tmp5_;
		_tmp6_ = adaptor;
		_tmp7_ = overlay;
		gst_bin_add_many (bin, _tmp6_, _tmp7_, NULL);
		_tmp8_ = overlay;
		_tmp9_ = adaptor;
		if (!gst_element_link_many (source, _tmp8_, _tmp9_, NULL)) {
			GError* _tmp10_;
			_tmp10_ = g_error_new_literal (PDFPC_PIPELINE_ERROR, PDFPC_PIPELINE_ERROR_Linking, "Could not link pipeline.");
			_inner_error0_ = _tmp10_;
			_g_object_unref0 (_tmp3_);
			_g_object_unref0 (_tmp0_);
			if (_inner_error0_->domain == PDFPC_PIPELINE_ERROR) {
				goto __catch0_pdfpc_pipeline_error;
			}
			_g_object_unref0 (adaptor);
			_g_object_unref0 (overlay);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_g_object_unref0 (_tmp3_);
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_pdfpc_pipeline_error:
	{
		GError* err = NULL;
		GError* _tmp11_;
		const gchar* _tmp12_;
		GstElement* _tmp13_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp11_ = err;
		_tmp12_ = _tmp11_->message;
		g_printerr ("Error creating control pipeline: %s\n", _tmp12_);
		_tmp13_ = _g_object_ref0 (source);
		result = _tmp13_;
		_g_error_free0 (err);
		_g_object_unref0 (adaptor);
		_g_object_unref0 (overlay);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (adaptor);
		_g_object_unref0 (overlay);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp14_ = *rect;
	self->rect = _tmp14_;
	_tmp15_ = overlay;
	g_signal_connect_object (_tmp15_, "draw", (GCallback) _pdfpc_controlled_movie_on_draw_dynamic_draw0_, self, 0);
	_tmp16_ = overlay;
	g_signal_connect_object (_tmp16_, "caps-changed", (GCallback) _pdfpc_controlled_movie_on_prepare_dynamic_caps_changed1_, self, 0);
	result = adaptor;
	_g_object_unref0 (overlay);
	return result;
}

/**
         * Seek to the time indicated by the mouse position on the progress bar.
         */
gint64
pdfpc_controlled_movie_mouse_seek (pdfpcControlledMovie* self,
                                   gdouble x,
                                   gdouble y)
{
	GdkRectangle _tmp0_;
	gdouble seek_fraction = 0.0;
	GdkRectangle _tmp1_;
	gint64 seek_time = 0LL;
	GstElement* _tmp2_;
	gint64 result;
	g_return_val_if_fail (self != NULL, 0LL);
	_tmp0_ = self->rect;
	x = x - _tmp0_.x;
	_tmp1_ = self->rect;
	seek_fraction = (x - self->seek_bar_padding) / (_tmp1_.width - (2 * self->seek_bar_padding));
	if (seek_fraction < ((gdouble) 0)) {
		seek_fraction = (gdouble) 0;
	}
	if (seek_fraction > ((gdouble) 1)) {
		seek_fraction = (gdouble) 1;
	}
	seek_time = (gint64) (seek_fraction * self->duration);
	_tmp2_ = self->pipeline;
	gst_element_seek_simple (_tmp2_, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, seek_time);
	if (self->paused_at >= ((gint64) 0)) {
		self->paused_at = seek_time;
	}
	result = seek_time;
	return result;
}

/**
         * Set a flag about whether the mouse is currently in the progress bar.
         */
static void
pdfpc_controlled_movie_set_mouse_in (pdfpcControlledMovie* self,
                                     gdouble x,
                                     gdouble y)
{
	GdkRectangle _tmp0_;
	GdkRectangle _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->rect;
	x = x - _tmp0_.x;
	_tmp1_ = self->rect;
	y = y - _tmp1_.y;
	if (self->shown) {
		_tmp5_ = x > ((gdouble) 0);
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		GdkRectangle _tmp6_;
		_tmp6_ = self->rect;
		_tmp4_ = x < ((gdouble) _tmp6_.width);
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		GdkRectangle _tmp7_;
		_tmp7_ = self->rect;
		_tmp3_ = y > (_tmp7_.height - self->seek_bar_height);
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		GdkRectangle _tmp8_;
		_tmp8_ = self->rect;
		_tmp2_ = y < ((gdouble) _tmp8_.height);
	} else {
		_tmp2_ = FALSE;
	}
	self->in_seek_bar = _tmp2_;
}

/**
         * Play the movie, rewinding to the beginning if we had reached the
         * end.
         */
void
pdfpc_controlled_movie_play (pdfpcControlledMovie* self)
{
	GstElement* _tmp2_;
	g_return_if_fail (self != NULL);
	pdfpc_controlled_movie_show (self);
	self->paused_at = (gint64) -1;
	if (self->eos) {
		GstElement* _tmp0_;
		pdfpcPlaybackOptions _tmp1_;
		self->eos = FALSE;
		_tmp0_ = self->pipeline;
		_tmp1_ = self->options;
		gst_element_seek_simple (_tmp0_, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, (gint64) (_tmp1_.starttime * GST_SECOND));
	}
	_tmp2_ = self->pipeline;
	gst_element_set_state (_tmp2_, GST_STATE_PLAYING);
}

/**
         * Pause playback.
         */
void
pdfpc_controlled_movie_pause (pdfpcControlledMovie* self)
{
	GstElement* _tmp0_;
	GstElement* _tmp1_;
	gint64 _tmp2_ = 0LL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->pipeline;
	gst_element_set_state (_tmp0_, GST_STATE_PAUSED);
	_tmp1_ = self->pipeline;
	gst_element_query_position (_tmp1_, GST_FORMAT_TIME, &_tmp2_);
	self->paused_at = _tmp2_;
	if (self->eos) {
		self->paused_at = self->paused_at - 1;
	}
}

/**
         * Rewind.
         */
void
pdfpc_controlled_movie_rewind (pdfpcControlledMovie* self)
{
	pdfpcPlaybackOptions _tmp0_;
	GstElement* _tmp1_;
	pdfpcPlaybackOptions _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->options;
	self->paused_at = (gint64) (_tmp0_.starttime * GST_SECOND);
	self->mouse_drag = FALSE;
	_tmp1_ = self->pipeline;
	_tmp2_ = self->options;
	gst_element_seek_simple (_tmp1_, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, (gint64) (_tmp2_.starttime * GST_SECOND));
}

/**
         * Stop playback.
         */
static void
pdfpc_controlled_movie_real_stop (pdfpcControlledMovie* self)
{
	GstElement* _tmp0_;
	_tmp0_ = self->pipeline;
	if (_tmp0_ != NULL) {
		GstElement* _tmp1_;
		_tmp1_ = self->pipeline;
		gst_element_set_state (_tmp1_, GST_STATE_NULL);
	}
}

void
pdfpc_controlled_movie_stop (pdfpcControlledMovie* self)
{
	pdfpcControlledMovieClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = PDFPC_CONTROLLED_MOVIE_GET_CLASS (self);
	if (_klass_->stop) {
		_klass_->stop (self);
	}
}

/**
         * Pause if playing, and vice versa.
         */
void
pdfpc_controlled_movie_toggle_play (pdfpcControlledMovie* self)
{
	GstState state = 0;
	GstClockTime time = 0ULL;
	GstElement* _tmp0_;
	GstState _tmp1_ = 0;
	g_return_if_fail (self != NULL);
	time = gst_util_get_timestamp ();
	_tmp0_ = self->pipeline;
	gst_element_get_state (_tmp0_, &_tmp1_, NULL, time);
	state = _tmp1_;
	if (state == GST_STATE_PLAYING) {
		pdfpc_controlled_movie_pause (self);
	} else {
		pdfpc_controlled_movie_play (self);
	}
}

pdfpcControlledMovie*
pdfpc_controlled_movie_construct (GType object_type)
{
	pdfpcControlledMovie * self = NULL;
	self = (pdfpcControlledMovie*) pdfpc_action_mapping_construct (object_type);
	return self;
}

pdfpcControlledMovie*
pdfpc_controlled_movie_new (void)
{
	return pdfpc_controlled_movie_construct (PDFPC_TYPE_CONTROLLED_MOVIE);
}

const gchar*
pdfpc_controlled_movie_get_filename (pdfpcControlledMovie* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_filename;
	result = _tmp0_;
	return result;
}

void
pdfpc_controlled_movie_set_filename (pdfpcControlledMovie* self,
                                     const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = pdfpc_controlled_movie_get_filename (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_filename);
		self->priv->_filename = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, pdfpc_controlled_movie_properties[PDFPC_CONTROLLED_MOVIE_FILENAME_PROPERTY]);
	}
}

static GObject *
pdfpc_controlled_movie_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	pdfpcControlledMovie * self;
	GeeArrayList* _tmp0_;
	GdkDisplay* display = NULL;
	GdkDisplay* _tmp1_;
	GdkDisplay* _tmp2_;
	GdkDisplay* _tmp3_;
	GdkCursor* _tmp4_;
	GdkDisplay* _tmp5_;
	GdkCursor* _tmp6_;
	GdkDisplay* _tmp7_;
	GdkCursor* _tmp8_;
	parent_class = G_OBJECT_CLASS (pdfpc_controlled_movie_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_TYPE_CONTROLLED_MOVIE, pdfpcControlledMovie);
	((pdfpcActionMapping*) self)->type = PDFPC_ACTION_MAPPING_ACTION_TYPE_MOVIE;
	_tmp0_ = gee_array_list_new (gtk_widget_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->sinks);
	self->sinks = (GeeList*) _tmp0_;
	_tmp1_ = gdk_display_get_default ();
	_tmp2_ = _g_object_ref0 (_tmp1_);
	display = _tmp2_;
	_tmp3_ = display;
	_tmp4_ = pdfpc_controlled_movie_load_cursor (self, _tmp3_, "pause_cur.svg");
	_g_object_unref0 (self->pause_cursor);
	self->pause_cursor = _tmp4_;
	_tmp5_ = display;
	_tmp6_ = pdfpc_controlled_movie_load_cursor (self, _tmp5_, "play_cur.svg");
	_g_object_unref0 (self->play_cursor);
	self->play_cursor = _tmp6_;
	_tmp7_ = display;
	_tmp8_ = gdk_cursor_new_from_name (_tmp7_, "hand1");
	_g_object_unref0 (self->drag_cursor);
	self->drag_cursor = _tmp8_;
	_g_object_unref0 (display);
	return obj;
}

static void
pdfpc_controlled_movie_class_init (pdfpcControlledMovieClass * klass,
                                   gpointer klass_data)
{
	pdfpc_controlled_movie_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &pdfpcControlledMovie_private_offset);
	((pdfpcActionMappingClass *) klass)->new_from_link_mapping = (pdfpcActionMapping* (*) (pdfpcActionMapping*, PopplerLinkMapping*, pdfpcPresentationController*)) pdfpc_controlled_movie_real_new_from_link_mapping;
	((pdfpcActionMappingClass *) klass)->new_from_annot_mapping = (pdfpcActionMapping* (*) (pdfpcActionMapping*, PopplerAnnotMapping*, pdfpcPresentationController*)) pdfpc_controlled_movie_real_new_from_annot_mapping;
	((pdfpcActionMappingClass *) klass)->deactivate = (void (*) (pdfpcActionMapping*)) pdfpc_controlled_movie_real_deactivate;
	((pdfpcActionMappingClass *) klass)->on_button_press = (gboolean (*) (pdfpcActionMapping*, GtkWidget*, GdkEventButton*)) pdfpc_controlled_movie_real_on_button_press;
	((pdfpcActionMappingClass *) klass)->on_button_release = (gboolean (*) (pdfpcActionMapping*, GtkWidget*, GdkEventButton*)) pdfpc_controlled_movie_real_on_button_release;
	((pdfpcActionMappingClass *) klass)->on_mouse_leave = (void (*) (pdfpcActionMapping*, GtkWidget*, GdkEventMotion*)) pdfpc_controlled_movie_real_on_mouse_leave;
	((pdfpcActionMappingClass *) klass)->on_freeze = (void (*) (pdfpcActionMapping*, gboolean)) pdfpc_controlled_movie_real_on_freeze;
	((pdfpcActionMappingClass *) klass)->on_mouse_move = (gboolean (*) (pdfpcActionMapping*, GtkWidget*, GdkEventMotion*)) pdfpc_controlled_movie_real_on_mouse_move;
	((pdfpcControlledMovieClass *) klass)->stop = (void (*) (pdfpcControlledMovie*)) pdfpc_controlled_movie_real_stop;
	G_OBJECT_CLASS (klass)->get_property = _vala_pdfpc_controlled_movie_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_pdfpc_controlled_movie_set_property;
	G_OBJECT_CLASS (klass)->constructor = pdfpc_controlled_movie_constructor;
	G_OBJECT_CLASS (klass)->finalize = pdfpc_controlled_movie_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_CONTROLLED_MOVIE_FILENAME_PROPERTY, pdfpc_controlled_movie_properties[PDFPC_CONTROLLED_MOVIE_FILENAME_PROPERTY] = g_param_spec_string ("filename", "filename", "filename", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
pdfpc_controlled_movie_instance_init (pdfpcControlledMovie * self,
                                      gpointer klass)
{
	self->priv = pdfpc_controlled_movie_get_instance_private (self);
	self->shown = FALSE;
	self->eos = FALSE;
	self->seek_bar_fontsize = (gdouble) 16;
	self->seek_bar_padding = (gdouble) 2;
	self->in_seek_bar = FALSE;
	self->mouse_drag = FALSE;
	self->paused_at = (gint64) 0;
}

static void
pdfpc_controlled_movie_finalize (GObject * obj)
{
	pdfpcControlledMovie * self;
	GstElement* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_TYPE_CONTROLLED_MOVIE, pdfpcControlledMovie);
	_tmp0_ = self->pipeline;
	if (_tmp0_ != NULL) {
		GstElement* _tmp1_;
		_tmp1_ = self->pipeline;
		gst_element_set_state (_tmp1_, GST_STATE_NULL);
	}
	_g_object_unref0 (self->pipeline);
	_g_object_unref0 (self->sinks);
	_g_free0 (self->priv->_filename);
	_g_object_unref0 (self->pause_cursor);
	_g_object_unref0 (self->play_cursor);
	_g_object_unref0 (self->drag_cursor);
	_g_free0 (self->temp);
	G_OBJECT_CLASS (pdfpc_controlled_movie_parent_class)->finalize (obj);
}

/**
     * A Movie with overlaid controls; specifically a draggable progress bar.
     */
static GType
pdfpc_controlled_movie_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcControlledMovieClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_controlled_movie_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcControlledMovie), 0, (GInstanceInitFunc) pdfpc_controlled_movie_instance_init, NULL };
	GType pdfpc_controlled_movie_type_id;
	pdfpc_controlled_movie_type_id = g_type_register_static (PDFPC_TYPE_ACTION_MAPPING, "pdfpcControlledMovie", &g_define_type_info, 0);
	pdfpcControlledMovie_private_offset = g_type_add_instance_private (pdfpc_controlled_movie_type_id, sizeof (pdfpcControlledMoviePrivate));
	return pdfpc_controlled_movie_type_id;
}

GType
pdfpc_controlled_movie_get_type (void)
{
	static volatile gsize pdfpc_controlled_movie_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_controlled_movie_type_id__once)) {
		GType pdfpc_controlled_movie_type_id;
		pdfpc_controlled_movie_type_id = pdfpc_controlled_movie_get_type_once ();
		g_once_init_leave (&pdfpc_controlled_movie_type_id__once, pdfpc_controlled_movie_type_id);
	}
	return pdfpc_controlled_movie_type_id__once;
}

static void
_vala_pdfpc_controlled_movie_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	pdfpcControlledMovie * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFPC_TYPE_CONTROLLED_MOVIE, pdfpcControlledMovie);
	switch (property_id) {
		case PDFPC_CONTROLLED_MOVIE_FILENAME_PROPERTY:
		g_value_set_string (value, pdfpc_controlled_movie_get_filename (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_pdfpc_controlled_movie_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	pdfpcControlledMovie * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFPC_TYPE_CONTROLLED_MOVIE, pdfpcControlledMovie);
	switch (property_id) {
		case PDFPC_CONTROLLED_MOVIE_FILENAME_PROPERTY:
		pdfpc_controlled_movie_set_filename (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

