Initial commit
[fillmore] / src / lombard / lombard / lombard.c
1 /* lombard.c generated by valac, the Vala compiler
2  * generated from lombard.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 <gtk/gtk.h>
13 #include <marina.h>
14 #include <float.h>
15 #include <math.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <gee.h>
19 #include <gio/gio.h>
20 #include <gdk/gdk.h>
21 #include <gst/gst.h>
22 #include <gdk/gdkkeysyms.h>
23 #include <glib/gstdio.h>
24 #include <stdio.h>
25
26
27 #define TYPE_APP (app_get_type ())
28 #define APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_APP, App))
29 #define APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_APP, AppClass))
30 #define IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_APP))
31 #define IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_APP))
32 #define APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_APP, AppClass))
33
34 typedef struct _App App;
35 typedef struct _AppClass AppClass;
36 typedef struct _AppPrivate AppPrivate;
37
38 #define MODEL_TYPE_VIDEO_PROJECT (model_video_project_get_type ())
39 #define MODEL_VIDEO_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_VIDEO_PROJECT, ModelVideoProject))
40 #define MODEL_VIDEO_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_VIDEO_PROJECT, ModelVideoProjectClass))
41 #define MODEL_IS_VIDEO_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_VIDEO_PROJECT))
42 #define MODEL_IS_VIDEO_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_VIDEO_PROJECT))
43 #define MODEL_VIDEO_PROJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_VIDEO_PROJECT, ModelVideoProjectClass))
44
45 typedef struct _ModelVideoProject ModelVideoProject;
46 typedef struct _ModelVideoProjectClass ModelVideoProjectClass;
47 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
48 #define _g_free0(var) (var = (g_free (var), NULL))
49 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
50 #define _gst_caps_unref0(var) ((var == NULL) ? NULL : (var = (gst_caps_unref (var), NULL)))
51 typedef struct _ModelVideoProjectPrivate ModelVideoProjectPrivate;
52 #define __g_slist_free_g_free0(var) ((var == NULL) ? NULL : (var = (_g_slist_free_g_free (var), NULL)))
53 #define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
54 #define _class_factory_unref0(var) ((var == NULL) ? NULL : (var = (class_factory_unref (var), NULL)))
55
56 struct _App {
57         GtkWindow parent_instance;
58         AppPrivate * priv;
59 };
60
61 struct _AppClass {
62         GtkWindowClass parent_class;
63 };
64
65 struct _AppPrivate {
66         GtkDrawingArea* drawing_area;
67         ModelVideoProject* project;
68         ViewVideoOutput* video_output;
69         ViewAudioOutput* audio_output;
70         ViewOggVorbisExport* export_connector;
71         TimeLine* timeline;
72         ClipLibraryView* library;
73         ViewStatusBar* status_bar;
74         GtkHPaned* h_pane;
75         GtkScrolledWindow* library_scrolled;
76         GtkScrolledWindow* timeline_scrolled;
77         GtkAdjustment* h_adjustment;
78         double prev_adjustment_lower;
79         double prev_adjustment_upper;
80         GtkActionGroup* main_group;
81         gint64 center_time;
82         GtkVBox* vbox;
83         GtkMenuBar* menubar;
84         GtkUIManager* manager;
85         char* project_filename;
86         GeeArrayList* load_errors;
87         gboolean loading;
88 };
89
90 struct _ModelVideoProject {
91         ModelProject parent_instance;
92         ModelVideoProjectPrivate * priv;
93         ModelTimecodeTimeSystem* time_provider;
94 };
95
96 struct _ModelVideoProjectClass {
97         ModelProjectClass parent_class;
98 };
99
100
101 extern gint debug_level;
102 gint debug_level = 0;
103 static gpointer app_parent_class = NULL;
104 static TransportDelegateIface* app_transport_delegate_parent_iface = NULL;
105
106 GType app_get_type (void);
107 GType model_video_project_get_type (void);
108 #define APP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_APP, AppPrivate))
109 enum  {
110         APP_DUMMY_PROPERTY
111 };
112 #define APP_NAME "Lombard"
113 #define APP_LibraryToggle "Library"
114 static void app_on_open (App* self);
115 static void _app_on_open_gtk_action_callback (GtkAction* action, gpointer self);
116 static void app_on_save (App* self);
117 static void _app_on_save_gtk_action_callback (GtkAction* action, gpointer self);
118 static void app_on_save_as (App* self);
119 static void _app_on_save_as_gtk_action_callback (GtkAction* action, gpointer self);
120 static void app_on_play_pause (App* self);
121 static void _app_on_play_pause_gtk_action_callback (GtkAction* action, gpointer self);
122 static void app_on_export (App* self);
123 static void _app_on_export_gtk_action_callback (GtkAction* action, gpointer self);
124 static void app_on_quit (App* self);
125 static void _app_on_quit_gtk_action_callback (GtkAction* action, gpointer self);
126 static void app_on_undo (App* self);
127 static void _app_on_undo_gtk_action_callback (GtkAction* action, gpointer self);
128 static void app_on_cut (App* self);
129 static void _app_on_cut_gtk_action_callback (GtkAction* action, gpointer self);
130 static void app_on_copy (App* self);
131 static void _app_on_copy_gtk_action_callback (GtkAction* action, gpointer self);
132 static void app_on_paste (App* self);
133 static void _app_on_paste_gtk_action_callback (GtkAction* action, gpointer self);
134 static void app_on_delete (App* self);
135 static void _app_on_delete_gtk_action_callback (GtkAction* action, gpointer self);
136 static void app_on_select_all (App* self);
137 static void _app_on_select_all_gtk_action_callback (GtkAction* action, gpointer self);
138 void app_on_split_at_playhead (App* self);
139 static void _app_on_split_at_playhead_gtk_action_callback (GtkAction* action, gpointer self);
140 void app_on_trim_to_playhead (App* self);
141 static void _app_on_trim_to_playhead_gtk_action_callback (GtkAction* action, gpointer self);
142 void app_on_clip_properties (App* self);
143 static void _app_on_clip_properties_gtk_action_callback (GtkAction* action, gpointer self);
144 static void app_on_zoom_in (App* self);
145 static void _app_on_zoom_in_gtk_action_callback (GtkAction* action, gpointer self);
146 static void app_on_zoom_out (App* self);
147 static void _app_on_zoom_out_gtk_action_callback (GtkAction* action, gpointer self);
148 static void app_on_zoom_to_project (App* self);
149 static void _app_on_zoom_to_project_gtk_action_callback (GtkAction* action, gpointer self);
150 static void app_on_go_start (App* self);
151 static void _app_on_go_start_gtk_action_callback (GtkAction* action, gpointer self);
152 static void app_on_go_end (App* self);
153 static void _app_on_go_end_gtk_action_callback (GtkAction* action, gpointer self);
154 static void app_on_help_contents (App* self);
155 static void _app_on_help_contents_gtk_action_callback (GtkAction* action, gpointer self);
156 static void app_on_about (App* self);
157 static void _app_on_about_gtk_action_callback (GtkAction* action, gpointer self);
158 static void app_on_save_graph (App* self);
159 static void _app_on_save_graph_gtk_action_callback (GtkAction* action, gpointer self);
160 static void app_on_view_library (App* self);
161 static void _app_on_view_library_gtk_action_callback (GtkAction* action, gpointer self);
162 static void app_on_snap (App* self);
163 static void _app_on_snap_gtk_action_callback (GtkAction* action, gpointer self);
164 #define APP_ui "\n" \
165 "<ui>\n" \
166 "  <menubar name=\"MenuBar\">\n" \
167 "    <menu name=\"Project\" action=\"Project\">\n" \
168 "      <menuitem name=\"Open\" action=\"Open\"/>\n" \
169 "      <menuitem name=\"Save\" action=\"Save\"/>\n" \
170 "      <menuitem name=\"SaveAs\" action=\"SaveAs\"/>\n" \
171 "      <separator/>\n" \
172 "      <menuitem name=\"Play\" action=\"Play\"/>\n" \
173 "      <separator/>\n" \
174 "      <menuitem name=\"Export\" action=\"Export\"/>\n" \
175 "      <menuitem name=\"Quit\" action=\"Quit\"/>\n" \
176 "    </menu>\n" \
177 "    <menu name=\"EditMenu\" action=\"Edit\">\n" \
178 "      <menuitem name=\"EditUndo\" action=\"Undo\"/>\n" \
179 "      <separator/>\n" \
180 "      <menuitem name=\"EditCut\" action=\"Cut\"/>\n" \
181 "      <menuitem name=\"EditCopy\" action=\"Copy\"/>\n" \
182 "      <menuitem name=\"EditPaste\" action=\"Paste\"/>\n" \
183 "      <menuitem name=\"EditDelete\" action=\"Delete\"/>\n" \
184 "      <separator/>\n" \
185 "      <menuitem name=\"EditSelectAll\" action=\"SelectAll\"/>\n" \
186 "      <separator/>\n" \
187 "      <menuitem name=\"ClipSplitAtPlayhead\" action=\"SplitAtPlayhead\"" \
188 "/>\n" \
189 "      <menuitem name=\"ClipTrimToPlayhead\" action=\"TrimToPlayhead\"/" \
190 ">\n" \
191 "      <separator/>\n" \
192 "      <menuitem name=\"ClipViewProperties\" action=\"ClipProperties\"/" \
193 ">\n" \
194 "    </menu>\n" \
195 "    <menu name=\"ViewMenu\" action=\"View\">\n" \
196 "        <menuitem name=\"ViewLibrary\" action=\"Library\"/>\n" \
197 "        <separator/>\n" \
198 "        <menuitem name=\"ViewZoomIn\" action=\"ZoomIn\"/>\n" \
199 "        <menuitem name=\"ViewZoomOut\" action=\"ZoomOut\"/>\n" \
200 "        <menuitem name=\"ViewZoomProject\" action=\"ZoomProject\"/>\n" \
201 "        <separator/>\n" \
202 "        <menuitem name=\"Snap\" action=\"Snap\"/>\n" \
203 "    </menu>\n" \
204 "    <menu name=\"GoMenu\" action=\"Go\">\n" \
205 "      <menuitem name=\"GoStart\" action=\"Start\"/>\n" \
206 "      <menuitem name=\"GoEnd\" action=\"End\"/>\n" \
207 "    </menu>\n" \
208 "    <menu name=\"HelpMenu\" action=\"Help\">\n" \
209 "      <menuitem name=\"HelpContents\" action=\"Contents\"/>\n" \
210 "      <separator/>\n" \
211 "      <menuitem name=\"HelpAbout\" action=\"About\"/>\n" \
212 "      <menuitem name=\"SaveGraph\" action=\"SaveGraph\"/>\n" \
213 "    </menu>\n" \
214 "  </menubar>\n" \
215 "\n" \
216 "  <popup name=\"ClipContextMenu\">\n" \
217 "    <menuitem name=\"ClipContextCut\" action=\"Cut\"/>\n" \
218 "    <menuitem name=\"ClipContextCopy\" action=\"Copy\"/>\n" \
219 "    <separator/>\n" \
220 "    <menuitem name=\"ClipContextProperties\" action=\"ClipProperties\"" \
221 "/>\n" \
222 "  </popup>\n" \
223 "  <popup name=\"LibraryContextMenu\">\n" \
224 "    <menuitem name=\"ClipContextProperties\" action=\"ClipProperties\"" \
225 "/>\n" \
226 "  </popup>\n" \
227 "</ui>\n"
228 #define APP_SCROLL_MARGIN 0.05f
229 static void app_on_drawing_realize (App* self);
230 static void _app_on_drawing_realize_gtk_widget_realize (GtkWidget* _sender, gpointer self);
231 ModelVideoProject* model_video_project_new (const char* filename, GError** error);
232 ModelVideoProject* model_video_project_construct (GType object_type, const char* filename, GError** error);
233 void app_set_project_name (App* self, const char* filename);
234 static void _app_set_project_name_model_project_name_changed (ModelProject* _sender, const char* project_file, gpointer self);
235 void app_on_load_error (App* self, const char* message);
236 static void _app_on_load_error_model_project_load_error (ModelProject* _sender, const char* _error_, gpointer self);
237 void app_on_load_complete (App* self);
238 static void _app_on_load_complete_model_project_load_complete (ModelProject* _sender, gpointer self);
239 void app_do_error_dialog (const char* message, const char* minor_message);
240 static void _app_do_error_dialog_model_project_error_occurred (ModelProject* _sender, const char* major_message, const char* minor_message, gpointer self);
241 static void app_on_undo_changed (App* self, gboolean can_undo);
242 static void _app_on_undo_changed_model_undo_manager_undo_changed (ModelUndoManager* _sender, gboolean can_undo, gpointer self);
243 static void app_on_post_export (App* self, gboolean canceled);
244 static void _app_on_post_export_view_media_engine_post_export (ViewMediaEngine* _sender, gboolean canceled, gpointer self);
245 static void app_on_playstate_changed (App* self, PlayState playstate);
246 static void _app_on_playstate_changed_model_project_playstate_changed (ModelProject* _sender, PlayState playstate, gpointer self);
247 void app_on_timeline_selection_changed (App* self, gboolean selected);
248 static void _app_on_timeline_selection_changed_time_line_selection_changed (TimeLine* _sender, gboolean selected, gpointer self);
249 void app_on_track_changed (App* self);
250 static void _app_on_track_changed_time_line_track_changed (TimeLine* _sender, gpointer self);
251 static void app_on_drag_data_received (App* self, GtkWidget* w, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint drag_info, guint time);
252 static void _app_on_drag_data_received_gtk_widget_drag_data_received (GtkWidget* _sender, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint info, guint time_, gpointer self);
253 static void app_on_timeline_size_allocate (App* self, GdkRectangle* rectangle);
254 static void _app_on_timeline_size_allocate_gtk_widget_size_allocate (GtkWidget* _sender, GdkRectangle* allocation, gpointer self);
255 void app_on_position_changed (App* self);
256 static void _app_on_position_changed_view_media_engine_position_changed (ViewMediaEngine* _sender, gint64 position, gpointer self);
257 static void app_on_callback_pulse (App* self);
258 static void _app_on_callback_pulse_view_media_engine_callback_pulse (ViewMediaEngine* _sender, gpointer self);
259 void app_on_library_selection_changed (App* self, gboolean selected);
260 static void _app_on_library_selection_changed_clip_library_view_selection_changed (ClipLibraryView* _sender, gboolean selected, gpointer self);
261 static void app_toggle_library (App* self, gboolean showing);
262 static gboolean app_on_delete_event (App* self);
263 static gboolean _app_on_delete_event_gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self);
264 static void app_default_track_set (App* self);
265 static void app_update_menu (App* self);
266 App* app_new (const char* project_file, GError** error);
267 App* app_construct (GType object_type, const char* project_file, GError** error);
268 static gboolean app_do_save (App* self);
269 static void app_on_library_size_allocate (App* self, GdkRectangle* rectangle);
270 static void _app_on_library_size_allocate_gtk_widget_size_allocate (GtkWidget* _sender, GdkRectangle* allocation, gpointer self);
271 static void app_on_adjustment_changed (App* self, GtkAdjustment* a);
272 static void _app_on_adjustment_changed_gtk_adjustment_changed (GtkAdjustment* _sender, gpointer self);
273 void app_load_project (App* self, const char* filename);
274 void app_load_file (App* self, const char* name, ModelLibraryImporter* im);
275 static void _g_slist_free_g_free (GSList* self);
276 static void app_on_importer_started (App* self, ModelClipImporter* i, gint num);
277 static void _app_on_importer_started_model_library_importer_started (ModelLibraryImporter* _sender, ModelClipImporter* i, gint num, gpointer self);
278 static gboolean app_do_save_dialog (App* self);
279 static void app_scroll_toward_center (App* self, gint xpos);
280 gboolean model_video_project_get_framerate_fraction (ModelVideoProject* self, Fraction* rate);
281 static Fraction* _fraction_dup (Fraction* self);
282 static void app_set_sensitive_group (App* self, GtkActionGroup* group, const char* group_path, gboolean sensitive);
283 void model_video_project_go_previous_frame (ModelVideoProject* self);
284 void model_video_project_go_next_frame (ModelVideoProject* self);
285 static gboolean app_real_key_press_event (GtkWidget* base, GdkEventKey* event);
286 static gint64 app_get_zoom_center_time (App* self);
287 static void app_do_zoom (App* self, float increment);
288 static gboolean app_real_is_recording (TransportDelegate* base);
289 static gboolean app_real_is_playing (TransportDelegate* base);
290 static gboolean app_real_is_stopped (TransportDelegate* base);
291 static void app_finalize (GObject* obj);
292 void _vala_main (char** args, int args_length1);
293 static int _vala_strcmp0 (const char * str1, const char * str2);
294
295 const GOptionEntry options[2] = {{"debug-level", (gchar) 0, 0, G_OPTION_ARG_INT, &debug_level, "Control amount of diagnostic information", "[0 (minimal),5 (maximum)]"}, {NULL}};
296 static const GtkActionEntry APP_entries[28] = {{"Project", NULL, "_Project", NULL, NULL, (GCallback) NULL}, {"Open", GTK_STOCK_OPEN, "_Open...", NULL, NULL, (GCallback) _app_on_open_gtk_action_callback}, {"Save", GTK_STOCK_SAVE, NULL, NULL, NULL, (GCallback) _app_on_save_gtk_action_callback}, {"SaveAs", GTK_STOCK_SAVE_AS, "Save _As...", "<Shift><Control>S", NULL, (GCallback) _app_on_save_as_gtk_action_callback}, {"Play", GTK_STOCK_MEDIA_PLAY, "_Play / Pause", "space", NULL, (GCallback) _app_on_play_pause_gtk_action_callback}, {"Export", NULL, "_Export...", "<Control>E", NULL, (GCallback) _app_on_export_gtk_action_callback}, {"Quit", GTK_STOCK_QUIT, NULL, NULL, NULL, (GCallback) _app_on_quit_gtk_action_callback}, {"Edit", NULL, "_Edit", NULL, NULL, (GCallback) NULL}, {"Undo", GTK_STOCK_UNDO, NULL, "<Control>Z", NULL, (GCallback) _app_on_undo_gtk_action_callback}, {"Cut", GTK_STOCK_CUT, NULL, NULL, NULL, (GCallback) _app_on_cut_gtk_action_callback}, {"Copy", GTK_STOCK_COPY, NULL, NULL, NULL, (GCallback) _app_on_copy_gtk_action_callback}, {"Paste", GTK_STOCK_PASTE, NULL, NULL, NULL, (GCallback) _app_on_paste_gtk_action_callback}, {"Delete", GTK_STOCK_DELETE, NULL, "Delete", NULL, (GCallback) _app_on_delete_gtk_action_callback}, {"SelectAll", GTK_STOCK_SELECT_ALL, NULL, "<Control>A", NULL, (GCallback) _app_on_select_all_gtk_action_callback}, {"SplitAtPlayhead", NULL, "_Split at Playhead", "<Control>P", NULL, (GCallback) _app_on_split_at_playhead_gtk_action_callback}, {"TrimToPlayhead", NULL, "Trim to Play_head", "<Control>H", NULL, (GCallback) _app_on_trim_to_playhead_gtk_action_callback}, {"ClipProperties", GTK_STOCK_PROPERTIES, "Properti_es", "<Alt>Return", NULL, (GCallback) _app_on_clip_properties_gtk_action_callback}, {"View", NULL, "_View", NULL, NULL, (GCallback) NULL}, {"ZoomIn", GTK_STOCK_ZOOM_IN, "Zoom _In", "<Control>plus", NULL, (GCallback) _app_on_zoom_in_gtk_action_callback}, {"ZoomOut", GTK_STOCK_ZOOM_OUT, "Zoom _Out", "<Control>minus", NULL, (GCallback) _app_on_zoom_out_gtk_action_callback}, {"ZoomProject", NULL, "Fit to _Window", "<Shift>Z", NULL, (GCallback) _app_on_zoom_to_project_gtk_action_callback}, {"Go", NULL, "_Go", NULL, NULL, (GCallback) NULL}, {"Start", GTK_STOCK_GOTO_FIRST, "_Start", "Home", NULL, (GCallback) _app_on_go_start_gtk_action_callback}, {"End", GTK_STOCK_GOTO_LAST, "_End", "End", NULL, (GCallback) _app_on_go_end_gtk_action_callback}, {"Help", NULL, "_Help", NULL, NULL, (GCallback) NULL}, {"Contents", GTK_STOCK_HELP, "_Contents", "F1", "More information on Lombard", (GCallback) _app_on_help_contents_gtk_action_callback}, {"About", GTK_STOCK_ABOUT, NULL, NULL, NULL, (GCallback) _app_on_about_gtk_action_callback}, {"SaveGraph", NULL, "Save _Graph", NULL, "Save graph", (GCallback) _app_on_save_graph_gtk_action_callback}};
297 static const GtkToggleActionEntry APP_check_actions[2] = {{APP_LibraryToggle, NULL, "_Library", "F9", NULL, (GCallback) _app_on_view_library_gtk_action_callback, TRUE}, {"Snap", NULL, "_Snap to Clip Edges", NULL, NULL, (GCallback) _app_on_snap_gtk_action_callback, TRUE}};
298 static const DialogUtilsfilter_description_struct APP_filters[2] = {{"Lombard Project Files", MODEL_PROJECT_LOMBARD_FILE_EXTENSION}, {"Fillmore Project Files", MODEL_PROJECT_FILLMORE_FILE_EXTENSION}};
299 static const DialogUtilsfilter_description_struct APP_export_filters[1] = {{"Ogg Files", "ogg"}};
300
301
302 #line 445 "lombard.vala"
303 static void _app_on_open_gtk_action_callback (GtkAction* action, gpointer self) {
304 #line 242 "lombard.c"
305         app_on_open (self);
306 }
307
308
309 #line 485 "lombard.vala"
310 static void _app_on_save_gtk_action_callback (GtkAction* action, gpointer self) {
311 #line 249 "lombard.c"
312         app_on_save (self);
313 }
314
315
316 #line 481 "lombard.vala"
317 static void _app_on_save_as_gtk_action_callback (GtkAction* action, gpointer self) {
318 #line 256 "lombard.c"
319         app_on_save_as (self);
320 }
321
322
323 #line 727 "lombard.vala"
324 static void _app_on_play_pause_gtk_action_callback (GtkAction* action, gpointer self) {
325 #line 263 "lombard.c"
326         app_on_play_pause (self);
327 }
328
329
330 #line 739 "lombard.vala"
331 static void _app_on_export_gtk_action_callback (GtkAction* action, gpointer self) {
332 #line 270 "lombard.c"
333         app_on_export (self);
334 }
335
336
337 #line 269 "lombard.vala"
338 static void _app_on_quit_gtk_action_callback (GtkAction* action, gpointer self) {
339 #line 277 "lombard.c"
340         app_on_quit (self);
341 }
342
343
344 #line 770 "lombard.vala"
345 static void _app_on_undo_gtk_action_callback (GtkAction* action, gpointer self) {
346 #line 284 "lombard.c"
347         app_on_undo (self);
348 }
349
350
351 #line 781 "lombard.vala"
352 static void _app_on_cut_gtk_action_callback (GtkAction* action, gpointer self) {
353 #line 291 "lombard.c"
354         app_on_cut (self);
355 }
356
357
358 #line 785 "lombard.vala"
359 static void _app_on_copy_gtk_action_callback (GtkAction* action, gpointer self) {
360 #line 298 "lombard.c"
361         app_on_copy (self);
362 }
363
364
365 #line 789 "lombard.vala"
366 static void _app_on_paste_gtk_action_callback (GtkAction* action, gpointer self) {
367 #line 305 "lombard.c"
368         app_on_paste (self);
369 }
370
371
372 #line 774 "lombard.vala"
373 static void _app_on_delete_gtk_action_callback (GtkAction* action, gpointer self) {
374 #line 312 "lombard.c"
375         app_on_delete (self);
376 }
377
378
379 #line 808 "lombard.vala"
380 static void _app_on_select_all_gtk_action_callback (GtkAction* action, gpointer self) {
381 #line 319 "lombard.c"
382         app_on_select_all (self);
383 }
384
385
386 #line 535 "lombard.vala"
387 static void _app_on_split_at_playhead_gtk_action_callback (GtkAction* action, gpointer self) {
388 #line 326 "lombard.c"
389         app_on_split_at_playhead (self);
390 }
391
392
393 #line 539 "lombard.vala"
394 static void _app_on_trim_to_playhead_gtk_action_callback (GtkAction* action, gpointer self) {
395 #line 333 "lombard.c"
396         app_on_trim_to_playhead (self);
397 }
398
399
400 #line 543 "lombard.vala"
401 static void _app_on_clip_properties_gtk_action_callback (GtkAction* action, gpointer self) {
402 #line 340 "lombard.c"
403         app_on_clip_properties (self);
404 }
405
406
407 #line 699 "lombard.vala"
408 static void _app_on_zoom_in_gtk_action_callback (GtkAction* action, gpointer self) {
409 #line 347 "lombard.c"
410         app_on_zoom_in (self);
411 }
412
413
414 #line 703 "lombard.vala"
415 static void _app_on_zoom_out_gtk_action_callback (GtkAction* action, gpointer self) {
416 #line 354 "lombard.c"
417         app_on_zoom_out (self);
418 }
419
420
421 #line 707 "lombard.vala"
422 static void _app_on_zoom_to_project_gtk_action_callback (GtkAction* action, gpointer self) {
423 #line 361 "lombard.c"
424         app_on_zoom_to_project (self);
425 }
426
427
428 #line 818 "lombard.vala"
429 static void _app_on_go_start_gtk_action_callback (GtkAction* action, gpointer self) {
430 #line 368 "lombard.c"
431         app_on_go_start (self);
432 }
433
434
435 #line 820 "lombard.vala"
436 static void _app_on_go_end_gtk_action_callback (GtkAction* action, gpointer self) {
437 #line 375 "lombard.c"
438         app_on_go_end (self);
439 }
440
441
442 #line 824 "lombard.vala"
443 static void _app_on_help_contents_gtk_action_callback (GtkAction* action, gpointer self) {
444 #line 382 "lombard.c"
445         app_on_help_contents (self);
446 }
447
448
449 #line 831 "lombard.vala"
450 static void _app_on_about_gtk_action_callback (GtkAction* action, gpointer self) {
451 #line 389 "lombard.c"
452         app_on_about (self);
453 }
454
455
456 #line 843 "lombard.vala"
457 static void _app_on_save_graph_gtk_action_callback (GtkAction* action, gpointer self) {
458 #line 396 "lombard.c"
459         app_on_save_graph (self);
460 }
461
462
463 #line 685 "lombard.vala"
464 static void _app_on_view_library_gtk_action_callback (GtkAction* action, gpointer self) {
465 #line 403 "lombard.c"
466         app_on_view_library (self);
467 }
468
469
470 #line 681 "lombard.vala"
471 static void _app_on_snap_gtk_action_callback (GtkAction* action, gpointer self) {
472 #line 410 "lombard.c"
473         app_on_snap (self);
474 }
475
476
477 #line 344 "lombard.vala"
478 static void _app_on_drawing_realize_gtk_widget_realize (GtkWidget* _sender, gpointer self) {
479 #line 417 "lombard.c"
480         app_on_drawing_realize (self);
481 }
482
483
484 #line 371 "lombard.vala"
485 static void _app_set_project_name_model_project_name_changed (ModelProject* _sender, const char* project_file, gpointer self) {
486 #line 424 "lombard.c"
487         app_set_project_name (self, project_file);
488 }
489
490
491 #line 380 "lombard.vala"
492 static void _app_on_load_error_model_project_load_error (ModelProject* _sender, const char* _error_, gpointer self) {
493 #line 431 "lombard.c"
494         app_on_load_error (self, _error_);
495 }
496
497
498 #line 385 "lombard.vala"
499 static void _app_on_load_complete_model_project_load_complete (ModelProject* _sender, gpointer self) {
500 #line 438 "lombard.c"
501         app_on_load_complete (self);
502 }
503
504
505 #line 376 "lombard.vala"
506 static void _app_do_error_dialog_model_project_error_occurred (ModelProject* _sender, const char* major_message, const char* minor_message, gpointer self) {
507 #line 445 "lombard.c"
508         app_do_error_dialog (major_message, minor_message);
509 }
510
511
512 #line 800 "lombard.vala"
513 static void _app_on_undo_changed_model_undo_manager_undo_changed (ModelUndoManager* _sender, gboolean can_undo, gpointer self) {
514 #line 452 "lombard.c"
515         app_on_undo_changed (self, can_undo);
516 }
517
518
519 #line 757 "lombard.vala"
520 static void _app_on_post_export_view_media_engine_post_export (ViewMediaEngine* _sender, gboolean canceled, gpointer self) {
521 #line 459 "lombard.c"
522         app_on_post_export (self, canceled);
523 }
524
525
526 #line 793 "lombard.vala"
527 static void _app_on_playstate_changed_model_project_playstate_changed (ModelProject* _sender, PlayState playstate, gpointer self) {
528 #line 466 "lombard.c"
529         app_on_playstate_changed (self, playstate);
530 }
531
532
533 #line 625 "lombard.vala"
534 static void _app_on_timeline_selection_changed_time_line_selection_changed (TimeLine* _sender, gboolean selected, gpointer self) {
535 #line 473 "lombard.c"
536         app_on_timeline_selection_changed (self, selected);
537 }
538
539
540 #line 575 "lombard.vala"
541 static void _app_on_track_changed_time_line_track_changed (TimeLine* _sender, gpointer self) {
542 #line 480 "lombard.c"
543         app_on_track_changed (self);
544 }
545
546
547 #line 366 "lombard.vala"
548 static void _app_on_drag_data_received_gtk_widget_drag_data_received (GtkWidget* _sender, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint info, guint time_, gpointer self) {
549 #line 487 "lombard.c"
550         app_on_drag_data_received (self, _sender, context, x, y, selection_data, info, time_);
551 }
552
553
554 #line 711 "lombard.vala"
555 static void _app_on_timeline_size_allocate_gtk_widget_size_allocate (GtkWidget* _sender, GdkRectangle* allocation, gpointer self) {
556 #line 494 "lombard.c"
557         app_on_timeline_size_allocate (self, allocation);
558 }
559
560
561 #line 562 "lombard.vala"
562 static void _app_on_position_changed_view_media_engine_position_changed (ViewMediaEngine* _sender, gint64 position, gpointer self) {
563 #line 501 "lombard.c"
564         app_on_position_changed (self);
565 }
566
567
568 #line 567 "lombard.vala"
569 static void _app_on_callback_pulse_view_media_engine_callback_pulse (ViewMediaEngine* _sender, gpointer self) {
570 #line 508 "lombard.c"
571         app_on_callback_pulse (self);
572 }
573
574
575 static gpointer _g_object_ref0 (gpointer self) {
576         return self ? g_object_ref (self) : NULL;
577 }
578
579
580 #line 632 "lombard.vala"
581 static void _app_on_library_selection_changed_clip_library_view_selection_changed (ClipLibraryView* _sender, gboolean selected, gpointer self) {
582 #line 520 "lombard.c"
583         app_on_library_selection_changed (self, selected);
584 }
585
586
587 #line 263 "lombard.vala"
588 static gboolean _app_on_delete_event_gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self) {
589 #line 527 "lombard.c"
590         gboolean result;
591         result = app_on_delete_event (self);
592         return result;
593 }
594
595
596 #line 165 "lombard.vala"
597 App* app_construct (GType object_type, const char* project_file, GError** error) {
598 #line 536 "lombard.c"
599         GError * _inner_error_;
600         App * self;
601         char* _tmp3_;
602         GeeArrayList* _tmp4_;
603         GtkDrawingArea* _tmp5_;
604         GdkColor _tmp7_;
605         GdkColor _tmp6_ = {0};
606         GtkActionGroup* _tmp8_;
607         GtkUIManager* _tmp9_;
608         GtkMenuBar* _tmp10_;
609         ModelVideoProject* _tmp11_;
610         ModelVideoProject* _tmp12_;
611         GstCaps* _tmp13_;
612         ViewAudioOutput* _tmp14_;
613         ViewAudioOutput* _tmp15_;
614         ViewAudioOutput* _tmp16_;
615         TimeLine* _tmp17_;
616         GtkMenu* _tmp18_;
617         GtkMenu* _tmp19_;
618         ClipLibraryView* _tmp20_;
619         ViewStatusBar* _tmp21_;
620         GtkScrolledWindow* _tmp22_;
621         GtkMenuItem* save_graph;
622         _inner_error_ = NULL;
623         self = g_object_newv (object_type, 0, NULL);
624         {
625                 char* _tmp2_;
626                 GFile* _tmp1_;
627                 GFile* _tmp0_;
628 #line 167 "lombard.vala"
629                 gtk_window_set_icon_from_file (GTK_WINDOW (self), _tmp2_ = g_file_get_path (_tmp1_ = g_file_get_child (_tmp0_ = app_dirs_get_resources_dir (), "lombard_icon.png")), &_inner_error_);
630 #line 568 "lombard.c"
631                 _g_free0 (_tmp2_);
632                 _g_object_unref0 (_tmp1_);
633                 _g_object_unref0 (_tmp0_);
634                 if (_inner_error_ != NULL) {
635                         goto __catch0_g_error;
636                 }
637         }
638         goto __finally0;
639         __catch0_g_error:
640         {
641                 GError * e;
642                 e = _inner_error_;
643                 _inner_error_ = NULL;
644                 {
645 #line 170 "lombard.vala"
646                         g_warning ("lombard.vala:170: Could not load application icon: %s", e->message);
647 #line 585 "lombard.c"
648                         _g_error_free0 (e);
649                 }
650         }
651         __finally0:
652         if (_inner_error_ != NULL) {
653                 g_propagate_error (error, _inner_error_);
654                 g_object_unref (self);
655                 return NULL;
656         }
657 #line 173 "lombard.vala"
658         if (debug_level > (-1)) {
659 #line 174 "lombard.vala"
660                 logging_set_logging_level ((LoggingLevel) debug_level);
661 #line 599 "lombard.c"
662         }
663 #line 176 "lombard.vala"
664         class_factory_set_transport_delegate (TRANSPORT_DELEGATE (self));
665 #line 177 "lombard.vala"
666         gtk_window_set_default_size (GTK_WINDOW (self), 600, 500);
667 #line 178 "lombard.vala"
668         self->priv->project_filename = (_tmp3_ = g_strdup (project_file), _g_free0 (self->priv->project_filename), _tmp3_);
669 #line 180 "lombard.vala"
670         self->priv->load_errors = (_tmp4_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL), _g_object_unref0 (self->priv->load_errors), _tmp4_);
671 #line 181 "lombard.vala"
672         self->priv->drawing_area = (_tmp5_ = g_object_ref_sink ((GtkDrawingArea*) gtk_drawing_area_new ()), _g_object_unref0 (self->priv->drawing_area), _tmp5_);
673 #line 182 "lombard.vala"
674         g_signal_connect_object (GTK_WIDGET (self->priv->drawing_area), "realize", (GCallback) _app_on_drawing_realize_gtk_widget_realize, self, 0);
675 #line 183 "lombard.vala"
676         gtk_widget_modify_bg (GTK_WIDGET (self->priv->drawing_area), GTK_STATE_NORMAL, (_tmp7_ = (parse_color ("#000", &_tmp6_), _tmp6_), &_tmp7_));
677 #line 185 "lombard.vala"
678         self->priv->main_group = (_tmp8_ = gtk_action_group_new ("main"), _g_object_unref0 (self->priv->main_group), _tmp8_);
679 #line 186 "lombard.vala"
680         gtk_action_group_add_actions (self->priv->main_group, APP_entries, G_N_ELEMENTS (APP_entries), self);
681 #line 187 "lombard.vala"
682         gtk_action_group_add_toggle_actions (self->priv->main_group, APP_check_actions, G_N_ELEMENTS (APP_check_actions), self);
683 #line 189 "lombard.vala"
684         self->priv->manager = (_tmp9_ = gtk_ui_manager_new (), _g_object_unref0 (self->priv->manager), _tmp9_);
685 #line 190 "lombard.vala"
686         gtk_ui_manager_insert_action_group (self->priv->manager, self->priv->main_group, 0);
687 #line 625 "lombard.c"
688         {
689 #line 192 "lombard.vala"
690                 gtk_ui_manager_add_ui_from_string (self->priv->manager, APP_ui, (gssize) (-1), &_inner_error_);
691 #line 629 "lombard.c"
692                 if (_inner_error_ != NULL) {
693                         goto __catch1_g_error;
694                 }
695         }
696         goto __finally1;
697         __catch1_g_error:
698         {
699                 GError * e;
700                 e = _inner_error_;
701                 _inner_error_ = NULL;
702                 {
703 #line 193 "lombard.vala"
704                         g_error ("lombard.vala:193: %s", e->message);
705 #line 643 "lombard.c"
706                         _g_error_free0 (e);
707                 }
708         }
709         __finally1:
710         if (_inner_error_ != NULL) {
711                 g_propagate_error (error, _inner_error_);
712                 g_object_unref (self);
713                 return NULL;
714         }
715 #line 195 "lombard.vala"
716         self->priv->menubar = (_tmp10_ = GTK_MENU_BAR (get_widget (self->priv->manager, "/MenuBar")), _g_object_unref0 (self->priv->menubar), _tmp10_);
717 #line 197 "lombard.vala"
718         _tmp11_ = model_video_project_new (self->priv->project_filename, &_inner_error_);
719 #line 657 "lombard.c"
720         if (_inner_error_ != NULL) {
721                 g_propagate_error (error, _inner_error_);
722                 g_object_unref (self);
723                 return NULL;
724         }
725 #line 197 "lombard.vala"
726         self->priv->project = (_tmp12_ = _tmp11_, _g_object_unref0 (self->priv->project), _tmp12_);
727 #line 198 "lombard.vala"
728         MODEL_PROJECT (self->priv->project)->snap_to_clip = TRUE;
729 #line 199 "lombard.vala"
730         g_signal_connect_object (MODEL_PROJECT (self->priv->project), "name-changed", (GCallback) _app_set_project_name_model_project_name_changed, self, 0);
731 #line 200 "lombard.vala"
732         g_signal_connect_object (MODEL_PROJECT (self->priv->project), "load-error", (GCallback) _app_on_load_error_model_project_load_error, self, 0);
733 #line 201 "lombard.vala"
734         g_signal_connect_object (MODEL_PROJECT (self->priv->project), "load-complete", (GCallback) _app_on_load_complete_model_project_load_complete, self, 0);
735 #line 202 "lombard.vala"
736         g_signal_connect (MODEL_PROJECT (self->priv->project), "error-occurred", (GCallback) _app_do_error_dialog_model_project_error_occurred, NULL);
737 #line 203 "lombard.vala"
738         g_signal_connect_object (MODEL_PROJECT (self->priv->project)->undo_manager, "undo-changed", (GCallback) _app_on_undo_changed_model_undo_manager_undo_changed, self, 0);
739 #line 204 "lombard.vala"
740         g_signal_connect_object (MODEL_PROJECT (self->priv->project)->media_engine, "post-export", (GCallback) _app_on_post_export_view_media_engine_post_export, self, 0);
741 #line 205 "lombard.vala"
742         g_signal_connect_object (MODEL_PROJECT (self->priv->project), "playstate-changed", (GCallback) _app_on_playstate_changed_model_project_playstate_changed, self, 0);
743 #line 207 "lombard.vala"
744         _tmp15_ = (_tmp14_ = view_audio_output_new (_tmp13_ = view_media_engine_get_project_audio_caps (MODEL_PROJECT (self->priv->project)->media_engine), &_inner_error_), _gst_caps_unref0 (_tmp13_), _tmp14_);
745 #line 683 "lombard.c"
746         if (_inner_error_ != NULL) {
747                 g_propagate_error (error, _inner_error_);
748                 g_object_unref (self);
749                 return NULL;
750         }
751 #line 207 "lombard.vala"
752         self->priv->audio_output = (_tmp16_ = _tmp15_, _g_object_unref0 (self->priv->audio_output), _tmp16_);
753 #line 208 "lombard.vala"
754         view_media_engine_connect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->audio_output));
755 #line 210 "lombard.vala"
756         self->priv->timeline = (_tmp17_ = g_object_ref_sink (time_line_new (MODEL_PROJECT (self->priv->project), MODEL_TIME_SYSTEM (self->priv->project->time_provider), GDK_ACTION_COPY | GDK_ACTION_MOVE)), _g_object_unref0 (self->priv->timeline), _tmp17_);
757 #line 212 "lombard.vala"
758         g_signal_connect_object (self->priv->timeline, "selection-changed", (GCallback) _app_on_timeline_selection_changed_time_line_selection_changed, self, 0);
759 #line 213 "lombard.vala"
760         g_signal_connect_object (self->priv->timeline, "track-changed", (GCallback) _app_on_track_changed_time_line_track_changed, self, 0);
761 #line 214 "lombard.vala"
762         g_signal_connect_object (GTK_WIDGET (self->priv->timeline), "drag-data-received", (GCallback) _app_on_drag_data_received_gtk_widget_drag_data_received, self, 0);
763 #line 215 "lombard.vala"
764         g_signal_connect_object (GTK_WIDGET (self->priv->timeline), "size-allocate", (GCallback) _app_on_timeline_size_allocate_gtk_widget_size_allocate, self, 0);
765 #line 216 "lombard.vala"
766         g_signal_connect_object (MODEL_PROJECT (self->priv->project)->media_engine, "position-changed", (GCallback) _app_on_position_changed_view_media_engine_position_changed, self, 0);
767 #line 217 "lombard.vala"
768         g_signal_connect_object (MODEL_PROJECT (self->priv->project)->media_engine, "callback-pulse", (GCallback) _app_on_callback_pulse_view_media_engine_callback_pulse, self, 0);
769 #line 218 "lombard.vala"
770         clip_view_context_menu = (_tmp18_ = _g_object_ref0 (GTK_MENU (gtk_ui_manager_get_widget (self->priv->manager, "/ClipContextMenu"))), _g_object_unref0 (clip_view_context_menu), _tmp18_);
771 #line 219 "lombard.vala"
772         clip_library_view_context_menu = (_tmp19_ = _g_object_ref0 (GTK_MENU (gtk_ui_manager_get_widget (self->priv->manager, "/LibraryContextMenu"))), _g_object_unref0 (clip_library_view_context_menu), _tmp19_);
773 #line 221 "lombard.vala"
774         self->priv->library = (_tmp20_ = g_object_ref_sink (clip_library_view_new (MODEL_PROJECT (self->priv->project), MODEL_TIME_SYSTEM (self->priv->project->time_provider), "Drag clips here.", GDK_ACTION_COPY | GDK_ACTION_MOVE)), _g_object_unref0 (self->priv->library), _tmp20_);
775 #line 223 "lombard.vala"
776         g_signal_connect_object (self->priv->library, "selection-changed", (GCallback) _app_on_library_selection_changed_clip_library_view_selection_changed, self, 0);
777 #line 224 "lombard.vala"
778         g_signal_connect_object (GTK_WIDGET (self->priv->library), "drag-data-received", (GCallback) _app_on_drag_data_received_gtk_widget_drag_data_received, self, 0);
779 #line 226 "lombard.vala"
780         self->priv->status_bar = (_tmp21_ = g_object_ref_sink (view_status_bar_new (MODEL_PROJECT (self->priv->project), MODEL_TIME_SYSTEM (self->priv->project->time_provider), TIME_LINE_BAR_HEIGHT)), _g_object_unref0 (self->priv->status_bar), _tmp21_);
781 #line 228 "lombard.vala"
782         self->priv->library_scrolled = (_tmp22_ = g_object_ref_sink ((GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL)), _g_object_unref0 (self->priv->library_scrolled), _tmp22_);
783 #line 229 "lombard.vala"
784         gtk_scrolled_window_set_policy (self->priv->library_scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
785 #line 230 "lombard.vala"
786         gtk_scrolled_window_add_with_viewport (self->priv->library_scrolled, GTK_WIDGET (self->priv->library));
787 #line 232 "lombard.vala"
788         app_toggle_library (self, TRUE);
789 #line 234 "lombard.vala"
790         save_graph = GTK_MENU_ITEM (get_widget (self->priv->manager, "/MenuBar/HelpMenu/SaveGraph"));
791 #line 239 "lombard.vala"
792         if (save_graph != NULL) {
793 #line 240 "lombard.vala"
794                 gtk_object_destroy (GTK_OBJECT (save_graph));
795 #line 733 "lombard.c"
796         }
797 #line 243 "lombard.vala"
798         gtk_window_add_accel_group (GTK_WINDOW (self), gtk_ui_manager_get_accel_group (self->priv->manager));
799 #line 245 "lombard.vala"
800         app_on_undo_changed (self, FALSE);
801 #line 247 "lombard.vala"
802         g_signal_connect_object (GTK_WIDGET (self), "delete-event", (GCallback) _app_on_delete_event_gtk_widget_delete_event, self, 0);
803 #line 249 "lombard.vala"
804         if (self->priv->project_filename == NULL) {
805 #line 250 "lombard.vala"
806                 app_default_track_set (self);
807 #line 251 "lombard.vala"
808                 app_on_load_complete (self);
809 #line 747 "lombard.c"
810         }
811 #line 254 "lombard.vala"
812         app_update_menu (self);
813 #line 255 "lombard.vala"
814         gtk_widget_show_all (GTK_WIDGET (self));
815 #line 753 "lombard.c"
816         _g_object_unref0 (save_graph);
817         return self;
818 }
819
820
821 #line 165 "lombard.vala"
822 App* app_new (const char* project_file, GError** error) {
823 #line 165 "lombard.vala"
824         return app_construct (TYPE_APP, project_file, error);
825 #line 763 "lombard.c"
826 }
827
828
829 #line 258 "lombard.vala"
830 static void app_default_track_set (App* self) {
831 #line 769 "lombard.c"
832         ModelVideoTrack* _tmp0_;
833         ModelAudioTrack* _tmp1_;
834 #line 258 "lombard.vala"
835         g_return_if_fail (IS_APP (self));
836 #line 259 "lombard.vala"
837         model_project_add_track (MODEL_PROJECT (self->priv->project), MODEL_TRACK (_tmp0_ = model_video_track_new (MODEL_PROJECT (self->priv->project))));
838 #line 776 "lombard.c"
839         _g_object_unref0 (_tmp0_);
840 #line 260 "lombard.vala"
841         model_project_add_track (MODEL_PROJECT (self->priv->project), MODEL_TRACK (_tmp1_ = model_audio_track_new (MODEL_PROJECT (self->priv->project), "Audio Track")));
842 #line 780 "lombard.c"
843         _g_object_unref0 (_tmp1_);
844 }
845
846
847 #line 263 "lombard.vala"
848 static gboolean app_on_delete_event (App* self) {
849 #line 787 "lombard.c"
850         gboolean result = FALSE;
851 #line 263 "lombard.vala"
852         g_return_val_if_fail (IS_APP (self), FALSE);
853 #line 264 "lombard.vala"
854         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_delete_event");
855 #line 265 "lombard.vala"
856         app_on_quit (self);
857 #line 795 "lombard.c"
858         result = TRUE;
859 #line 266 "lombard.vala"
860         return result;
861 #line 799 "lombard.c"
862 }
863
864
865 #line 269 "lombard.vala"
866 static void app_on_quit (App* self) {
867 #line 269 "lombard.vala"
868         g_return_if_fail (IS_APP (self));
869 #line 270 "lombard.vala"
870         if (model_undo_manager_get_is_dirty (MODEL_PROJECT (self->priv->project)->undo_manager)) {
871 #line 271 "lombard.vala"
872                 switch (dialog_utils_save_close_cancel (GTK_WINDOW (self), NULL, "Save changes before closing?")) {
873 #line 811 "lombard.c"
874                         case GTK_RESPONSE_ACCEPT:
875                         {
876 #line 273 "lombard.vala"
877                                 if (!app_do_save (self)) {
878 #line 274 "lombard.vala"
879                                         return;
880 #line 818 "lombard.c"
881                                 }
882 #line 276 "lombard.vala"
883                                 break;
884 #line 822 "lombard.c"
885                         }
886                         case GTK_RESPONSE_CLOSE:
887                         {
888 #line 278 "lombard.vala"
889                                 break;
890 #line 828 "lombard.c"
891                         }
892                         case GTK_RESPONSE_DELETE_EVENT:
893                         case GTK_RESPONSE_CANCEL:
894                         {
895 #line 281 "lombard.vala"
896                                 return;
897 #line 835 "lombard.c"
898                         }
899                         default:
900                         {
901 #line 283 "lombard.vala"
902                                 g_assert (FALSE);
903 #line 284 "lombard.vala"
904                                 break;
905 #line 843 "lombard.c"
906                         }
907                 }
908         }
909 #line 288 "lombard.vala"
910         gtk_main_quit ();
911 #line 849 "lombard.c"
912 }
913
914
915 #line 424 "lombard.vala"
916 static void _app_on_library_size_allocate_gtk_widget_size_allocate (GtkWidget* _sender, GdkRectangle* allocation, gpointer self) {
917 #line 855 "lombard.c"
918         app_on_library_size_allocate (self, allocation);
919 }
920
921
922 #line 356 "lombard.vala"
923 static void _app_on_adjustment_changed_gtk_adjustment_changed (GtkAdjustment* _sender, gpointer self) {
924 #line 862 "lombard.c"
925         app_on_adjustment_changed (self, _sender);
926 }
927
928
929 #line 291 "lombard.vala"
930 static void app_toggle_library (App* self, gboolean showing) {
931 #line 291 "lombard.vala"
932         g_return_if_fail (IS_APP (self));
933 #line 292 "lombard.vala"
934         if (self->priv->vbox == NULL) {
935 #line 873 "lombard.c"
936                 GtkVBox* _tmp0_;
937                 GtkVPaned* v_pane;
938                 GtkHPaned* _tmp1_;
939                 GtkScrolledWindow* _tmp2_;
940                 GtkVBox* timeline_vbox;
941                 GtkAdjustment* _tmp3_;
942 #line 293 "lombard.vala"
943                 self->priv->vbox = (_tmp0_ = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 0)), _g_object_unref0 (self->priv->vbox), _tmp0_);
944 #line 294 "lombard.vala"
945                 gtk_box_pack_start (GTK_BOX (self->priv->vbox), GTK_WIDGET (self->priv->menubar), FALSE, FALSE, (guint) 0);
946 #line 296 "lombard.vala"
947                 v_pane = g_object_ref_sink ((GtkVPaned*) gtk_vpaned_new ());
948 #line 297 "lombard.vala"
949                 gtk_paned_set_position (GTK_PANED (v_pane), 290);
950 #line 299 "lombard.vala"
951                 self->priv->h_pane = (_tmp1_ = g_object_ref_sink ((GtkHPaned*) gtk_hpaned_new ()), _g_object_unref0 (self->priv->h_pane), _tmp1_);
952 #line 300 "lombard.vala"
953                 gtk_paned_set_position (GTK_PANED (self->priv->h_pane), 300);
954 #line 301 "lombard.vala"
955                 GTK_PANED (self->priv->h_pane)->child2_resize = (guint) 1;
956 #line 302 "lombard.vala"
957                 GTK_PANED (self->priv->h_pane)->child1_resize = (guint) 0;
958 #line 304 "lombard.vala"
959                 if (showing) {
960 #line 305 "lombard.vala"
961                         gtk_paned_add1 (GTK_PANED (self->priv->h_pane), GTK_WIDGET (self->priv->library_scrolled));
962 #line 306 "lombard.vala"
963                         gtk_paned_add2 (GTK_PANED (self->priv->h_pane), GTK_WIDGET (self->priv->drawing_area));
964 #line 902 "lombard.c"
965                 } else {
966 #line 308 "lombard.vala"
967                         gtk_paned_add2 (GTK_PANED (self->priv->h_pane), GTK_WIDGET (self->priv->drawing_area));
968 #line 906 "lombard.c"
969                 }
970 #line 310 "lombard.vala"
971                 g_signal_connect_object (GTK_PANED (self->priv->h_pane)->child2, "size-allocate", (GCallback) _app_on_library_size_allocate_gtk_widget_size_allocate, self, 0);
972 #line 311 "lombard.vala"
973                 gtk_paned_add1 (GTK_PANED (v_pane), GTK_WIDGET (self->priv->h_pane));
974 #line 313 "lombard.vala"
975                 self->priv->timeline_scrolled = (_tmp2_ = g_object_ref_sink ((GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL)), _g_object_unref0 (self->priv->timeline_scrolled), _tmp2_);
976 #line 314 "lombard.vala"
977                 gtk_scrolled_window_set_policy (self->priv->timeline_scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
978 #line 315 "lombard.vala"
979                 gtk_scrolled_window_add_with_viewport (self->priv->timeline_scrolled, GTK_WIDGET (self->priv->timeline));
980 #line 317 "lombard.vala"
981                 timeline_vbox = g_object_ref_sink ((GtkVBox*) gtk_vbox_new (FALSE, 0));
982 #line 318 "lombard.vala"
983                 gtk_box_pack_start (GTK_BOX (timeline_vbox), GTK_WIDGET (self->priv->status_bar), FALSE, FALSE, (guint) 0);
984 #line 319 "lombard.vala"
985                 gtk_box_pack_start (GTK_BOX (timeline_vbox), GTK_WIDGET (self->priv->timeline_scrolled), TRUE, TRUE, (guint) 0);
986 #line 320 "lombard.vala"
987                 gtk_paned_add2 (GTK_PANED (v_pane), GTK_WIDGET (timeline_vbox));
988 #line 322 "lombard.vala"
989                 GTK_PANED (v_pane)->child1_resize = (guint) 1;
990 #line 323 "lombard.vala"
991                 GTK_PANED (v_pane)->child2_resize = (guint) 0;
992 #line 325 "lombard.vala"
993                 self->priv->h_adjustment = (_tmp3_ = _g_object_ref0 (gtk_scrolled_window_get_hadjustment (self->priv->timeline_scrolled)), _g_object_unref0 (self->priv->h_adjustment), _tmp3_);
994 #line 326 "lombard.vala"
995                 g_signal_connect_object (self->priv->h_adjustment, "changed", (GCallback) _app_on_adjustment_changed_gtk_adjustment_changed, self, 0);
996 #line 327 "lombard.vala"
997                 self->priv->prev_adjustment_lower = gtk_adjustment_get_lower (self->priv->h_adjustment);
998 #line 328 "lombard.vala"
999                 self->priv->prev_adjustment_upper = gtk_adjustment_get_upper (self->priv->h_adjustment);
1000 #line 330 "lombard.vala"
1001                 gtk_box_pack_start (GTK_BOX (self->priv->vbox), GTK_WIDGET (v_pane), TRUE, TRUE, (guint) 0);
1002 #line 332 "lombard.vala"
1003                 gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->priv->vbox));
1004 #line 942 "lombard.c"
1005                 _g_object_unref0 (v_pane);
1006                 _g_object_unref0 (timeline_vbox);
1007         } else {
1008 #line 334 "lombard.vala"
1009                 MODEL_PROJECT (self->priv->project)->library_visible = showing;
1010 #line 335 "lombard.vala"
1011                 if (showing) {
1012 #line 336 "lombard.vala"
1013                         gtk_paned_add1 (GTK_PANED (self->priv->h_pane), GTK_WIDGET (self->priv->library_scrolled));
1014 #line 952 "lombard.c"
1015                 } else {
1016 #line 338 "lombard.vala"
1017                         gtk_container_remove (GTK_CONTAINER (self->priv->h_pane), GTK_WIDGET (self->priv->library_scrolled));
1018 #line 956 "lombard.c"
1019                 }
1020         }
1021 #line 341 "lombard.vala"
1022         gtk_widget_show_all (GTK_WIDGET (self));
1023 #line 961 "lombard.c"
1024 }
1025
1026
1027 #line 344 "lombard.vala"
1028 static void app_on_drawing_realize (App* self) {
1029 #line 967 "lombard.c"
1030         GError * _inner_error_;
1031 #line 344 "lombard.vala"
1032         g_return_if_fail (IS_APP (self));
1033 #line 971 "lombard.c"
1034         _inner_error_ = NULL;
1035 #line 345 "lombard.vala"
1036         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_drawing_realize");
1037 #line 346 "lombard.vala"
1038         self->priv->loading = TRUE;
1039 #line 347 "lombard.vala"
1040         model_project_load (MODEL_PROJECT (self->priv->project), self->priv->project_filename);
1041 #line 979 "lombard.c"
1042         {
1043                 ViewVideoOutput* _tmp0_;
1044                 ViewVideoOutput* _tmp1_;
1045 #line 349 "lombard.vala"
1046                 _tmp0_ = view_video_output_new (GTK_WIDGET (self->priv->drawing_area), &_inner_error_);
1047 #line 985 "lombard.c"
1048                 if (_inner_error_ != NULL) {
1049                         goto __catch2_g_error;
1050                 }
1051 #line 349 "lombard.vala"
1052                 self->priv->video_output = (_tmp1_ = _tmp0_, _g_object_unref0 (self->priv->video_output), _tmp1_);
1053 #line 350 "lombard.vala"
1054                 view_media_engine_connect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->video_output));
1055 #line 993 "lombard.c"
1056         }
1057         goto __finally2;
1058         __catch2_g_error:
1059         {
1060                 GError * e;
1061                 e = _inner_error_;
1062                 _inner_error_ = NULL;
1063                 {
1064 #line 352 "lombard.vala"
1065                         app_do_error_dialog ("Could not create video output", e->message);
1066 #line 1004 "lombard.c"
1067                         _g_error_free0 (e);
1068                 }
1069         }
1070         __finally2:
1071         if (_inner_error_ != NULL) {
1072                 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);
1073                 g_clear_error (&_inner_error_);
1074                 return;
1075         }
1076 }
1077
1078
1079 #line 356 "lombard.vala"
1080 static void app_on_adjustment_changed (App* self, GtkAdjustment* a) {
1081 #line 1019 "lombard.c"
1082         gboolean _tmp0_ = FALSE;
1083 #line 356 "lombard.vala"
1084         g_return_if_fail (IS_APP (self));
1085 #line 356 "lombard.vala"
1086         g_return_if_fail (GTK_IS_ADJUSTMENT (a));
1087 #line 357 "lombard.vala"
1088         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_adjustment_changed");
1089 #line 358 "lombard.vala"
1090         if (self->priv->prev_adjustment_upper != gtk_adjustment_get_upper (a)) {
1091 #line 358 "lombard.vala"
1092                 _tmp0_ = TRUE;
1093 #line 1031 "lombard.c"
1094         } else {
1095 #line 359 "lombard.vala"
1096                 _tmp0_ = self->priv->prev_adjustment_lower != gtk_adjustment_get_lower (a);
1097 #line 1035 "lombard.c"
1098         }
1099 #line 358 "lombard.vala"
1100         if (_tmp0_) {
1101 #line 361 "lombard.vala"
1102                 self->priv->prev_adjustment_lower = gtk_adjustment_get_lower (a);
1103 #line 362 "lombard.vala"
1104                 self->priv->prev_adjustment_upper = gtk_adjustment_get_upper (a);
1105 #line 1043 "lombard.c"
1106         }
1107 }
1108
1109
1110 #line 366 "lombard.vala"
1111 static void app_on_drag_data_received (App* self, GtkWidget* w, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint drag_info, guint time) {
1112 #line 366 "lombard.vala"
1113         g_return_if_fail (IS_APP (self));
1114 #line 366 "lombard.vala"
1115         g_return_if_fail (GTK_IS_WIDGET (w));
1116 #line 366 "lombard.vala"
1117         g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
1118 #line 366 "lombard.vala"
1119         g_return_if_fail (selection_data != NULL);
1120 #line 368 "lombard.vala"
1121         gtk_window_present (GTK_WINDOW (self));
1122 #line 1060 "lombard.c"
1123 }
1124
1125
1126 #line 371 "lombard.vala"
1127 void app_set_project_name (App* self, const char* filename) {
1128 #line 1066 "lombard.c"
1129         char* _tmp0_;
1130 #line 371 "lombard.vala"
1131         g_return_if_fail (IS_APP (self));
1132 #line 372 "lombard.vala"
1133         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "set_project_name");
1134 #line 373 "lombard.vala"
1135         gtk_window_set_title (GTK_WINDOW (self), _tmp0_ = model_project_get_file_display_name (MODEL_PROJECT (self->priv->project)));
1136 #line 1074 "lombard.c"
1137         _g_free0 (_tmp0_);
1138 }
1139
1140
1141 #line 376 "lombard.vala"
1142 void app_do_error_dialog (const char* message, const char* minor_message) {
1143 #line 376 "lombard.vala"
1144         g_return_if_fail (message != NULL);
1145 #line 377 "lombard.vala"
1146         dialog_utils_error (message, minor_message);
1147 #line 1085 "lombard.c"
1148 }
1149
1150
1151 #line 380 "lombard.vala"
1152 void app_on_load_error (App* self, const char* message) {
1153 #line 380 "lombard.vala"
1154         g_return_if_fail (IS_APP (self));
1155 #line 380 "lombard.vala"
1156         g_return_if_fail (message != NULL);
1157 #line 381 "lombard.vala"
1158         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_load_error");
1159 #line 382 "lombard.vala"
1160         gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->priv->load_errors), message);
1161 #line 1099 "lombard.c"
1162 }
1163
1164
1165 #line 385 "lombard.vala"
1166 void app_on_load_complete (App* self) {
1167 #line 1105 "lombard.c"
1168         ModelVideoTrack* _tmp0_;
1169         gboolean _tmp1_;
1170         GtkAction* _tmp3_;
1171         GtkToggleAction* action;
1172         GtkToggleAction* _tmp5_;
1173         GtkAction* _tmp4_;
1174 #line 385 "lombard.vala"
1175         g_return_if_fail (IS_APP (self));
1176 #line 386 "lombard.vala"
1177         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_load_complete");
1178 #line 387 "lombard.vala"
1179         gtk_widget_queue_draw (GTK_WIDGET (self));
1180 #line 388 "lombard.vala"
1181         if ((_tmp1_ = (_tmp0_ = model_project_find_video_track (MODEL_PROJECT (self->priv->project))) == NULL, _g_object_unref0 (_tmp0_), _tmp1_)) {
1182 #line 1120 "lombard.c"
1183                 ModelVideoTrack* _tmp2_;
1184 #line 389 "lombard.vala"
1185                 model_project_add_track (MODEL_PROJECT (self->priv->project), MODEL_TRACK (_tmp2_ = model_video_track_new (MODEL_PROJECT (self->priv->project))));
1186 #line 1124 "lombard.c"
1187                 _g_object_unref0 (_tmp2_);
1188         }
1189 #line 392 "lombard.vala"
1190         gst_element_set_state (GST_ELEMENT (MODEL_PROJECT (self->priv->project)->media_engine->pipeline), GST_STATE_PAUSED);
1191 #line 393 "lombard.vala"
1192         gtk_paned_set_position (GTK_PANED (self->priv->h_pane), GTK_WIDGET (self->priv->h_pane)->allocation.width - MODEL_PROJECT (self->priv->project)->library_width);
1193 #line 394 "lombard.vala"
1194         action = _g_object_ref0 ((_tmp3_ = gtk_action_group_get_action (self->priv->main_group, APP_LibraryToggle), GTK_IS_TOGGLE_ACTION (_tmp3_) ? ((GtkToggleAction*) _tmp3_) : NULL));
1195 #line 395 "lombard.vala"
1196         if (gtk_toggle_action_get_active (action) != MODEL_PROJECT (self->priv->project)->library_visible) {
1197 #line 396 "lombard.vala"
1198                 gtk_toggle_action_set_active (action, MODEL_PROJECT (self->priv->project)->library_visible);
1199 #line 1137 "lombard.c"
1200         }
1201 #line 399 "lombard.vala"
1202         action = (_tmp5_ = _g_object_ref0 ((_tmp4_ = gtk_action_group_get_action (self->priv->main_group, "Snap"), GTK_IS_TOGGLE_ACTION (_tmp4_) ? ((GtkToggleAction*) _tmp4_) : NULL)), _g_object_unref0 (action), _tmp5_);
1203 #line 400 "lombard.vala"
1204         if (gtk_toggle_action_get_active (action) != MODEL_PROJECT (self->priv->project)->snap_to_clip) {
1205 #line 401 "lombard.vala"
1206                 gtk_toggle_action_set_active (action, MODEL_PROJECT (self->priv->project)->snap_to_clip);
1207 #line 1145 "lombard.c"
1208         }
1209 #line 404 "lombard.vala"
1210         if (MODEL_PROJECT (self->priv->project)->library_visible) {
1211 #line 405 "lombard.vala"
1212                 if (GTK_PANED (self->priv->h_pane)->child1 != GTK_WIDGET (self->priv->library_scrolled)) {
1213 #line 406 "lombard.vala"
1214                         gtk_paned_add1 (GTK_PANED (self->priv->h_pane), GTK_WIDGET (self->priv->library_scrolled));
1215 #line 1153 "lombard.c"
1216                 }
1217         } else {
1218 #line 409 "lombard.vala"
1219                 if (GTK_PANED (self->priv->h_pane)->child1 == GTK_WIDGET (self->priv->library_scrolled)) {
1220 #line 410 "lombard.vala"
1221                         gtk_container_remove (GTK_CONTAINER (self->priv->h_pane), GTK_WIDGET (self->priv->library_scrolled));
1222 #line 1160 "lombard.c"
1223                 }
1224         }
1225 #line 414 "lombard.vala"
1226         if (gee_collection_get_size (GEE_COLLECTION (self->priv->load_errors)) > 0) {
1227 #line 1165 "lombard.c"
1228                 char* message;
1229 #line 415 "lombard.vala"
1230                 message = g_strdup ("");
1231 #line 1169 "lombard.c"
1232                 {
1233                         GeeIterator* _s_it;
1234                         _s_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->priv->load_errors));
1235 #line 416 "lombard.vala"
1236                         while (TRUE) {
1237 #line 1175 "lombard.c"
1238                                 char* s;
1239                                 char* _tmp7_;
1240                                 char* _tmp6_;
1241 #line 416 "lombard.vala"
1242                                 if (!gee_iterator_next (_s_it)) {
1243 #line 416 "lombard.vala"
1244                                         break;
1245 #line 1183 "lombard.c"
1246                                 }
1247 #line 416 "lombard.vala"
1248                                 s = (char*) gee_iterator_get (_s_it);
1249 #line 417 "lombard.vala"
1250                                 message = (_tmp7_ = g_strconcat (_tmp6_ = g_strconcat (message, s, NULL), "\n", NULL), _g_free0 (message), _tmp7_);
1251 #line 1189 "lombard.c"
1252                                 _g_free0 (_tmp6_);
1253                                 _g_free0 (s);
1254                         }
1255                         _g_object_unref0 (_s_it);
1256                 }
1257 #line 419 "lombard.vala"
1258                 app_do_error_dialog ("An error occurred loading the project.", message);
1259 #line 1197 "lombard.c"
1260                 _g_free0 (message);
1261         }
1262 #line 421 "lombard.vala"
1263         self->priv->loading = FALSE;
1264 #line 1202 "lombard.c"
1265         _g_object_unref0 (action);
1266 }
1267
1268
1269 #line 424 "lombard.vala"
1270 static void app_on_library_size_allocate (App* self, GdkRectangle* rectangle) {
1271 #line 1209 "lombard.c"
1272         gboolean _tmp0_ = FALSE;
1273 #line 424 "lombard.vala"
1274         g_return_if_fail (IS_APP (self));
1275 #line 425 "lombard.vala"
1276         if (!self->priv->loading) {
1277 #line 425 "lombard.vala"
1278                 _tmp0_ = GTK_PANED (self->priv->h_pane)->child1 == GTK_WIDGET (self->priv->library_scrolled);
1279 #line 1217 "lombard.c"
1280         } else {
1281 #line 425 "lombard.vala"
1282                 _tmp0_ = FALSE;
1283 #line 1221 "lombard.c"
1284         }
1285 #line 425 "lombard.vala"
1286         if (_tmp0_) {
1287 #line 426 "lombard.vala"
1288                 MODEL_PROJECT (self->priv->project)->library_width = (*rectangle).width;
1289 #line 1227 "lombard.c"
1290         }
1291 }
1292
1293
1294 #line 432 "lombard.vala"
1295 void app_load_file (App* self, const char* name, ModelLibraryImporter* im) {
1296 #line 1234 "lombard.c"
1297         GError * _inner_error_;
1298         gboolean _tmp0_ = FALSE;
1299         char* _tmp1_;
1300         gboolean _tmp2_;
1301 #line 432 "lombard.vala"
1302         g_return_if_fail (IS_APP (self));
1303 #line 432 "lombard.vala"
1304         g_return_if_fail (name != NULL);
1305 #line 432 "lombard.vala"
1306         g_return_if_fail (MODEL_IS_LIBRARY_IMPORTER (im));
1307 #line 1245 "lombard.c"
1308         _inner_error_ = NULL;
1309 #line 433 "lombard.vala"
1310         if ((_tmp2_ = _vala_strcmp0 (_tmp1_ = get_file_extension (name), MODEL_PROJECT_LOMBARD_FILE_EXTENSION) == 0, _g_free0 (_tmp1_), _tmp2_)) {
1311 #line 433 "lombard.vala"
1312                 _tmp0_ = TRUE;
1313 #line 1251 "lombard.c"
1314         } else {
1315                 char* _tmp3_;
1316 #line 434 "lombard.vala"
1317                 _tmp0_ = _vala_strcmp0 (_tmp3_ = get_file_extension (name), MODEL_PROJECT_FILLMORE_FILE_EXTENSION) == 0;
1318 #line 1256 "lombard.c"
1319                 _g_free0 (_tmp3_);
1320         }
1321 #line 433 "lombard.vala"
1322         if (_tmp0_) {
1323 #line 435 "lombard.vala"
1324                 app_load_project (self, name);
1325 #line 1263 "lombard.c"
1326         } else {
1327                 {
1328 #line 438 "lombard.vala"
1329                         model_library_importer_add_file (im, name, &_inner_error_);
1330 #line 1268 "lombard.c"
1331                         if (_inner_error_ != NULL) {
1332                                 goto __catch3_g_error;
1333                         }
1334                 }
1335                 goto __finally3;
1336                 __catch3_g_error:
1337                 {
1338                         GError * e;
1339                         e = _inner_error_;
1340                         _inner_error_ = NULL;
1341                         {
1342 #line 440 "lombard.vala"
1343                                 app_do_error_dialog ("Error loading file", e->message);
1344 #line 1282 "lombard.c"
1345                                 _g_error_free0 (e);
1346                         }
1347                 }
1348                 __finally3:
1349                 if (_inner_error_ != NULL) {
1350                         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);
1351                         g_clear_error (&_inner_error_);
1352                         return;
1353                 }
1354         }
1355 }
1356
1357
1358 static void _g_slist_free_g_free (GSList* self) {
1359         g_slist_foreach (self, (GFunc) g_free, NULL);
1360         g_slist_free (self);
1361 }
1362
1363
1364 #line 466 "lombard.vala"
1365 static void _app_on_importer_started_model_library_importer_started (ModelLibraryImporter* _sender, ModelClipImporter* i, gint num, gpointer self) {
1366 #line 1304 "lombard.c"
1367         app_on_importer_started (self, i, num);
1368 }
1369
1370
1371 #line 445 "lombard.vala"
1372 static void app_on_open (App* self) {
1373 #line 1311 "lombard.c"
1374         GError * _inner_error_;
1375         GSList* filenames;
1376         GSList* _tmp2_;
1377         gboolean _tmp1_;
1378         GSList* _tmp0_ = NULL;
1379 #line 445 "lombard.vala"
1380         g_return_if_fail (IS_APP (self));
1381 #line 1319 "lombard.c"
1382         _inner_error_ = NULL;
1383 #line 446 "lombard.vala"
1384         gee_abstract_collection_clear (GEE_ABSTRACT_COLLECTION (self->priv->load_errors));
1385 #line 1323 "lombard.c"
1386         filenames = NULL;
1387 #line 448 "lombard.vala"
1388         if ((_tmp1_ = dialog_utils_open (GTK_WINDOW (self), APP_filters, G_N_ELEMENTS (APP_filters), TRUE, TRUE, &_tmp0_), filenames = (_tmp2_ = _tmp0_, __g_slist_free_g_free0 (filenames), _tmp2_), _tmp1_)) {
1389 #line 449 "lombard.vala"
1390                 model_project_create_clip_importer (MODEL_PROJECT (self->priv->project), NULL, FALSE, (gint64) 0, FALSE, NULL, 0);
1391 #line 450 "lombard.vala"
1392                 g_signal_connect_object (MODEL_PROJECT (self->priv->project)->importer, "started", (GCallback) _app_on_importer_started_model_library_importer_started, self, 0);
1393 #line 1331 "lombard.c"
1394                 {
1395                         {
1396                                 GSList* s_collection;
1397                                 GSList* s_it;
1398 #line 452 "lombard.vala"
1399                                 s_collection = filenames;
1400 #line 1338 "lombard.c"
1401                                 for (s_it = s_collection; s_it != NULL; s_it = s_it->next) {
1402                                         char* s;
1403 #line 452 "lombard.vala"
1404                                         s = g_strdup ((const char*) s_it->data);
1405 #line 1343 "lombard.c"
1406                                         {
1407                                                 char* str;
1408                                                 str = NULL;
1409                                                 {
1410                                                         char* _tmp3_;
1411                                                         char* _tmp4_;
1412 #line 455 "lombard.vala"
1413                                                         _tmp3_ = g_filename_from_uri (s, NULL, &_inner_error_);
1414 #line 1352 "lombard.c"
1415                                                         if (_inner_error_ != NULL) {
1416                                                                 if (_inner_error_->domain == G_CONVERT_ERROR) {
1417                                                                         goto __catch5_g_convert_error;
1418                                                                 }
1419                                                                 _g_free0 (s);
1420                                                                 _g_free0 (str);
1421                                                                 __g_slist_free_g_free0 (filenames);
1422                                                                 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);
1423                                                                 g_clear_error (&_inner_error_);
1424                                                                 return;
1425                                                         }
1426 #line 455 "lombard.vala"
1427                                                         str = (_tmp4_ = _tmp3_, _g_free0 (str), _tmp4_);
1428 #line 1366 "lombard.c"
1429                                                 }
1430                                                 goto __finally5;
1431                                                 __catch5_g_convert_error:
1432                                                 {
1433                                                         GError * e;
1434                                                         e = _inner_error_;
1435                                                         _inner_error_ = NULL;
1436                                                         {
1437                                                                 char* _tmp5_;
1438 #line 456 "lombard.vala"
1439                                                                 str = (_tmp5_ = g_strdup (s), _g_free0 (str), _tmp5_);
1440 #line 1378 "lombard.c"
1441                                                                 _g_error_free0 (e);
1442                                                         }
1443                                                 }
1444                                                 __finally5:
1445                                                 if (_inner_error_ != NULL) {
1446                                                         _g_free0 (s);
1447                                                         _g_free0 (str);
1448                                                         goto __catch4_g_error;
1449                                                 }
1450 #line 457 "lombard.vala"
1451                                                 app_load_file (self, str, MODEL_PROJECT (self->priv->project)->importer);
1452 #line 1390 "lombard.c"
1453                                                 _g_free0 (s);
1454                                                 _g_free0 (str);
1455                                         }
1456                                 }
1457                         }
1458 #line 459 "lombard.vala"
1459                         model_library_importer_start (MODEL_PROJECT (self->priv->project)->importer, &_inner_error_);
1460 #line 1398 "lombard.c"
1461                         if (_inner_error_ != NULL) {
1462                                 goto __catch4_g_error;
1463                         }
1464                 }
1465                 goto __finally4;
1466                 __catch4_g_error:
1467                 {
1468                         GError * e;
1469                         e = _inner_error_;
1470                         _inner_error_ = NULL;
1471                         {
1472 #line 461 "lombard.vala"
1473                                 app_do_error_dialog ("Could not open file", e->message);
1474 #line 1412 "lombard.c"
1475                                 _g_error_free0 (e);
1476                         }
1477                 }
1478                 __finally4:
1479                 if (_inner_error_ != NULL) {
1480                         __g_slist_free_g_free0 (filenames);
1481                         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);
1482                         g_clear_error (&_inner_error_);
1483                         return;
1484                 }
1485         }
1486         __g_slist_free_g_free0 (filenames);
1487 }
1488
1489
1490 #line 466 "lombard.vala"
1491 static void app_on_importer_started (App* self, ModelClipImporter* i, gint num) {
1492 #line 1430 "lombard.c"
1493         MultiFileProgress* _tmp0_;
1494 #line 466 "lombard.vala"
1495         g_return_if_fail (IS_APP (self));
1496 #line 466 "lombard.vala"
1497         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (i));
1498 #line 467 "lombard.vala"
1499         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_importer_started");
1500 #line 468 "lombard.vala"
1501         _tmp0_ = g_object_ref_sink (multi_file_progress_new (GTK_WINDOW (self), num, "Import", MULTI_FILE_PROGRESS_INTERFACE (i)));
1502 #line 1440 "lombard.c"
1503         _g_object_unref0 (_tmp0_);
1504 }
1505
1506
1507 #line 471 "lombard.vala"
1508 static gboolean app_do_save_dialog (App* self) {
1509 #line 1447 "lombard.c"
1510         gboolean result = FALSE;
1511         char* filename;
1512         gboolean create_directory;
1513 #line 471 "lombard.vala"
1514         g_return_val_if_fail (IS_APP (self), FALSE);
1515 #line 472 "lombard.vala"
1516         filename = model_project_get_project_file (MODEL_PROJECT (self->priv->project));
1517 #line 473 "lombard.vala"
1518         create_directory = filename == NULL;
1519 #line 474 "lombard.vala"
1520         if (dialog_utils_save (GTK_WINDOW (self), "Save Project", create_directory, APP_filters, G_N_ELEMENTS (APP_filters), &filename)) {
1521 #line 475 "lombard.vala"
1522                 model_project_save (MODEL_PROJECT (self->priv->project), filename);
1523 #line 1461 "lombard.c"
1524                 result = TRUE;
1525                 _g_free0 (filename);
1526 #line 476 "lombard.vala"
1527                 return result;
1528 #line 1466 "lombard.c"
1529         }
1530         result = FALSE;
1531         _g_free0 (filename);
1532 #line 478 "lombard.vala"
1533         return result;
1534 #line 1472 "lombard.c"
1535 }
1536
1537
1538 #line 481 "lombard.vala"
1539 static void app_on_save_as (App* self) {
1540 #line 481 "lombard.vala"
1541         g_return_if_fail (IS_APP (self));
1542 #line 482 "lombard.vala"
1543         app_do_save_dialog (self);
1544 #line 1482 "lombard.c"
1545 }
1546
1547
1548 #line 485 "lombard.vala"
1549 static void app_on_save (App* self) {
1550 #line 485 "lombard.vala"
1551         g_return_if_fail (IS_APP (self));
1552 #line 486 "lombard.vala"
1553         app_do_save (self);
1554 #line 1492 "lombard.c"
1555 }
1556
1557
1558 #line 489 "lombard.vala"
1559 static gboolean app_do_save (App* self) {
1560 #line 1498 "lombard.c"
1561         gboolean result = FALSE;
1562         char* _tmp0_;
1563         gboolean _tmp1_;
1564 #line 489 "lombard.vala"
1565         g_return_val_if_fail (IS_APP (self), FALSE);
1566 #line 490 "lombard.vala"
1567         if ((_tmp1_ = (_tmp0_ = model_project_get_project_file (MODEL_PROJECT (self->priv->project))) != NULL, _g_free0 (_tmp0_), _tmp1_)) {
1568 #line 491 "lombard.vala"
1569                 model_project_save (MODEL_PROJECT (self->priv->project), NULL);
1570 #line 1508 "lombard.c"
1571                 result = TRUE;
1572 #line 492 "lombard.vala"
1573                 return result;
1574 #line 1512 "lombard.c"
1575         }
1576         result = app_do_save_dialog (self);
1577 #line 494 "lombard.vala"
1578         return result;
1579 #line 1517 "lombard.c"
1580 }
1581
1582
1583 #line 497 "lombard.vala"
1584 void app_load_project (App* self, const char* filename) {
1585 #line 1523 "lombard.c"
1586         GError * _inner_error_;
1587 #line 497 "lombard.vala"
1588         g_return_if_fail (IS_APP (self));
1589 #line 497 "lombard.vala"
1590         g_return_if_fail (filename != NULL);
1591 #line 1529 "lombard.c"
1592         _inner_error_ = NULL;
1593 #line 498 "lombard.vala"
1594         self->priv->loading = TRUE;
1595 #line 1533 "lombard.c"
1596         {
1597                 ViewVideoOutput* _tmp0_;
1598                 ViewVideoOutput* _tmp1_;
1599 #line 501 "lombard.vala"
1600                 view_media_engine_disconnect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->video_output));
1601 #line 502 "lombard.vala"
1602                 _tmp0_ = view_video_output_new (GTK_WIDGET (self->priv->drawing_area), &_inner_error_);
1603 #line 1541 "lombard.c"
1604                 if (_inner_error_ != NULL) {
1605                         goto __catch6_g_error;
1606                 }
1607 #line 502 "lombard.vala"
1608                 self->priv->video_output = (_tmp1_ = _tmp0_, _g_object_unref0 (self->priv->video_output), _tmp1_);
1609 #line 503 "lombard.vala"
1610                 view_media_engine_connect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->video_output));
1611 #line 1549 "lombard.c"
1612         }
1613         goto __finally6;
1614         __catch6_g_error:
1615         {
1616                 GError * e;
1617                 e = _inner_error_;
1618                 _inner_error_ = NULL;
1619                 {
1620 #line 505 "lombard.vala"
1621                         app_do_error_dialog ("Could not create video output", e->message);
1622 #line 1560 "lombard.c"
1623                         _g_error_free0 (e);
1624                 }
1625         }
1626         __finally6:
1627         if (_inner_error_ != NULL) {
1628                 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);
1629                 g_clear_error (&_inner_error_);
1630                 return;
1631         }
1632 #line 508 "lombard.vala"
1633         model_project_load (MODEL_PROJECT (self->priv->project), filename);
1634 #line 1572 "lombard.c"
1635 }
1636
1637
1638 #line 514 "lombard.vala"
1639 static void app_scroll_toward_center (App* self, gint xpos) {
1640 #line 1578 "lombard.c"
1641         gint cursor_pos;
1642         gint page_size;
1643         gint diff;
1644         gint d;
1645         gint x;
1646         gint max_value;
1647 #line 514 "lombard.vala"
1648         g_return_if_fail (IS_APP (self));
1649 #line 515 "lombard.vala"
1650         cursor_pos = xpos - ((gint) gtk_adjustment_get_value (self->priv->h_adjustment));
1651 #line 520 "lombard.vala"
1652         page_size = (gint) gtk_adjustment_get_page_size (self->priv->h_adjustment);
1653 #line 521 "lombard.vala"
1654         diff = (page_size / 2) - cursor_pos;
1655 #line 522 "lombard.vala"
1656         d = sign (diff) * ((gint) sqrt ((double) abs (diff)));
1657 #line 523 "lombard.vala"
1658         cursor_pos = cursor_pos + d;
1659 #line 525 "lombard.vala"
1660         x = MAX (0, xpos - cursor_pos);
1661 #line 526 "lombard.vala"
1662         max_value = (gint) (gtk_adjustment_get_upper (self->priv->h_adjustment) - GTK_WIDGET (self->priv->timeline_scrolled)->allocation.width);
1663 #line 527 "lombard.vala"
1664         if (x > max_value) {
1665 #line 528 "lombard.vala"
1666                 x = max_value;
1667 #line 1605 "lombard.c"
1668         }
1669 #line 530 "lombard.vala"
1670         gtk_adjustment_set_value (self->priv->h_adjustment, (double) x);
1671 #line 532 "lombard.vala"
1672         gtk_adjustment_set_value (self->priv->h_adjustment, (double) x);
1673 #line 1611 "lombard.c"
1674 }
1675
1676
1677 #line 535 "lombard.vala"
1678 void app_on_split_at_playhead (App* self) {
1679 #line 535 "lombard.vala"
1680         g_return_if_fail (IS_APP (self));
1681 #line 536 "lombard.vala"
1682         model_project_split_at_playhead (MODEL_PROJECT (self->priv->project));
1683 #line 1621 "lombard.c"
1684 }
1685
1686
1687 #line 539 "lombard.vala"
1688 void app_on_trim_to_playhead (App* self) {
1689 #line 539 "lombard.vala"
1690         g_return_if_fail (IS_APP (self));
1691 #line 540 "lombard.vala"
1692         model_project_trim_to_playhead (MODEL_PROJECT (self->priv->project));
1693 #line 1631 "lombard.c"
1694 }
1695
1696
1697 static Fraction* _fraction_dup (Fraction* self) {
1698         Fraction* dup;
1699         dup = g_new0 (Fraction, 1);
1700         memcpy (dup, self, sizeof (Fraction));
1701         return dup;
1702 }
1703
1704
1705 static gpointer __fraction_dup0 (gpointer self) {
1706         return self ? _fraction_dup (self) : NULL;
1707 }
1708
1709
1710 #line 543 "lombard.vala"
1711 void app_on_clip_properties (App* self) {
1712 #line 1650 "lombard.c"
1713         Fraction* frames_per_second;
1714         Fraction* _tmp1_;
1715         Fraction _tmp0_ = {0};
1716 #line 543 "lombard.vala"
1717         g_return_if_fail (IS_APP (self));
1718 #line 544 "lombard.vala"
1719         frames_per_second = NULL;
1720 #line 545 "lombard.vala"
1721         model_video_project_get_framerate_fraction (self->priv->project, &_tmp0_);
1722 #line 545 "lombard.vala"
1723         frames_per_second = (_tmp1_ = __fraction_dup0 (&_tmp0_), _g_free0 (frames_per_second), _tmp1_);
1724 #line 546 "lombard.vala"
1725         if (clip_library_view_has_selection (self->priv->library)) {
1726 #line 1664 "lombard.c"
1727                 GeeArrayList* files;
1728 #line 547 "lombard.vala"
1729                 files = clip_library_view_get_selected_files (self->priv->library);
1730 #line 548 "lombard.vala"
1731                 if (gee_collection_get_size (GEE_COLLECTION (files)) == 1) {
1732 #line 1670 "lombard.c"
1733                         char* file_name;
1734                         ModelClipFile* clip_file;
1735 #line 549 "lombard.vala"
1736                         file_name = (char*) gee_abstract_list_get (GEE_ABSTRACT_LIST (files), 0);
1737 #line 550 "lombard.vala"
1738                         clip_file = model_project_find_clipfile (MODEL_PROJECT (self->priv->project), file_name);
1739 #line 551 "lombard.vala"
1740                         dialog_utils_show_clip_properties (GTK_WINDOW (self), NULL, clip_file, frames_per_second);
1741 #line 1679 "lombard.c"
1742                         _g_free0 (file_name);
1743                         _g_object_unref0 (clip_file);
1744                 }
1745                 _g_object_unref0 (files);
1746         } else {
1747                 GeeArrayList* clips;
1748 #line 554 "lombard.vala"
1749                 clips = _g_object_ref0 (self->priv->timeline->selected_clips);
1750 #line 555 "lombard.vala"
1751                 if (gee_collection_get_size (GEE_COLLECTION (clips)) == 1) {
1752 #line 1690 "lombard.c"
1753                         ClipView* clip_view;
1754 #line 556 "lombard.vala"
1755                         clip_view = (ClipView*) gee_abstract_list_get (GEE_ABSTRACT_LIST (clips), 0);
1756 #line 557 "lombard.vala"
1757                         dialog_utils_show_clip_properties (GTK_WINDOW (self), clip_view, NULL, frames_per_second);
1758 #line 1696 "lombard.c"
1759                         _g_object_unref0 (clip_view);
1760                 }
1761                 _g_object_unref0 (clips);
1762         }
1763         _g_free0 (frames_per_second);
1764 }
1765
1766
1767 #line 562 "lombard.vala"
1768 void app_on_position_changed (App* self) {
1769 #line 562 "lombard.vala"
1770         g_return_if_fail (IS_APP (self));
1771 #line 563 "lombard.vala"
1772         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_position_changed");
1773 #line 564 "lombard.vala"
1774         app_update_menu (self);
1775 #line 1713 "lombard.c"
1776 }
1777
1778
1779 #line 567 "lombard.vala"
1780 static void app_on_callback_pulse (App* self) {
1781 #line 567 "lombard.vala"
1782         g_return_if_fail (IS_APP (self));
1783 #line 568 "lombard.vala"
1784         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_callback_pulse");
1785 #line 569 "lombard.vala"
1786         if (model_project_transport_is_playing (MODEL_PROJECT (self->priv->project))) {
1787 #line 570 "lombard.vala"
1788                 app_scroll_toward_center (self, model_time_system_time_to_xpos (MODEL_TIME_SYSTEM (self->priv->project->time_provider), MODEL_PROJECT (self->priv->project)->media_engine->position));
1789 #line 1727 "lombard.c"
1790         }
1791 #line 572 "lombard.vala"
1792         gtk_widget_queue_draw (GTK_WIDGET (self->priv->timeline));
1793 #line 1731 "lombard.c"
1794 }
1795
1796
1797 #line 575 "lombard.vala"
1798 void app_on_track_changed (App* self) {
1799 #line 575 "lombard.vala"
1800         g_return_if_fail (IS_APP (self));
1801 #line 576 "lombard.vala"
1802         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_track_changed");
1803 #line 577 "lombard.vala"
1804         app_update_menu (self);
1805 #line 1743 "lombard.c"
1806 }
1807
1808
1809 #line 580 "lombard.vala"
1810 static void app_update_menu (App* self) {
1811 #line 1749 "lombard.c"
1812         gboolean library_selected;
1813         gboolean clip_selected;
1814         gboolean stopped;
1815         gboolean clip_is_trimmed;
1816         gboolean playhead_on_clip;
1817         gboolean dir = FALSE;
1818         gboolean can_trim;
1819         gboolean one_selected;
1820         gboolean _tmp1_ = FALSE;
1821         gboolean _tmp2_ = FALSE;
1822         gboolean _tmp4_ = FALSE;
1823         gboolean _tmp5_ = FALSE;
1824         gboolean _tmp6_ = FALSE;
1825         gboolean _tmp7_ = FALSE;
1826         gboolean _tmp8_ = FALSE;
1827 #line 580 "lombard.vala"
1828         g_return_if_fail (IS_APP (self));
1829 #line 581 "lombard.vala"
1830         library_selected = clip_library_view_has_selection (self->priv->library);
1831 #line 582 "lombard.vala"
1832         clip_selected = time_line_is_clip_selected (self->priv->timeline);
1833 #line 583 "lombard.vala"
1834         stopped = transport_delegate_is_stopped (TRANSPORT_DELEGATE (self));
1835 #line 584 "lombard.vala"
1836         clip_is_trimmed = FALSE;
1837 #line 585 "lombard.vala"
1838         playhead_on_clip = model_project_playhead_on_clip (MODEL_PROJECT (self->priv->project));
1839 #line 587 "lombard.vala"
1840         can_trim = model_project_can_trim (MODEL_PROJECT (self->priv->project), &dir);
1841 #line 588 "lombard.vala"
1842         one_selected = FALSE;
1843 #line 589 "lombard.vala"
1844         if (library_selected) {
1845 #line 1783 "lombard.c"
1846                 GeeArrayList* _tmp0_;
1847 #line 590 "lombard.vala"
1848                 one_selected = gee_collection_get_size (GEE_COLLECTION (_tmp0_ = clip_library_view_get_selected_files (self->priv->library))) == 1;
1849 #line 1787 "lombard.c"
1850                 _g_object_unref0 (_tmp0_);
1851         } else {
1852 #line 591 "lombard.vala"
1853                 if (clip_selected) {
1854 #line 592 "lombard.vala"
1855                         one_selected = gee_collection_get_size (GEE_COLLECTION (self->priv->timeline->selected_clips)) == 1;
1856 #line 1794 "lombard.c"
1857                 }
1858         }
1859 #line 595 "lombard.vala"
1860         if (clip_selected) {
1861 #line 1799 "lombard.c"
1862                 {
1863                         GeeIterator* _clip_view_it;
1864                         _clip_view_it = gee_abstract_collection_iterator (GEE_ABSTRACT_COLLECTION (self->priv->timeline->selected_clips));
1865 #line 596 "lombard.vala"
1866                         while (TRUE) {
1867 #line 1805 "lombard.c"
1868                                 ClipView* clip_view;
1869 #line 596 "lombard.vala"
1870                                 if (!gee_iterator_next (_clip_view_it)) {
1871 #line 596 "lombard.vala"
1872                                         break;
1873 #line 1811 "lombard.c"
1874                                 }
1875 #line 596 "lombard.vala"
1876                                 clip_view = (ClipView*) gee_iterator_get (_clip_view_it);
1877 #line 597 "lombard.vala"
1878                                 clip_is_trimmed = model_clip_is_trimmed (clip_view->clip);
1879 #line 598 "lombard.vala"
1880                                 if (clip_is_trimmed) {
1881 #line 1819 "lombard.c"
1882                                         _g_object_unref0 (clip_view);
1883 #line 599 "lombard.vala"
1884                                         break;
1885 #line 1823 "lombard.c"
1886                                 }
1887                                 _g_object_unref0 (clip_view);
1888                         }
1889                         _g_object_unref0 (_clip_view_it);
1890                 }
1891         }
1892 #line 604 "lombard.vala"
1893         app_set_sensitive_group (self, self->priv->main_group, "Open", stopped);
1894 #line 605 "lombard.vala"
1895         app_set_sensitive_group (self, self->priv->main_group, "Save", stopped);
1896 #line 606 "lombard.vala"
1897         app_set_sensitive_group (self, self->priv->main_group, "SaveAs", stopped);
1898 #line 607 "lombard.vala"
1899         app_set_sensitive_group (self, self->priv->main_group, "Export", model_project_can_export (MODEL_PROJECT (self->priv->project)));
1900 #line 610 "lombard.vala"
1901         if (stopped) {
1902 #line 610 "lombard.vala"
1903                 _tmp1_ = model_undo_manager_get_can_undo (MODEL_PROJECT (self->priv->project)->undo_manager);
1904 #line 1842 "lombard.c"
1905         } else {
1906 #line 610 "lombard.vala"
1907                 _tmp1_ = FALSE;
1908 #line 1846 "lombard.c"
1909         }
1910 #line 610 "lombard.vala"
1911         app_set_sensitive_group (self, self->priv->main_group, "Undo", _tmp1_);
1912 #line 611 "lombard.vala"
1913         if (stopped) {
1914 #line 1852 "lombard.c"
1915                 gboolean _tmp3_ = FALSE;
1916 #line 611 "lombard.vala"
1917                 if (clip_selected) {
1918 #line 611 "lombard.vala"
1919                         _tmp3_ = TRUE;
1920 #line 1858 "lombard.c"
1921                 } else {
1922 #line 611 "lombard.vala"
1923                         _tmp3_ = library_selected;
1924 #line 1862 "lombard.c"
1925                 }
1926 #line 611 "lombard.vala"
1927                 _tmp2_ = _tmp3_;
1928 #line 1866 "lombard.c"
1929         } else {
1930 #line 611 "lombard.vala"
1931                 _tmp2_ = FALSE;
1932 #line 1870 "lombard.c"
1933         }
1934 #line 611 "lombard.vala"
1935         app_set_sensitive_group (self, self->priv->main_group, "Delete", _tmp2_);
1936 #line 612 "lombard.vala"
1937         if (stopped) {
1938 #line 612 "lombard.vala"
1939                 _tmp4_ = clip_selected;
1940 #line 1878 "lombard.c"
1941         } else {
1942 #line 612 "lombard.vala"
1943                 _tmp4_ = FALSE;
1944 #line 1882 "lombard.c"
1945         }
1946 #line 612 "lombard.vala"
1947         app_set_sensitive_group (self, self->priv->main_group, "Cut", _tmp4_);
1948 #line 613 "lombard.vala"
1949         if (stopped) {
1950 #line 613 "lombard.vala"
1951                 _tmp5_ = clip_selected;
1952 #line 1890 "lombard.c"
1953         } else {
1954 #line 613 "lombard.vala"
1955                 _tmp5_ = FALSE;
1956 #line 1894 "lombard.c"
1957         }
1958 #line 613 "lombard.vala"
1959         app_set_sensitive_group (self, self->priv->main_group, "Copy", _tmp5_);
1960 #line 614 "lombard.vala"
1961         if (stopped) {
1962 #line 614 "lombard.vala"
1963                 _tmp6_ = gee_collection_get_size (GEE_COLLECTION (self->priv->timeline->clipboard->clips)) > 0;
1964 #line 1902 "lombard.c"
1965         } else {
1966 #line 614 "lombard.vala"
1967                 _tmp6_ = FALSE;
1968 #line 1906 "lombard.c"
1969         }
1970 #line 614 "lombard.vala"
1971         app_set_sensitive_group (self, self->priv->main_group, "Paste", _tmp6_);
1972 #line 615 "lombard.vala"
1973         app_set_sensitive_group (self, self->priv->main_group, "ClipProperties", one_selected);
1974 #line 617 "lombard.vala"
1975         if (stopped) {
1976 #line 617 "lombard.vala"
1977                 _tmp7_ = playhead_on_clip;
1978 #line 1916 "lombard.c"
1979         } else {
1980 #line 617 "lombard.vala"
1981                 _tmp7_ = FALSE;
1982 #line 1920 "lombard.c"
1983         }
1984 #line 617 "lombard.vala"
1985         app_set_sensitive_group (self, self->priv->main_group, "SplitAtPlayhead", _tmp7_);
1986 #line 618 "lombard.vala"
1987         if (stopped) {
1988 #line 618 "lombard.vala"
1989                 _tmp8_ = can_trim;
1990 #line 1928 "lombard.c"
1991         } else {
1992 #line 618 "lombard.vala"
1993                 _tmp8_ = FALSE;
1994 #line 1932 "lombard.c"
1995         }
1996 #line 618 "lombard.vala"
1997         app_set_sensitive_group (self, self->priv->main_group, "TrimToPlayhead", _tmp8_);
1998 #line 621 "lombard.vala"
1999         app_set_sensitive_group (self, self->priv->main_group, "ZoomProject", model_project_get_length (MODEL_PROJECT (self->priv->project)) != 0);
2000 #line 1938 "lombard.c"
2001 }
2002
2003
2004 #line 625 "lombard.vala"
2005 void app_on_timeline_selection_changed (App* self, gboolean selected) {
2006 #line 625 "lombard.vala"
2007         g_return_if_fail (IS_APP (self));
2008 #line 626 "lombard.vala"
2009         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_timeline_selection_changed");
2010 #line 627 "lombard.vala"
2011         if (selected) {
2012 #line 628 "lombard.vala"
2013                 clip_library_view_unselect_all (self->priv->library);
2014 #line 1952 "lombard.c"
2015         }
2016 #line 629 "lombard.vala"
2017         app_update_menu (self);
2018 #line 1956 "lombard.c"
2019 }
2020
2021
2022 #line 632 "lombard.vala"
2023 void app_on_library_selection_changed (App* self, gboolean selected) {
2024 #line 632 "lombard.vala"
2025         g_return_if_fail (IS_APP (self));
2026 #line 633 "lombard.vala"
2027         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_library_selection_changed");
2028 #line 634 "lombard.vala"
2029         if (selected) {
2030 #line 635 "lombard.vala"
2031                 time_line_deselect_all_clips (self->priv->timeline);
2032 #line 636 "lombard.vala"
2033                 gtk_widget_queue_draw (GTK_WIDGET (self->priv->timeline));
2034 #line 1972 "lombard.c"
2035         }
2036 #line 638 "lombard.vala"
2037         app_update_menu (self);
2038 #line 1976 "lombard.c"
2039 }
2040
2041
2042 #line 643 "lombard.vala"
2043 static gboolean app_real_key_press_event (GtkWidget* base, GdkEventKey* event) {
2044 #line 1982 "lombard.c"
2045         App * self;
2046         gboolean result = FALSE;
2047         self = APP (base);
2048 #line 644 "lombard.vala"
2049         switch ((*event).keyval) {
2050 #line 1988 "lombard.c"
2051                 case GDK_KP_Enter:
2052                 case GDK_Return:
2053                 {
2054 #line 647 "lombard.vala"
2055                         if (((*event).state & GDK_SHIFT_ALT_CONTROL_MASK) != 0) {
2056 #line 1994 "lombard.c"
2057                                 result = GTK_WIDGET_CLASS (app_parent_class)->key_press_event (GTK_WIDGET (GTK_WINDOW (self)), event);
2058 #line 648 "lombard.vala"
2059                                 return result;
2060 #line 1998 "lombard.c"
2061                         }
2062 #line 649 "lombard.vala"
2063                         app_on_go_start (self);
2064 #line 650 "lombard.vala"
2065                         break;
2066 #line 2004 "lombard.c"
2067                 }
2068                 case GDK_Left:
2069                 {
2070 #line 652 "lombard.vala"
2071                         if (((*event).state & GDK_CONTROL_MASK) != 0) {
2072 #line 653 "lombard.vala"
2073                                 model_project_go_previous (MODEL_PROJECT (self->priv->project));
2074 #line 2012 "lombard.c"
2075                         } else {
2076 #line 655 "lombard.vala"
2077                                 model_video_project_go_previous_frame (self->priv->project);
2078 #line 2016 "lombard.c"
2079                         }
2080 #line 657 "lombard.vala"
2081                         break;
2082 #line 2020 "lombard.c"
2083                 }
2084                 case GDK_Right:
2085                 {
2086 #line 659 "lombard.vala"
2087                         if (((*event).state & GDK_CONTROL_MASK) != 0) {
2088 #line 660 "lombard.vala"
2089                                 model_project_go_next (MODEL_PROJECT (self->priv->project));
2090 #line 2028 "lombard.c"
2091                         } else {
2092 #line 662 "lombard.vala"
2093                                 model_video_project_go_next_frame (self->priv->project);
2094 #line 2032 "lombard.c"
2095                         }
2096 #line 664 "lombard.vala"
2097                         break;
2098 #line 2036 "lombard.c"
2099                 }
2100                 case GDK_KP_Add:
2101                 case GDK_equal:
2102                 case GDK_plus:
2103                 {
2104 #line 668 "lombard.vala"
2105                         app_on_zoom_in (self);
2106 #line 669 "lombard.vala"
2107                         break;
2108 #line 2046 "lombard.c"
2109                 }
2110                 case GDK_KP_Subtract:
2111                 case GDK_minus:
2112                 case GDK_underscore:
2113                 {
2114 #line 673 "lombard.vala"
2115                         app_on_zoom_out (self);
2116 #line 674 "lombard.vala"
2117                         break;
2118 #line 2056 "lombard.c"
2119                 }
2120                 default:
2121                 {
2122                         result = GTK_WIDGET_CLASS (app_parent_class)->key_press_event (GTK_WIDGET (GTK_WINDOW (self)), event);
2123 #line 676 "lombard.vala"
2124                         return result;
2125 #line 2063 "lombard.c"
2126                 }
2127         }
2128         result = TRUE;
2129 #line 678 "lombard.vala"
2130         return result;
2131 #line 2069 "lombard.c"
2132 }
2133
2134
2135 #line 681 "lombard.vala"
2136 static void app_on_snap (App* self) {
2137 #line 681 "lombard.vala"
2138         g_return_if_fail (IS_APP (self));
2139 #line 682 "lombard.vala"
2140         MODEL_PROJECT (self->priv->project)->snap_to_clip = !MODEL_PROJECT (self->priv->project)->snap_to_clip;
2141 #line 2079 "lombard.c"
2142 }
2143
2144
2145 #line 685 "lombard.vala"
2146 static void app_on_view_library (App* self) {
2147 #line 2085 "lombard.c"
2148         GtkAction* _tmp0_;
2149         GtkToggleAction* action;
2150 #line 685 "lombard.vala"
2151         g_return_if_fail (IS_APP (self));
2152 #line 686 "lombard.vala"
2153         action = _g_object_ref0 ((_tmp0_ = gtk_action_group_get_action (self->priv->main_group, APP_LibraryToggle), GTK_IS_TOGGLE_ACTION (_tmp0_) ? ((GtkToggleAction*) _tmp0_) : NULL));
2154 #line 687 "lombard.vala"
2155         app_toggle_library (self, gtk_toggle_action_get_active (action));
2156 #line 2094 "lombard.c"
2157         _g_object_unref0 (action);
2158 }
2159
2160
2161 #line 690 "lombard.vala"
2162 static gint64 app_get_zoom_center_time (App* self) {
2163 #line 2101 "lombard.c"
2164         gint64 result = 0LL;
2165 #line 690 "lombard.vala"
2166         g_return_val_if_fail (IS_APP (self), 0LL);
2167 #line 2105 "lombard.c"
2168         result = model_project_transport_get_position (MODEL_PROJECT (self->priv->project));
2169 #line 691 "lombard.vala"
2170         return result;
2171 #line 2109 "lombard.c"
2172 }
2173
2174
2175 #line 694 "lombard.vala"
2176 static void app_do_zoom (App* self, float increment) {
2177 #line 694 "lombard.vala"
2178         g_return_if_fail (IS_APP (self));
2179 #line 695 "lombard.vala"
2180         self->priv->center_time = app_get_zoom_center_time (self);
2181 #line 696 "lombard.vala"
2182         time_line_zoom (self->priv->timeline, increment);
2183 #line 2121 "lombard.c"
2184 }
2185
2186
2187 #line 699 "lombard.vala"
2188 static void app_on_zoom_in (App* self) {
2189 #line 699 "lombard.vala"
2190         g_return_if_fail (IS_APP (self));
2191 #line 700 "lombard.vala"
2192         app_do_zoom (self, 0.1f);
2193 #line 2131 "lombard.c"
2194 }
2195
2196
2197 #line 703 "lombard.vala"
2198 static void app_on_zoom_out (App* self) {
2199 #line 703 "lombard.vala"
2200         g_return_if_fail (IS_APP (self));
2201 #line 704 "lombard.vala"
2202         app_do_zoom (self, -0.1f);
2203 #line 2141 "lombard.c"
2204 }
2205
2206
2207 #line 707 "lombard.vala"
2208 static void app_on_zoom_to_project (App* self) {
2209 #line 707 "lombard.vala"
2210         g_return_if_fail (IS_APP (self));
2211 #line 708 "lombard.vala"
2212         time_line_zoom_to_project (self->priv->timeline, gtk_adjustment_get_page_size (self->priv->h_adjustment));
2213 #line 2151 "lombard.c"
2214 }
2215
2216
2217 #line 711 "lombard.vala"
2218 static void app_on_timeline_size_allocate (App* self, GdkRectangle* rectangle) {
2219 #line 711 "lombard.vala"
2220         g_return_if_fail (IS_APP (self));
2221 #line 712 "lombard.vala"
2222         if (self->priv->center_time != (-1)) {
2223 #line 2161 "lombard.c"
2224                 gint new_center_pixel;
2225                 gint page_size;
2226 #line 713 "lombard.vala"
2227                 new_center_pixel = model_time_system_time_to_xpos (MODEL_TIME_SYSTEM (self->priv->project->time_provider), self->priv->center_time);
2228 #line 714 "lombard.vala"
2229                 page_size = (gint) (gtk_adjustment_get_page_size (self->priv->h_adjustment) / 2);
2230 #line 715 "lombard.vala"
2231                 gtk_adjustment_clamp_page (self->priv->h_adjustment, (double) (new_center_pixel - page_size), (double) (new_center_pixel + page_size));
2232 #line 716 "lombard.vala"
2233                 self->priv->center_time = (gint64) (-1);
2234 #line 2172 "lombard.c"
2235         }
2236 }
2237
2238
2239 #line 720 "lombard.vala"
2240 static void app_set_sensitive_group (App* self, GtkActionGroup* group, const char* group_path, gboolean sensitive) {
2241 #line 2179 "lombard.c"
2242         GtkAction* action;
2243 #line 720 "lombard.vala"
2244         g_return_if_fail (IS_APP (self));
2245 #line 720 "lombard.vala"
2246         g_return_if_fail (GTK_IS_ACTION_GROUP (group));
2247 #line 720 "lombard.vala"
2248         g_return_if_fail (group_path != NULL);
2249 #line 721 "lombard.vala"
2250         action = _g_object_ref0 (gtk_action_group_get_action (group, group_path));
2251 #line 722 "lombard.vala"
2252         gtk_action_set_sensitive (action, sensitive);
2253 #line 2191 "lombard.c"
2254         _g_object_unref0 (action);
2255 }
2256
2257
2258 #line 727 "lombard.vala"
2259 static void app_on_play_pause (App* self) {
2260 #line 727 "lombard.vala"
2261         g_return_if_fail (IS_APP (self));
2262 #line 728 "lombard.vala"
2263         if (model_project_transport_is_playing (MODEL_PROJECT (self->priv->project))) {
2264 #line 729 "lombard.vala"
2265                 view_media_engine_pause (MODEL_PROJECT (self->priv->project)->media_engine);
2266 #line 2204 "lombard.c"
2267         } else {
2268 #line 735 "lombard.vala"
2269                 view_media_engine_do_play (MODEL_PROJECT (self->priv->project)->media_engine, PLAY_STATE_PLAYING);
2270 #line 2208 "lombard.c"
2271         }
2272 }
2273
2274
2275 #line 739 "lombard.vala"
2276 static void app_on_export (App* self) {
2277 #line 2215 "lombard.c"
2278         GError * _inner_error_;
2279         char* filename;
2280 #line 739 "lombard.vala"
2281         g_return_if_fail (IS_APP (self));
2282 #line 2220 "lombard.c"
2283         _inner_error_ = NULL;
2284 #line 740 "lombard.vala"
2285         filename = NULL;
2286 #line 741 "lombard.vala"
2287         if (dialog_utils_save (GTK_WINDOW (self), "Export", FALSE, APP_export_filters, G_N_ELEMENTS (APP_export_filters), &filename)) {
2288 #line 2226 "lombard.c"
2289                 MultiFileProgress* _tmp0_;
2290 #line 742 "lombard.vala"
2291                 _tmp0_ = g_object_ref_sink (multi_file_progress_new (GTK_WINDOW (self), 1, "Export", MULTI_FILE_PROGRESS_INTERFACE (MODEL_PROJECT (self->priv->project)->media_engine)));
2292 #line 2230 "lombard.c"
2293                 _g_object_unref0 (_tmp0_);
2294 #line 743 "lombard.vala"
2295                 view_media_engine_disconnect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->audio_output));
2296 #line 744 "lombard.vala"
2297                 view_media_engine_disconnect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->video_output));
2298 #line 2236 "lombard.c"
2299                 {
2300                         GstCaps* _tmp1_;
2301                         ViewOggVorbisExport* _tmp2_;
2302                         ViewOggVorbisExport* _tmp3_;
2303                         ViewOggVorbisExport* _tmp4_;
2304 #line 746 "lombard.vala"
2305                         _tmp3_ = (_tmp2_ = view_ogg_vorbis_export_new (VIEW_MEDIA_CONNECTOR_MEDIA_TYPES_Audio | VIEW_MEDIA_CONNECTOR_MEDIA_TYPES_Video, filename, _tmp1_ = view_media_engine_get_project_audio_export_caps (MODEL_PROJECT (self->priv->project)->media_engine), &_inner_error_), _gst_caps_unref0 (_tmp1_), _tmp2_);
2306 #line 2244 "lombard.c"
2307                         if (_inner_error_ != NULL) {
2308                                 goto __catch7_g_error;
2309                         }
2310 #line 746 "lombard.vala"
2311                         self->priv->export_connector = (_tmp4_ = _tmp3_, _g_object_unref0 (self->priv->export_connector), _tmp4_);
2312 #line 749 "lombard.vala"
2313                         view_media_engine_connect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->export_connector));
2314 #line 750 "lombard.vala"
2315                         view_media_engine_start_export (MODEL_PROJECT (self->priv->project)->media_engine, filename);
2316 #line 2254 "lombard.c"
2317                 }
2318                 goto __finally7;
2319                 __catch7_g_error:
2320                 {
2321                         GError * e;
2322                         e = _inner_error_;
2323                         _inner_error_ = NULL;
2324                         {
2325 #line 752 "lombard.vala"
2326                                 app_do_error_dialog ("Could not export file", e->message);
2327 #line 2265 "lombard.c"
2328                                 _g_error_free0 (e);
2329                         }
2330                 }
2331                 __finally7:
2332                 if (_inner_error_ != NULL) {
2333                         _g_free0 (filename);
2334                         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);
2335                         g_clear_error (&_inner_error_);
2336                         return;
2337                 }
2338         }
2339         _g_free0 (filename);
2340 }
2341
2342
2343 #line 757 "lombard.vala"
2344 static void app_on_post_export (App* self, gboolean canceled) {
2345 #line 2283 "lombard.c"
2346         ViewOggVorbisExport* _tmp1_;
2347 #line 757 "lombard.vala"
2348         g_return_if_fail (IS_APP (self));
2349 #line 758 "lombard.vala"
2350         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_post_export");
2351 #line 759 "lombard.vala"
2352         view_media_engine_disconnect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->export_connector));
2353 #line 760 "lombard.vala"
2354         view_media_engine_connect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->audio_output));
2355 #line 761 "lombard.vala"
2356         view_media_engine_connect_output (MODEL_PROJECT (self->priv->project)->media_engine, VIEW_MEDIA_CONNECTOR (self->priv->video_output));
2357 #line 762 "lombard.vala"
2358         if (canceled) {
2359 #line 2297 "lombard.c"
2360                 char* _tmp0_;
2361 #line 763 "lombard.vala"
2362                 g_remove (_tmp0_ = view_ogg_vorbis_export_get_filename (self->priv->export_connector));
2363 #line 2301 "lombard.c"
2364                 _g_free0 (_tmp0_);
2365         }
2366 #line 765 "lombard.vala"
2367         self->priv->export_connector = (_tmp1_ = NULL, _g_object_unref0 (self->priv->export_connector), _tmp1_);
2368 #line 2306 "lombard.c"
2369 }
2370
2371
2372 #line 770 "lombard.vala"
2373 static void app_on_undo (App* self) {
2374 #line 770 "lombard.vala"
2375         g_return_if_fail (IS_APP (self));
2376 #line 771 "lombard.vala"
2377         model_project_undo (MODEL_PROJECT (self->priv->project));
2378 #line 2316 "lombard.c"
2379 }
2380
2381
2382 #line 774 "lombard.vala"
2383 static void app_on_delete (App* self) {
2384 #line 774 "lombard.vala"
2385         g_return_if_fail (IS_APP (self));
2386 #line 775 "lombard.vala"
2387         if (clip_library_view_has_selection (self->priv->library)) {
2388 #line 776 "lombard.vala"
2389                 clip_library_view_delete_selection (self->priv->library);
2390 #line 2328 "lombard.c"
2391         } else {
2392 #line 778 "lombard.vala"
2393                 time_line_delete_selection (self->priv->timeline);
2394 #line 2332 "lombard.c"
2395         }
2396 }
2397
2398
2399 #line 781 "lombard.vala"
2400 static void app_on_cut (App* self) {
2401 #line 781 "lombard.vala"
2402         g_return_if_fail (IS_APP (self));
2403 #line 782 "lombard.vala"
2404         time_line_do_cut (self->priv->timeline);
2405 #line 2343 "lombard.c"
2406 }
2407
2408
2409 #line 785 "lombard.vala"
2410 static void app_on_copy (App* self) {
2411 #line 785 "lombard.vala"
2412         g_return_if_fail (IS_APP (self));
2413 #line 786 "lombard.vala"
2414         time_line_do_copy (self->priv->timeline);
2415 #line 2353 "lombard.c"
2416 }
2417
2418
2419 #line 789 "lombard.vala"
2420 static void app_on_paste (App* self) {
2421 #line 789 "lombard.vala"
2422         g_return_if_fail (IS_APP (self));
2423 #line 790 "lombard.vala"
2424         time_line_paste (self->priv->timeline);
2425 #line 2363 "lombard.c"
2426 }
2427
2428
2429 #line 793 "lombard.vala"
2430 static void app_on_playstate_changed (App* self, PlayState playstate) {
2431 #line 793 "lombard.vala"
2432         g_return_if_fail (IS_APP (self));
2433 #line 794 "lombard.vala"
2434         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_playstate_changed");
2435 #line 795 "lombard.vala"
2436         if (playstate == PLAY_STATE_STOPPED) {
2437 #line 796 "lombard.vala"
2438                 app_update_menu (self);
2439 #line 2377 "lombard.c"
2440         }
2441 }
2442
2443
2444 #line 800 "lombard.vala"
2445 static void app_on_undo_changed (App* self, gboolean can_undo) {
2446 #line 2384 "lombard.c"
2447         GtkMenuItem* undo;
2448         gboolean _tmp0_ = FALSE;
2449 #line 800 "lombard.vala"
2450         g_return_if_fail (IS_APP (self));
2451 #line 801 "lombard.vala"
2452         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_undo_changed");
2453 #line 802 "lombard.vala"
2454         undo = GTK_MENU_ITEM (get_widget (self->priv->manager, "/MenuBar/EditMenu/EditUndo"));
2455 #line 803 "lombard.vala"
2456         g_assert (undo != NULL);
2457 #line 805 "lombard.vala"
2458         if (transport_delegate_is_stopped (TRANSPORT_DELEGATE (self))) {
2459 #line 805 "lombard.vala"
2460                 _tmp0_ = model_undo_manager_get_can_undo (MODEL_PROJECT (self->priv->project)->undo_manager);
2461 #line 2399 "lombard.c"
2462         } else {
2463 #line 805 "lombard.vala"
2464                 _tmp0_ = FALSE;
2465 #line 2403 "lombard.c"
2466         }
2467 #line 805 "lombard.vala"
2468         app_set_sensitive_group (self, self->priv->main_group, "Undo", _tmp0_);
2469 #line 2407 "lombard.c"
2470         _g_object_unref0 (undo);
2471 }
2472
2473
2474 #line 808 "lombard.vala"
2475 static void app_on_select_all (App* self) {
2476 #line 808 "lombard.vala"
2477         g_return_if_fail (IS_APP (self));
2478 #line 809 "lombard.vala"
2479         if (clip_library_view_has_selection (self->priv->library)) {
2480 #line 810 "lombard.vala"
2481                 clip_library_view_select_all (self->priv->library);
2482 #line 2420 "lombard.c"
2483         } else {
2484 #line 812 "lombard.vala"
2485                 time_line_select_all (self->priv->timeline);
2486 #line 2424 "lombard.c"
2487         }
2488 }
2489
2490
2491 #line 818 "lombard.vala"
2492 static void app_on_go_start (App* self) {
2493 #line 818 "lombard.vala"
2494         g_return_if_fail (IS_APP (self));
2495 #line 818 "lombard.vala"
2496         model_project_go_start (MODEL_PROJECT (self->priv->project));
2497 #line 2435 "lombard.c"
2498 }
2499
2500
2501 #line 820 "lombard.vala"
2502 static void app_on_go_end (App* self) {
2503 #line 820 "lombard.vala"
2504         g_return_if_fail (IS_APP (self));
2505 #line 820 "lombard.vala"
2506         model_project_go_end (MODEL_PROJECT (self->priv->project));
2507 #line 2445 "lombard.c"
2508 }
2509
2510
2511 #line 824 "lombard.vala"
2512 static void app_on_help_contents (App* self) {
2513 #line 2451 "lombard.c"
2514         GError * _inner_error_;
2515 #line 824 "lombard.vala"
2516         g_return_if_fail (IS_APP (self));
2517 #line 2455 "lombard.c"
2518         _inner_error_ = NULL;
2519         {
2520 #line 826 "lombard.vala"
2521                 gtk_show_uri (NULL, "http://trac.yorba.org/wiki/UsingLombard0.1", (guint32) 0, &_inner_error_);
2522 #line 2460 "lombard.c"
2523                 if (_inner_error_ != NULL) {
2524                         goto __catch8_g_error;
2525                 }
2526         }
2527         goto __finally8;
2528         __catch8_g_error:
2529         {
2530                 GError * e;
2531                 e = _inner_error_;
2532                 _inner_error_ = NULL;
2533                 {
2534                         _g_error_free0 (e);
2535                 }
2536         }
2537         __finally8:
2538         if (_inner_error_ != NULL) {
2539                 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);
2540                 g_clear_error (&_inner_error_);
2541                 return;
2542         }
2543 }
2544
2545
2546 #line 831 "lombard.vala"
2547 static void app_on_about (App* self) {
2548 #line 2486 "lombard.c"
2549         char* _tmp1_;
2550         char* _tmp0_;
2551 #line 831 "lombard.vala"
2552         g_return_if_fail (IS_APP (self));
2553 #line 832 "lombard.vala"
2554         gtk_show_about_dialog (GTK_WINDOW (self), "version", _tmp0_ = model_project_get_version (MODEL_PROJECT (self->priv->project)), "comments", "A video editor", "copyright", "Copyright 2009-2010 Yorba Foundation", "website", "http://www.yorba.org", "license", _tmp1_ = model_project_get_license (MODEL_PROJECT (self->priv->project)), "website-label", "Visit the Yorba web site", "authors", MODEL_PROJECT_authors, NULL);
2555 #line 2493 "lombard.c"
2556         _g_free0 (_tmp1_);
2557         _g_free0 (_tmp0_);
2558 }
2559
2560
2561 #line 843 "lombard.vala"
2562 static void app_on_save_graph (App* self) {
2563 #line 843 "lombard.vala"
2564         g_return_if_fail (IS_APP (self));
2565 #line 844 "lombard.vala"
2566         model_project_print_graph (MODEL_PROJECT (self->priv->project), GST_BIN (MODEL_PROJECT (self->priv->project)->media_engine->pipeline), "save_graph");
2567 #line 2505 "lombard.c"
2568 }
2569
2570
2571 #line 848 "lombard.vala"
2572 static gboolean app_real_is_recording (TransportDelegate* base) {
2573 #line 2511 "lombard.c"
2574         App * self;
2575         gboolean result = FALSE;
2576         self = APP (base);
2577         result = model_project_transport_is_recording (MODEL_PROJECT (self->priv->project));
2578 #line 849 "lombard.vala"
2579         return result;
2580 #line 2518 "lombard.c"
2581 }
2582
2583
2584 #line 852 "lombard.vala"
2585 static gboolean app_real_is_playing (TransportDelegate* base) {
2586 #line 2524 "lombard.c"
2587         App * self;
2588         gboolean result = FALSE;
2589         self = APP (base);
2590         result = model_project_transport_is_playing (MODEL_PROJECT (self->priv->project));
2591 #line 853 "lombard.vala"
2592         return result;
2593 #line 2531 "lombard.c"
2594 }
2595
2596
2597 #line 856 "lombard.vala"
2598 static gboolean app_real_is_stopped (TransportDelegate* base) {
2599 #line 2537 "lombard.c"
2600         App * self;
2601         gboolean result = FALSE;
2602         gboolean _tmp0_ = FALSE;
2603         self = APP (base);
2604 #line 857 "lombard.vala"
2605         if (transport_delegate_is_playing (TRANSPORT_DELEGATE (self))) {
2606 #line 857 "lombard.vala"
2607                 _tmp0_ = TRUE;
2608 #line 2546 "lombard.c"
2609         } else {
2610 #line 857 "lombard.vala"
2611                 _tmp0_ = transport_delegate_is_recording (TRANSPORT_DELEGATE (self));
2612 #line 2550 "lombard.c"
2613         }
2614         result = !_tmp0_;
2615 #line 857 "lombard.vala"
2616         return result;
2617 #line 2555 "lombard.c"
2618 }
2619
2620
2621 static void app_class_init (AppClass * klass) {
2622         app_parent_class = g_type_class_peek_parent (klass);
2623         g_type_class_add_private (klass, sizeof (AppPrivate));
2624         GTK_WIDGET_CLASS (klass)->key_press_event = app_real_key_press_event;
2625         G_OBJECT_CLASS (klass)->finalize = app_finalize;
2626 }
2627
2628
2629 static void app_transport_delegate_interface_init (TransportDelegateIface * iface) {
2630         app_transport_delegate_parent_iface = g_type_interface_peek_parent (iface);
2631         iface->is_recording = app_real_is_recording;
2632         iface->is_playing = app_real_is_playing;
2633         iface->is_stopped = app_real_is_stopped;
2634 }
2635
2636
2637 static void app_instance_init (App * self) {
2638         self->priv = APP_GET_PRIVATE (self);
2639         self->priv->center_time = (gint64) (-1);
2640         self->priv->vbox = NULL;
2641 }
2642
2643
2644 static void app_finalize (GObject* obj) {
2645         App * self;
2646         self = APP (obj);
2647         _g_object_unref0 (self->priv->drawing_area);
2648         _g_object_unref0 (self->priv->project);
2649         _g_object_unref0 (self->priv->video_output);
2650         _g_object_unref0 (self->priv->audio_output);
2651         _g_object_unref0 (self->priv->export_connector);
2652         _g_object_unref0 (self->priv->timeline);
2653         _g_object_unref0 (self->priv->library);
2654         _g_object_unref0 (self->priv->status_bar);
2655         _g_object_unref0 (self->priv->h_pane);
2656         _g_object_unref0 (self->priv->library_scrolled);
2657         _g_object_unref0 (self->priv->timeline_scrolled);
2658         _g_object_unref0 (self->priv->h_adjustment);
2659         _g_object_unref0 (self->priv->main_group);
2660         _g_object_unref0 (self->priv->vbox);
2661         _g_object_unref0 (self->priv->menubar);
2662         _g_object_unref0 (self->priv->manager);
2663         _g_free0 (self->priv->project_filename);
2664         _g_object_unref0 (self->priv->load_errors);
2665         G_OBJECT_CLASS (app_parent_class)->finalize (obj);
2666 }
2667
2668
2669 GType app_get_type (void) {
2670         static volatile gsize app_type_id__volatile = 0;
2671         if (g_once_init_enter (&app_type_id__volatile)) {
2672                 static const GTypeInfo g_define_type_info = { sizeof (AppClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) app_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (App), 0, (GInstanceInitFunc) app_instance_init, NULL };
2673                 static const GInterfaceInfo transport_delegate_info = { (GInterfaceInitFunc) app_transport_delegate_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
2674                 GType app_type_id;
2675                 app_type_id = g_type_register_static (GTK_TYPE_WINDOW, "App", &g_define_type_info, 0);
2676                 g_type_add_interface_static (app_type_id, TYPE_TRANSPORT_DELEGATE, &transport_delegate_info);
2677                 g_once_init_leave (&app_type_id__volatile, app_type_id);
2678         }
2679         return app_type_id__volatile;
2680 }
2681
2682
2683 #line 863 "lombard.vala"
2684 void _vala_main (char** args, int args_length1) {
2685 #line 2623 "lombard.c"
2686         GError * _inner_error_;
2687         GOptionContext* context;
2688         _inner_error_ = NULL;
2689 #line 864 "lombard.vala"
2690         debug_level = -1;
2691 #line 865 "lombard.vala"
2692         context = g_option_context_new (" [project file] - Create and edit movies");
2693 #line 867 "lombard.vala"
2694         g_option_context_add_main_entries (context, options, NULL);
2695 #line 868 "lombard.vala"
2696         g_option_context_add_group (context, gst_init_get_option_group ());
2697 #line 2635 "lombard.c"
2698         {
2699 #line 871 "lombard.vala"
2700                 g_option_context_parse (context, &args_length1, &args, &_inner_error_);
2701 #line 2639 "lombard.c"
2702                 if (_inner_error_ != NULL) {
2703                         goto __catch9_g_error;
2704                 }
2705         }
2706         goto __finally9;
2707         __catch9_g_error:
2708         {
2709                 GError * arg_error;
2710                 arg_error = _inner_error_;
2711                 _inner_error_ = NULL;
2712                 {
2713 #line 873 "lombard.vala"
2714                         fprintf (stderr, "%s\n" \
2715 "Run 'lombard --help' for a full list of available command line options" \
2716 ".", arg_error->message);
2717 #line 2653 "lombard.c"
2718                         _g_error_free0 (arg_error);
2719                         _g_option_context_free0 (context);
2720 #line 875 "lombard.vala"
2721                         return;
2722 #line 2658 "lombard.c"
2723                 }
2724         }
2725         __finally9:
2726         if (_inner_error_ != NULL) {
2727                 _g_option_context_free0 (context);
2728                 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);
2729                 g_clear_error (&_inner_error_);
2730                 return;
2731         }
2732 #line 877 "lombard.vala"
2733         gtk_init (&args_length1, &args);
2734 #line 2670 "lombard.c"
2735         {
2736                 char* project_file;
2737                 char* str;
2738                 gboolean _tmp3_ = FALSE;
2739                 ClassFactory* _tmp4_;
2740                 App* _tmp5_;
2741 #line 880 "lombard.vala"
2742                 g_set_application_name ("Lombard");
2743 #line 882 "lombard.vala"
2744                 app_dirs_init (args[0], _PROGRAM_NAME);
2745 #line 883 "lombard.vala"
2746                 gst_init (&args_length1, &args);
2747 #line 885 "lombard.vala"
2748                 if (args_length1 > 2) {
2749 #line 886 "lombard.vala"
2750                         fprintf (stderr, "usage: %s [project-file]\n", args[0]);
2751 #line 2687 "lombard.c"
2752                         _g_option_context_free0 (context);
2753 #line 887 "lombard.vala"
2754                         return;
2755 #line 2691 "lombard.c"
2756                 }
2757 #line 890 "lombard.vala"
2758                 project_file = NULL;
2759 #line 891 "lombard.vala"
2760                 if (args_length1 > 1) {
2761 #line 2697 "lombard.c"
2762                         char* _tmp0_;
2763 #line 892 "lombard.vala"
2764                         project_file = (_tmp0_ = g_strdup (args[1]), _g_free0 (project_file), _tmp0_);
2765 #line 2701 "lombard.c"
2766                         {
2767                                 char* _tmp1_;
2768                                 char* _tmp2_;
2769 #line 894 "lombard.vala"
2770                                 _tmp1_ = g_filename_from_uri (project_file, NULL, &_inner_error_);
2771 #line 2707 "lombard.c"
2772                                 if (_inner_error_ != NULL) {
2773                                         goto __catch11_g_error;
2774                                 }
2775 #line 894 "lombard.vala"
2776                                 project_file = (_tmp2_ = _tmp1_, _g_free0 (project_file), _tmp2_);
2777 #line 2713 "lombard.c"
2778                         }
2779                         goto __finally11;
2780                         __catch11_g_error:
2781                         {
2782                                 GError * e;
2783                                 e = _inner_error_;
2784                                 _inner_error_ = NULL;
2785                                 {
2786                                         _g_error_free0 (e);
2787                                 }
2788                         }
2789                         __finally11:
2790                         if (_inner_error_ != NULL) {
2791                                 _g_free0 (project_file);
2792                                 goto __catch10_g_error;
2793                         }
2794                 }
2795 #line 898 "lombard.vala"
2796                 str = g_strdup (g_getenv ("LOMBARD_DEBUG"));
2797 #line 899 "lombard.vala"
2798                 if (str != NULL) {
2799 #line 899 "lombard.vala"
2800                         _tmp3_ = g_utf8_get_char (g_utf8_offset_to_pointer (str, 0)) >= '1';
2801 #line 2737 "lombard.c"
2802                 } else {
2803 #line 899 "lombard.vala"
2804                         _tmp3_ = FALSE;
2805 #line 2741 "lombard.c"
2806                 }
2807 #line 899 "lombard.vala"
2808                 debug_enabled = _tmp3_;
2809 #line 900 "lombard.vala"
2810                 class_factory_set_class_factory (_tmp4_ = class_factory_new ());
2811 #line 2747 "lombard.c"
2812                 _class_factory_unref0 (_tmp4_);
2813 #line 901 "lombard.vala"
2814                 view_media_engine_can_run (&_inner_error_);
2815 #line 2751 "lombard.c"
2816                 if (_inner_error_ != NULL) {
2817                         _g_free0 (project_file);
2818                         _g_free0 (str);
2819                         goto __catch10_g_error;
2820                 }
2821 #line 903 "lombard.vala"
2822                 _tmp5_ = g_object_ref_sink (app_new (project_file, &_inner_error_));
2823 #line 2759 "lombard.c"
2824                 _g_object_unref0 (_tmp5_);
2825                 if (_inner_error_ != NULL) {
2826                         _g_free0 (project_file);
2827                         _g_free0 (str);
2828                         goto __catch10_g_error;
2829                 }
2830 #line 904 "lombard.vala"
2831                 gtk_main ();
2832 #line 2768 "lombard.c"
2833                 _g_free0 (project_file);
2834                 _g_free0 (str);
2835         }
2836         goto __finally10;
2837         __catch10_g_error:
2838         {
2839                 GError * e;
2840                 e = _inner_error_;
2841                 _inner_error_ = NULL;
2842                 {
2843                         char* _tmp6_;
2844 #line 906 "lombard.vala"
2845                         app_do_error_dialog ("Could not launch application", _tmp6_ = g_strdup_printf ("%s.", e->message));
2846 #line 2782 "lombard.c"
2847                         _g_free0 (_tmp6_);
2848                         _g_error_free0 (e);
2849                 }
2850         }
2851         __finally10:
2852         if (_inner_error_ != NULL) {
2853                 _g_option_context_free0 (context);
2854                 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);
2855                 g_clear_error (&_inner_error_);
2856                 return;
2857         }
2858         _g_option_context_free0 (context);
2859 }
2860
2861
2862 #line 863 "lombard.vala"
2863 int main (int argc, char ** argv) {
2864 #line 2800 "lombard.c"
2865         g_thread_init (NULL);
2866 #line 863 "lombard.vala"
2867         g_type_init ();
2868 #line 863 "lombard.vala"
2869         _vala_main (argv, argc);
2870 #line 863 "lombard.vala"
2871         return 0;
2872 #line 2808 "lombard.c"
2873 }
2874
2875
2876 static int _vala_strcmp0 (const char * str1, const char * str2) {
2877         if (str1 == NULL) {
2878                 return -(str1 != str2);
2879         }
2880         if (str2 == NULL) {
2881                 return str1 != str2;
2882         }
2883         return strcmp (str1, str2);
2884 }
2885
2886
2887
2888