Commits

Bob Ippolito committed 252e0b1

Fix plugin bug, should be done as a "1.3.6" release.. doh

Comments (0)

Files changed (8)

Examples/Plugins/ProgressViewPalette/ProgressCell.py

     """
     # float   percentageIncrement;
     # float   percentage;
-    # NSView *controlView;
     # NSColor *color;
-    # int     tag;
 
     def init(self):
         self = super(ProgressCell, self).init()
-        if self is None: return None
-
+        if self is None:
+            return None
         self._color = NSColor.redColor()
+        self._controlView = None
         self._percentageIncrement = 5.0
         self._percentage = 0.0
         self._tag = 0
         NSColor.controlDarkShadowColor().set()
         NSFrameRect(cellFrame)
 
+    def tag(self):
+        return self._tag
+
+    def setTag_(self, value):
+        self._tag = value
+
     def controlView(self):
         return self._controlView
 
-    def setControlView_(self, view):
-        self._controlView = view
-
-    def tag(self):
-        return self._tag
-    tag = objc.selector(tag, signature='i@:')
-
-    def setTag_(self, tag):
-        self._tag = tag
-    setTag_ = objc.selector(setTag_, signature='v@:i')
+    def setControlView_(self, value):
+        self._controlView = value
 
     def percentageIncrement(self):
         return self._percentageIncrement
         return self._percentage
 
     def setPercentage_(self, value):
-        if value > 100: value = 100
-        if value < 0: value = 0
+        value = max(0, min(value, 100))
 
         if self._percentage != value:
             self._percentage = value
-            self.controlView.updateCellInside_(self)
+            self.controlView().updateCellInside_(self)
 
     def color(self):
         return self._color
 
-    def setColor(self, value):
+    def setColor_(self, value):
         self._color = value
-        self.controlView.updateCellInside_(self)
+        self.controlView().updateCellInside_(self)
 
     def increment_(self, sender):
         self.setPercentage_(self.percentage() + self.percentageIncrement())
 
     def initWithCoder_(self, coder):
         self = super(ProgressCell, self).initWithCoder_(coder)
-        if self is None: return None
+        if self is None:
+            return None
 
         if coder.allowsKeyedCoding():
             self._percentageIncrement = coder.decodeFloatForKey_(
                     "percentageIncrement")
             self._percentage = coder.decodeFloatForKey_("percentage")
-            self._tag = coder.decodeFloatForKey_("tag")
+            self.setTag_(coder.decodeFloatForKey_("tag"))
             self._color = coder.decodeObjectForKey_("color")
         else:
             self._percentageIncrement = coder.decodeValueOfObjCType_at_("f")
             self._percentage = coder.decodeValueOfObjCType_at_("f")
-            self._tag = coder.decodeValueOfObjCType_at_("f")
+            self.setTag_(coder.decodeValueOfObjCType_at_("i"))
             self._color = coder.decodeObject()
         return self;
 
 
         if (coder.allowsKeyedCoding()):
             coder.encodeFloat_forKey_(
-                    self._percentageIncrement, "percentageIncrement")
-            coder.encodeFloat_forKey_(self._percentage, "percentage")
-            coder.encodeFloat_forKey_(self._tag, "tag")
-            coder.encodeObject_forKey_(self._color, "color")
+                    self.percentageIncrement(), "percentageIncrement")
+            coder.encodeFloat_forKey_(self.percentage(), "percentage")
+            coder.encodeFloat_forKey_(self.tag(), "tag")
+            coder.encodeObject_forKey_(self.color(), "color")
         else:
-            coder.encodeValueOfObjCType_at_("f", self._percentageIncrement)
-            coder.encodeValueOfObjCType_at_("f", self._percentage)
-            coder.encodeValueOfObjCType_at_("f", self._tag)
-            coder.encodeObject_(self._color)
+            coder.encodeValueOfObjCType_at_("f", self.percentageIncrement())
+            coder.encodeValueOfObjCType_at_("f", self.percentage())
+            coder.encodeValueOfObjCType_at_("i", self.tag())
+            coder.encodeObject_(self.color())

Examples/Plugins/ProgressViewPalette/ProgressView.py

     A simple progress view
     """
 
-
     def percentageIncrement(self):
         return self.cell().percentageIncrement()
 
-    def setPercentageIncrement(self, value):
+    def setPercentageIncrement_(self, value):
         self.cell().setPercentageIncrement_(value)
 
     def percentage(self):

Examples/Plugins/ProgressViewPalette/ProgressViewInspector.py

 from AppKit import *
 from Foundation import *
 from InterfaceBuilder import *
-from objc import IBOutlet, selector
+import objc
 
-class ProgressViewInspector (IBInspector):
-    slider = IBOutlet('slider')
-    textField = IBOutlet('textField')
-    colorWell = IBOutlet('colorWell')
+class ProgressViewInspector(IBInspector):
+    slider = objc.IBOutlet('slider')
+    textField = objc.IBOutlet('textField')
+    colorWell = objc.IBOutlet('colorWell')
 
     def init(self):
         self = super(ProgressViewInspector, self).init()
-        if self is None: return None
+        if self is None:
+            return None
 
         if not NSBundle.loadNibNamed_owner_("ProgressViewInspector", self):
             NSLog("Couldn't load ProgressViewInspector.nib")
         Modify object state
         """
         if sender is self.slider:
-            self.object().setPercentageIncrement_(sender.initValue())
+            self.object().setPercentageIncrement_(sender.intValue())
             self.textField.setIntValue_(sender.intValue())
         elif sender is self.textField:
             self.object().setPercentageIncrement_(sender.floatValue())
             self.slider.setFloatValue_(sender.floatValue())
-
-        self.object().setColor_(self.colorWell.color())
+        elif sender is self.colorWell:
+            self.object().setColor_(self.colorWell.color())
         super(ProgressViewInspector, self).ok_(sender)
 
     def revert_(self, sender):
         percentageIncrement = self.object().percentageIncrement()
         self.slider.setFloatValue_(percentageIncrement)
         self.textField.setFloatValue_(percentageIncrement)
-        self.colorWell.setColor-(self.object().color())
+        self.colorWell.setColor_(self.object().color())
         super(ProgressViewInspector, self).revert_(sender)
 
     def wantsButtons(self):

Examples/Plugins/ProgressViewPalette/ProgressViewPalette.py

 from InterfaceBuilder import *
 from ProgressView import ProgressView
 from ProgressCell import ProgressCell
+from ProgressViewInspector import ProgressViewInspector
 #import pprint, os
 
 #objc.setVerbose(1) ### DEBUG
 
     def init(self):
         self = super(ProgressViewPalette, self).init()
-        if self is None: return None
+        if self is None:
+            return None
 
         NSView.registerViewResourceDraggingDelegate_(self)
         return self
     def viewResourcePasteboardTypes(self):
         return [NSColorPboardType]
 
-    def acceptsViewResourceFromPasteboard_forObjeect_atPoint_(self,
+    def acceptsViewResourceFromPasteboard_forObject_atPoint_(self,
             pasteboard, object, point):
 
         if NSColorPboardType in pasteboard.types():
     def inspectorClassName(self):
         return u'ProgressViewInspector'
 
-def ibMatchPrototype_(self, prototype):
-    super(ProgressCell, self).ibMatchPrototype_(prototype)
-    self.setPercentageIncrement_(prototype.percentageIncrement())
-
-objc.removeAutoreleasePool()
+    def ibMatchPrototype_(self, prototype):
+        super(ProgressCell, self).ibMatchPrototype_(prototype)
+        self.setPercentageIncrement_(prototype.percentageIncrement())

Modules/objc/objc-class.m

 	char* name;
 	PyObject* bases;
 	PyObject* dict;
+	PyObject* old_dict;
 	PyObject* res;
+	PyObject* k;
 	PyObject* v;
 	int       i;
 	int       len;
 	Class	   super_class = NULL;
 	PyObject*  py_super_class = NULL;
 	PyObjCClassObject* info;
+	PyObject* keys;
 	PyObject* protocols;
 	PyObject* real_bases;
 	PyObject* delmethod;
 	 * call to super-class implementation, because '__*' methods
 	 * are treated specially there.
 	 */
-	if (add_convenience_methods(objc_class, dict) < 0) {
+	old_dict = PyDict_Copy(dict);
+	if (old_dict == NULL) {
 		(void)PyObjCClass_UnbuildClass(objc_class);
 		Py_DECREF(protocols);
 		Py_DECREF(real_bases);
 		return NULL;
 	}
+		
+	if (add_convenience_methods(objc_class, dict) < 0) {
+		(void)PyObjCClass_UnbuildClass(objc_class);
+		Py_DECREF(old_dict);
+		Py_DECREF(protocols);
+		Py_DECREF(real_bases);
+		return NULL;
+	}
+
+
 
 	/* call super-class implementation */
 	args = Py_BuildValue("(sOO)", name, real_bases, dict);
 	if (res == NULL) {
 		Py_DECREF(args);
 		Py_DECREF(real_bases);
+		Py_DECREF(protocols);
+		Py_DECREF(old_dict);
 		(void)PyObjCClass_UnbuildClass(objc_class);
 		return NULL;
 	}
 
 	if (objc_class_register(objc_class, res) < 0) {
 		Py_DECREF(res);
+		Py_DECREF(old_dict);
 		(void)PyObjCClass_UnbuildClass(objc_class);
 		return NULL;
 	}
 		info->useKVO = PyObject_IsTrue(useKVOObj);
 	}
 
+
+	keys = PyDict_Keys(dict);
+	if (keys == NULL) {
+		Py_DECREF(old_dict);
+		return NULL;
+	}
+	
+	/* Merge the "difference" to pick up new selectors */
+	len = PyList_GET_SIZE(keys);
+	for (i=0; i < len; i++) {
+		k = PyList_GET_ITEM(keys, i);
+		if (PyDict_GetItem(old_dict, k) == NULL) {
+			v = PyDict_GetItem(dict, k);
+			if (v != NULL && PyObject_SetAttr(res, k, v) == -1) {
+				PyErr_Clear();
+			}
+		}
+	}
+	Py_DECREF(keys);
+	Py_DECREF(old_dict);
+	
+	/* This is an "extra" ref */
 	Py_INCREF(res);
 	return res;
 }

Modules/objc/pyobjc.h

  * Central include file for PyObjC. 
  */
 
-#define OBJC_VERSION "1.3.9"
+#define OBJC_VERSION "1.3.6"
 
 // Loading in AppKit on Mac OS X 10.3 results in
 // a bit less than 1500 classes.
 <body>
 <h2>PyObjC NEWS</h2>
 <p>An overview of the relevant changes in new, and older, releases.</p>
-<h2><a name="version-1-4-2005">Version 1.4 (2005-??-??)</a></h2>
+<h2><a name="version-1-3-6-2005-05-19">Version 1.3.6 (2005-05-19)</a></h2>
 <ul>
+<li>Fixed bugs in the ProgressViewPalette example</li>
+<li>Fixed a bug in the class builder that caused most plugins to break</li>
 <li>Removed all references to Project Builder</li>
 <li>Mac OS X 10.2 (Jaguar) no longer supported</li>
 </ul>
 
 An overview of the relevant changes in new, and older, releases.
 
-Version 1.4 (2005-??-??)
-------------------------
+Version 1.3.6 (2005-05-19)
+--------------------------
+
+- Fixed bugs in the ProgressViewPalette example
+
+- Fixed a bug in the class builder that caused most plugins to break
 
 - Removed all references to Project Builder
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.