From f5c861ddc365f962098b90313337b3f54d19d86e Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sat, 7 Jan 2012 13:28:15 -0300 Subject: [PATCH] formatter: Add a "loaded" signal API: GESFormatter::loaded signal API: GESFormatter->project_loaded VMethod --- docs/libs/ges-sections.txt | 1 + ges/ges-formatter.c | 25 +++++++++++++++++++++++++ ges/ges-formatter.h | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index 6e99045..6fdd8ea 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -753,6 +753,7 @@ GESFormatterClass GESFormatterLoadFromURIMethod GESFormatterSaveToURIMethod GESFormatterSourceMovedMethod +GESFormatterLoadedMethod ges_default_formatter_new ges_formatter_load_from_uri ges_formatter_save_to_uri diff --git a/ges/ges-formatter.c b/ges/ges-formatter.c index 43993a5..0daa653 100644 --- a/ges/ges-formatter.c +++ b/ges/ges-formatter.c @@ -38,6 +38,9 @@ * * Support for saving or loading new formats can be added by creating a subclass of * #GESFormatter and implement the various vmethods of #GESFormatterClass. + * + * Note that subclasses should call project_loaded wen they are done loading + * a project. **/ #include @@ -71,9 +74,13 @@ static gboolean default_can_save_uri (const gchar * uri); static void discovery_error_cb (GESTimeline * timeline, GESTimelineFileSource * tfs, GError * error, GESFormatter * formatter); +static gboolean project_loaded (GESFormatter * formatter, + GESTimeline * timeline); + enum { SOURCE_MOVED_SIGNAL, + LOADED_SIGNAL, LAST_SIGNAL }; @@ -98,6 +105,15 @@ ges_formatter_class_init (GESFormatterClass * klass) G_SIGNAL_RUN_LAST, 0, NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TIMELINE_FILE_SOURCE); + /** + * GESFormatter::loaded: + * @formatter: the #GESFormatter that is done loading a project. + */ + ges_formatter_signals[LOADED_SIGNAL] = + g_signal_new ("loaded", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, + 1, GES_TYPE_TIMELINE); + object_class->dispose = ges_formatter_dispose; klass->can_load_uri = default_can_load_uri; @@ -105,6 +121,7 @@ ges_formatter_class_init (GESFormatterClass * klass) klass->load_from_uri = load_from_uri; klass->save_to_uri = save_to_uri; klass->update_source_uri = NULL; + klass->project_loaded = project_loaded; } static void @@ -535,3 +552,11 @@ discovery_error_cb (GESTimeline * timeline, tfs); } } + +static gboolean +project_loaded (GESFormatter * formatter, GESTimeline * timeline) +{ + g_signal_emit (formatter, ges_formatter_signals[LOADED_SIGNAL], 0, timeline); + + return TRUE; +} diff --git a/ges/ges-formatter.h b/ges/ges-formatter.h index 0d00358..2cc6dda 100644 --- a/ges/ges-formatter.h +++ b/ges/ges-formatter.h @@ -118,6 +118,17 @@ typedef gboolean (*GESFormatterSourceMovedMethod) (GESFormatter *formatte GESTimelineFileSource *tfs, gchar *new_uri); /** + * GESFormatterLoadedMethod + * @formatter: The #GESFormatter that is done loading + * @timeline: The #GESTimeline that has finnished to load + * + * This method should be called by sublcasses when they are done + * loading @timeline + */ +typedef gboolean (*GESFormatterLoadedMethod) (GESFormatter *formatter, + GESTimeline *timeline); + +/** * GESFormatterClass: * @parent_class: the parent class structure * @can_load_uri: Whether the URI can be loaded @@ -126,6 +137,7 @@ typedef gboolean (*GESFormatterSourceMovedMethod) (GESFormatter *formatte * @save_to_uri: class method to serialize data to a URI * @update_source_uri: virtual method to specify that a source has moved, and thus its URI * must be set to its new location (specified by the user) + * @project_loaded: Must be called by subclasses when done loading a project * * GES Formatter class. Override the vmethods to implement the formatter functionnality. */ @@ -138,6 +150,7 @@ struct _GESFormatterClass { GESFormatterLoadFromURIMethod load_from_uri; GESFormatterSaveToURIMethod save_to_uri; GESFormatterSourceMovedMethod update_source_uri; + GESFormatterLoadedMethod project_loaded; /*< private >*/ /* FIXME : formatter name */ -- 2.7.4