formatter: Make the emit_loaded a real method and not a virtual method

+ Modify formatter subclasses accordingly

API:ges_formatter_emit_loaded

This API wasn't released so it could still be changed
This commit is contained in:
Thibault Saunier 2012-07-01 19:57:30 -04:00
parent 2d13b12878
commit b13942c5b5
3 changed files with 24 additions and 21 deletions

View file

@ -39,8 +39,8 @@
* Support for saving or loading new formats can be added by creating a subclass of * Support for saving or loading new formats can be added by creating a subclass of
* #GESFormatter and implement the various vmethods of #GESFormatterClass. * #GESFormatter and implement the various vmethods of #GESFormatterClass.
* *
* Note that subclasses should call project_loaded wen they are done loading * Note that subclasses should call ges_formatter_project_loaded when they are done
* a project. * loading a project.
**/ **/
#include <gst/gst.h> #include <gst/gst.h>
@ -76,9 +76,6 @@ static gboolean default_can_save_uri (const gchar * uri);
static void discovery_error_cb (GESTimeline * timeline, static void discovery_error_cb (GESTimeline * timeline,
GESTimelineFileSource * tfs, GError * error, GESFormatter * formatter); GESTimelineFileSource * tfs, GError * error, GESFormatter * formatter);
static gboolean project_loaded (GESFormatter * formatter,
GESTimeline * timeline);
enum enum
{ {
SOURCE_MOVED_SIGNAL, SOURCE_MOVED_SIGNAL,
@ -123,7 +120,6 @@ ges_formatter_class_init (GESFormatterClass * klass)
klass->load_from_uri = load_from_uri; klass->load_from_uri = load_from_uri;
klass->save_to_uri = save_to_uri; klass->save_to_uri = save_to_uri;
klass->update_source_uri = NULL; klass->update_source_uri = NULL;
klass->project_loaded = project_loaded;
} }
static void static void
@ -594,11 +590,22 @@ discovery_error_cb (GESTimeline * timeline,
} }
} }
static gboolean /*< protected >*/
project_loaded (GESFormatter * formatter, GESTimeline * timeline) /**
* ges_formatter_emit_loaded:
* @formatter: The #GESFormatter from which to emit the "project-loaded" signal
*
* Emits the "loaded" signal. This method should be called by sublasses when
* the project is fully loaded.
*
* Returns: %TRUE if the signale could be emitted %FALSE otherwize
*/
gboolean
ges_formatter_emit_loaded (GESFormatter * formatter)
{ {
GST_INFO_OBJECT (formatter, "Emit project loaded"); GST_INFO_OBJECT (formatter, "Emit project loaded");
g_signal_emit (formatter, ges_formatter_signals[LOADED_SIGNAL], 0, timeline); g_signal_emit (formatter, ges_formatter_signals[LOADED_SIGNAL], 0,
formatter->timeline);
return TRUE; return TRUE;
} }

View file

@ -140,7 +140,6 @@ typedef gboolean (*GESFormatterLoadedMethod) (GESFormatter *formatter,
* @save_to_uri: class method to serialize data to a URI * @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 * @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) * 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. * GES Formatter class. Override the vmethods to implement the formatter functionnality.
*/ */
@ -153,7 +152,6 @@ struct _GESFormatterClass {
GESFormatterLoadFromURIMethod load_from_uri; GESFormatterLoadFromURIMethod load_from_uri;
GESFormatterSaveToURIMethod save_to_uri; GESFormatterSaveToURIMethod save_to_uri;
GESFormatterSourceMovedMethod update_source_uri; GESFormatterSourceMovedMethod update_source_uri;
GESFormatterLoadedMethod project_loaded;
/*< private >*/ /*< private >*/
/* FIXME : formatter name */ /* FIXME : formatter name */
@ -188,6 +186,10 @@ gboolean
ges_formatter_update_source_uri (GESFormatter * formatter, ges_formatter_update_source_uri (GESFormatter * formatter,
GESTimelineFileSource * source, gchar * new_uri); GESTimelineFileSource * source, gchar * new_uri);
/*< protected >*/
gboolean
ges_formatter_emit_loaded (GESFormatter * formatter);
/* Non-standard methods. WILL BE DEPRECATED */ /* Non-standard methods. WILL BE DEPRECATED */
gboolean ges_formatter_load (GESFormatter * formatter, gboolean ges_formatter_load (GESFormatter * formatter,
GESTimeline * timeline); GESTimeline * timeline);

View file

@ -807,12 +807,8 @@ track_object_added_cb (GESTimelineObject * object,
g_hash_table_steal (props_table, "current-formatter"); g_hash_table_steal (props_table, "current-formatter");
priv->sources_to_load = g_list_remove (priv->sources_to_load, object); priv->sources_to_load = g_list_remove (priv->sources_to_load, object);
if (!priv->sources_to_load) { if (!priv->sources_to_load)
GESFormatterClass *klass = GES_FORMATTER_GET_CLASS (formatter); ges_formatter_emit_loaded (GES_FORMATTER (formatter));
klass->project_loaded (GES_FORMATTER (formatter),
GES_FORMATTER (formatter)->timeline);
}
} }
if (lockedstr && !g_strcmp0 (lockedstr, "(bool)False")) if (lockedstr && !g_strcmp0 (lockedstr, "(bool)False"))
@ -909,7 +905,7 @@ make_source (GESFormatter * self, GList * reflist, GHashTable * source_table)
if (!(layer = g_hash_table_lookup (priv->layers_table, &prio))) { if (!(layer = g_hash_table_lookup (priv->layers_table, &prio))) {
layer = ges_timeline_layer_new (); layer = ges_timeline_layer_new ();
g_object_set (layer, "auto-transition", TRUE, "priority", prio, NULL); g_object_set (layer, "auto-transition", TRUE, "priority", prio, NULL);
ges_timeline_add_layer (priv->timeline, layer); ges_timeline_add_layer (self->timeline, layer);
g_hash_table_insert (priv->layers_table, g_memdup (&prio, g_hash_table_insert (priv->layers_table, g_memdup (&prio,
sizeof (guint64)), layer); sizeof (guint64)), layer);
} }
@ -1106,9 +1102,7 @@ load_pitivi_file_from_uri (GESFormatter * self,
* 'project-loaded' signal. * 'project-loaded' signal.
*/ */
if (!g_hash_table_size (priv->timeline_objects_table)) { if (!g_hash_table_size (priv->timeline_objects_table)) {
GESFormatterClass *klass = GES_FORMATTER_GET_CLASS (self); ges_formatter_emit_loaded (self);
klass->project_loaded (self, self->timeline);
} else { } else {
if (!make_timeline_objects (self)) { if (!make_timeline_objects (self)) {
GST_ERROR ("Couldn't deserialise the project properly"); GST_ERROR ("Couldn't deserialise the project properly");