From a35094f1b3e50aa785e27a7b0d2756df1d48b8d6 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 12 Dec 2014 21:38:26 +0100 Subject: [PATCH] preset: add gst_preset_is_editable() Add a function to check if the preset iface implementation is editable and document this from the implementers perspective. API: gst_preset_is_editable() --- gst/gstpreset.c | 21 +++++++++++++++++++++ gst/gstpreset.h | 1 + 2 files changed, 22 insertions(+) diff --git a/gst/gstpreset.c b/gst/gstpreset.c index d595abcd27..6953508a06 100644 --- a/gst/gstpreset.c +++ b/gst/gstpreset.c @@ -34,6 +34,9 @@ * native preset format of those wrapped plugins. * One method that is useful to be overridden is gst_preset_get_property_names(). * With that one can control which properties are saved and in which order. + * When implementing support for read-only presets, one should set the vmethods + * for gst_preset_save_preset() and gst_preset_delete_preset() to %NULL. + * Applications can use gst_preset_is_editable() to check for that. * * The default implementation supports presets located in a system directory, * application specific directory and in the users home directory. When getting @@ -1148,6 +1151,24 @@ gst_preset_get_app_dir (void) return preset_app_dir; } +/** + * gst_preset_is_editable: + * @preset: a #GObject that implements #GstPreset + * + * Check if one can add new presets, change existing ones and remove presets. + * + * Returns: %TRUE if presets are editable or %FALSE if they are static + * + * Since: 1.6 + */ +gboolean +gst_preset_is_editable (GstPreset * preset) +{ + GstPresetInterface *iface = GST_PRESET_GET_INTERFACE (preset); + + return iface->save_preset && iface->delete_preset; +} + /* class internals */ static void diff --git a/gst/gstpreset.h b/gst/gstpreset.h index 8e3ea2a557..178eccd245 100644 --- a/gst/gstpreset.h +++ b/gst/gstpreset.h @@ -97,6 +97,7 @@ gboolean gst_preset_get_meta (GstPreset *preset, const gchar *name gboolean gst_preset_set_app_dir (const gchar *app_dir); const gchar *gst_preset_get_app_dir (void); +gboolean gst_preset_is_editable (GstPreset *preset); G_END_DECLS #endif /* __GST_PRESET_H__ */