Author: jackson
Date: 2007-08-24 15:47:27 -0400 (Fri, 24 Aug 2007)
New Revision: 84818

Modified:
   trunk/moon/plugin/ChangeLog
   trunk/moon/plugin/plugin-class.cpp
   trunk/moon/plugin/plugin-class.h
Log:

                * plugin-class.cpp|h: Add a new EventListenerObject that
                * we can
        return from addEventListener.
        - Implement removeEventListener.



Modified: trunk/moon/plugin/ChangeLog
===================================================================
--- trunk/moon/plugin/ChangeLog 2007-08-24 19:03:20 UTC (rev 84817)
+++ trunk/moon/plugin/ChangeLog 2007-08-24 19:47:27 UTC (rev 84818)
@@ -1,5 +1,11 @@
 2007-08-24  Jackson Harper  <[EMAIL PROTECTED]>
 
+       * plugin-class.cpp|h: Add a new EventListenerObject that we can
+       return from addEventListener.
+       - Implement removeEventListener.
+
+2007-08-24  Jackson Harper  <[EMAIL PROTECTED]>
+
        * plugin-class.cpp|h: Now that getPosition works as intended, we
        don't need to store the position as an NPObject on the
        MouseEventArgs.

Modified: trunk/moon/plugin/plugin-class.cpp
===================================================================
--- trunk/moon/plugin/plugin-class.cpp  2007-08-24 19:03:20 UTC (rev 84817)
+++ trunk/moon/plugin/plugin-class.cpp  2007-08-24 19:47:27 UTC (rev 84818)
@@ -328,6 +328,28 @@
        proxy->AddHandler (obj);
 }
 
+static NPObject*
+event_listener_allocate (NPP instance, NPClass *)
+{
+       return new MoonlightEventListenerObject (instance);
+}
+
+static void
+event_listener_deallocate (NPObject *npobject)
+{
+       delete (MoonlightEventListenerObject *) npobject;
+}
+
+
+MoonlightEventListenerType::MoonlightEventListenerType ()
+{
+       allocate = event_listener_allocate;
+       deallocate = event_listener_deallocate;
+}
+
+MoonlightEventListenerType *MoonlightEventListenerClass;
+
+
 /*** ErrorEventArgs ***/
 static NPObject*
 erroreventargs_allocate (NPP instance, NPClass *)
@@ -1786,11 +1808,24 @@
 
                g_free (name);
 
+               MoonlightEventListenerObject *res = 
(MoonlightEventListenerObject *) NPN_CreateObject 
(((MoonlightObject*)npobj)->instance,
+                                                                               
                   MoonlightEventListenerClass);
+               res->proxy = proxy;
+               res->target = dob;
+
+               OBJECT_TO_NPVARIANT (res, *result);
                return true;
        }
        else if (name_matches (name, "removeEventListener")) {
-               // not yet implemented
-               DEBUG_WARN_NOTIMPLEMENTED ("do.removeEventListener");
+               if (argCount < 2)
+                       return false;
+
+               if (!NPVARIANT_IS_OBJECT (args [1]))
+                       return true;
+
+               MoonlightEventListenerObject *res = 
(MoonlightEventListenerObject *) NPVARIANT_TO_OBJECT (args [1]);
+               res->proxy->RemoveHandler (res->target);
+
                return true;
        }
        // XXX these next two methods should live in a UIElement
@@ -3227,5 +3262,6 @@
        MoonlightPointClass = new MoonlightPointType ();
        MoonlightDurationClass = new MoonlightDurationType ();
        MoonlightTimeSpanClass = new MoonlightTimeSpanType ();
+       MoonlightEventListenerClass = new MoonlightEventListenerType ();
 }
 

Modified: trunk/moon/plugin/plugin-class.h
===================================================================
--- trunk/moon/plugin/plugin-class.h    2007-08-24 19:03:20 UTC (rev 84817)
+++ trunk/moon/plugin/plugin-class.h    2007-08-24 19:47:27 UTC (rev 84818)
@@ -23,7 +23,7 @@
 /*** EventListenerProxy */
 typedef void (*EventArgsWrapper)(NPP instance, gpointer calldata, NPVariant 
*value);
 
-class EventListenerProxy {
+class EventListenerProxy : public List::Node {
  public:
        EventListenerProxy (NPP instance, const char *event_name, const char 
*cb_name);
        EventListenerProxy (NPP instance, const char *event_name, const 
NPVariant *cb);
@@ -74,6 +74,20 @@
        Type::Kind moonlight_type;
 };
 
+/*** MoonlightEventListenerObject 
******************************************************/
+struct MoonlightEventListenerType : MoonlightObjectType {
+       MoonlightEventListenerType ();
+};
+
+extern MoonlightEventListenerType* MoonlightEventListenerClass;
+
+struct MoonlightEventListenerObject : MoonlightObject {
+       MoonlightEventListenerObject (NPP instance) : MoonlightObject 
(instance), proxy (NULL), target (NULL) { }
+
+       EventListenerProxy *proxy;
+       EventObject *target;
+};
+
 /*** MoonlightErrorEventArgsClass 
******************************************************/
 struct MoonlightErrorEventArgsType : MoonlightObjectType {
        MoonlightErrorEventArgsType ();

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to