Initial commit
[fillmore] / src / marina / marina / timeline.c
1 /* timeline.c generated by valac, the Vala compiler
2  * generated from timeline.vala, do not modify */
3
4 /* Copyright 2009-2010 Yorba Foundation
5  *
6  * This software is licensed under the GNU Lesser General Public License
7  * (version 2.1 or later).  See the COPYING file in this distribution. 
8  */
9
10 #include <glib.h>
11 #include <glib-object.h>
12 #include <gee.h>
13 #include <gtk/gtk.h>
14 #include <float.h>
15 #include <math.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <gdk/gdk.h>
19 #include <gst/gst.h>
20 #include <gobject/gvaluecollector.h>
21
22
23 #define TYPE_TRACK_CLIP_PAIR (track_clip_pair_get_type ())
24 #define TRACK_CLIP_PAIR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRACK_CLIP_PAIR, TrackClipPair))
25 #define TRACK_CLIP_PAIR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TRACK_CLIP_PAIR, TrackClipPairClass))
26 #define IS_TRACK_CLIP_PAIR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRACK_CLIP_PAIR))
27 #define IS_TRACK_CLIP_PAIR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TRACK_CLIP_PAIR))
28 #define TRACK_CLIP_PAIR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TRACK_CLIP_PAIR, TrackClipPairClass))
29
30 typedef struct _TrackClipPair TrackClipPair;
31 typedef struct _TrackClipPairClass TrackClipPairClass;
32 typedef struct _TrackClipPairPrivate TrackClipPairPrivate;
33
34 #define MODEL_TYPE_TRACK (model_track_get_type ())
35 #define MODEL_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TRACK, ModelTrack))
36 #define MODEL_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_TRACK, ModelTrackClass))
37 #define MODEL_IS_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TRACK))
38 #define MODEL_IS_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_TRACK))
39 #define MODEL_TRACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_TRACK, ModelTrackClass))
40
41 typedef struct _ModelTrack ModelTrack;
42 typedef struct _ModelTrackClass ModelTrackClass;
43
44 #define MODEL_TYPE_CLIP (model_clip_get_type ())
45 #define MODEL_CLIP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_CLIP, ModelClip))
46 #define MODEL_CLIP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_CLIP, ModelClipClass))
47 #define MODEL_IS_CLIP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_CLIP))
48 #define MODEL_IS_CLIP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_CLIP))
49 #define MODEL_CLIP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_CLIP, ModelClipClass))
50
51 typedef struct _ModelClip ModelClip;
52 typedef struct _ModelClipClass ModelClipClass;
53 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
54 typedef struct _ParamSpecTrackClipPair ParamSpecTrackClipPair;
55
56 #define TYPE_CLIPBOARD (clipboard_get_type ())
57 #define CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CLIPBOARD, Clipboard))
58 #define CLIPBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CLIPBOARD, ClipboardClass))
59 #define IS_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CLIPBOARD))
60 #define IS_CLIPBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CLIPBOARD))
61 #define CLIPBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CLIPBOARD, ClipboardClass))
62
63 typedef struct _Clipboard Clipboard;
64 typedef struct _ClipboardClass ClipboardClass;
65 typedef struct _ClipboardPrivate ClipboardPrivate;
66
67 #define TYPE_CLIP_VIEW (clip_view_get_type ())
68 #define CLIP_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CLIP_VIEW, ClipView))
69 #define CLIP_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CLIP_VIEW, ClipViewClass))
70 #define IS_CLIP_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CLIP_VIEW))
71 #define IS_CLIP_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CLIP_VIEW))
72 #define CLIP_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CLIP_VIEW, ClipViewClass))
73
74 typedef struct _ClipView ClipView;
75 typedef struct _ClipViewClass ClipViewClass;
76
77 #define TYPE_TRACK_VIEW (track_view_get_type ())
78 #define TRACK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRACK_VIEW, TrackView))
79 #define IS_TRACK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRACK_VIEW))
80 #define TRACK_VIEW_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_TRACK_VIEW, TrackViewIface))
81
82 typedef struct _TrackView TrackView;
83 typedef struct _TrackViewIface TrackViewIface;
84 typedef struct _ClipViewPrivate ClipViewPrivate;
85 #define _track_clip_pair_unref0(var) ((var == NULL) ? NULL : (var = (track_clip_pair_unref (var), NULL)))
86 typedef struct _ParamSpecClipboard ParamSpecClipboard;
87
88 #define TYPE_TIME_LINE (time_line_get_type ())
89 #define TIME_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TIME_LINE, TimeLine))
90 #define TIME_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TIME_LINE, TimeLineClass))
91 #define IS_TIME_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TIME_LINE))
92 #define IS_TIME_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TIME_LINE))
93 #define TIME_LINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TIME_LINE, TimeLineClass))
94
95 typedef struct _TimeLine TimeLine;
96 typedef struct _TimeLineClass TimeLineClass;
97 typedef struct _TimeLinePrivate TimeLinePrivate;
98
99 #define MODEL_TYPE_PROJECT (model_project_get_type ())
100 #define MODEL_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_PROJECT, ModelProject))
101 #define MODEL_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_PROJECT, ModelProjectClass))
102 #define MODEL_IS_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_PROJECT))
103 #define MODEL_IS_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_PROJECT))
104 #define MODEL_PROJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_PROJECT, ModelProjectClass))
105
106 typedef struct _ModelProject ModelProject;
107 typedef struct _ModelProjectClass ModelProjectClass;
108
109 #define MODEL_TYPE_TIME_SYSTEM (model_time_system_get_type ())
110 #define MODEL_TIME_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TIME_SYSTEM, ModelTimeSystem))
111 #define MODEL_IS_TIME_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TIME_SYSTEM))
112 #define MODEL_TIME_SYSTEM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MODEL_TYPE_TIME_SYSTEM, ModelTimeSystemIface))
113
114 typedef struct _ModelTimeSystem ModelTimeSystem;
115 typedef struct _ModelTimeSystemIface ModelTimeSystemIface;
116
117 #define VIEW_TYPE_RULER (view_ruler_get_type ())
118 #define VIEW_RULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIEW_TYPE_RULER, ViewRuler))
119 #define VIEW_RULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIEW_TYPE_RULER, ViewRulerClass))
120 #define VIEW_IS_RULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIEW_TYPE_RULER))
121 #define VIEW_IS_RULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIEW_TYPE_RULER))
122 #define VIEW_RULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VIEW_TYPE_RULER, ViewRulerClass))
123
124 typedef struct _ViewRuler ViewRuler;
125 typedef struct _ViewRulerClass ViewRulerClass;
126 #define _clipboard_unref0(var) ((var == NULL) ? NULL : (var = (clipboard_unref (var), NULL)))
127
128 #define MODEL_TYPE_TEMPO_INFORMATION (model_tempo_information_get_type ())
129 #define MODEL_TEMPO_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TEMPO_INFORMATION, ModelTempoInformation))
130 #define MODEL_IS_TEMPO_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TEMPO_INFORMATION))
131 #define MODEL_TEMPO_INFORMATION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MODEL_TYPE_TEMPO_INFORMATION, ModelTempoInformationIface))
132
133 typedef struct _ModelTempoInformation ModelTempoInformation;
134 typedef struct _ModelTempoInformationIface ModelTempoInformationIface;
135
136 #define TYPE_FRACTION (fraction_get_type ())
137 typedef struct _Fraction Fraction;
138 typedef struct _ModelProjectPrivate ModelProjectPrivate;
139
140 #define MODEL_TYPE_CLIP_FILE (model_clip_file_get_type ())
141 #define MODEL_CLIP_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_CLIP_FILE, ModelClipFile))
142 #define MODEL_CLIP_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_CLIP_FILE, ModelClipFileClass))
143 #define MODEL_IS_CLIP_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_CLIP_FILE))
144 #define MODEL_IS_CLIP_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_CLIP_FILE))
145 #define MODEL_CLIP_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_CLIP_FILE, ModelClipFileClass))
146
147 typedef struct _ModelClipFile ModelClipFile;
148 typedef struct _ModelClipFileClass ModelClipFileClass;
149
150 #define TYPE_TIME_CODE (time_code_get_type ())
151 typedef struct _TimeCode TimeCode;
152
153 #define VIEW_TYPE_MEDIA_ENGINE (view_media_engine_get_type ())
154 #define VIEW_MEDIA_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIEW_TYPE_MEDIA_ENGINE, ViewMediaEngine))
155 #define VIEW_MEDIA_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIEW_TYPE_MEDIA_ENGINE, ViewMediaEngineClass))
156 #define VIEW_IS_MEDIA_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIEW_TYPE_MEDIA_ENGINE))
157 #define VIEW_IS_MEDIA_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIEW_TYPE_MEDIA_ENGINE))
158 #define VIEW_MEDIA_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VIEW_TYPE_MEDIA_ENGINE, ViewMediaEngineClass))
159
160 typedef struct _ViewMediaEngine ViewMediaEngine;
161 typedef struct _ViewMediaEngineClass ViewMediaEngineClass;
162
163 #define MODEL_TYPE_PROJECT_LOADER (model_project_loader_get_type ())
164 #define MODEL_PROJECT_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_PROJECT_LOADER, ModelProjectLoader))
165 #define MODEL_PROJECT_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_PROJECT_LOADER, ModelProjectLoaderClass))
166 #define MODEL_IS_PROJECT_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_PROJECT_LOADER))
167 #define MODEL_IS_PROJECT_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_PROJECT_LOADER))
168 #define MODEL_PROJECT_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_PROJECT_LOADER, ModelProjectLoaderClass))
169
170 typedef struct _ModelProjectLoader ModelProjectLoader;
171 typedef struct _ModelProjectLoaderClass ModelProjectLoaderClass;
172
173 #define MODEL_TYPE_UNDO_MANAGER (model_undo_manager_get_type ())
174 #define MODEL_UNDO_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_UNDO_MANAGER, ModelUndoManager))
175 #define MODEL_UNDO_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_UNDO_MANAGER, ModelUndoManagerClass))
176 #define MODEL_IS_UNDO_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_UNDO_MANAGER))
177 #define MODEL_IS_UNDO_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_UNDO_MANAGER))
178 #define MODEL_UNDO_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_UNDO_MANAGER, ModelUndoManagerClass))
179
180 typedef struct _ModelUndoManager ModelUndoManager;
181 typedef struct _ModelUndoManagerClass ModelUndoManagerClass;
182
183 #define MODEL_TYPE_LIBRARY_IMPORTER (model_library_importer_get_type ())
184 #define MODEL_LIBRARY_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_LIBRARY_IMPORTER, ModelLibraryImporter))
185 #define MODEL_LIBRARY_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_LIBRARY_IMPORTER, ModelLibraryImporterClass))
186 #define MODEL_IS_LIBRARY_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_LIBRARY_IMPORTER))
187 #define MODEL_IS_LIBRARY_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_LIBRARY_IMPORTER))
188 #define MODEL_LIBRARY_IMPORTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_LIBRARY_IMPORTER, ModelLibraryImporterClass))
189
190 typedef struct _ModelLibraryImporter ModelLibraryImporter;
191 typedef struct _ModelLibraryImporterClass ModelLibraryImporterClass;
192
193 #define LOGGING_TYPE_FACILITY (logging_facility_get_type ())
194
195 #define LOGGING_TYPE_LEVEL (logging_level_get_type ())
196
197 #define TYPE_CLASS_FACTORY (class_factory_get_type ())
198 #define CLASS_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CLASS_FACTORY, ClassFactory))
199 #define CLASS_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CLASS_FACTORY, ClassFactoryClass))
200 #define IS_CLASS_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CLASS_FACTORY))
201 #define IS_CLASS_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CLASS_FACTORY))
202 #define CLASS_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CLASS_FACTORY, ClassFactoryClass))
203
204 typedef struct _ClassFactory ClassFactory;
205 typedef struct _ClassFactoryClass ClassFactoryClass;
206 #define _class_factory_unref0(var) ((var == NULL) ? NULL : (var = (class_factory_unref (var), NULL)))
207
208 #define MODEL_TYPE_MEDIA_TYPE (model_media_type_get_type ())
209 typedef struct _ModelClipPrivate ModelClipPrivate;
210 #define _g_free0(var) (var = (g_free (var), NULL))
211 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
212 #define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
213
214 struct _TrackClipPair {
215         GTypeInstance parent_instance;
216         volatile int ref_count;
217         TrackClipPairPrivate * priv;
218         ModelTrack* track;
219         ModelClip* clip;
220 };
221
222 struct _TrackClipPairClass {
223         GTypeClass parent_class;
224         void (*finalize) (TrackClipPair *self);
225 };
226
227 struct _ParamSpecTrackClipPair {
228         GParamSpec parent_instance;
229 };
230
231 struct _Clipboard {
232         GTypeInstance parent_instance;
233         volatile int ref_count;
234         ClipboardPrivate * priv;
235         GeeArrayList* clips;
236 };
237
238 struct _ClipboardClass {
239         GTypeClass parent_class;
240         void (*finalize) (Clipboard *self);
241 };
242
243 struct _ClipboardPrivate {
244         gint64 minimum_time;
245 };
246
247 struct _TrackViewIface {
248         GTypeInterface parent_iface;
249         void (*move_to_top) (TrackView* self, ClipView* clip_view);
250         void (*resize) (TrackView* self);
251         ModelTrack* (*get_track) (TrackView* self);
252         gint (*get_track_height) (TrackView* self);
253         GtkWidget* (*find_child) (TrackView* self, double x, double y);
254         void (*select_all) (TrackView* self);
255 };
256
257 struct _ClipView {
258         GtkDrawingArea parent_instance;
259         ClipViewPrivate * priv;
260         ModelClip* clip;
261         gint64 initial_time;
262         gboolean is_selected;
263         gint height;
264 };
265
266 struct _ClipViewClass {
267         GtkDrawingAreaClass parent_class;
268 };
269
270 struct _ParamSpecClipboard {
271         GParamSpec parent_instance;
272 };
273
274 struct _ModelTimeSystemIface {
275         GTypeInterface parent_iface;
276         void (*calculate_pixel_step) (ModelTimeSystem* self, float inc, float pixel_min, float pixel_div);
277         gint64 (*xpos_to_time) (ModelTimeSystem* self, gint x);
278         gint64 (*xsize_to_time) (ModelTimeSystem* self, gint x);
279         gint (*time_to_xpos) (ModelTimeSystem* self, gint64 time);
280         gint64 (*get_pixel_snap_time) (ModelTimeSystem* self);
281         gint (*time_to_xsize) (ModelTimeSystem* self, gint64 time);
282         float (*get_pixel_percentage) (ModelTimeSystem* self);
283         gint (*get_start_token) (ModelTimeSystem* self, gint xsize);
284         gint (*get_next_position) (ModelTimeSystem* self, gint token);
285         gint (*get_pixel_height) (ModelTimeSystem* self, gint token);
286         char* (*get_display_string) (ModelTimeSystem* self, gint token);
287         gint (*frame_to_xsize) (ModelTimeSystem* self, gint frame);
288         gint (*xsize_to_frame) (ModelTimeSystem* self, gint xsize);
289         char* (*get_time_string) (ModelTimeSystem* self, gint64 time);
290         char* (*get_time_duration) (ModelTimeSystem* self, gint64 time);
291 };
292
293 struct _TimeLine {
294         GtkEventBox parent_instance;
295         TimeLinePrivate * priv;
296         ModelProject* project;
297         ModelTimeSystem* provider;
298         ViewRuler* ruler;
299         GeeArrayList* tracks;
300         GeeArrayList* selected_clips;
301         Clipboard* clipboard;
302 };
303
304 struct _TimeLineClass {
305         GtkEventBoxClass parent_class;
306 };
307
308 struct _TimeLinePrivate {
309         GtkWidget* drag_widget;
310         gboolean copying;
311         GtkVBox* vbox;
312         float pixel_div;
313         float pixel_min;
314         float pixel_max;
315         GtkLabel* high_water;
316 };
317
318 struct _Fraction {
319         gint numerator;
320         gint denominator;
321 };
322
323 struct _ModelTempoInformationIface {
324         GTypeInterface parent_iface;
325         void (*get_time_signature) (ModelTempoInformation* self, Fraction* result);
326         gint (*get_bpm) (ModelTempoInformation* self);
327 };
328
329 struct _TimeCode {
330         gint hour;
331         gint minute;
332         gint second;
333         gint frame;
334         gboolean drop_code;
335 };
336
337 struct _ModelProject {
338         GObject parent_instance;
339         ModelProjectPrivate * priv;
340         GeeArrayList* tracks;
341         GeeArrayList* inactive_tracks;
342         GeeArrayList* clipfiles;
343         ViewMediaEngine* media_engine;
344         char* project_file;
345         ModelProjectLoader* loader;
346         ModelUndoManager* undo_manager;
347         ModelLibraryImporter* importer;
348         Fraction default_framerate;
349         gboolean click_during_play;
350         gboolean click_during_record;
351         double click_volume;
352         gboolean library_visible;
353         gint library_width;
354         gboolean snap_to_clip;
355 };
356
357 struct _ModelProjectClass {
358         GObjectClass parent_class;
359         void (*get_clip_time) (ModelProject* self, ModelClipFile* f, TimeCode* result);
360         char* (*get_project_file) (ModelProject* self);
361         void (*do_append) (ModelProject* self, ModelTrack* track, ModelClipFile* clipfile, const char* name, gint64 insert_time);
362         void (*add_track) (ModelProject* self, ModelTrack* track);
363         void (*insert_track) (ModelProject* self, gint index, ModelTrack* track);
364         void (*load) (ModelProject* self, const char* fname);
365         void (*save) (ModelProject* self, const char* filename);
366         char* (*get_app_name) (ModelProject* self);
367         void (*load_complete) (ModelProject* self);
368 };
369
370 typedef enum  {
371         LOGGING_FACILITY_SIGNAL_HANDLERS,
372         LOGGING_FACILITY_DEVELOPER_WARNINGS,
373         LOGGING_FACILITY_GRAPH,
374         LOGGING_FACILITY_LOADING,
375         LOGGING_FACILITY_IMPORT,
376         LOGGING_FACILITY_SINGLEDECODEBIN
377 } LoggingFacility;
378
379 typedef enum  {
380         LOGGING_LEVEL_CRITICAL,
381         LOGGING_LEVEL_HIGH,
382         LOGGING_LEVEL_MEDIUM,
383         LOGGING_LEVEL_LOW,
384         LOGGING_LEVEL_INFO,
385         LOGGING_LEVEL_VERBOSE
386 } LoggingLevel;
387
388 typedef enum  {
389         MODEL_MEDIA_TYPE_AUDIO,
390         MODEL_MEDIA_TYPE_VIDEO
391 } ModelMediaType;
392
393 struct _ModelClip {
394         GObject parent_instance;
395         ModelClipPrivate * priv;
396         ModelClipFile* clipfile;
397         ModelMediaType type;
398         gboolean is_recording;
399         char* name;
400 };
401
402 struct _ModelClipClass {
403         GObjectClass parent_class;
404 };
405
406
407 static gpointer track_clip_pair_parent_class = NULL;
408 static gpointer clipboard_parent_class = NULL;
409 static gpointer time_line_parent_class = NULL;
410
411 gpointer track_clip_pair_ref (gpointer instance);
412 void track_clip_pair_unref (gpointer instance);
413 GParamSpec* param_spec_track_clip_pair (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
414 void value_set_track_clip_pair (GValue* value, gpointer v_object);
415 void value_take_track_clip_pair (GValue* value, gpointer v_object);
416 gpointer value_get_track_clip_pair (const GValue* value);
417 GType track_clip_pair_get_type (void);
418 GType model_track_get_type (void);
419 GType model_clip_get_type (void);
420 enum  {
421         TRACK_CLIP_PAIR_DUMMY_PROPERTY
422 };
423 TrackClipPair* track_clip_pair_new (ModelTrack* track, ModelClip* clip);
424 TrackClipPair* track_clip_pair_construct (GType object_type, ModelTrack* track, ModelClip* clip);
425 static void track_clip_pair_finalize (TrackClipPair* obj);
426 gpointer clipboard_ref (gpointer instance);
427 void clipboard_unref (gpointer instance);
428 GParamSpec* param_spec_clipboard (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
429 void value_set_clipboard (GValue* value, gpointer v_object);
430 void value_take_clipboard (GValue* value, gpointer v_object);
431 gpointer value_get_clipboard (const GValue* value);
432 GType clipboard_get_type (void);
433 #define CLIPBOARD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_CLIPBOARD, ClipboardPrivate))
434 enum  {
435         CLIPBOARD_DUMMY_PROPERTY
436 };
437 GType clip_view_get_type (void);
438 GType track_view_get_type (void);
439 gint64 model_clip_get_start (ModelClip* self);
440 ModelTrack* track_view_get_track (TrackView* self);
441 void clipboard_select (Clipboard* self, GeeArrayList* selected_clips);
442 void model_track_do_clip_paste (ModelTrack* self, ModelClip* clip, gint64 position);
443 ModelClip* model_clip_copy (ModelClip* self);
444 void clipboard_paste (Clipboard* self, ModelTrack* selected_track, gint64 time);
445 Clipboard* clipboard_new (void);
446 Clipboard* clipboard_construct (GType object_type);
447 static void clipboard_finalize (Clipboard* obj);
448 GType time_line_get_type (void);
449 GType model_project_get_type (void);
450 GType model_time_system_get_type (void);
451 GType view_ruler_get_type (void);
452 #define TIME_LINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_TIME_LINE, TimeLinePrivate))
453 enum  {
454         TIME_LINE_DUMMY_PROPERTY
455 };
456 #define TIME_LINE_BAR_HEIGHT 32
457 #define TIME_LINE_BORDER 4
458 #define TIME_LINE_RULER_HEIGHT 32
459 static void time_line_on_geometry_changed (TimeLine* self);
460 static void _time_line_on_geometry_changed_model_time_system_geometry_changed (ModelTimeSystem* _sender, gpointer self);
461 ViewRuler* view_ruler_new (ModelTimeSystem* provider, gint height);
462 ViewRuler* view_ruler_construct (GType object_type, ModelTimeSystem* provider, gint height);
463 void time_line_on_ruler_position_changed (TimeLine* self, gint x);
464 static void _time_line_on_ruler_position_changed_view_ruler_position_changed (ViewRuler* _sender, gint x, gpointer self);
465 static void time_line_on_track_added (TimeLine* self, ModelTrack* track);
466 static void _time_line_on_track_added_model_project_track_added (ModelProject* _sender, ModelTrack* track, gpointer self);
467 static void time_line_on_track_removed (TimeLine* self, ModelTrack* track);
468 static void _time_line_on_track_removed_model_project_track_removed (ModelProject* _sender, ModelTrack* track, gpointer self);
469 GType fraction_get_type (void);
470 Fraction* fraction_dup (const Fraction* self);
471 void fraction_free (Fraction* self);
472 GType model_tempo_information_get_type (void);
473 GType model_clip_file_get_type (void);
474 GType time_code_get_type (void);
475 TimeCode* time_code_dup (const TimeCode* self);
476 void time_code_free (TimeCode* self);
477 GType view_media_engine_get_type (void);
478 GType model_project_loader_get_type (void);
479 gpointer model_undo_manager_ref (gpointer instance);
480 void model_undo_manager_unref (gpointer instance);
481 GParamSpec* model_param_spec_undo_manager (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
482 void model_value_set_undo_manager (GValue* value, gpointer v_object);
483 void model_value_take_undo_manager (GValue* value, gpointer v_object);
484 gpointer model_value_get_undo_manager (const GValue* value);
485 GType model_undo_manager_get_type (void);
486 GType model_library_importer_get_type (void);
487 static void time_line_on_position_changed (TimeLine* self);
488 static void _time_line_on_position_changed_view_media_engine_position_changed (ViewMediaEngine* _sender, gint64 position, gpointer self);
489 void parse_color (const char* color, GdkColor* result);
490 void model_time_system_calculate_pixel_step (ModelTimeSystem* self, float inc, float pixel_min, float pixel_div);
491 TimeLine* time_line_new (ModelProject* p, ModelTimeSystem* provider, GdkDragAction actions);
492 TimeLine* time_line_construct (GType object_type, ModelProject* p, ModelTimeSystem* provider, GdkDragAction actions);
493 gint64 model_project_get_length (ModelProject* self);
494 void time_line_zoom (TimeLine* self, float inc);
495 float model_time_system_get_pixel_percentage (ModelTimeSystem* self);
496 void time_line_zoom_to_project (TimeLine* self, double width);
497 void track_view_resize (TrackView* self);
498 gint64 model_project_transport_get_position (ModelProject* self);
499 GType logging_facility_get_type (void);
500 GType logging_level_get_type (void);
501 void logging_emit (GObject* object, LoggingFacility facility, LoggingLevel level, const char* message);
502 gpointer class_factory_ref (gpointer instance);
503 void class_factory_unref (gpointer instance);
504 GParamSpec* param_spec_class_factory (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
505 void value_set_class_factory (GValue* value, gpointer v_object);
506 void value_take_class_factory (GValue* value, gpointer v_object);
507 gpointer value_get_class_factory (const GValue* value);
508 GType class_factory_get_type (void);
509 ClassFactory* class_factory_get_class_factory (void);
510 TrackView* class_factory_get_track_view (ClassFactory* self, ModelTrack* track, TimeLine* timeline);
511 void time_line_on_clip_view_added (TimeLine* self, ClipView* clip_view);
512 static void _time_line_on_clip_view_added_track_view_clip_view_added (TrackView* _sender, ClipView* clip_view, gpointer self);
513 GType model_media_type_get_type (void);
514 ModelMediaType model_track_media_type (ModelTrack* self);
515 static void time_line_on_clip_view_selection_request (TimeLine* self, ClipView* clip_view, gboolean extend);
516 static void _time_line_on_clip_view_selection_request_clip_view_selection_request (ClipView* _sender, ClipView* clip_view, gboolean extend_selection, gpointer self);
517 static void time_line_on_clip_view_move_request (TimeLine* self, ClipView* clip_view, gint64 delta);
518 static void _time_line_on_clip_view_move_request_clip_view_move_request (ClipView* _sender, ClipView* clip_view, gint64 delta, gpointer self);
519 static void time_line_on_clip_view_move_commit (TimeLine* self, ClipView* clip_view, gint64 delta);
520 static void _time_line_on_clip_view_move_commit_clip_view_move_commit (ClipView* _sender, ClipView* clip_view, gint64 delta, gpointer self);
521 static void time_line_on_clip_view_move_begin (TimeLine* self, ClipView* clip_view, gboolean copy);
522 static void _time_line_on_clip_view_move_begin_clip_view_move_begin (ClipView* _sender, ClipView* clip_view, gboolean copy, gpointer self);
523 static void time_line_on_clip_view_trim_begin (TimeLine* self, ClipView* clip, GdkWindowEdge edge);
524 static void _time_line_on_clip_view_trim_begin_clip_view_trim_begin (ClipView* _sender, ClipView* clip_view, GdkWindowEdge edge, gpointer self);
525 static void time_line_on_clip_view_trim_commit (TimeLine* self, ClipView* clip_view, GdkWindowEdge edge);
526 static void _time_line_on_clip_view_trim_commit_clip_view_trim_commit (ClipView* _sender, ClipView* clip_view, GdkWindowEdge edge, gpointer self);
527 void time_line_deselect_all_clips (TimeLine* self);
528 void model_undo_manager_start_transaction (ModelUndoManager* self, const char* description);
529 gint64 model_clip_get_end (ModelClip* self);
530 void model_clip_gnonlin_disconnect (ModelClip* self);
531 void model_track_remove_clip_from_array (ModelTrack* self, ModelClip* pos);
532 void model_track_append_at_time (ModelTrack* self, ModelClip* c, gint64 time, gboolean select);
533 void track_view_move_to_top (TrackView* self, ClipView* clip_view);
534 gint64 model_clip_get_duration (ModelClip* self);
535 gboolean time_line_is_clip_selected (TimeLine* self);
536 void model_clip_gnonlin_connect (ModelClip* self);
537 void model_track_move (ModelTrack* self, ModelClip* c, gint64 pos, gint64 original_time);
538 void model_undo_manager_end_transaction (ModelUndoManager* self, const char* description);
539 void model_clip_trim (ModelClip* self, gint64 delta, GdkWindowEdge edge);
540 void model_track_trim (ModelTrack* self, ModelClip* clip, gint64 delta, GdkWindowEdge edge);
541 #define CLIP_VIEW_SNAP_DELTA 10
542 gint model_time_system_time_to_xsize (ModelTimeSystem* self, gint64 time);
543 gint64 model_time_system_xsize_to_time (ModelTimeSystem* self, gint x);
544 gboolean model_track_clip_is_near (ModelTrack* self, ModelClip* clip, gint64 range, gint64* adjustment);
545 void clip_view_snap (ClipView* self, gint64 amount);
546 static void time_line_constrain_move (TimeLine* self, ClipView* clip_view, gint64* delta);
547 static gboolean time_line_move_allowed (TimeLine* self, gint64* move_distance);
548 static void time_line_move_the_clips (TimeLine* self, gint64 move_distance);
549 gint model_time_system_time_to_xpos (ModelTimeSystem* self, gint64 time);
550 void time_line_do_clip_move (TimeLine* self, ClipView* clip_view, gint64 delta);
551 void model_clip_set_start (ModelClip* self, gint64 value);
552 gboolean model_project_transport_is_recording (ModelProject* self);
553 void time_line_update_pos (TimeLine* self, gint event_x);
554 gboolean time_line_gap_selected (TimeLine* self);
555 void clip_view_delete_clip (ClipView* self);
556 void time_line_delete_selection (TimeLine* self);
557 void time_line_do_cut (TimeLine* self);
558 void time_line_do_copy (TimeLine* self);
559 void time_line_do_paste (TimeLine* self, gint64 pos);
560 void time_line_paste (TimeLine* self);
561 gboolean model_track_get_is_selected (ModelTrack* self);
562 static TrackView* time_line_find_video_track_view (TimeLine* self);
563 static TrackView* time_line_find_audio_track_view (TimeLine* self);
564 void track_view_select_all (TrackView* self);
565 void time_line_select_all (TimeLine* self);
566 static gboolean time_line_real_expose_event (GtkWidget* base, GdkEventExpose* event);
567 GtkWidget* time_line_find_child (TimeLine* self, double x, double y);
568 void dialog_utils_warning (const char* major_message, const char* minor_message);
569 GtkResponseType dialog_utils_add_cancel (const char* message);
570 void model_project_create_clip_importer (ModelProject* self, ModelTrack* track, gboolean timeline_add, gint64 time_to_add, gboolean both_tracks, GtkWindow* progress_window_parent, gint number);
571 gint64 model_time_system_xpos_to_time (ModelTimeSystem* self, gint x);
572 void model_library_importer_add_file (ModelLibraryImporter* self, const char* filename, GError** error);
573 void model_library_importer_start (ModelLibraryImporter* self, GError** error);
574 static void time_line_real_drag_data_received (GtkWidget* base, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint drag_info, guint time);
575 void model_project_snap_coord (ModelProject* self, gint64* coord, gint64 span);
576 gint64 model_time_system_get_pixel_snap_time (ModelTimeSystem* self);
577 void view_media_engine_go (ViewMediaEngine* self, gint64 pos);
578 static void time_line_deselect_all (TimeLine* self);
579 GtkWidget* track_view_find_child (TrackView* self, double x, double y);
580 void model_track_set_selected (ModelTrack* self, gboolean is_selected);
581 static gboolean time_line_real_button_press_event (GtkWidget* base, GdkEventButton* event);
582 static gboolean time_line_real_button_release_event (GtkWidget* base, GdkEventButton* event);
583 static gboolean time_line_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event);
584 static void time_line_finalize (GObject* obj);
585 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
586 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
587 static gint _vala_array_length (gpointer array);
588
589 extern const GtkTargetEntry drag_target_entries[1];
590
591
592 static gpointer _g_object_ref0 (gpointer self) {
593         return self ? g_object_ref (self) : NULL;
594 }
595
596
597 #line 10 "timeline.vala"
598 TrackClipPair* track_clip_pair_construct (GType object_type, ModelTrack* track, ModelClip* clip) {
599 #line 600 "timeline.c"
600         TrackClipPair* self;
601         ModelTrack* _tmp0_;
602         ModelClip* _tmp1_;
603 #line 10 "timeline.vala"
604         g_return_val_if_fail (MODEL_IS_TRACK (track), NULL);
605 #line 10 "timeline.vala"
606         g_return_val_if_fail (MODEL_IS_CLIP (clip), NULL);
607 #line 608 "timeline.c"
608         self = (TrackClipPair*) g_type_create_instance (object_type);
609 #line 11 "timeline.vala"
610         self->track = (_tmp0_ = _g_object_ref0 (track), _g_object_unref0 (self->track), _tmp0_);
611 #line 12 "timeline.vala"
612         self->clip = (_tmp1_ = _g_object_ref0 (clip), _g_object_unref0 (self->clip), _tmp1_);
613 #line 614 "timeline.c"
614         return self;
615 }
616
617
618 #line 10 "timeline.vala"
619 TrackClipPair* track_clip_pair_new (ModelTrack* track, ModelClip* clip) {
620 #line 10 "timeline.vala"
621         return track_clip_pair_construct (TYPE_TRACK_CLIP_PAIR, track, clip);
622 #line 623 "timeline.c"
623 }
624
625
626 static void value_track_clip_pair_init (GValue* value) {
627         value->data[0].v_pointer = NULL;
628 }
629
630
631 static void value_track_clip_pair_free_value (GValue* value) {
632         if (value->data[0].v_pointer) {
633                 track_clip_pair_unref (value->data[0].v_pointer);
634         }
635 }
636
637
638 static void value_track_clip_pair_copy_value (const GValue* src_value, GValue* dest_value) {
639         if (src_value->data[0].v_pointer) {
640                 dest_value->data[0].v_pointer = track_clip_pair_ref (src_value->data[0].v_pointer);
641         } else {
642                 dest_value->data[0].v_pointer = NULL;
643         }
644 }
645
646
647 static gpointer value_track_clip_pair_peek_pointer (const GValue* value) {
648         return value->data[0].v_pointer;
649 }
650
651
652 static gchar* value_track_clip_pair_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
653         if (collect_values[0].v_pointer) {
654                 TrackClipPair* object;
655                 object = collect_values[0].v_pointer;
656                 if (object->parent_instance.g_class == NULL) {
657                         return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
658                 } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
659                         return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
660                 }
661                 value->data[0].v_pointer = track_clip_pair_ref (object);
662         } else {
663                 value->data[0].v_pointer = NULL;
664         }
665         return NULL;
666 }
667
668
669 static gchar* value_track_clip_pair_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
670         TrackClipPair** object_p;
671         object_p = collect_values[0].v_pointer;
672         if (!object_p) {
673                 return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
674         }
675         if (!value->data[0].v_pointer) {
676                 *object_p = NULL;
677         } else if (collect_flags && G_VALUE_NOCOPY_CONTENTS) {
678                 *object_p = value->data[0].v_pointer;
679         } else {
680                 *object_p = track_clip_pair_ref (value->data[0].v_pointer);
681         }
682         return NULL;
683 }
684
685
686 GParamSpec* param_spec_track_clip_pair (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
687         ParamSpecTrackClipPair* spec;
688         g_return_val_if_fail (g_type_is_a (object_type, TYPE_TRACK_CLIP_PAIR), NULL);
689         spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
690         G_PARAM_SPEC (spec)->value_type = object_type;
691         return G_PARAM_SPEC (spec);
692 }
693
694
695 gpointer value_get_track_clip_pair (const GValue* value) {
696         g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TRACK_CLIP_PAIR), NULL);
697         return value->data[0].v_pointer;
698 }
699
700
701 void value_set_track_clip_pair (GValue* value, gpointer v_object) {
702         TrackClipPair* old;
703         g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TRACK_CLIP_PAIR));
704         old = value->data[0].v_pointer;
705         if (v_object) {
706                 g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_TRACK_CLIP_PAIR));
707                 g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
708                 value->data[0].v_pointer = v_object;
709                 track_clip_pair_ref (value->data[0].v_pointer);
710         } else {
711                 value->data[0].v_pointer = NULL;
712         }
713         if (old) {
714                 track_clip_pair_unref (old);
715         }
716 }
717
718
719 void value_take_track_clip_pair (GValue* value, gpointer v_object) {
720         TrackClipPair* old;
721         g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TRACK_CLIP_PAIR));
722         old = value->data[0].v_pointer;
723         if (v_object) {
724                 g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_TRACK_CLIP_PAIR));
725                 g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
726                 value->data[0].v_pointer = v_object;
727         } else {
728                 value->data[0].v_pointer = NULL;
729         }
730         if (old) {
731                 track_clip_pair_unref (old);
732         }
733 }
734
735
736 static void track_clip_pair_class_init (TrackClipPairClass * klass) {
737         track_clip_pair_parent_class = g_type_class_peek_parent (klass);
738         TRACK_CLIP_PAIR_CLASS (klass)->finalize = track_clip_pair_finalize;
739 }
740
741
742 static void track_clip_pair_instance_init (TrackClipPair * self) {
743         self->ref_count = 1;
744 }
745
746
747 static void track_clip_pair_finalize (TrackClipPair* obj) {
748         TrackClipPair * self;
749         self = TRACK_CLIP_PAIR (obj);
750         _g_object_unref0 (self->track);
751         _g_object_unref0 (self->clip);
752 }
753
754
755 GType track_clip_pair_get_type (void) {
756         static volatile gsize track_clip_pair_type_id__volatile = 0;
757         if (g_once_init_enter (&track_clip_pair_type_id__volatile)) {
758                 static const GTypeValueTable g_define_type_value_table = { value_track_clip_pair_init, value_track_clip_pair_free_value, value_track_clip_pair_copy_value, value_track_clip_pair_peek_pointer, "p", value_track_clip_pair_collect_value, "p", value_track_clip_pair_lcopy_value };
759                 static const GTypeInfo g_define_type_info = { sizeof (TrackClipPairClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) track_clip_pair_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TrackClipPair), 0, (GInstanceInitFunc) track_clip_pair_instance_init, &g_define_type_value_table };
760                 static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
761                 GType track_clip_pair_type_id;
762                 track_clip_pair_type_id = g_type_register_fundamental (g_type_fundamental_next (), "TrackClipPair", &g_define_type_info, &g_define_type_fundamental_info, 0);
763                 g_once_init_leave (&track_clip_pair_type_id__volatile, track_clip_pair_type_id);
764         }
765         return track_clip_pair_type_id__volatile;
766 }
767
768
769 gpointer track_clip_pair_ref (gpointer instance) {
770         TrackClipPair* self;
771         self = instance;
772         g_atomic_int_inc (&self->ref_count);
773         return instance;
774 }
775
776
777 void track_clip_pair_unref (gpointer instance) {
778         TrackClipPair* self;
779         self = instance;
780         if (g_atomic_int_dec_and_test (&self->ref_count)) {
781                 TRACK_CLIP_PAIR_GET_CLASS (self)->finalize (self);
782                 g_type_free_instance ((GTypeInstance *) self);
783         }
784 }
785
786
787 #line 22 "timeline.vala"
788 void clipboard_select (Clipboard* self, GeeArrayList* selected_clips) {
789 #line 22 "timeline.vala"
790         g_return_if_fail (IS_CLIPBOARD (self));
791 #line 22 "timeline.vala"
792         g_return_if_fail (GEE_IS_ARRAY_LIST (selected_clips));
793 #line 23 "timeline.vala"
794         gee_abstract_collection_clear (GEE_ABSTRACT_COLLECTION (self->clips));
795 #line 24 "timeline.vala"
796         self->priv->minimum_time = (gint64) (-1);
797 #line 798 "timeline.c"
798         {
799                 GeeIterator* _clip_view_it;
800                 _clip_view_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (selected_clips));
801 #line 25 "timeline.vala"
802                 while (TRUE) {
803 #line 804 "timeline.c"
804                         ClipView* clip_view;
805                         GtkContainer* _tmp0_;
806                         TrackView* track_view;
807                         gboolean _tmp1_ = FALSE;
808                         ModelTrack* _tmp2_;
809                         TrackClipPair* _tmp3_;
810                         TrackClipPair* track_clip_pair;
811 #line 25 "timeline.vala"
812                         if (!gee_iterator_next (_clip_view_it)) {
813 #line 25 "timeline.vala"
814                                 break;
815 #line 816 "timeline.c"
816                         }
817 #line 25 "timeline.vala"
818                         clip_view = (ClipView*) gee_iterator_get (_clip_view_it);
819 #line 26 "timeline.vala"
820                         track_view = _g_object_ref0 ((_tmp0_ = gtk_widget_get_parent (GTK_WIDGET (clip_view)), IS_TRACK_VIEW (_tmp0_) ? ((TrackView*) _tmp0_) : NULL));
821 #line 27 "timeline.vala"
822                         if (self->priv->minimum_time < 0) {
823 #line 27 "timeline.vala"
824                                 _tmp1_ = TRUE;
825 #line 826 "timeline.c"
826                         } else {
827 #line 27 "timeline.vala"
828                                 _tmp1_ = model_clip_get_start (clip_view->clip) < self->priv->minimum_time;
829 #line 830 "timeline.c"
830                         }
831 #line 27 "timeline.vala"
832                         if (_tmp1_) {
833 #line 28 "timeline.vala"
834                                 self->priv->minimum_time = model_clip_get_start (clip_view->clip);
835 #line 836 "timeline.c"
836                         }
837 #line 30 "timeline.vala"
838                         track_clip_pair = (_tmp3_ = track_clip_pair_new (_tmp2_ = track_view_get_track (track_view), clip_view->clip), _g_object_unref0 (_tmp2_), _tmp3_);
839 #line 31 "timeline.vala"
840                         gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->clips), track_clip_pair);
841 #line 842 "timeline.c"
842                         _g_object_unref0 (clip_view);
843                         _g_object_unref0 (track_view);
844                         _track_clip_pair_unref0 (track_clip_pair);
845                 }
846                 _g_object_unref0 (_clip_view_it);
847         }
848 }
849
850
851 #line 35 "timeline.vala"
852 void clipboard_paste (Clipboard* self, ModelTrack* selected_track, gint64 time) {
853 #line 35 "timeline.vala"
854         g_return_if_fail (IS_CLIPBOARD (self));
855 #line 35 "timeline.vala"
856         g_return_if_fail (MODEL_IS_TRACK (selected_track));
857 #line 36 "timeline.vala"
858         if (gee_collection_get_size (GEE_COLLECTION (self->clips)) != 1) {
859 #line 860 "timeline.c"
860                 {
861                         GeeIterator* _pair_it;
862                         _pair_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->clips));
863 #line 37 "timeline.vala"
864                         while (TRUE) {
865 #line 866 "timeline.c"
866                                 TrackClipPair* pair;
867                                 ModelClip* _tmp0_;
868 #line 37 "timeline.vala"
869                                 if (!gee_iterator_next (_pair_it)) {
870 #line 37 "timeline.vala"
871                                         break;
872 #line 873 "timeline.c"
873                                 }
874 #line 37 "timeline.vala"
875                                 pair = (TrackClipPair*) gee_iterator_get (_pair_it);
876 #line 38 "timeline.vala"
877                                 model_track_do_clip_paste (pair->track, _tmp0_ = model_clip_copy (pair->clip), (time + model_clip_get_start (pair->clip)) - self->priv->minimum_time);
878 #line 879 "timeline.c"
879                                 _g_object_unref0 (_tmp0_);
880                                 _track_clip_pair_unref0 (pair);
881                         }
882                         _g_object_unref0 (_pair_it);
883                 }
884         } else {
885                 ModelClip* _tmp2_;
886                 TrackClipPair* _tmp1_;
887 #line 41 "timeline.vala"
888                 model_track_do_clip_paste (selected_track, _tmp2_ = model_clip_copy ((_tmp1_ = (TrackClipPair*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->clips), 0))->clip), time);
889 #line 890 "timeline.c"
890                 _g_object_unref0 (_tmp2_);
891                 _track_clip_pair_unref0 (_tmp1_);
892         }
893 }
894
895
896 #line 18 "timeline.vala"
897 Clipboard* clipboard_construct (GType object_type) {
898 #line 899 "timeline.c"
899         Clipboard* self;
900         self = (Clipboard*) g_type_create_instance (object_type);
901         return self;
902 }
903
904
905 #line 18 "timeline.vala"
906 Clipboard* clipboard_new (void) {
907 #line 18 "timeline.vala"
908         return clipboard_construct (TYPE_CLIPBOARD);
909 #line 910 "timeline.c"
910 }
911
912
913 static void value_clipboard_init (GValue* value) {
914         value->data[0].v_pointer = NULL;
915 }
916
917
918 static void value_clipboard_free_value (GValue* value) {
919         if (value->data[0].v_pointer) {
920                 clipboard_unref (value->data[0].v_pointer);
921         }
922 }
923
924
925 static void value_clipboard_copy_value (const GValue* src_value, GValue* dest_value) {
926         if (src_value->data[0].v_pointer) {
927                 dest_value->data[0].v_pointer = clipboard_ref (src_value->data[0].v_pointer);
928         } else {
929                 dest_value->data[0].v_pointer = NULL;
930         }
931 }
932
933
934 static gpointer value_clipboard_peek_pointer (const GValue* value) {
935         return value->data[0].v_pointer;
936 }
937
938
939 static gchar* value_clipboard_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
940         if (collect_values[0].v_pointer) {
941                 Clipboard* object;
942                 object = collect_values[0].v_pointer;
943                 if (object->parent_instance.g_class == NULL) {
944                         return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
945                 } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
946                         return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
947                 }
948                 value->data[0].v_pointer = clipboard_ref (object);
949         } else {
950                 value->data[0].v_pointer = NULL;
951         }
952         return NULL;
953 }
954
955
956 static gchar* value_clipboard_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
957         Clipboard** object_p;
958         object_p = collect_values[0].v_pointer;
959         if (!object_p) {
960                 return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
961         }
962         if (!value->data[0].v_pointer) {
963                 *object_p = NULL;
964         } else if (collect_flags && G_VALUE_NOCOPY_CONTENTS) {
965                 *object_p = value->data[0].v_pointer;
966         } else {
967                 *object_p = clipboard_ref (value->data[0].v_pointer);
968         }
969         return NULL;
970 }
971
972
973 GParamSpec* param_spec_clipboard (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
974         ParamSpecClipboard* spec;
975         g_return_val_if_fail (g_type_is_a (object_type, TYPE_CLIPBOARD), NULL);
976         spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
977         G_PARAM_SPEC (spec)->value_type = object_type;
978         return G_PARAM_SPEC (spec);
979 }
980
981
982 gpointer value_get_clipboard (const GValue* value) {
983         g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_CLIPBOARD), NULL);
984         return value->data[0].v_pointer;
985 }
986
987
988 void value_set_clipboard (GValue* value, gpointer v_object) {
989         Clipboard* old;
990         g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_CLIPBOARD));
991         old = value->data[0].v_pointer;
992         if (v_object) {
993                 g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_CLIPBOARD));
994                 g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
995                 value->data[0].v_pointer = v_object;
996                 clipboard_ref (value->data[0].v_pointer);
997         } else {
998                 value->data[0].v_pointer = NULL;
999         }
1000         if (old) {
1001                 clipboard_unref (old);
1002         }
1003 }
1004
1005
1006 void value_take_clipboard (GValue* value, gpointer v_object) {
1007         Clipboard* old;
1008         g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_CLIPBOARD));
1009         old = value->data[0].v_pointer;
1010         if (v_object) {
1011                 g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_CLIPBOARD));
1012                 g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
1013                 value->data[0].v_pointer = v_object;
1014         } else {
1015                 value->data[0].v_pointer = NULL;
1016         }
1017         if (old) {
1018                 clipboard_unref (old);
1019         }
1020 }
1021
1022
1023 static void clipboard_class_init (ClipboardClass * klass) {
1024         clipboard_parent_class = g_type_class_peek_parent (klass);
1025         CLIPBOARD_CLASS (klass)->finalize = clipboard_finalize;
1026         g_type_class_add_private (klass, sizeof (ClipboardPrivate));
1027 }
1028
1029
1030 static void clipboard_instance_init (Clipboard * self) {
1031         self->priv = CLIPBOARD_GET_PRIVATE (self);
1032         self->clips = gee_array_list_new (TYPE_TRACK_CLIP_PAIR, (GBoxedCopyFunc) track_clip_pair_ref, track_clip_pair_unref, NULL);
1033         self->priv->minimum_time = (gint64) (-1);
1034         self->ref_count = 1;
1035 }
1036
1037
1038 static void clipboard_finalize (Clipboard* obj) {
1039         Clipboard * self;
1040         self = CLIPBOARD (obj);
1041         _g_object_unref0 (self->clips);
1042 }
1043
1044
1045 GType clipboard_get_type (void) {
1046         static volatile gsize clipboard_type_id__volatile = 0;
1047         if (g_once_init_enter (&clipboard_type_id__volatile)) {
1048                 static const GTypeValueTable g_define_type_value_table = { value_clipboard_init, value_clipboard_free_value, value_clipboard_copy_value, value_clipboard_peek_pointer, "p", value_clipboard_collect_value, "p", value_clipboard_lcopy_value };
1049                 static const GTypeInfo g_define_type_info = { sizeof (ClipboardClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) clipboard_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Clipboard), 0, (GInstanceInitFunc) clipboard_instance_init, &g_define_type_value_table };
1050                 static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
1051                 GType clipboard_type_id;
1052                 clipboard_type_id = g_type_register_fundamental (g_type_fundamental_next (), "Clipboard", &g_define_type_info, &g_define_type_fundamental_info, 0);
1053                 g_once_init_leave (&clipboard_type_id__volatile, clipboard_type_id);
1054         }
1055         return clipboard_type_id__volatile;
1056 }
1057
1058
1059 gpointer clipboard_ref (gpointer instance) {
1060         Clipboard* self;
1061         self = instance;
1062         g_atomic_int_inc (&self->ref_count);
1063         return instance;
1064 }
1065
1066
1067 void clipboard_unref (gpointer instance) {
1068         Clipboard* self;
1069         self = instance;
1070         if (g_atomic_int_dec_and_test (&self->ref_count)) {
1071                 CLIPBOARD_GET_CLASS (self)->finalize (self);
1072                 g_type_free_instance ((GTypeInstance *) self);
1073         }
1074 }
1075
1076
1077 #line 124 "timeline.vala"
1078 static void _time_line_on_geometry_changed_model_time_system_geometry_changed (ModelTimeSystem* _sender, gpointer self) {
1079 #line 1080 "timeline.c"
1080         time_line_on_geometry_changed (self);
1081 }
1082
1083
1084 #line 368 "timeline.vala"
1085 static void _time_line_on_ruler_position_changed_view_ruler_position_changed (ViewRuler* _sender, gint x, gpointer self) {
1086 #line 1087 "timeline.c"
1087         time_line_on_ruler_position_changed (self, x);
1088 }
1089
1090
1091 #line 135 "timeline.vala"
1092 static void _time_line_on_track_added_model_project_track_added (ModelProject* _sender, ModelTrack* track, gpointer self) {
1093 #line 1094 "timeline.c"
1094         time_line_on_track_added (self, track);
1095 }
1096
1097
1098 #line 148 "timeline.vala"
1099 static void _time_line_on_track_removed_model_project_track_removed (ModelProject* _sender, ModelTrack* track, gpointer self) {
1100 #line 1101 "timeline.c"
1101         time_line_on_track_removed (self, track);
1102 }
1103
1104
1105 #line 130 "timeline.vala"
1106 static void _time_line_on_position_changed_view_media_engine_position_changed (ViewMediaEngine* _sender, gint64 position, gpointer self) {
1107 #line 1108 "timeline.c"
1108         time_line_on_position_changed (self);
1109 }
1110
1111
1112 #line 75 "timeline.vala"
1113 TimeLine* time_line_construct (GType object_type, ModelProject* p, ModelTimeSystem* provider, GdkDragAction actions) {
1114 #line 1115 "timeline.c"
1115         TimeLine * self;
1116         GtkWidget* _tmp0_;
1117         ModelProject* _tmp1_;
1118         GtkVBox* _tmp2_;
1119         ViewRuler* _tmp3_;
1120         GdkColor _tmp5_;
1121         GdkColor _tmp4_ = {0};
1122         GdkColor _tmp7_;
1123         GdkColor _tmp6_ = {0};
1124 #line 75 "timeline.vala"
1125         g_return_val_if_fail (MODEL_IS_PROJECT (p), NULL);
1126 #line 75 "timeline.vala"
1127         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM (provider), NULL);
1128 #line 1129 "timeline.c"
1129         self = g_object_newv (object_type, 0, NULL);
1130 #line 76 "timeline.vala"
1131         gtk_widget_add_events (GTK_WIDGET (self), (gint) GDK_POINTER_MOTION_MASK);
1132 #line 77 "timeline.vala"
1133         self->priv->drag_widget = (_tmp0_ = NULL, _g_object_unref0 (self->priv->drag_widget), _tmp0_);
1134 #line 78 "timeline.vala"
1135         g_object_set (GTK_WIDGET (self), "can-focus", TRUE, NULL);
1136 #line 79 "timeline.vala"
1137         self->project = (_tmp1_ = _g_object_ref0 (p), _g_object_unref0 (self->project), _tmp1_);
1138 #line 80 "timeline.vala"
1139         self->provider = provider;
1140 #line 81 "timeline.vala"
1141         g_signal_connect_object (provider, "geometry-changed", (GCallback) _time_line_on_geometry_changed_model_time_system_geometry_changed, self, 0);
1142 #line 83 "timeline.vala"
1143         self->priv->vbox = (_tmp2_ = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 0)), _g_object_unref0 (self->priv->vbox), _tmp2_);
1144 #line 84 "timeline.vala"
1145         self->ruler = (_tmp3_ = g_object_ref_sink (view_ruler_new (provider, TIME_LINE_RULER_HEIGHT)), _g_object_unref0 (self->ruler), _tmp3_);
1146 #line 85 "timeline.vala"
1147         g_signal_connect_object (self->ruler, "position-changed", (GCallback) _time_line_on_ruler_position_changed_view_ruler_position_changed, self, 0);
1148 #line 86 "timeline.vala"
1149         gtk_box_pack_start (GTK_BOX (self->priv->vbox), GTK_WIDGET (self->ruler), FALSE, FALSE, (guint) 0);
1150 #line 88 "timeline.vala"
1151         g_signal_connect_object (self->project, "track-added", (GCallback) _time_line_on_track_added_model_project_track_added, self, 0);
1152 #line 89 "timeline.vala"
1153         g_signal_connect_object (self->project, "track-removed", (GCallback) _time_line_on_track_removed_model_project_track_removed, self, 0);
1154 #line 90 "timeline.vala"
1155         g_signal_connect_object (self->project->media_engine, "position-changed", (GCallback) _time_line_on_position_changed_view_media_engine_position_changed, self, 0);
1156 #line 91 "timeline.vala"
1157         gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->priv->vbox));
1158 #line 93 "timeline.vala"
1159         gtk_widget_modify_bg (GTK_WIDGET (self), GTK_STATE_NORMAL, (_tmp5_ = (parse_color ("#444", &_tmp4_), _tmp4_), &_tmp5_));
1160 #line 94 "timeline.vala"
1161         gtk_widget_modify_fg (GTK_WIDGET (self), GTK_STATE_NORMAL, (_tmp7_ = (parse_color ("#f00", &_tmp6_), _tmp6_), &_tmp7_));
1162 #line 96 "timeline.vala"
1163         self->priv->pixel_div = self->priv->pixel_max / self->priv->pixel_min;
1164 #line 97 "timeline.vala"
1165         model_time_system_calculate_pixel_step (provider, 0.5f, self->priv->pixel_min, self->priv->pixel_div);
1166 #line 98 "timeline.vala"
1167         gtk_drag_dest_set (GTK_WIDGET (self), GTK_DEST_DEFAULT_ALL, drag_target_entries, G_N_ELEMENTS (drag_target_entries), actions);
1168 #line 1169 "timeline.c"
1169         return self;
1170 }
1171
1172
1173 #line 75 "timeline.vala"
1174 TimeLine* time_line_new (ModelProject* p, ModelTimeSystem* provider, GdkDragAction actions) {
1175 #line 75 "timeline.vala"
1176         return time_line_construct (TYPE_TIME_LINE, p, provider, actions);
1177 #line 1178 "timeline.c"
1178 }
1179
1180
1181 #line 101 "timeline.vala"
1182 void time_line_zoom_to_project (TimeLine* self, double width) {
1183 #line 1184 "timeline.c"
1184         double numerator;
1185         double denominator;
1186 #line 101 "timeline.vala"
1187         g_return_if_fail (IS_TIME_LINE (self));
1188 #line 102 "timeline.vala"
1189         if (model_project_get_length (self->project) == 0) {
1190 #line 103 "timeline.vala"
1191                 return;
1192 #line 1193 "timeline.c"
1193         }
1194 #line 106 "timeline.vala"
1195         width = width - 12.0;
1196 #line 108 "timeline.vala"
1197         numerator = log ((width * GST_SECOND) / (((double) model_project_get_length (self->project)) * ((double) self->priv->pixel_min)));
1198 #line 110 "timeline.vala"
1199         denominator = log ((double) self->priv->pixel_div);
1200 #line 112 "timeline.vala"
1201         time_line_zoom (self, ((float) (numerator / denominator)) - model_time_system_get_pixel_percentage (self->provider));
1202 #line 1203 "timeline.c"
1203 }
1204
1205
1206 #line 115 "timeline.vala"
1207 void time_line_zoom (TimeLine* self, float inc) {
1208 #line 115 "timeline.vala"
1209         g_return_if_fail (IS_TIME_LINE (self));
1210 #line 116 "timeline.vala"
1211         model_time_system_calculate_pixel_step (self->provider, inc, self->priv->pixel_min, self->priv->pixel_div);
1212 #line 1213 "timeline.c"
1213         {
1214                 GeeIterator* _track_it;
1215                 _track_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->tracks));
1216 #line 117 "timeline.vala"
1217                 while (TRUE) {
1218 #line 1219 "timeline.c"
1219                         TrackView* track;
1220 #line 117 "timeline.vala"
1221                         if (!gee_iterator_next (_track_it)) {
1222 #line 117 "timeline.vala"
1223                                 break;
1224 #line 1225 "timeline.c"
1225                         }
1226 #line 117 "timeline.vala"
1227                         track = (TrackView*) gee_iterator_get (_track_it);
1228 #line 118 "timeline.vala"
1229                         track_view_resize (track);
1230 #line 1231 "timeline.c"
1231                         _g_object_unref0 (track);
1232                 }
1233                 _g_object_unref0 (_track_it);
1234         }
1235 #line 120 "timeline.vala"
1236         g_signal_emit_by_name (self->project->media_engine, "position-changed", model_project_transport_get_position (self->project));
1237 #line 121 "timeline.vala"
1238         gtk_widget_queue_draw (GTK_WIDGET (self));
1239 #line 1240 "timeline.c"
1240 }
1241
1242
1243 #line 124 "timeline.vala"
1244 static void time_line_on_geometry_changed (TimeLine* self) {
1245 #line 124 "timeline.vala"
1246         g_return_if_fail (IS_TIME_LINE (self));
1247 #line 125 "timeline.vala"
1248         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_geometry_changed");
1249 #line 126 "timeline.vala"
1250         model_time_system_calculate_pixel_step (self->provider, (float) 0, self->priv->pixel_min, self->priv->pixel_div);
1251 #line 127 "timeline.vala"
1252         gtk_widget_queue_draw (GTK_WIDGET (self->ruler));
1253 #line 1254 "timeline.c"
1254 }
1255
1256
1257 #line 130 "timeline.vala"
1258 static void time_line_on_position_changed (TimeLine* self) {
1259 #line 130 "timeline.vala"
1260         g_return_if_fail (IS_TIME_LINE (self));
1261 #line 131 "timeline.vala"
1262         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_position_changed");
1263 #line 132 "timeline.vala"
1264         gtk_widget_queue_draw (GTK_WIDGET (self));
1265 #line 1266 "timeline.c"
1266 }
1267
1268
1269 #line 160 "timeline.vala"
1270 static void _time_line_on_clip_view_added_track_view_clip_view_added (TrackView* _sender, ClipView* clip_view, gpointer self) {
1271 #line 1272 "timeline.c"
1272         time_line_on_clip_view_added (self, clip_view);
1273 }
1274
1275
1276 #line 135 "timeline.vala"
1277 static void time_line_on_track_added (TimeLine* self, ModelTrack* track) {
1278 #line 1279 "timeline.c"
1279         ClassFactory* _tmp0_;
1280         TrackView* _tmp1_;
1281         TrackView* track_view;
1282 #line 135 "timeline.vala"
1283         g_return_if_fail (IS_TIME_LINE (self));
1284 #line 135 "timeline.vala"
1285         g_return_if_fail (MODEL_IS_TRACK (track));
1286 #line 136 "timeline.vala"
1287         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_track_added");
1288 #line 137 "timeline.vala"
1289         track_view = (_tmp1_ = class_factory_get_track_view (_tmp0_ = class_factory_get_class_factory (), track, self), _class_factory_unref0 (_tmp0_), _tmp1_);
1290 #line 138 "timeline.vala"
1291         g_signal_connect_object (track_view, "clip-view-added", (GCallback) _time_line_on_clip_view_added_track_view_clip_view_added, self, 0);
1292 #line 139 "timeline.vala"
1293         gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->tracks), track_view);
1294 #line 140 "timeline.vala"
1295         gtk_box_pack_start (GTK_BOX (self->priv->vbox), GTK_WIDGET (track_view), FALSE, FALSE, (guint) 0);
1296 #line 141 "timeline.vala"
1297         g_signal_emit_by_name (self, "trackview-added", track_view);
1298 #line 142 "timeline.vala"
1299         if (model_track_media_type (track) == MODEL_MEDIA_TYPE_VIDEO) {
1300 #line 143 "timeline.vala"
1301                 gtk_box_reorder_child (GTK_BOX (self->priv->vbox), GTK_WIDGET (track_view), 1);
1302 #line 1303 "timeline.c"
1303         }
1304 #line 145 "timeline.vala"
1305         gtk_widget_show_all (GTK_WIDGET (self->priv->vbox));
1306 #line 1307 "timeline.c"
1307         _g_object_unref0 (track_view);
1308 }
1309
1310
1311 #line 148 "timeline.vala"
1312 static void time_line_on_track_removed (TimeLine* self, ModelTrack* track) {
1313 #line 148 "timeline.vala"
1314         g_return_if_fail (IS_TIME_LINE (self));
1315 #line 148 "timeline.vala"
1316         g_return_if_fail (MODEL_IS_TRACK (track));
1317 #line 149 "timeline.vala"
1318         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_track_removed");
1319 #line 1320 "timeline.c"
1320         {
1321                 GeeIterator* _track_view_it;
1322                 _track_view_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->tracks));
1323 #line 150 "timeline.vala"
1324                 while (TRUE) {
1325 #line 1326 "timeline.c"
1326                         TrackView* track_view;
1327                         ModelTrack* _tmp0_;
1328                         gboolean _tmp1_;
1329 #line 150 "timeline.vala"
1330                         if (!gee_iterator_next (_track_view_it)) {
1331 #line 150 "timeline.vala"
1332                                 break;
1333 #line 1334 "timeline.c"
1334                         }
1335 #line 150 "timeline.vala"
1336                         track_view = (TrackView*) gee_iterator_get (_track_view_it);
1337 #line 151 "timeline.vala"
1338                         if ((_tmp1_ = (_tmp0_ = track_view_get_track (track_view)) == track, _g_object_unref0 (_tmp0_), _tmp1_)) {
1339 #line 152 "timeline.vala"
1340                                 g_signal_emit_by_name (self, "trackview-removed", track_view);
1341 #line 153 "timeline.vala"
1342                                 gtk_container_remove (GTK_CONTAINER (self->priv->vbox), GTK_WIDGET (track_view));
1343 #line 154 "timeline.vala"
1344                                 gee_abstract_collection_remove (GEE_ABSTRACT_COLLECTION (self->tracks), track_view);
1345 #line 1346 "timeline.c"
1346                                 _g_object_unref0 (track_view);
1347 #line 155 "timeline.vala"
1348                                 break;
1349 #line 1350 "timeline.c"
1350                         }
1351                         _g_object_unref0 (track_view);
1352                 }
1353                 _g_object_unref0 (_track_view_it);
1354         }
1355 }
1356
1357
1358 #line 234 "timeline.vala"
1359 static void _time_line_on_clip_view_selection_request_clip_view_selection_request (ClipView* _sender, ClipView* clip_view, gboolean extend_selection, gpointer self) {
1360 #line 1361 "timeline.c"
1361         time_line_on_clip_view_selection_request (self, clip_view, extend_selection);
1362 }
1363
1364
1365 #line 327 "timeline.vala"
1366 static void _time_line_on_clip_view_move_request_clip_view_move_request (ClipView* _sender, ClipView* clip_view, gint64 delta, gpointer self) {
1367 #line 1368 "timeline.c"
1368         time_line_on_clip_view_move_request (self, clip_view, delta);
1369 }
1370
1371
1372 #line 267 "timeline.vala"
1373 static void _time_line_on_clip_view_move_commit_clip_view_move_commit (ClipView* _sender, ClipView* clip_view, gint64 delta, gpointer self) {
1374 #line 1375 "timeline.c"
1375         time_line_on_clip_view_move_commit (self, clip_view, delta);
1376 }
1377
1378
1379 #line 177 "timeline.vala"
1380 static void _time_line_on_clip_view_move_begin_clip_view_move_begin (ClipView* _sender, ClipView* clip_view, gboolean copy, gpointer self) {
1381 #line 1382 "timeline.c"
1382         time_line_on_clip_view_move_begin (self, clip_view, copy);
1383 }
1384
1385
1386 #line 219 "timeline.vala"
1387 static void _time_line_on_clip_view_trim_begin_clip_view_trim_begin (ClipView* _sender, ClipView* clip_view, GdkWindowEdge edge, gpointer self) {
1388 #line 1389 "timeline.c"
1389         time_line_on_clip_view_trim_begin (self, clip_view, edge);
1390 }
1391
1392
1393 #line 288 "timeline.vala"
1394 static void _time_line_on_clip_view_trim_commit_clip_view_trim_commit (ClipView* _sender, ClipView* clip_view, GdkWindowEdge edge, gpointer self) {
1395 #line 1396 "timeline.c"
1396         time_line_on_clip_view_trim_commit (self, clip_view, edge);
1397 }
1398
1399
1400 #line 160 "timeline.vala"
1401 void time_line_on_clip_view_added (TimeLine* self, ClipView* clip_view) {
1402 #line 160 "timeline.vala"
1403         g_return_if_fail (IS_TIME_LINE (self));
1404 #line 160 "timeline.vala"
1405         g_return_if_fail (IS_CLIP_VIEW (clip_view));
1406 #line 161 "timeline.vala"
1407         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_clip_clip_view_added");
1408 #line 162 "timeline.vala"
1409         g_signal_connect_object (clip_view, "selection-request", (GCallback) _time_line_on_clip_view_selection_request_clip_view_selection_request, self, 0);
1410 #line 163 "timeline.vala"
1411         g_signal_connect_object (clip_view, "move-request", (GCallback) _time_line_on_clip_view_move_request_clip_view_move_request, self, 0);
1412 #line 164 "timeline.vala"
1413         g_signal_connect_object (clip_view, "move-commit", (GCallback) _time_line_on_clip_view_move_commit_clip_view_move_commit, self, 0);
1414 #line 165 "timeline.vala"
1415         g_signal_connect_object (clip_view, "move-begin", (GCallback) _time_line_on_clip_view_move_begin_clip_view_move_begin, self, 0);
1416 #line 166 "timeline.vala"
1417         g_signal_connect_object (clip_view, "trim-begin", (GCallback) _time_line_on_clip_view_trim_begin_clip_view_trim_begin, self, 0);
1418 #line 167 "timeline.vala"
1419         g_signal_connect_object (clip_view, "trim-commit", (GCallback) _time_line_on_clip_view_trim_commit_clip_view_trim_commit, self, 0);
1420 #line 1421 "timeline.c"
1421 }
1422
1423
1424 #line 170 "timeline.vala"
1425 void time_line_deselect_all_clips (TimeLine* self) {
1426 #line 170 "timeline.vala"
1427         g_return_if_fail (IS_TIME_LINE (self));
1428 #line 1429 "timeline.c"
1429         {
1430                 GeeIterator* _selected_clip_view_it;
1431                 _selected_clip_view_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->selected_clips));
1432 #line 171 "timeline.vala"
1433                 while (TRUE) {
1434 #line 1435 "timeline.c"
1435                         ClipView* selected_clip_view;
1436 #line 171 "timeline.vala"
1437                         if (!gee_iterator_next (_selected_clip_view_it)) {
1438 #line 171 "timeline.vala"
1439                                 break;
1440 #line 1441 "timeline.c"
1441                         }
1442 #line 171 "timeline.vala"
1443                         selected_clip_view = (ClipView*) gee_iterator_get (_selected_clip_view_it);
1444 #line 172 "timeline.vala"
1445                         selected_clip_view->is_selected = FALSE;
1446 #line 1447 "timeline.c"
1447                         _g_object_unref0 (selected_clip_view);
1448                 }
1449                 _g_object_unref0 (_selected_clip_view_it);
1450         }
1451 #line 174 "timeline.vala"
1452         gee_abstract_collection_clear (GEE_ABSTRACT_COLLECTION (self->selected_clips));
1453 #line 1454 "timeline.c"
1454 }
1455
1456
1457 #line 177 "timeline.vala"
1458 static void time_line_on_clip_view_move_begin (TimeLine* self, ClipView* clip_view, gboolean copy) {
1459 #line 1460 "timeline.c"
1460         ClipView* max_clip;
1461         GtkLabel* _tmp5_;
1462         GtkWidget* _tmp6_;
1463         GtkFixed* the_parent;
1464 #line 177 "timeline.vala"
1465         g_return_if_fail (IS_TIME_LINE (self));
1466 #line 177 "timeline.vala"
1467         g_return_if_fail (IS_CLIP_VIEW (clip_view));
1468 #line 178 "timeline.vala"
1469         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_clip_view_move_begin");
1470 #line 179 "timeline.vala"
1471         self->priv->copying = copy;
1472 #line 180 "timeline.vala"
1473         if (copy) {
1474 #line 181 "timeline.vala"
1475                 model_undo_manager_start_transaction (self->project->undo_manager, "Copy Clip");
1476 #line 1477 "timeline.c"
1477         }
1478 #line 183 "timeline.vala"
1479         max_clip = NULL;
1480 #line 1481 "timeline.c"
1481         {
1482                 GeeIterator* _selected_clip_it;
1483                 _selected_clip_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->selected_clips));
1484 #line 185 "timeline.vala"
1485                 while (TRUE) {
1486 #line 1487 "timeline.c"
1487                         ClipView* selected_clip;
1488                         GtkWidget* _tmp2_;
1489                         TrackView* track_view;
1490 #line 185 "timeline.vala"
1491                         if (!gee_iterator_next (_selected_clip_it)) {
1492 #line 185 "timeline.vala"
1493                                 break;
1494 #line 1495 "timeline.c"
1495                         }
1496 #line 185 "timeline.vala"
1497                         selected_clip = (ClipView*) gee_iterator_get (_selected_clip_it);
1498 #line 186 "timeline.vala"
1499                         if (max_clip == NULL) {
1500 #line 1501 "timeline.c"
1501                                 ClipView* _tmp0_;
1502 #line 187 "timeline.vala"
1503                                 max_clip = (_tmp0_ = _g_object_ref0 (selected_clip), _g_object_unref0 (max_clip), _tmp0_);
1504 #line 1505 "timeline.c"
1505                         } else {
1506 #line 188 "timeline.vala"
1507                                 if (model_clip_get_end (max_clip->clip) < model_clip_get_end (selected_clip->clip)) {
1508 #line 1509 "timeline.c"
1509                                         ClipView* _tmp1_;
1510 #line 189 "timeline.vala"
1511                                         max_clip = (_tmp1_ = _g_object_ref0 (selected_clip), _g_object_unref0 (max_clip), _tmp1_);
1512 #line 1513 "timeline.c"
1513                                 }
1514                         }
1515 #line 191 "timeline.vala"
1516                         selected_clip->initial_time = model_clip_get_start (selected_clip->clip);
1517 #line 192 "timeline.vala"
1518                         model_clip_gnonlin_disconnect (selected_clip->clip);
1519 #line 193 "timeline.vala"
1520                         track_view = _g_object_ref0 ((_tmp2_ = gtk_widget_get_parent (GTK_WIDGET (selected_clip)), IS_TRACK_VIEW (_tmp2_) ? ((TrackView*) _tmp2_) : NULL));
1521 #line 194 "timeline.vala"
1522                         if (track_view != NULL) {
1523 #line 1524 "timeline.c"
1524                                 ModelTrack* _tmp3_;
1525 #line 195 "timeline.vala"
1526                                 model_track_remove_clip_from_array (_tmp3_ = track_view_get_track (track_view), selected_clip->clip);
1527 #line 1528 "timeline.c"
1528                                 _g_object_unref0 (_tmp3_);
1529                         }
1530 #line 197 "timeline.vala"
1531                         if (copy) {
1532 #line 1533 "timeline.c"
1533                                 ModelClip* clip;
1534                                 ModelTrack* _tmp4_;
1535 #line 201 "timeline.vala"
1536                                 clip = model_clip_copy (selected_clip->clip);
1537 #line 202 "timeline.vala"
1538                                 model_track_append_at_time (_tmp4_ = track_view_get_track (track_view), clip, model_clip_get_start (selected_clip->clip), FALSE);
1539 #line 1540 "timeline.c"
1540                                 _g_object_unref0 (_tmp4_);
1541                                 _g_object_unref0 (clip);
1542                         }
1543                         _g_object_unref0 (selected_clip);
1544                         _g_object_unref0 (track_view);
1545                 }
1546                 _g_object_unref0 (_selected_clip_it);
1547         }
1548 #line 206 "timeline.vala"
1549         self->priv->high_water = (_tmp5_ = g_object_ref_sink ((GtkLabel*) gtk_label_new (NULL)), _g_object_unref0 (self->priv->high_water), _tmp5_);
1550 #line 207 "timeline.vala"
1551         the_parent = _g_object_ref0 ((_tmp6_ = gtk_widget_get_parent (GTK_WIDGET (clip_view)), GTK_IS_FIXED (_tmp6_) ? ((GtkFixed*) _tmp6_) : NULL));
1552 #line 208 "timeline.vala"
1553         gtk_fixed_put (the_parent, GTK_WIDGET (self->priv->high_water), GTK_WIDGET (max_clip)->allocation.x + GTK_WIDGET (max_clip)->allocation.width, GTK_WIDGET (max_clip)->allocation.y);
1554 #line 1555 "timeline.c"
1555         {
1556                 GeeIterator* _selected_clip_it;
1557                 _selected_clip_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->selected_clips));
1558 #line 213 "timeline.vala"
1559                 while (TRUE) {
1560 #line 1561 "timeline.c"
1561                         ClipView* selected_clip;
1562                         GtkWidget* _tmp7_;
1563                         TrackView* track_view;
1564 #line 213 "timeline.vala"
1565                         if (!gee_iterator_next (_selected_clip_it)) {
1566 #line 213 "timeline.vala"
1567                                 break;
1568 #line 1569 "timeline.c"
1569                         }
1570 #line 213 "timeline.vala"
1571                         selected_clip = (ClipView*) gee_iterator_get (_selected_clip_it);
1572 #line 214 "timeline.vala"
1573                         track_view = _g_object_ref0 ((_tmp7_ = gtk_widget_get_parent (GTK_WIDGET (selected_clip)), IS_TRACK_VIEW (_tmp7_) ? ((TrackView*) _tmp7_) : NULL));
1574 #line 215 "timeline.vala"
1575                         track_view_move_to_top (track_view, selected_clip);
1576 #line 1577 "timeline.c"
1577                         _g_object_unref0 (selected_clip);
1578                         _g_object_unref0 (track_view);
1579                 }
1580                 _g_object_unref0 (_selected_clip_it);
1581         }
1582         _g_object_unref0 (max_clip);
1583         _g_object_unref0 (the_parent);
1584 }
1585
1586
1587 #line 219 "timeline.vala"
1588 static void time_line_on_clip_view_trim_begin (TimeLine* self, ClipView* clip, GdkWindowEdge edge) {
1589 #line 219 "timeline.vala"
1590         g_return_if_fail (IS_TIME_LINE (self));
1591 #line 219 "timeline.vala"
1592         g_return_if_fail (IS_CLIP_VIEW (clip));
1593 #line 220 "timeline.vala"
1594         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_clip_view_trim_begin");
1595 #line 221 "timeline.vala"
1596         switch (edge) {
1597 #line 1598 "timeline.c"
1598                 case GDK_WINDOW_EDGE_WEST:
1599                 {
1600 #line 223 "timeline.vala"
1601                         clip->initial_time = model_clip_get_start (clip->clip);
1602 #line 224 "timeline.vala"
1603                         break;
1604 #line 1605 "timeline.c"
1605                 }
1606                 case GDK_WINDOW_EDGE_EAST:
1607                 {
1608 #line 226 "timeline.vala"
1609                         clip->initial_time = model_clip_get_duration (clip->clip);
1610 #line 227 "timeline.vala"
1611                         break;
1612 #line 1613 "timeline.c"
1613                 }
1614                 default:
1615                 {
1616 #line 229 "timeline.vala"
1617                         g_assert (FALSE);
1618 #line 230 "timeline.vala"
1619                         break;
1620 #line 1621 "timeline.c"
1621                 }
1622         }
1623 }
1624
1625
1626 #line 234 "timeline.vala"
1627 static void time_line_on_clip_view_selection_request (TimeLine* self, ClipView* clip_view, gboolean extend) {
1628 #line 1629 "timeline.c"
1629         gboolean in_selected_clips;
1630 #line 234 "timeline.vala"
1631         g_return_if_fail (IS_TIME_LINE (self));
1632 #line 234 "timeline.vala"
1633         g_return_if_fail (IS_CLIP_VIEW (clip_view));
1634 #line 235 "timeline.vala"
1635         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_clip_view_selection_request");
1636 #line 241 "timeline.vala"
1637         in_selected_clips = gee_abstract_collection_contains (GEE_ABSTRACT_COLLECTION (self->selected_clips), clip_view);
1638 #line 242 "timeline.vala"
1639         if (!extend) {
1640 #line 243 "timeline.vala"
1641                 if (!in_selected_clips) {
1642 #line 244 "timeline.vala"
1643                         time_line_deselect_all_clips (self);
1644 #line 245 "timeline.vala"
1645                         clip_view->is_selected = TRUE;
1646 #line 246 "timeline.vala"
1647                         gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->selected_clips), clip_view);
1648 #line 1649 "timeline.c"
1649                 }
1650         } else {
1651 #line 249 "timeline.vala"
1652                 if (gee_collection_get_size (GEE_COLLECTION (self->selected_clips)) > 1) {
1653 #line 1654 "timeline.c"
1654                         gboolean _tmp0_ = FALSE;
1655 #line 250 "timeline.vala"
1656                         if (in_selected_clips) {
1657 #line 250 "timeline.vala"
1658                                 _tmp0_ = clip_view->is_selected;
1659 #line 1660 "timeline.c"
1660                         } else {
1661 #line 250 "timeline.vala"
1662                                 _tmp0_ = FALSE;
1663 #line 1664 "timeline.c"
1664                         }
1665 #line 250 "timeline.vala"
1666                         if (_tmp0_) {
1667 #line 1668 "timeline.c"
1668                                 GtkWidget* _tmp1_;
1669 #line 251 "timeline.vala"
1670                                 clip_view->is_selected = FALSE;
1671 #line 253 "timeline.vala"
1672                                 self->priv->drag_widget = (_tmp1_ = NULL, _g_object_unref0 (self->priv->drag_widget), _tmp1_);
1673 #line 254 "timeline.vala"
1674                                 gee_abstract_collection_remove (GEE_ABSTRACT_COLLECTION (self->selected_clips), clip_view);
1675 #line 1676 "timeline.c"
1676                         }
1677                 }
1678 #line 257 "timeline.vala"
1679                 if (!in_selected_clips) {
1680 #line 258 "timeline.vala"
1681                         clip_view->is_selected = TRUE;
1682 #line 259 "timeline.vala"
1683                         gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->selected_clips), clip_view);
1684 #line 1685 "timeline.c"
1685                 }
1686         }
1687 #line 262 "timeline.vala"
1688         g_signal_emit_by_name (self, "track-changed");
1689 #line 263 "timeline.vala"
1690         g_signal_emit_by_name (self, "selection-changed", time_line_is_clip_selected (self));
1691 #line 264 "timeline.vala"
1692         gtk_widget_queue_draw (GTK_WIDGET (self));
1693 #line 1694 "timeline.c"
1694 }
1695
1696
1697 #line 267 "timeline.vala"
1698 static void time_line_on_clip_view_move_commit (TimeLine* self, ClipView* clip_view, gint64 delta) {
1699 #line 1700 "timeline.c"
1700         GtkWidget* _tmp0_;
1701         GtkFixed* fixed;
1702         GtkLabel* _tmp1_;
1703 #line 267 "timeline.vala"
1704         g_return_if_fail (IS_TIME_LINE (self));
1705 #line 267 "timeline.vala"
1706         g_return_if_fail (IS_CLIP_VIEW (clip_view));
1707 #line 268 "timeline.vala"
1708         gdk_window_set_cursor (GTK_WIDGET (self)->window, NULL);
1709 #line 269 "timeline.vala"
1710         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_clip_view_move_request");
1711 #line 270 "timeline.vala"
1712         fixed = _g_object_ref0 ((_tmp0_ = gtk_widget_get_parent (GTK_WIDGET (self->priv->high_water)), GTK_IS_FIXED (_tmp0_) ? ((GtkFixed*) _tmp0_) : NULL));
1713 #line 271 "timeline.vala"
1714         gtk_container_remove (GTK_CONTAINER (fixed), GTK_WIDGET (self->priv->high_water));
1715 #line 272 "timeline.vala"
1716         self->priv->high_water = (_tmp1_ = NULL, _g_object_unref0 (self->priv->high_water), _tmp1_);
1717 #line 274 "timeline.vala"
1718         model_undo_manager_start_transaction (self->project->undo_manager, "Move Clip");
1719 #line 1720 "timeline.c"
1720         {
1721                 GeeIterator* _selected_clip_view_it;
1722                 _selected_clip_view_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->selected_clips));
1723 #line 275 "timeline.vala"
1724                 while (TRUE) {
1725 #line 1726 "timeline.c"
1726                         ClipView* selected_clip_view;
1727                         GtkWidget* _tmp2_;
1728                         TrackView* track_view;
1729                         ModelTrack* _tmp3_;
1730 #line 275 "timeline.vala"
1731                         if (!gee_iterator_next (_selected_clip_view_it)) {
1732 #line 275 "timeline.vala"
1733                                 break;
1734 #line 1735 "timeline.c"
1735                         }
1736 #line 275 "timeline.vala"
1737                         selected_clip_view = (ClipView*) gee_iterator_get (_selected_clip_view_it);
1738 #line 276 "timeline.vala"
1739                         track_view = _g_object_ref0 ((_tmp2_ = gtk_widget_get_parent (GTK_WIDGET (selected_clip_view)), IS_TRACK_VIEW (_tmp2_) ? ((TrackView*) _tmp2_) : NULL));
1740 #line 277 "timeline.vala"
1741                         model_clip_gnonlin_connect (selected_clip_view->clip);
1742 #line 278 "timeline.vala"
1743                         model_track_move (_tmp3_ = track_view_get_track (track_view), selected_clip_view->clip, model_clip_get_start (selected_clip_view->clip), selected_clip_view->initial_time);
1744 #line 1745 "timeline.c"
1745                         _g_object_unref0 (_tmp3_);
1746                         _g_object_unref0 (selected_clip_view);
1747                         _g_object_unref0 (track_view);
1748                 }
1749                 _g_object_unref0 (_selected_clip_view_it);
1750         }
1751 #line 281 "timeline.vala"
1752         model_undo_manager_end_transaction (self->project->undo_manager, "Move Clip");
1753 #line 282 "timeline.vala"
1754         if (self->priv->copying) {
1755 #line 283 "timeline.vala"
1756                 self->priv->copying = FALSE;
1757 #line 284 "timeline.vala"
1758                 model_undo_manager_end_transaction (self->project->undo_manager, "Copy Clip");
1759 #line 1760 "timeline.c"
1760         }
1761         _g_object_unref0 (fixed);
1762 }
1763
1764
1765 #line 288 "timeline.vala"
1766 static void time_line_on_clip_view_trim_commit (TimeLine* self, ClipView* clip_view, GdkWindowEdge edge) {
1767 #line 1768 "timeline.c"
1768         GtkWidget* _tmp0_;
1769         TrackView* track_view;
1770         gint64 delta;
1771         ModelTrack* _tmp1_;
1772 #line 288 "timeline.vala"
1773         g_return_if_fail (IS_TIME_LINE (self));
1774 #line 288 "timeline.vala"
1775         g_return_if_fail (IS_CLIP_VIEW (clip_view));
1776 #line 289 "timeline.vala"
1777         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_clip_view_move_commit");
1778 #line 290 "timeline.vala"
1779         gdk_window_set_cursor (GTK_WIDGET (self)->window, NULL);
1780 #line 291 "timeline.vala"
1781         track_view = _g_object_ref0 ((_tmp0_ = gtk_widget_get_parent (GTK_WIDGET (clip_view)), IS_TRACK_VIEW (_tmp0_) ? ((TrackView*) _tmp0_) : NULL));
1782 #line 292 "timeline.vala"
1783         delta = (gint64) 0;
1784 #line 293 "timeline.vala"
1785         switch (edge) {
1786 #line 1787 "timeline.c"
1787                 case GDK_WINDOW_EDGE_WEST:
1788                 {
1789 #line 295 "timeline.vala"
1790                         delta = model_clip_get_start (clip_view->clip) - clip_view->initial_time;
1791 #line 296 "timeline.vala"
1792                         break;
1793 #line 1794 "timeline.c"
1794                 }
1795                 case GDK_WINDOW_EDGE_EAST:
1796                 {
1797 #line 298 "timeline.vala"
1798                         delta = model_clip_get_duration (clip_view->clip) - clip_view->initial_time;
1799 #line 299 "timeline.vala"
1800                         break;
1801 #line 1802 "timeline.c"
1802                 }
1803                 default:
1804                 {
1805 #line 301 "timeline.vala"
1806                         g_assert (FALSE);
1807 #line 302 "timeline.vala"
1808                         break;
1809 #line 1810 "timeline.c"
1810                 }
1811         }
1812 #line 305 "timeline.vala"
1813         model_undo_manager_start_transaction (self->project->undo_manager, "Trim Clip");
1814 #line 306 "timeline.vala"
1815         model_clip_trim (clip_view->clip, -delta, edge);
1816 #line 307 "timeline.vala"
1817         model_clip_gnonlin_connect (clip_view->clip);
1818 #line 308 "timeline.vala"
1819         model_track_trim (_tmp1_ = track_view_get_track (track_view), clip_view->clip, delta, edge);
1820 #line 1821 "timeline.c"
1821         _g_object_unref0 (_tmp1_);
1822 #line 309 "timeline.vala"
1823         model_undo_manager_end_transaction (self->project->undo_manager, "Trim Clip");
1824 #line 1825 "timeline.c"
1825         _g_object_unref0 (track_view);
1826 }
1827
1828
1829 #line 312 "timeline.vala"
1830 static void time_line_constrain_move (TimeLine* self, ClipView* clip_view, gint64* delta) {
1831 #line 1832 "timeline.c"
1832         gint min_delta;
1833         gint delta_xsize;
1834         TrackView* _tmp0_;
1835         TrackView* track_view;
1836         ModelTrack* track;
1837 #line 312 "timeline.vala"
1838         g_return_if_fail (IS_TIME_LINE (self));
1839 #line 312 "timeline.vala"
1840         g_return_if_fail (IS_CLIP_VIEW (clip_view));
1841 #line 313 "timeline.vala"
1842         min_delta = CLIP_VIEW_SNAP_DELTA;
1843 #line 314 "timeline.vala"
1844         delta_xsize = model_time_system_time_to_xsize (self->provider, *delta);
1845 #line 315 "timeline.vala"
1846         track_view = _g_object_ref0 ((_tmp0_ = TRACK_VIEW (gtk_widget_get_parent (GTK_WIDGET (clip_view))), IS_TRACK_VIEW (_tmp0_) ? ((TrackView*) _tmp0_) : NULL));
1847 #line 316 "timeline.vala"
1848         track = track_view_get_track (track_view);
1849 #line 317 "timeline.vala"
1850         if (abs (delta_xsize) < min_delta) {
1851 #line 1852 "timeline.c"
1852                 gint64 range;
1853                 gint64 adjustment = 0LL;
1854 #line 318 "timeline.vala"
1855                 range = model_time_system_xsize_to_time (self->provider, min_delta);
1856 #line 320 "timeline.vala"
1857                 if (model_track_clip_is_near (track, clip_view->clip, range, &adjustment)) {
1858 #line 321 "timeline.vala"
1859                         *delta = adjustment;
1860 #line 322 "timeline.vala"
1861                         clip_view_snap (clip_view, (gint64) model_time_system_time_to_xsize (self->provider, adjustment));
1862 #line 1863 "timeline.c"
1863                 }
1864         }
1865         _g_object_unref0 (track_view);
1866         _g_object_unref0 (track);
1867 }
1868
1869
1870 #line 327 "timeline.vala"
1871 static void time_line_on_clip_view_move_request (TimeLine* self, ClipView* clip_view, gint64 delta) {
1872 #line 327 "timeline.vala"
1873         g_return_if_fail (IS_TIME_LINE (self));
1874 #line 327 "timeline.vala"
1875         g_return_if_fail (IS_CLIP_VIEW (clip_view));
1876 #line 328 "timeline.vala"
1877         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_clip_view_move_request");
1878 #line 329 "timeline.vala"
1879         if (self->project->snap_to_clip) {
1880 #line 330 "timeline.vala"
1881                 time_line_constrain_move (self, clip_view, &delta);
1882 #line 1883 "timeline.c"
1883         }
1884 #line 332 "timeline.vala"
1885         if (time_line_move_allowed (self, &delta)) {
1886 #line 333 "timeline.vala"
1887                 time_line_move_the_clips (self, delta);
1888 #line 1889 "timeline.c"
1889         }
1890 }
1891
1892
1893 #line 337 "timeline.vala"
1894 static gboolean time_line_move_allowed (TimeLine* self, gint64* move_distance) {
1895 #line 1896 "timeline.c"
1896         gboolean result = FALSE;
1897         ClipView* max_clip;
1898 #line 337 "timeline.vala"
1899         g_return_val_if_fail (IS_TIME_LINE (self), FALSE);
1900 #line 338 "timeline.vala"
1901         if (self->priv->drag_widget == NULL) {
1902 #line 1903 "timeline.c"
1903                 result = FALSE;
1904 #line 339 "timeline.vala"
1905                 return result;
1906 #line 1907 "timeline.c"
1907         }
1908 #line 342 "timeline.vala"
1909         max_clip = NULL;
1910 #line 1911 "timeline.c"
1911         {
1912                 GeeIterator* _clip_view_it;
1913                 _clip_view_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->selected_clips));
1914 #line 344 "timeline.vala"
1915                 while (TRUE) {
1916 #line 1917 "timeline.c"
1917                         ClipView* clip_view;
1918                         gint position;
1919 #line 344 "timeline.vala"
1920                         if (!gee_iterator_next (_clip_view_it)) {
1921 #line 344 "timeline.vala"
1922                                 break;
1923 #line 1924 "timeline.c"
1924                         }
1925 #line 344 "timeline.vala"
1926                         clip_view = (ClipView*) gee_iterator_get (_clip_view_it);
1927 #line 345 "timeline.vala"
1928                         if (max_clip == NULL) {
1929 #line 1930 "timeline.c"
1930                                 ClipView* _tmp0_;
1931 #line 346 "timeline.vala"
1932                                 max_clip = (_tmp0_ = _g_object_ref0 (clip_view), _g_object_unref0 (max_clip), _tmp0_);
1933 #line 1934 "timeline.c"
1934                         } else {
1935 #line 347 "timeline.vala"
1936                                 if (model_clip_get_end (clip_view->clip) > model_clip_get_end (max_clip->clip)) {
1937 #line 1938 "timeline.c"
1938                                         ClipView* _tmp1_;
1939 #line 348 "timeline.vala"
1940                                         max_clip = (_tmp1_ = _g_object_ref0 (clip_view), _g_object_unref0 (max_clip), _tmp1_);
1941 #line 1942 "timeline.c"
1942                                 }
1943                         }
1944 #line 350 "timeline.vala"
1945                         position = model_time_system_time_to_xpos (self->provider, model_clip_get_start (clip_view->clip) + (*move_distance));
1946 #line 351 "timeline.vala"
1947                         if (position < TIME_LINE_BORDER) {
1948 #line 1949 "timeline.c"
1949                                 result = FALSE;
1950                                 _g_object_unref0 (clip_view);
1951                                 _g_object_unref0 (_clip_view_it);
1952                                 _g_object_unref0 (max_clip);
1953 #line 352 "timeline.vala"
1954                                 return result;
1955 #line 1956 "timeline.c"
1956                         }
1957                         _g_object_unref0 (clip_view);
1958                 }
1959                 _g_object_unref0 (_clip_view_it);
1960         }
1961         result = TRUE;
1962         _g_object_unref0 (max_clip);
1963 #line 355 "timeline.vala"
1964         return result;
1965 #line 1966 "timeline.c"
1966 }
1967
1968
1969 #line 358 "timeline.vala"
1970 static void time_line_move_the_clips (TimeLine* self, gint64 move_distance) {
1971 #line 358 "timeline.vala"
1972         g_return_if_fail (IS_TIME_LINE (self));
1973 #line 1974 "timeline.c"
1974         {
1975                 GeeIterator* _clip_view_it;
1976                 _clip_view_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->selected_clips));
1977 #line 359 "timeline.vala"
1978                 while (TRUE) {
1979 #line 1980 "timeline.c"
1980                         ClipView* clip_view;
1981 #line 359 "timeline.vala"
1982                         if (!gee_iterator_next (_clip_view_it)) {
1983 #line 359 "timeline.vala"
1984                                 break;
1985 #line 1986 "timeline.c"
1986                         }
1987 #line 359 "timeline.vala"
1988                         clip_view = (ClipView*) gee_iterator_get (_clip_view_it);
1989 #line 360 "timeline.vala"
1990                         time_line_do_clip_move (self, clip_view, move_distance);
1991 #line 1992 "timeline.c"
1992                         _g_object_unref0 (clip_view);
1993                 }
1994                 _g_object_unref0 (_clip_view_it);
1995         }
1996 }
1997
1998
1999 #line 364 "timeline.vala"
2000 void time_line_do_clip_move (TimeLine* self, ClipView* clip_view, gint64 delta) {
2001 #line 364 "timeline.vala"
2002         g_return_if_fail (IS_TIME_LINE (self));
2003 #line 364 "timeline.vala"
2004         g_return_if_fail (IS_CLIP_VIEW (clip_view));
2005 #line 365 "timeline.vala"
2006         model_clip_set_start (clip_view->clip, model_clip_get_start (clip_view->clip) + delta);
2007 #line 2008 "timeline.c"
2008 }
2009
2010
2011 #line 368 "timeline.vala"
2012 void time_line_on_ruler_position_changed (TimeLine* self, gint x) {
2013 #line 368 "timeline.vala"
2014         g_return_if_fail (IS_TIME_LINE (self));
2015 #line 369 "timeline.vala"
2016         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_ruler_position_changed");
2017 #line 370 "timeline.vala"
2018         if (!model_project_transport_is_recording (self->project)) {
2019 #line 371 "timeline.vala"
2020                 time_line_update_pos (self, x);
2021 #line 2022 "timeline.c"
2022         }
2023 }
2024
2025
2026 #line 375 "timeline.vala"
2027 gboolean time_line_is_clip_selected (TimeLine* self) {
2028 #line 2029 "timeline.c"
2029         gboolean result = FALSE;
2030 #line 375 "timeline.vala"
2031         g_return_val_if_fail (IS_TIME_LINE (self), FALSE);
2032 #line 2033 "timeline.c"
2033         result = gee_collection_get_size (GEE_COLLECTION (self->selected_clips)) > 0;
2034 #line 376 "timeline.vala"
2035         return result;
2036 #line 2037 "timeline.c"
2037 }
2038
2039
2040 #line 379 "timeline.vala"
2041 gboolean time_line_gap_selected (TimeLine* self) {
2042 #line 2043 "timeline.c"
2043         gboolean result = FALSE;
2044 #line 379 "timeline.vala"
2045         g_return_val_if_fail (IS_TIME_LINE (self), FALSE);
2046 #line 2047 "timeline.c"
2047         result = FALSE;
2048 #line 380 "timeline.vala"
2049         return result;
2050 #line 2051 "timeline.c"
2051 }
2052
2053
2054 #line 384 "timeline.vala"
2055 void time_line_delete_selection (TimeLine* self) {
2056 #line 2057 "timeline.c"
2057         GtkWidget* _tmp0_;
2058 #line 384 "timeline.vala"
2059         g_return_if_fail (IS_TIME_LINE (self));
2060 #line 385 "timeline.vala"
2061         model_undo_manager_start_transaction (self->project->undo_manager, "Delete Clips From Timeline");
2062 #line 386 "timeline.vala"
2063         self->priv->drag_widget = (_tmp0_ = NULL, _g_object_unref0 (self->priv->drag_widget), _tmp0_);
2064 #line 387 "timeline.vala"
2065         if (time_line_is_clip_selected (self)) {
2066 #line 388 "timeline.vala"
2067                 while (TRUE) {
2068 #line 2069 "timeline.c"
2069                         ClipView* _tmp1_;
2070                         ClipView* _tmp2_;
2071 #line 388 "timeline.vala"
2072                         if (!(gee_collection_get_size (GEE_COLLECTION (self->selected_clips)) > 0)) {
2073 #line 388 "timeline.vala"
2074                                 break;
2075 #line 2076 "timeline.c"
2076                         }
2077 #line 389 "timeline.vala"
2078                         clip_view_delete_clip (_tmp1_ = (ClipView*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->selected_clips), 0));
2079 #line 2080 "timeline.c"
2080                         _g_object_unref0 (_tmp1_);
2081 #line 390 "timeline.vala"
2082                         _tmp2_ = (ClipView*) gee_abstract_list_remove_at (GEE_ABSTRACT_LIST (self->selected_clips), 0);
2083 #line 2084 "timeline.c"
2084                         _g_object_unref0 (_tmp2_);
2085                 }
2086 #line 392 "timeline.vala"
2087                 g_signal_emit_by_name (self, "track-changed");
2088 #line 2089 "timeline.c"
2089         } else {
2090         }
2091 #line 409 "timeline.vala"
2092         model_undo_manager_end_transaction (self->project->undo_manager, "Delete Clips From Timeline");
2093 #line 2094 "timeline.c"
2094 }
2095
2096
2097 #line 412 "timeline.vala"
2098 void time_line_do_cut (TimeLine* self) {
2099 #line 412 "timeline.vala"
2100         g_return_if_fail (IS_TIME_LINE (self));
2101 #line 413 "timeline.vala"
2102         clipboard_select (self->clipboard, self->selected_clips);
2103 #line 414 "timeline.vala"
2104         time_line_delete_selection (self);
2105 #line 2106 "timeline.c"
2106 }
2107
2108
2109 #line 417 "timeline.vala"
2110 void time_line_do_copy (TimeLine* self) {
2111 #line 417 "timeline.vala"
2112         g_return_if_fail (IS_TIME_LINE (self));
2113 #line 418 "timeline.vala"
2114         clipboard_select (self->clipboard, self->selected_clips);
2115 #line 419 "timeline.vala"
2116         g_signal_emit_by_name (self, "selection-changed", TRUE);
2117 #line 2118 "timeline.c"
2118 }
2119
2120
2121 #line 422 "timeline.vala"
2122 void time_line_paste (TimeLine* self) {
2123 #line 422 "timeline.vala"
2124         g_return_if_fail (IS_TIME_LINE (self));
2125 #line 423 "timeline.vala"
2126         time_line_do_paste (self, model_project_transport_get_position (self->project));
2127 #line 2128 "timeline.c"
2128 }
2129
2130
2131 #line 426 "timeline.vala"
2132 void time_line_do_paste (TimeLine* self, gint64 pos) {
2133 #line 2134 "timeline.c"
2134         TrackView* view;
2135         ModelTrack* _tmp9_;
2136 #line 426 "timeline.vala"
2137         g_return_if_fail (IS_TIME_LINE (self));
2138 #line 427 "timeline.vala"
2139         view = NULL;
2140 #line 2141 "timeline.c"
2141         {
2142                 GeeIterator* _track_view_it;
2143                 _track_view_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->tracks));
2144 #line 428 "timeline.vala"
2145                 while (TRUE) {
2146 #line 2147 "timeline.c"
2147                         TrackView* track_view;
2148                         ModelTrack* _tmp0_;
2149                         gboolean _tmp1_;
2150 #line 428 "timeline.vala"
2151                         if (!gee_iterator_next (_track_view_it)) {
2152 #line 428 "timeline.vala"
2153                                 break;
2154 #line 2155 "timeline.c"
2155                         }
2156 #line 428 "timeline.vala"
2157                         track_view = (TrackView*) gee_iterator_get (_track_view_it);
2158 #line 429 "timeline.vala"
2159                         if ((_tmp1_ = model_track_get_is_selected (_tmp0_ = track_view_get_track (track_view)), _g_object_unref0 (_tmp0_), _tmp1_)) {
2160 #line 2161 "timeline.c"
2161                                 TrackView* _tmp2_;
2162 #line 430 "timeline.vala"
2163                                 view = (_tmp2_ = _g_object_ref0 (track_view), _g_object_unref0 (view), _tmp2_);
2164 #line 2165 "timeline.c"
2165                         }
2166                         _g_object_unref0 (track_view);
2167                 }
2168                 _g_object_unref0 (_track_view_it);
2169         }
2170 #line 435 "timeline.vala"
2171         if (view == NULL) {
2172 #line 2173 "timeline.c"
2173                 TrackView* _tmp3_;
2174                 TrackClipPair* _tmp4_;
2175                 gboolean _tmp5_;
2176                 TrackView* _tmp8_;
2177                 _tmp3_ = NULL;
2178 #line 436 "timeline.vala"
2179                 if ((_tmp5_ = (_tmp4_ = (TrackClipPair*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->clipboard->clips), 0))->clip->type == MODEL_MEDIA_TYPE_VIDEO, _track_clip_pair_unref0 (_tmp4_), _tmp5_)) {
2180 #line 2181 "timeline.c"
2181                         TrackView* _tmp6_;
2182 #line 437 "timeline.vala"
2183                         _tmp3_ = (_tmp6_ = time_line_find_video_track_view (self), _g_object_unref0 (_tmp3_), _tmp6_);
2184 #line 2185 "timeline.c"
2185                 } else {
2186                         TrackView* _tmp7_;
2187 #line 437 "timeline.vala"
2188                         _tmp3_ = (_tmp7_ = time_line_find_audio_track_view (self), _g_object_unref0 (_tmp3_), _tmp7_);
2189 #line 2190 "timeline.c"
2190                 }
2191 #line 436 "timeline.vala"
2192                 view = (_tmp8_ = _g_object_ref0 (_tmp3_), _g_object_unref0 (view), _tmp8_);
2193 #line 2194 "timeline.c"
2194                 _g_object_unref0 (_tmp3_);
2195         }
2196 #line 439 "timeline.vala"
2197         model_undo_manager_start_transaction (self->project->undo_manager, "Paste");
2198 #line 440 "timeline.vala"
2199         clipboard_paste (self->clipboard, _tmp9_ = track_view_get_track (view), pos);
2200 #line 2201 "timeline.c"
2201         _g_object_unref0 (_tmp9_);
2202 #line 441 "timeline.vala"
2203         model_undo_manager_end_transaction (self->project->undo_manager, "Paste");
2204 #line 442 "timeline.vala"
2205         gtk_widget_queue_draw (GTK_WIDGET (self));
2206 #line 2207 "timeline.c"
2207         _g_object_unref0 (view);
2208 }
2209
2210
2211 #line 445 "timeline.vala"
2212 void time_line_select_all (TimeLine* self) {
2213 #line 445 "timeline.vala"
2214         g_return_if_fail (IS_TIME_LINE (self));
2215 #line 2216 "timeline.c"
2216         {
2217                 GeeIterator* _track_it;
2218                 _track_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->tracks));
2219 #line 446 "timeline.vala"
2220                 while (TRUE) {
2221 #line 2222 "timeline.c"
2222                         TrackView* track;
2223 #line 446 "timeline.vala"
2224                         if (!gee_iterator_next (_track_it)) {
2225 #line 446 "timeline.vala"
2226                                 break;
2227 #line 2228 "timeline.c"
2228                         }
2229 #line 446 "timeline.vala"
2230                         track = (TrackView*) gee_iterator_get (_track_it);
2231 #line 447 "timeline.vala"
2232                         track_view_select_all (track);
2233 #line 2234 "timeline.c"
2234                         _g_object_unref0 (track);
2235                 }
2236                 _g_object_unref0 (_track_it);
2237         }
2238 }
2239
2240
2241 #line 451 "timeline.vala"
2242 static gboolean time_line_real_expose_event (GtkWidget* base, GdkEventExpose* event) {
2243 #line 2244 "timeline.c"
2244         TimeLine * self;
2245         gboolean result = FALSE;
2246         gint xpos;
2247         self = TIME_LINE (base);
2248 #line 452 "timeline.vala"
2249         GTK_WIDGET_CLASS (time_line_parent_class)->expose_event (GTK_WIDGET (GTK_EVENT_BOX (self)), event);
2250 #line 454 "timeline.vala"
2251         xpos = model_time_system_time_to_xpos (self->provider, model_project_transport_get_position (self->project));
2252 #line 455 "timeline.vala"
2253         gdk_draw_line (GDK_DRAWABLE (GTK_WIDGET (self)->window), gtk_widget_get_style (GTK_WIDGET (self))->fg_gc[(gint) GTK_STATE_NORMAL], xpos, 0, xpos, GTK_WIDGET (self)->allocation.height);
2254 #line 2255 "timeline.c"
2255         result = TRUE;
2256 #line 459 "timeline.vala"
2257         return result;
2258 #line 2259 "timeline.c"
2259 }
2260
2261
2262 #line 462 "timeline.vala"
2263 static void time_line_real_drag_data_received (GtkWidget* base, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint drag_info, guint time) {
2264 #line 2265 "timeline.c"
2265         TimeLine * self;
2266         GError * _inner_error_;
2267         char** _tmp1_;
2268         gint _a_size_;
2269         gint a_length1;
2270         char** _tmp0_;
2271         char** a;
2272         ModelTrack* track;
2273         GtkWidget* _tmp2_;
2274         TrackView* track_view;
2275         gboolean timeline_add;
2276         self = TIME_LINE (base);
2277 #line 462 "timeline.vala"
2278         g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
2279 #line 462 "timeline.vala"
2280         g_return_if_fail (selection_data != NULL);
2281 #line 2282 "timeline.c"
2282         _inner_error_ = NULL;
2283 #line 465 "timeline.vala"
2284         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_drag_data_received");
2285 #line 2286 "timeline.c"
2286         a = (_tmp1_ = _tmp0_ = gtk_selection_data_get_uris (selection_data), a_length1 = _vala_array_length (_tmp0_), _a_size_ = a_length1, _tmp1_);
2287 #line 467 "timeline.vala"
2288         gtk_drag_finish (context, TRUE, FALSE, (guint32) time);
2289 #line 469 "timeline.vala"
2290         track = NULL;
2291 #line 470 "timeline.vala"
2292         track_view = (_tmp2_ = time_line_find_child (self, (double) x, (double) y), IS_TRACK_VIEW (_tmp2_) ? ((TrackView*) _tmp2_) : NULL);
2293 #line 472 "timeline.vala"
2294         if (track_view == NULL) {
2295 #line 2296 "timeline.c"
2296                 a = (_vala_array_free (a, a_length1, (GDestroyNotify) g_free), NULL);
2297                 _g_object_unref0 (track);
2298                 _g_object_unref0 (track_view);
2299 #line 473 "timeline.vala"
2300                 return;
2301 #line 2302 "timeline.c"
2302         }
2303 #line 476 "timeline.vala"
2304         timeline_add = TRUE;
2305 #line 478 "timeline.vala"
2306         if (a_length1 > 1) {
2307 #line 479 "timeline.vala"
2308                 if (gtk_drag_get_source_widget (context) != NULL) {
2309 #line 480 "timeline.vala"
2310                         dialog_utils_warning ("Cannot add files", "Files must be dropped onto the timeline individually.");
2311 #line 2312 "timeline.c"
2312                         a = (_vala_array_free (a, a_length1, (GDestroyNotify) g_free), NULL);
2313                         _g_object_unref0 (track);
2314                         _g_object_unref0 (track_view);
2315 #line 482 "timeline.vala"
2316                         return;
2317 #line 2318 "timeline.c"
2318                 }
2319 #line 485 "timeline.vala"
2320                 if (dialog_utils_add_cancel ("Files must be dropped onto the timeline individually.\n" "Do you wish to add these files to the library?") != GTK_RESPONSE_YES) {
2321 #line 2322 "timeline.c"
2322                         a = (_vala_array_free (a, a_length1, (GDestroyNotify) g_free), NULL);
2323                         _g_object_unref0 (track);
2324                         _g_object_unref0 (track_view);
2325 #line 488 "timeline.vala"
2326                         return;
2327 #line 2328 "timeline.c"
2328                 }
2329 #line 490 "timeline.vala"
2330                 timeline_add = FALSE;
2331 #line 2332 "timeline.c"
2332         } else {
2333                 ModelTrack* _tmp3_;
2334 #line 492 "timeline.vala"
2335                 track = (_tmp3_ = track_view_get_track (track_view), _g_object_unref0 (track), _tmp3_);
2336 #line 2337 "timeline.c"
2337         }
2338 #line 495 "timeline.vala"
2339         model_project_create_clip_importer (self->project, track, timeline_add, model_time_system_xpos_to_time (self->provider, x), context->action == GDK_ACTION_COPY, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))), a_length1);
2340 #line 2341 "timeline.c"
2341         {
2342                 {
2343                         char** s_collection;
2344                         int s_collection_length1;
2345                         int s_it;
2346 #line 498 "timeline.vala"
2347                         s_collection = a;
2348 #line 2349 "timeline.c"
2349                         s_collection_length1 = a_length1;
2350                         for (s_it = 0; s_it < a_length1; s_it = s_it + 1) {
2351                                 char* s;
2352                                 s = g_strdup (s_collection[s_it]);
2353                                 {
2354                                         char* filename;
2355                                         filename = NULL;
2356                                         {
2357                                                 char* _tmp4_;
2358                                                 char* _tmp5_;
2359 #line 501 "timeline.vala"
2360                                                 _tmp4_ = g_filename_from_uri (s, NULL, &_inner_error_);
2361 #line 2362 "timeline.c"
2362                                                 if (_inner_error_ != NULL) {
2363                                                         if (_inner_error_->domain == G_CONVERT_ERROR) {
2364                                                                 goto __catch16_g_convert_error;
2365                                                         }
2366                                                         _g_free0 (s);
2367                                                         _g_free0 (filename);
2368                                                         a = (_vala_array_free (a, a_length1, (GDestroyNotify) g_free), NULL);
2369                                                         _g_object_unref0 (track);
2370                                                         _g_object_unref0 (track_view);
2371                                                         g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
2372                                                         g_clear_error (&_inner_error_);
2373                                                         return;
2374                                                 }
2375 #line 501 "timeline.vala"
2376                                                 filename = (_tmp5_ = _tmp4_, _g_free0 (filename), _tmp5_);
2377 #line 2378 "timeline.c"
2378                                         }
2379                                         goto __finally16;
2380                                         __catch16_g_convert_error:
2381                                         {
2382                                                 GError * e;
2383                                                 e = _inner_error_;
2384                                                 _inner_error_ = NULL;
2385                                                 {
2386                                                         _g_error_free0 (e);
2387                                                         _g_free0 (s);
2388                                                         _g_free0 (filename);
2389 #line 502 "timeline.vala"
2390                                                         continue;
2391 #line 2392 "timeline.c"
2392                                                 }
2393                                         }
2394                                         __finally16:
2395                                         if (_inner_error_ != NULL) {
2396                                                 _g_free0 (s);
2397                                                 _g_free0 (filename);
2398                                                 goto __catch15_g_error;
2399                                         }
2400 #line 503 "timeline.vala"
2401                                         model_library_importer_add_file (self->project->importer, filename, &_inner_error_);
2402 #line 2403 "timeline.c"
2403                                         if (_inner_error_ != NULL) {
2404                                                 _g_free0 (s);
2405                                                 _g_free0 (filename);
2406                                                 goto __catch15_g_error;
2407                                         }
2408                                         _g_free0 (s);
2409                                         _g_free0 (filename);
2410                                 }
2411                         }
2412                 }
2413 #line 505 "timeline.vala"
2414                 model_library_importer_start (self->project->importer, &_inner_error_);
2415 #line 2416 "timeline.c"
2416                 if (_inner_error_ != NULL) {
2417                         goto __catch15_g_error;
2418                 }
2419         }
2420         goto __finally15;
2421         __catch15_g_error:
2422         {
2423                 GError * e;
2424                 e = _inner_error_;
2425                 _inner_error_ = NULL;
2426                 {
2427 #line 507 "timeline.vala"
2428                         g_signal_emit_by_name (self->project, "error-occurred", "Error importing", e->message);
2429 #line 2430 "timeline.c"
2430                         _g_error_free0 (e);
2431                 }
2432         }
2433         __finally15:
2434         if (_inner_error_ != NULL) {
2435                 a = (_vala_array_free (a, a_length1, (GDestroyNotify) g_free), NULL);
2436                 _g_object_unref0 (track);
2437                 _g_object_unref0 (track_view);
2438                 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
2439                 g_clear_error (&_inner_error_);
2440                 return;
2441         }
2442         a = (_vala_array_free (a, a_length1, (GDestroyNotify) g_free), NULL);
2443         _g_object_unref0 (track);
2444         _g_object_unref0 (track_view);
2445 }
2446
2447
2448 #line 511 "timeline.vala"
2449 void time_line_update_pos (TimeLine* self, gint event_x) {
2450 #line 2451 "timeline.c"
2451         gint64 time;
2452 #line 511 "timeline.vala"
2453         g_return_if_fail (IS_TIME_LINE (self));
2454 #line 512 "timeline.vala"
2455         time = model_time_system_xpos_to_time (self->provider, event_x);
2456 #line 513 "timeline.vala"
2457         if (self->project->snap_to_clip) {
2458 #line 514 "timeline.vala"
2459                 model_project_snap_coord (self->project, &time, model_time_system_get_pixel_snap_time (self->provider));
2460 #line 2461 "timeline.c"
2461         }
2462 #line 516 "timeline.vala"
2463         view_media_engine_go (self->project->media_engine, time);
2464 #line 2465 "timeline.c"
2465 }
2466
2467
2468 #line 519 "timeline.vala"
2469 GtkWidget* time_line_find_child (TimeLine* self, double x, double y) {
2470 #line 2471 "timeline.c"
2471         GtkWidget* result = NULL;
2472 #line 519 "timeline.vala"
2473         g_return_val_if_fail (IS_TIME_LINE (self), NULL);
2474 #line 2475 "timeline.c"
2475         {
2476                 GList* w_collection;
2477                 GList* w_it;
2478 #line 520 "timeline.vala"
2479                 w_collection = gtk_container_get_children (GTK_CONTAINER (self->priv->vbox));
2480 #line 2481 "timeline.c"
2481                 for (w_it = w_collection; w_it != NULL; w_it = w_it->next) {
2482                         GtkWidget* w;
2483 #line 520 "timeline.vala"
2484                         w = _g_object_ref0 ((GtkWidget*) w_it->data);
2485 #line 2486 "timeline.c"
2486                         {
2487                                 gboolean _tmp0_ = FALSE;
2488 #line 521 "timeline.vala"
2489                                 if (w->allocation.y <= y) {
2490 #line 521 "timeline.vala"
2491                                         _tmp0_ = y < (w->allocation.y + w->allocation.height);
2492 #line 2493 "timeline.c"
2493                                 } else {
2494 #line 521 "timeline.vala"
2495                                         _tmp0_ = FALSE;
2496 #line 2497 "timeline.c"
2497                                 }
2498 #line 521 "timeline.vala"
2499                                 if (_tmp0_) {
2500 #line 2501 "timeline.c"
2501                                         result = w;
2502                                         _g_list_free0 (w_collection);
2503 #line 522 "timeline.vala"
2504                                         return result;
2505 #line 2506 "timeline.c"
2506                                 }
2507                                 _g_object_unref0 (w);
2508                         }
2509                 }
2510 #line 520 "timeline.vala"
2511                 _g_list_free0 (w_collection);
2512 #line 2513 "timeline.c"
2513         }
2514         result = NULL;
2515 #line 524 "timeline.vala"
2516         return result;
2517 #line 2518 "timeline.c"
2518 }
2519
2520
2521 #line 527 "timeline.vala"
2522 static void time_line_deselect_all (TimeLine* self) {
2523 #line 527 "timeline.vala"
2524         g_return_if_fail (IS_TIME_LINE (self));
2525 #line 2526 "timeline.c"
2526         {
2527                 GeeIterator* _clip_view_it;
2528                 _clip_view_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->selected_clips));
2529 #line 528 "timeline.vala"
2530                 while (TRUE) {
2531 #line 2532 "timeline.c"
2532                         ClipView* clip_view;
2533 #line 528 "timeline.vala"
2534                         if (!gee_iterator_next (_clip_view_it)) {
2535 #line 528 "timeline.vala"
2536                                 break;
2537 #line 2538 "timeline.c"
2538                         }
2539 #line 528 "timeline.vala"
2540                         clip_view = (ClipView*) gee_iterator_get (_clip_view_it);
2541 #line 529 "timeline.vala"
2542                         clip_view->is_selected = FALSE;
2543 #line 2544 "timeline.c"
2544                         _g_object_unref0 (clip_view);
2545                 }
2546                 _g_object_unref0 (_clip_view_it);
2547         }
2548 #line 531 "timeline.vala"
2549         gee_abstract_collection_clear (GEE_ABSTRACT_COLLECTION (self->selected_clips));
2550 #line 532 "timeline.vala"
2551         g_signal_emit_by_name (self, "selection-changed", FALSE);
2552 #line 2553 "timeline.c"
2553 }
2554
2555
2556 #line 535 "timeline.vala"
2557 static gboolean time_line_real_button_press_event (GtkWidget* base, GdkEventButton* event) {
2558 #line 2559 "timeline.c"
2559         TimeLine * self;
2560         gboolean result = FALSE;
2561         GtkWidget* _tmp0_;
2562         GtkWidget* child;
2563         self = TIME_LINE (base);
2564 #line 540 "timeline.vala"
2565         self->priv->drag_widget = (_tmp0_ = NULL, _g_object_unref0 (self->priv->drag_widget), _tmp0_);
2566 #line 541 "timeline.vala"
2567         child = time_line_find_child (self, (*event).x, (*event).y);
2568 #line 543 "timeline.vala"
2569         if (VIEW_IS_RULER (child)) {
2570 #line 2571 "timeline.c"
2571                 GtkWidget* _tmp1_;
2572                 ViewRuler* ruler;
2573                 gboolean _tmp2_;
2574                 GtkWidget* _tmp3_;
2575 #line 544 "timeline.vala"
2576                 ruler = _g_object_ref0 ((_tmp1_ = child, VIEW_IS_RULER (_tmp1_) ? ((ViewRuler*) _tmp1_) : NULL));
2577 #line 545 "timeline.vala"
2578                 g_signal_emit_by_name (GTK_WIDGET (ruler), "button-press-event", event, &_tmp2_);
2579 #line 545 "timeline.vala"
2580                 _tmp2_;
2581 #line 546 "timeline.vala"
2582                 self->priv->drag_widget = (_tmp3_ = _g_object_ref0 (child), _g_object_unref0 (self->priv->drag_widget), _tmp3_);
2583 #line 2584 "timeline.c"
2584                 _g_object_unref0 (ruler);
2585         } else {
2586 #line 547 "timeline.vala"
2587                 if (IS_TRACK_VIEW (child)) {
2588 #line 2589 "timeline.c"
2589                         GtkWidget* _tmp4_;
2590                         TrackView* track_view;
2591                         GtkWidget* _tmp5_;
2592 #line 548 "timeline.vala"
2593                         track_view = _g_object_ref0 ((_tmp4_ = child, IS_TRACK_VIEW (_tmp4_) ? ((TrackView*) _tmp4_) : NULL));
2594 #line 550 "timeline.vala"
2595                         self->priv->drag_widget = (_tmp5_ = track_view_find_child (track_view, (*event).x, (*event).y), _g_object_unref0 (self->priv->drag_widget), _tmp5_);
2596 #line 551 "timeline.vala"
2597                         if (self->priv->drag_widget != NULL) {
2598 #line 2599 "timeline.c"
2599                                 gboolean _tmp6_;
2600 #line 552 "timeline.vala"
2601                                 g_signal_emit_by_name (self->priv->drag_widget, "button-press-event", event, &_tmp6_);
2602 #line 552 "timeline.vala"
2603                                 _tmp6_;
2604 #line 2605 "timeline.c"
2605                         } else {
2606                                 ModelTrack* _tmp7_;
2607 #line 554 "timeline.vala"
2608                                 time_line_deselect_all (self);
2609 #line 556 "timeline.vala"
2610                                 model_track_set_selected (_tmp7_ = track_view_get_track (track_view), TRUE);
2611 #line 2612 "timeline.c"
2612                                 _g_object_unref0 (_tmp7_);
2613                         }
2614                         _g_object_unref0 (track_view);
2615                 } else {
2616 #line 559 "timeline.vala"
2617                         time_line_deselect_all (self);
2618 #line 2619 "timeline.c"
2619                 }
2620         }
2621 #line 561 "timeline.vala"
2622         gtk_widget_queue_draw (GTK_WIDGET (self));
2623 #line 2624 "timeline.c"
2624         result = TRUE;
2625         _g_object_unref0 (child);
2626 #line 563 "timeline.vala"
2627         return result;
2628 #line 2629 "timeline.c"
2629 }
2630
2631
2632 #line 566 "timeline.vala"
2633 static gboolean time_line_real_button_release_event (GtkWidget* base, GdkEventButton* event) {
2634 #line 2635 "timeline.c"
2635         TimeLine * self;
2636         gboolean result = FALSE;
2637         self = TIME_LINE (base);
2638 #line 567 "timeline.vala"
2639         if (self->priv->drag_widget != NULL) {
2640 #line 2641 "timeline.c"
2641                 gboolean _tmp0_;
2642                 GtkWidget* _tmp1_;
2643 #line 568 "timeline.vala"
2644                 g_signal_emit_by_name (self->priv->drag_widget, "button-release-event", event, &_tmp0_);
2645 #line 568 "timeline.vala"
2646                 _tmp0_;
2647 #line 569 "timeline.vala"
2648                 self->priv->drag_widget = (_tmp1_ = NULL, _g_object_unref0 (self->priv->drag_widget), _tmp1_);
2649 #line 2650 "timeline.c"
2650         }
2651         result = TRUE;
2652 #line 571 "timeline.vala"
2653         return result;
2654 #line 2655 "timeline.c"
2655 }
2656
2657
2658 #line 574 "timeline.vala"
2659 static gboolean time_line_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) {
2660 #line 2661 "timeline.c"
2661         TimeLine * self;
2662         gboolean result = FALSE;
2663         self = TIME_LINE (base);
2664 #line 575 "timeline.vala"
2665         if (self->priv->drag_widget != NULL) {
2666 #line 2667 "timeline.c"
2667                 gboolean _tmp0_;
2668 #line 576 "timeline.vala"
2669                 g_signal_emit_by_name (self->priv->drag_widget, "motion-notify-event", event, &_tmp0_);
2670 #line 576 "timeline.vala"
2671                 _tmp0_;
2672 #line 2673 "timeline.c"
2673         } else {
2674                 GtkWidget* widget;
2675 #line 578 "timeline.vala"
2676                 widget = time_line_find_child (self, (*event).x, (*event).y);
2677 #line 579 "timeline.vala"
2678                 if (IS_TRACK_VIEW (widget)) {
2679 #line 2680 "timeline.c"
2680                         GtkWidget* _tmp1_;
2681                         TrackView* track_view;
2682 #line 580 "timeline.vala"
2683                         track_view = _g_object_ref0 ((_tmp1_ = widget, IS_TRACK_VIEW (_tmp1_) ? ((TrackView*) _tmp1_) : NULL));
2684 #line 581 "timeline.vala"
2685                         if (track_view != NULL) {
2686 #line 2687 "timeline.c"
2687                                 GtkWidget* _tmp2_;
2688                                 ClipView* clip_view;
2689 #line 582 "timeline.vala"
2690                                 clip_view = (_tmp2_ = track_view_find_child (track_view, (*event).x, (*event).y), IS_CLIP_VIEW (_tmp2_) ? ((ClipView*) _tmp2_) : NULL);
2691 #line 583 "timeline.vala"
2692                                 if (clip_view != NULL) {
2693 #line 2694 "timeline.c"
2694                                         gboolean _tmp3_;
2695 #line 584 "timeline.vala"
2696                                         g_signal_emit_by_name (GTK_WIDGET (clip_view), "motion-notify-event", event, &_tmp3_);
2697 #line 584 "timeline.vala"
2698                                         _tmp3_;
2699 #line 2700 "timeline.c"
2700                                 } else {
2701 #line 586 "timeline.vala"
2702                                         gdk_window_set_cursor (GTK_WIDGET (self)->window, NULL);
2703 #line 2704 "timeline.c"
2704                                 }
2705                                 _g_object_unref0 (clip_view);
2706                         }
2707                         _g_object_unref0 (track_view);
2708                 } else {
2709 #line 589 "timeline.vala"
2710                         if (VIEW_IS_RULER (widget)) {
2711 #line 2712 "timeline.c"
2712                                 gboolean _tmp4_;
2713 #line 590 "timeline.vala"
2714                                 g_signal_emit_by_name (widget, "motion-notify-event", event, &_tmp4_);
2715 #line 590 "timeline.vala"
2716                                 _tmp4_;
2717 #line 2718 "timeline.c"
2718                         } else {
2719 #line 592 "timeline.vala"
2720                                 gdk_window_set_cursor (GTK_WIDGET (self)->window, NULL);
2721 #line 2722 "timeline.c"
2722                         }
2723                 }
2724                 _g_object_unref0 (widget);
2725         }
2726         result = TRUE;
2727 #line 595 "timeline.vala"
2728         return result;
2729 #line 2730 "timeline.c"
2730 }
2731
2732
2733 #line 598 "timeline.vala"
2734 static TrackView* time_line_find_video_track_view (TimeLine* self) {
2735 #line 2736 "timeline.c"
2736         TrackView* result = NULL;
2737 #line 598 "timeline.vala"
2738         g_return_val_if_fail (IS_TIME_LINE (self), NULL);
2739 #line 2740 "timeline.c"
2740         {
2741                 GeeIterator* _track_it;
2742                 _track_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->tracks));
2743 #line 599 "timeline.vala"
2744                 while (TRUE) {
2745 #line 2746 "timeline.c"
2746                         TrackView* track;
2747                         ModelTrack* _tmp0_;
2748                         gboolean _tmp1_;
2749 #line 599 "timeline.vala"
2750                         if (!gee_iterator_next (_track_it)) {
2751 #line 599 "timeline.vala"
2752                                 break;
2753 #line 2754 "timeline.c"
2754                         }
2755 #line 599 "timeline.vala"
2756                         track = (TrackView*) gee_iterator_get (_track_it);
2757 #line 600 "timeline.vala"
2758                         if ((_tmp1_ = model_track_media_type (_tmp0_ = track_view_get_track (track)) == MODEL_MEDIA_TYPE_VIDEO, _g_object_unref0 (_tmp0_), _tmp1_)) {
2759 #line 2760 "timeline.c"
2760                                 result = track;
2761                                 _g_object_unref0 (_track_it);
2762 #line 601 "timeline.vala"
2763                                 return result;
2764 #line 2765 "timeline.c"
2765                         }
2766                         _g_object_unref0 (track);
2767                 }
2768                 _g_object_unref0 (_track_it);
2769         }
2770         result = NULL;
2771 #line 605 "timeline.vala"
2772         return result;
2773 #line 2774 "timeline.c"
2774 }
2775
2776
2777 #line 608 "timeline.vala"
2778 static TrackView* time_line_find_audio_track_view (TimeLine* self) {
2779 #line 2780 "timeline.c"
2780         TrackView* result = NULL;
2781 #line 608 "timeline.vala"
2782         g_return_val_if_fail (IS_TIME_LINE (self), NULL);
2783 #line 2784 "timeline.c"
2784         {
2785                 GeeIterator* _track_it;
2786                 _track_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->tracks));
2787 #line 609 "timeline.vala"
2788                 while (TRUE) {
2789 #line 2790 "timeline.c"
2790                         TrackView* track;
2791                         ModelTrack* _tmp0_;
2792                         gboolean _tmp1_;
2793 #line 609 "timeline.vala"
2794                         if (!gee_iterator_next (_track_it)) {
2795 #line 609 "timeline.vala"
2796                                 break;
2797 #line 2798 "timeline.c"
2798                         }
2799 #line 609 "timeline.vala"
2800                         track = (TrackView*) gee_iterator_get (_track_it);
2801 #line 610 "timeline.vala"
2802                         if ((_tmp1_ = model_track_media_type (_tmp0_ = track_view_get_track (track)) == MODEL_MEDIA_TYPE_AUDIO, _g_object_unref0 (_tmp0_), _tmp1_)) {
2803 #line 2804 "timeline.c"
2804                                 result = track;
2805                                 _g_object_unref0 (_track_it);
2806 #line 611 "timeline.vala"
2807                                 return result;
2808 #line 2809 "timeline.c"
2809                         }
2810                         _g_object_unref0 (track);
2811                 }
2812                 _g_object_unref0 (_track_it);
2813         }
2814         result = NULL;
2815 #line 615 "timeline.vala"
2816         return result;
2817 #line 2818 "timeline.c"
2818 }
2819
2820
2821 static void time_line_class_init (TimeLineClass * klass) {
2822         time_line_parent_class = g_type_class_peek_parent (klass);
2823         g_type_class_add_private (klass, sizeof (TimeLinePrivate));
2824         GTK_WIDGET_CLASS (klass)->expose_event = time_line_real_expose_event;
2825         GTK_WIDGET_CLASS (klass)->drag_data_received = time_line_real_drag_data_received;
2826         GTK_WIDGET_CLASS (klass)->button_press_event = time_line_real_button_press_event;
2827         GTK_WIDGET_CLASS (klass)->button_release_event = time_line_real_button_release_event;
2828         GTK_WIDGET_CLASS (klass)->motion_notify_event = time_line_real_motion_notify_event;
2829         G_OBJECT_CLASS (klass)->finalize = time_line_finalize;
2830         g_signal_new ("selection_changed", TYPE_TIME_LINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
2831         g_signal_new ("track_changed", TYPE_TIME_LINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2832         g_signal_new ("trackview_added", TYPE_TIME_LINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, TYPE_TRACK_VIEW);
2833         g_signal_new ("trackview_removed", TYPE_TIME_LINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, TYPE_TRACK_VIEW);
2834 }
2835
2836
2837 static void time_line_instance_init (TimeLine * self) {
2838         self->priv = TIME_LINE_GET_PRIVATE (self);
2839         self->priv->drag_widget = NULL;
2840         self->tracks = gee_array_list_new (TYPE_TRACK_VIEW, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
2841         self->selected_clips = gee_array_list_new (TYPE_CLIP_VIEW, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
2842         self->clipboard = clipboard_new ();
2843         self->priv->pixel_min = 0.1f;
2844         self->priv->pixel_max = 4505.0f;
2845 }
2846
2847
2848 static void time_line_finalize (GObject* obj) {
2849         TimeLine * self;
2850         self = TIME_LINE (obj);
2851         _g_object_unref0 (self->project);
2852         _g_object_unref0 (self->ruler);
2853         _g_object_unref0 (self->priv->drag_widget);
2854         _g_object_unref0 (self->tracks);
2855         _g_object_unref0 (self->priv->vbox);
2856         _g_object_unref0 (self->selected_clips);
2857         _clipboard_unref0 (self->clipboard);
2858         _g_object_unref0 (self->priv->high_water);
2859         G_OBJECT_CLASS (time_line_parent_class)->finalize (obj);
2860 }
2861
2862
2863 GType time_line_get_type (void) {
2864         static volatile gsize time_line_type_id__volatile = 0;
2865         if (g_once_init_enter (&time_line_type_id__volatile)) {
2866                 static const GTypeInfo g_define_type_info = { sizeof (TimeLineClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) time_line_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TimeLine), 0, (GInstanceInitFunc) time_line_instance_init, NULL };
2867                 GType time_line_type_id;
2868                 time_line_type_id = g_type_register_static (GTK_TYPE_EVENT_BOX, "TimeLine", &g_define_type_info, 0);
2869                 g_once_init_leave (&time_line_type_id__volatile, time_line_type_id);
2870         }
2871         return time_line_type_id__volatile;
2872 }
2873
2874
2875 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
2876         if ((array != NULL) && (destroy_func != NULL)) {
2877                 int i;
2878                 for (i = 0; i < array_length; i = i + 1) {
2879                         if (((gpointer*) array)[i] != NULL) {
2880                                 destroy_func (((gpointer*) array)[i]);
2881                         }
2882                 }
2883         }
2884 }
2885
2886
2887 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
2888         _vala_array_destroy (array, array_length, destroy_func);
2889         g_free (array);
2890 }
2891
2892
2893 static gint _vala_array_length (gpointer array) {
2894         int length;
2895         length = 0;
2896         if (array) {
2897                 while (((gpointer*) array)[length]) {
2898                         length++;
2899                 }
2900         }
2901         return length;
2902 }
2903
2904
2905
2906