Changeset 924

Show
Ignore:
Timestamp:
06/02/06 02:37:25 (2 years ago)
Author:
arjanmol
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/ChangeLog

    r898 r924  
     12006-06-01  arjan <arjan at yirdis dot nl> 
     2 
     3        * some cleanup, added TODO: comments for conversion to Gaphas. 
     4 
    152006-05-29  arjan <arjan at yirdis dot nl> 
    26 
  • gaphor/trunk/gaphor/UML/diagram.py

    r897 r924  
    9696        return obj 
    9797 
     98    # TODO: remove 
    9899    def substitute_item(self, item, new_item_type): 
    99100        """Create a new item and replace item with the new item. 
  • gaphor/trunk/gaphor/UML/element.py

    r505 r924  
    1515     '__unlink__' signal to all attached signals. unlink() can not be called 
    1616     recursively. 
    17 #relink() 
    18 #    Inverse operation of unlink(). Used by diagram items during undo operations. 
    1917 
    2018connect ('name', callback, *data) or 
     
    5452                       doc="The factory that created this element") 
    5553 
     54    # TODO: move save/load code to adapters 
    5655    def save(self, save_func): 
    5756        """Save the state by calling save_func(name, value).""" 
     
    8887                    prop.postload(self) 
    8988 
    90     def __unlink(self, signal): 
    91         """Unlink the element. For both the __unlink__ and __relink__ signal 
    92         the __unlink__ callback list is used. 
     89    def unlink(self): 
     90        """Unlink the element. 
    9391        """ 
    9492        # Uses a mutex to make sure it is not called recursively 
    9593        if self.__in_unlink.testandset(): 
    9694            try: 
    97                 self.notify(signal, '__unlink__') 
     95                self.notify('__unlink__', '__unlink__') 
    9896            finally: 
    9997                self.__in_unlink.unlock() 
    10098 
    101     def unlink(self): 
    102         """Unlink the element.""" 
    103         #log.debug('Element.unlink(%s)' % self) 
    104         self.__unlink('__unlink__') 
    105  
    106 #    def relink(self): 
    107 #        """Undo the unlink operation.""" 
    108 #        log.debug('Element.relink(%s)' % self) 
    109 #        self.__unlink('__relink__') 
    110  
    11199    def connect(self, names, callback, *data): 
    112100        """Attach 'callback' to a list of names. Names may also be a string. 
    113         A name is the name od a property of the object or '__unlink__'. 
     101        A name is the name of a property of the object or '__unlink__'. 
    114102        """ 
    115103        #log.debug('Element.connect(%s, %s, %s)' % (names, callback, data)) 
     
    118106        cb = (callback,) + data 
    119107        for name in names: 
    120             try: 
    121                 o = self._observers[name] 
    122                 if not cb in o: 
    123                     o.append(cb) 
    124             except KeyError: 
    125                 # create new entry 
    126                 self._observers[name] = [cb] 
     108            self._observers.setdefault(name, []).append(cb) 
    127109 
    128110    def disconnect(self, callback, *data): 
     
    140122    def notify(self, name, cb_name=None, pspec=None): 
    141123        """Send notification to attached callbacks that a property 
    142         has changed. the __relink__ signal uses the callbacks for __unlink__. 
     124        has changed. 
    143125        """ 
    144126        cb_list = self._observers.get(cb_name or name, ()) 
     
    180162    psyco.bind(Element) 
    181163 
    182 if __name__ == '__main__': 
    183     a = Element() 
    184     b = Element() 
    185     def cb_func(name, *args): 
    186         print '  cb_func:', name, args 
    187  
    188     a.connect('ev1', cb_func, a) 
    189     a.connect('ev1', cb_func, a) 
    190     a.connect('ev2', cb_func, 'ev2', a) 
    191  
    192     print 'notify: ev1' 
    193     a.notify('ev1') 
    194     print 'notify: ev2' 
    195     a.notify('ev2') 
    196   
    197     a.disconnect(cb_func, a) 
    198  
    199     print 'notify: ev1' 
    200     a.notify('ev1') 
    201     print 'notify: ev2' 
    202     a.notify('ev2') 
    203   
  • gaphor/trunk/gaphor/diagram/__init__.py

    r772 r924  
    2323def get_diagram_item(element): 
    2424    global _uml_to_item_map 
    25     try: 
    26         return _uml_to_item_map[element] 
    27     except: 
    28         return None 
     25    return _uml_to_item_map.get(element) 
    2926 
    3027def set_diagram_item(element, item): 
     
    5552                (diacanvas.CanvasElement in all_bases) or \ 
    5653                (diacanvas.CanvasBox in all_bases) or \ 
    57                 (diacanvas.CanvasText in all_bases) or \ 
    5854                (diacanvas.CanvasImage in all_bases): 
    5955            diacanvas.set_callbacks(item_class) 
  • gaphor/trunk/gaphor/diagram/diagramitem.py

    r772 r924  
    99 
    1010from gaphor import resource 
    11 from gaphor.misc import uniqueid 
    1211from gaphor.UML import Element, Presentation 
    1312from gaphor.UML.properties import association 
     
    8786    # UML.Element interface used by properties: 
    8887 
     88    # TODO: Use adapters for load/save functionality 
    8989    def save(self, save_func): 
    9090        if self.subject: 
     
    111111            self.on_subject_notify(type(self).subject) 
    112112 
     113    # TODO: remove, use signaling from gaphor.UML.Element 
    113114    def unlink(self): 
    114115        """Send the unlink signal and remove itself from the canvas. 
     
    123124        self.set_property('parent', None) 
    124125 
    125 #    def relink(self): 
    126 #        """Relinking is done by popping the undo stack... 
    127 #        """ 
    128 #        log.info('RELINK DiagramItem') 
    129 #        #self.emit('__unlink__', '__relink__') 
    130  
    131126    # gaphor.UML.Element like signal interface: 
    132127 
     128    # TODO: remove, use signaling from gaphor.UML.Element 
    133129    def connect(self, name, handler, *args): 
    134130        """Connect a handler to signal name with args. 
     
    146142        return id 
    147143 
     144    # TODO: remove, use signaling from gaphor.UML.Element 
    148145    def disconnect(self, handler_or_id, *args): 
    149146        """Disconnect a signal handler. If handler_or_id is an integer (int) 
     
    318315    # DiaCanvasItem callbacks 
    319316 
     317    # TODO: use connectable adapter here. 
    320318    def _on_glue(self, handle, wx, wy, parent_class): 
    321319        """This function is used to notify the connecting item 
  • gaphor/trunk/gaphor/diagram/groupable.py

    r772 r924  
    88import diacanvas 
    99 
     10# TODO: Remove alltogether (no longer used for Gaphas) 
    1011class GroupBase(diacanvas.CanvasGroupable): 
    1112    """ 
  • gaphor/trunk/gaphor/misc/uniqueid.py

    r465 r924  
    8181                        f.close() 
    8282                        break; 
    83             elif sys.platform.find('sun') >= 0: 
     83            elif sys.platform.find('darwin') >= 0 \ 
     84                 or sys.platform.find('sun') >= 0: 
    8485                # 
    85                 # SunOS 
     86                # Darwin (Mac OS X) and SunOS 
    8687                # 
    8788                f = os.popen("/sbin/ifconfig -a") 
  • gaphor/trunk/setup.py

    r900 r924  
    1818from glob import glob 
    1919from commands import getoutput, getstatus, getstatusoutput 
     20 
     21# Py2App should be imported before the utils classes are loaded 
    2022try: 
    2123    import py2app 
    2224except ImportError: 
    23     print 'No py2app.' 
    24     py2appargs = dict() 
     25    print "No py2app, can't create application bundle" 
    2526else: 
    26     py2appargs = dict(app=['gaphor-osx.py']) 
     27    from modulegraph.modulegraph import AddPackagePath 
     28    AddPackagePath('gaphor', 'build/lib/gaphor') 
     29    AddPackagePath('gaphor.UML', 'build/lib/gaphor/UML') 
    2730 
    2831from distutils.core import setup, Command 
     
    196199        outfile = os.path.join(self.build_lib, py_model) 
    197200        self.mkpath(os.path.dirname(outfile)) 
    198  
    199         # Figure out if the uml2.py (outfile) is the newest or should be 
    200         # generated (again). 
    201         if self.force or reduce(lambda a, b: newer(a,b) and a or b, 
    202                                 (model, overrides, gen, outfile)) != outfile: 
     201        if self.force or newer(model, outfile) \ 
     202                      or newer(overrides, outfile) \ 
     203                      or newer(gen, outfile): 
    203204            print 'generating %s from %s...' % (py_model, model) 
    204205            print '  (warnings can be ignored)' 
     
    380381      "It uses the GNOME2 environment for user interaction.", 
    381382      platforms=['GNOME2'], 
    382       all_linguas=['ca', 'es', 'nl', 'sv'], 
     383      all_linguas=['nl', 'es'], 
    383384      packages=['gaphor', 
    384385                'gaphor.UML', 
     
    427428                'run': run_Gaphor 
    428429      }, 
    429       **py2appargs 
     430      app=['gaphor-osx.py'], 
     431      options = dict( 
     432         py2app = dict( 
     433             includes=['atk', 'pango', 'cairo', 'pangocairo'], 
     434#             CFBundleDisplayName='Gaphor', 
     435#             CFBundleIdentifier='net.sourceforge.gaphor' 
     436         ) 
     437     ) 
    430438) 
    431  
  • gaphor/trunk/tests/test-uml2.py

    r376 r924  
    66 
    77class TestUML2(unittest.TestCase): 
     8 
     9    def test_element(self): 
     10        a = UML.Element() 
     11        b = UML.Element() 
     12        def cb_func(name, *args): 
     13            print '  cb_func:', name, args 
     14 
     15        a.connect('ev1', cb_func, a) 
     16        a.connect('ev1', cb_func, a) 
     17        a.connect('ev2', cb_func, 'ev2', a) 
     18 
     19        print 'notify: ev1' 
     20        a.notify('ev1') 
     21        print 'notify: ev2' 
     22        a.notify('ev2') 
     23 
     24        a.disconnect(cb_func, a) 
     25 
     26        print 'notify: ev1' 
     27        a.notify('ev1') 
     28        print 'notify: ev2' 
     29        a.notify('ev2') 
    830 
    931    def test1(self):