control/tree.c: Notify subtree/addition removal.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 20 Aug 2007 02:29:34 +0000 (02:29 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 20 Aug 2007 02:29:34 +0000 (02:29 +0000)
include/vlc/libvlc_structures.h
src/control/tree.c

index 54c5b86..8297f9b 100644 (file)
@@ -307,6 +307,10 @@ typedef enum libvlc_event_type_t {
     libvlc_MediaListItemDeleted,
     libvlc_MediaListItemChanged,
 
+    libvlc_TreeSubtreeAdded,
+    libvlc_TreeSubtreeDeleted,
+    libvlc_TreeItemValueChanged,
+
 } libvlc_event_type_t;
 
 /**
@@ -348,6 +352,23 @@ typedef struct libvlc_event_t
             libvlc_media_descriptor_t * item;
             int index;
         } media_list_item_changed;
+
+        /* Tree */
+        struct
+        {
+            libvlc_tree_t * subtree;
+            int index;
+        } tree_subtree_added;
+        struct
+        {
+            libvlc_tree_t * subtree;
+            int index;
+        } tree_subtree_deleted;
+        struct
+        {
+            void * new_value;
+        } tree_item_value_changed;
+
     } u;
 } libvlc_event_t;
 
index 913b434..f9f0c26 100644 (file)
@@ -40,7 +40,15 @@ notify_subtree_addition( libvlc_tree_t * p_tree,
                          libvlc_tree_t * p_subtree,
                          int index )
 {
+    libvlc_event_t event;
 
+    /* Construct the event */
+    event.type = libvlc_TreeSubtreeAdded;
+    event.u.tree_subtree_added.subtree = p_subtree;
+    event.u.tree_subtree_added.index = index;
+
+    /* Send the event */
+    libvlc_event_send( p_tree->p_event_manager, &event );
 }
 
 /**************************************************************************
@@ -53,9 +61,39 @@ notify_subtree_deletion( libvlc_tree_t * p_tree,
                          libvlc_tree_t * p_subtree,
                          int index )
 {
+    libvlc_event_t event;
+
+    /* Construct the event */
+    event.type = libvlc_TreeSubtreeDeleted;
+    event.u.tree_subtree_deleted.subtree = p_subtree;
+    event.u.tree_subtree_deleted.index = index;
 
+    /* Send the event */
+    libvlc_event_send( p_tree->p_event_manager, &event );
 }
 
+#ifdef NOT_USED
+/**************************************************************************
+ *       notify_tree_item_value_changed (private)
+ *
+ * Do the appropriate action when a tree's item changes.
+ **************************************************************************/
+static void
+notify_tree_item_value_changed( libvlc_tree_t * p_tree,
+                                libvlc_tree_t * p_subtree,
+                                int index )
+{
+    libvlc_event_t event;
+
+    /* Construct the event */
+    event.type = libvlc_TreeItemValueChanged;
+    event.u.tree_item_value_changed.new_value = p_tree->p_item;
+
+    /* Send the event */
+    libvlc_event_send( p_tree->p_event_manager, &event );
+}
+#endif
+
 /**************************************************************************
  *       new (Private)
  **************************************************************************/
@@ -76,6 +114,15 @@ libvlc_tree_new( libvlc_retain_function item_retain,
     p_tree->i_refcount = 1;
     p_tree->p_item = item;
     ARRAY_INIT( p_tree->subtrees );
+    
+    p_tree->p_event_manager = libvlc_event_manager_new( p_tree, NULL, p_e );
+    libvlc_event_manager_register_event_type( p_tree->p_event_manager,
+            libvlc_TreeSubtreeAdded, p_e );
+    libvlc_event_manager_register_event_type( p_tree->p_event_manager,
+            libvlc_TreeSubtreeDeleted, p_e );
+    libvlc_event_manager_register_event_type( p_tree->p_event_manager,
+            libvlc_TreeItemValueChanged, p_e );
+
        return p_tree;
 }