diff m_property.h @ 23393:a5e55cb59bbc

Rework the property API to allow sub properties such as metadata/title, etc.
author albeu
date Tue, 29 May 2007 21:49:39 +0000
parents a5e5b0c45c03
children d4e8613ddc95
line wrap: on
line diff
--- a/m_property.h	Tue May 29 18:52:20 2007 +0000
+++ b/m_property.h	Tue May 29 21:49:39 2007 +0000
@@ -48,6 +48,32 @@
  */
 #define M_PROPERTY_STEP_DOWN   5
 
+/// Get a string containg a parsable representation.
+/** Set the variable to a newly allocated string or NULL.
+ *  \param arg Pointer to a char* variable.
+ */
+#define M_PROPERTY_TO_STRING   6
+
+/// Pass down an action to a sub-property.
+#define M_PROPERTY_KEY_ACTION  7
+
+/// Get a m_option describing the property.
+#define M_PROPERTY_GET_TYPE    8
+
+///@}
+
+/// \defgroup PropertyActionsArg Property actions argument type
+/// \ingroup Properties
+/// \brief  Types used as action argument.
+///@{
+
+/// Argument for \ref M_PROPERTY_KEY_ACTION
+typedef struct {
+    const char* key;
+    int action;
+    void* arg;
+} m_property_action_t;
+
 ///@}
 
 /// \defgroup PropertyActionsReturn Property actions return code
@@ -81,25 +107,14 @@
 typedef int(*m_property_ctrl_f)(m_option_t* prop,int action,void* arg,void *ctx);
 
 /// Do an action on a property.
-/** \param prop The property.
+/** \param prop_list The list of properties.
+ *  \param prop The path of the property.
  *  \param action See \ref PropertyActions.
  *  \param arg Argument, usually a pointer to the data type used by the property.
  *  \return See \ref PropertyActionsReturn.
  */
-int m_property_do(m_option_t* prop, int action, void* arg, void *ctx);
-
-/// Print the current value of a property.
-/** \param prop The property.
- *  \return A newly allocated string with the current value or NULL on error.
- */
-char* m_property_print(m_option_t* prop, void *ctx);
-
-/// Set a property.
-/** \param prop The property.
- *  \param txt The value to set.
- *  \return 1 on success, 0 on error.
- */
-int m_property_parse(m_option_t* prop, char* txt, void *ctx);
+int m_property_do(m_option_t* prop_list, const char* prop,
+                  int action, void* arg, void *ctx);
 
 /// Print a list of properties.
 void m_properties_print_help_list(m_option_t* list);
@@ -119,12 +134,12 @@
 
 // Helpers to use MPlayer's properties
 
-/// Get an MPlayer property.
-m_option_t*  mp_property_find(const char* name);
-
 /// Do an action with an MPlayer property.
 int mp_property_do(const char* name,int action, void* val, void *ctx);
 
+/// Get the value of a property as a string suitable for display in an UI.
+char* mp_property_print(const char *name, void* ctx);
+
 /// \defgroup PropertyImplHelper Property implementation helpers
 /// \ingroup Properties
 /// \brief Helper functions for common property types.