2008-05-28 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / pyatspi / event.py
index 9b9295f..4c581bd 100644 (file)
@@ -140,8 +140,11 @@ class Event(object):
     # store the event source and increase the reference count since event 
     # sources are borrowed references; the AccessibleMixin automatically
     # decrements it later
+    try:
+      event.source.ref()
+    except AttributeError:
+      pass
     self.source = event.source
-    self.source.ref()
 
     # process any_data in a at-spi version independent manner
     details = event.any_data.value()
@@ -165,6 +168,11 @@ class Event(object):
       self.any_data.ref()
     except AttributeError:
       pass
+    try:
+      # if we received a host application, be sure to increment the ref count
+      self.host_application.ref()
+    except AttributeError:
+      pass
 
   def __str__(self):
     '''
@@ -178,7 +186,7 @@ class Event(object):
            (self.type, self.detail1, self.detail2, self.any_data,
             self.source, self.host_application)
   
-class EventType(object):
+class EventType(str):
   '''
   Wraps the AT-SPI event type string so its components can be accessed 
   individually as klass (can't use the keyword class), major, minor, and detail 
@@ -212,23 +220,17 @@ class EventType(object):
     @raise AttributeError: When the given event name is not a valid string 
     '''
     # get rid of any leading and trailing ':' separators
-    self.name = name.strip(':')
+    self.value = name.strip(':')
+    self.name = self.value # Backward compatability
     self.klass = None
     self.major = None
     self.minor = None
     self.detail = None
     
     # split type according to delimiters
-    split = self.name.split(':')
+    split = self.value.split(':', 3)
     # loop over all the components
     for i in xrange(len(split)):
       # store values of attributes in this object
       setattr(self, self.format[i], split[i])
       
-  def __str__(self):
-    '''
-    @return: Full event name as human readable representation of this event 
-      type
-    @rtype: string
-    '''
-    return self.name