Changeset 897

Show
Ignore:
Timestamp:
05/24/06 03:54:25 (2 years ago)
Author:
arjanmol
Message:

--

Files:

Legend:

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

    r893 r897  
     12006-05-23  arjan <arjan at yirdis dot nl> 
     2 
     3        * gaphor/undomanager.py: disconnected from diacanvas.UndoManager 
     4        * */*actions.py: use new undoable descriptior in stead of aspects 
     5 
    162006-05-18  arjan <arjan at yirdis dot nl> 
    27        * po/es.po: updated by Jordi Vilalta Prat. 
  • trunk/gaphor/TODO

    r894 r897  
    2020As always, there is much to do... 
    2121 
     22- At this point we have three event systems: 
     23   1. GObject - used by GTK+, should be restricted to the GUI 
     24   2. Actions - used for (pseudo) menu actions (artifical actions are triggered 
     25                some times (e.g. to notify about changes in the Undo Manager) 
     26                works with string based notifiers. 
     27   3. Zope - fairly optimized, works with interfaces and objects for a 
     28             change. 
     29 
     30   GObject will stay as long as we use GTK+. Restrict it's influence to the GUI. 
     31   (to much management overhead) 
     32   Actions work fine, for menu actions. Gaphor specific and should work 
     33   with the GTK+ menu manager classes. 
     34   Zope classes are quite optimized. However, mainly provides the same 
     35   functionality as Actions, but not as fine grained. 
     36 
    2237- Check association removal when connected to a class. 
    2338 
    2439- Fix namespace relations between Lifeline and Interaction and Message and 
    2540  Interaction 
     41 
     42- Allow to make Action objects, instead of defining classes. 
     43  Should use meta-classes for registration too (define __abstract__ or\something to prevent registration). 
    2644 
    2745#- Store application state: 
     
    6381- Use default GTK+ menu classes, in stead of the home-brew one. 
    6482 
    65 #- Use GTK+ 2.4 UIManager and ActionGroups (?): 
     83- Use GTK+ 2.4 UIManager and ActionGroups (?): 
     84  * Reconsider since GTK+ 2.8 bindings are fairly better than the 2.4 bindings 
    6685  . We have to keep the gaphor.misc.action module intact. 
    6786  . As far as I can see, cross action updates, are not supported. 
     
    7493  . The current structure is simple and quite Pythonic. It should be this way. 
    7594  . Stuff like a recent-file box will be easier to create (I guess). 
    76   Conclusion: keep using the gaphor.misc.action code 
     95  Previous conclusion: keep using the gaphor.misc.action code 
    7796 
    7897#- Storing last open files or having a quick-list of most important 
     
    134153> nice in Gaphor 
    135154 
    136 Lineup selected elements vertically, horizontally in context menu 
     155- Lineup selected elements vertically, horizontally in context menu 
    137156 
    138 I also intend to "merge" lines (as is often used for generalizations: a line with one arrow, which splits into two lines, one for each subclass) 
     157- I also intend to "merge" lines (as is often used for generalizations: a 
     158  line with one arrow, which splits into two lines, one for each subclass) 
    139159 
    140 The text editing also needs a facelift. 
     160- The text editing also needs a facelift. 
    141161 
    142 Alert a user when deleting the last reference to an object (Are you sure you want to remove all the selected elements from the model?) 
     162#- Alert a user when deleting the last reference to an object (Are you 
     163  sure you want to remove all the selected elements from the model?) 
     164 
  • trunk/gaphor/gaphor/UML/diagram.py

    r505 r897  
    1111import diacanvas 
    1212from gaphor.misc import uniqueid 
    13 from gaphor.undomanager import get_undo_manager 
    1413from uml2 import Namespace, PackageableElement 
    1514 
     
    2625        self.__gobject_init__() 
    2726        self._diagram = diagram 
    28         self.set_undo_manager(get_undo_manager()) 
    2927 
    3028    diagram = property(lambda d: d._diagram) 
  • trunk/gaphor/gaphor/__init__.py

    r529 r897  
    77 
    88# Check for GTK-2.0, since we need it anyway... 
    9 import pygtk 
    10 pygtk.require('2.0') 
    11 del pygtk 
     9#import pygtk 
     10#pygtk.require('2.0') 
     11#del pygtk 
    1212 
    1313import misc.singleton 
  • trunk/gaphor/gaphor/diagram/association.py

    r772 r897  
    1919 
    2020from gaphor import resource, UML 
     21from gaphor.undomanager import undoable 
    2122from gaphor.diagram.diagramitem import DiagramItem 
    2223from gaphor.diagram.relationship import RelationshipItem 
     
    876877        pass 
    877878 
     879    @undoable 
    878880    def on_editable_editing_done(self, shape, new_text): 
    879881        if shape in (self._name, self._mult): 
    880882            if self.subject and (shape == self._name or new_text != ''): 
    881                 self.canvas.get_undo_manager().begin_transaction() 
    882883                self.subject.parse(new_text) 
    883                 self.canvas.get_undo_manager().commit_transaction() 
    884884            #self.set_text() 
    885885            #log.info('editing done') 
  • trunk/gaphor/gaphor/diagram/feature.py

    r772 r897  
    1212from diacanvas.geometry import distance_rectangle_point 
    1313from diagramitem import DiagramItem 
     14from gaphor.undomanager import undoable 
    1415from gaphor.diagram import DiagramItemMeta 
     16 
    1517 
    1618class FeatureItem(CanvasItem, CanvasEditable, DiagramItem): 
     
    5759            self._expression.set_text(self.subject.render()) 
    5860 
     61    @undoable 
    5962    def do_set_property(self, pspec, value): 
    6063        if pspec.name == 'expression': 
    6164            if self.subject: 
    6265                #self.preserve_property('expression') 
    63                 self.canvas.get_undo_manager().begin_transaction() 
    6466                self.subject.parse(value) 
    65                 self.canvas.get_undo_manager().commit_transaction() 
    6667 
    6768                self._expression.set_text(self.subject.render()) 
  • trunk/gaphor/gaphor/diagram/itemactions.py

    r772 r897  
    1010from gaphor import GaphorError, resource 
    1111from gaphor import UML 
    12 from gaphor.undomanager import UndoTransactionAspect, weave_method 
     12from gaphor.undomanager import undoable 
    1313from gaphor.misc.action import Action, CheckAction, RadioAction, ObjectAction 
    1414from gaphor.misc.action import register_action 
     
    126126                self.active = item.subject and item.subject.isAbstract 
    127127 
     128    @undoable 
    128129    def execute(self): 
    129130        item = get_parent_focus_item(self._window) 
     
    131132            item.subject.isAbstract = self.active 
    132133 
    133 weave_method(AbstractClassAction.execute, UndoTransactionAspect) 
    134134register_action(AbstractClassAction, 'ItemFocus') 
    135135 
     
    154154                self.active = item.subject and item.subject.isAbstract 
    155155 
     156    @undoable 
    156157    def execute(self): 
    157158        item = self._window.get_current_diagram_view() \ 
     
    160161            item.subject.isAbstract = self.active 
    161162 
    162 weave_method(AbstractOperationAction.execute, UndoTransactionAspect) 
    163163register_action(AbstractOperationAction, 'ItemFocus') 
    164164 
     
    185185                self.sensitive = item.get_property('show-attributes') 
    186186 
     187    @undoable 
    187188    def execute(self): 
    188189        view = self._window.get_current_diagram_view() 
     
    207208                break 
    208209 
    209 weave_method(CreateAttributeAction.execute, UndoTransactionAspect) 
    210210register_action(CreateAttributeAction, 'ShowAttributes', 'ItemFocus') 
    211211 
     
    228228                self.sensitive = item.get_property('show-operations') 
    229229 
     230    @undoable 
    230231    def execute(self): 
    231232        view = self._window.get_current_diagram_view() 
     
    249250                break 
    250251 
    251 weave_method(CreateOperationAction.execute, UndoTransactionAspect) 
    252252register_action(CreateOperationAction, 'ShowOperations', 'ItemFocus') 
    253253 
     
    258258        self._window = window 
    259259 
     260    @undoable 
    260261    def execute(self): 
    261262        #subject = get_parent_focus_item(self._window).subject 
     
    270271    tooltip='Delete the selected attribute' 
    271272 
    272 weave_method(DeleteAttributeAction.execute, UndoTransactionAspect) 
    273273register_action(DeleteAttributeAction, 'ShowAttributes', 'CreateAttribute', 'ItemFocus') 
    274274 
     
    279279    tooltip = 'Delete the selected operation' 
    280280 
    281 weave_method(DeleteOperationAction.execute, UndoTransactionAspect) 
    282281register_action(DeleteOperationAction, 'ShowOperations', 'CreateOperation', 'ItemFocus') 
    283282 
     
    300299                self.active = item.get_property('show-attributes') 
    301300 
     301    @undoable 
    302302    def execute(self): 
    303303        item = get_parent_focus_item(self._window) 
    304304        item.set_property('show-attributes', self.active) 
    305305 
    306 weave_method(DeleteOperationAction.execute, UndoTransactionAspect) 
    307306register_action(ShowAttributesAction, 'ItemFocus') 
    308307 
     
    325324                self.active = item.get_property('show-operations') 
    326325 
     326    @undoable 
    327327    def execute(self): 
    328328        item = get_parent_focus_item(self._window) 
    329329        item.set_property('show-operations', self.active) 
    330330 
    331 weave_method(ShowOperationsAction.execute, UndoTransactionAspect) 
    332331register_action(ShowOperationsAction, 'ItemFocus') 
    333332 
     
    359358    tooltip='Add a segment to the line' 
    360359 
     360    @undoable 
    361361    def execute(self): 
    362362        item, segment = self.get_item_and_segment() 
     
    364364            item.set_property('add_segment', segment) 
    365365             
    366 weave_method(AddSegmentAction.execute, UndoTransactionAspect) 
    367366register_action(AddSegmentAction, 'ItemFocus') 
    368367 
     
    381380            pass 
    382381 
     382    @undoable 
    383383    def execute(self): 
    384384        item, segment = self.get_item_and_segment() 
     
    386386            item.set_property('del_segment', segment) 
    387387             
    388 weave_method(DeleteSegmentAction.execute, UndoTransactionAspect) 
    389388register_action(DeleteSegmentAction, 'ItemFocus', 'AddSegment') 
    390389 
     
    406405            pass 
    407406 
     407    @undoable 
    408408    def execute(self): 
    409409        fi = get_parent_focus_item(self._window) 
     
    413413        fi.set_property('orthogonal', self.active) 
    414414 
    415 weave_method(OrthogonalAction.execute, UndoTransactionAspect) 
    416415register_action(OrthogonalAction, 'ItemFocus', 'AddSegment', 'DeleteSegment') 
    417416 
     
    434433            pass 
    435434 
     435    @undoable 
    436436    def execute(self): 
    437437        fi = get_parent_focus_item(self._window) 
     
    439439        fi.set_property('horizontal', self.active) 
    440440 
    441 weave_method(OrthogonalAlignmentAction.execute, UndoTransactionAspect) 
    442441register_action(OrthogonalAlignmentAction, 'ItemFocus', 'Orthogonal') 
    443442 
     
    463462            pass 
    464463 
     464    @undoable 
    465465    def execute(self): 
    466466        fi = get_parent_focus_item(self._window) 
     
    468468        fi.set_property('show-direction', self.active) 
    469469 
    470 weave_method(AssociationShowDirectionAction.execute, UndoTransactionAspect) 
    471470register_action(AssociationShowDirectionAction, 'ItemFocus') 
    472471 
     
    480479        self._window = window 
    481480 
     481    @undoable 
    482482    def execute(self): 
    483483        fi = get_parent_focus_item(self._window) 
     
    485485        fi.invert_direction() 
    486486 
    487 weave_method(AssociationInvertDirectionAction.execute, UndoTransactionAspect) 
    488487register_action(AssociationInvertDirectionAction, 'ItemFocus') 
    489488 
     
    507506            pass 
    508507 
     508    @undoable 
    509509    def execute(self): 
    510510        item = self.get_association_end() 
     
    512512        assert isinstance(item.subject, UML.Property) 
    513513        item.set_navigable(self.navigable) 
    514  
    515 weave_method(NavigableAction.execute, UndoTransactionAspect) 
    516514 
    517515 
     
    585583            pass 
    586584 
     585    @undoable 
    587586    def execute(self): 
    588587        if self.active: 
     
    591590            subject.aggregation = self.aggregation 
    592591 
    593 weave_method(AggregationAction.execute, UndoTransactionAspect) 
    594592 
    595593class HeadNoneAction(AggregationAction): 
     
    722720            pass 
    723721 
     722    @undoable 
    724723    def execute(self): 
    725724        if self.active: 
     
    728727            #item.auto_dependency = False 
    729728            self._window.get_action_pool().execute('AutoDependency', active=False) 
    730  
    731 weave_method(DependencyTypeAction.execute, UndoTransactionAspect) 
    732729         
    733730 
     
    784781                self.active = item.auto_dependency 
    785782 
     783    @undoable 
    786784    def execute(self): 
    787785        item = get_parent_focus_item(self._window) 
    788786        item.auto_dependency = self.active 
    789787 
    790 weave_method(AutoDependencyAction.execute, UndoTransactionAspect) 
    791788register_action(AutoDependencyAction, 'ItemFocus') 
    792789 
     
    809806                self.active = item.subject and item.subject.isIndirectlyInstantiated 
    810807 
     808    @undoable 
    811809    def execute(self): 
    812810        item = get_parent_focus_item(self._window) 
     
    814812            item.subject.isIndirectlyInstantiated = self.active 
    815813 
    816 weave_method(IndirectlyInstantiatedComponentAction.execute, UndoTransactionAspect) 
    817814register_action(IndirectlyInstantiatedComponentAction, 'ItemFocus') 
    818815 
     
    850847                self.sensitive = self._isSensitive(cls_item.subject, item) 
    851848 
     849    @undoable 
    852850    def execute(self): 
    853851        cls = self._getParent().subject 
     
    862860        self._window.execute_action('ItemFocus') 
    863861 
    864 weave_method(MoveAction.execute, UndoTransactionAspect) 
    865862 
    866863class MoveUpAction(MoveAction): 
     
    906903            self.sensitive = isinstance(item, InterfaceItem) 
    907904 
     905    @undoable 
    908906    def execute(self): 
    909907        item = get_parent_focus_item(self._window) 
     
    912910        item.set_property('drawing-style', InterfaceItem.DRAW_ICON) 
    913911 
    914 weave_method(FoldAction.execute, UndoTransactionAspect) 
    915912register_action(FoldAction, 'ItemFocus') 
    916913 
     
    921918    tooltip = 'View details' 
    922919 
     920    @undoable 
    923921    def execute(self): 
    924922        item = get_parent_focus_item(self._window) 
     
    930928        item.canvas.update_now() 
    931929 
    932 weave_method(UnfoldAction.execute, UndoTransactionAspect) 
    933930register_action(UnfoldAction, 'ItemFocus') 
    934931 
     
    957954                self.active = False 
    958955 
     956    @undoable 
    959957    def execute(self): 
    960958        item = get_parent_focus_item(self._window) 
     
    963961        else: 
    964962            del item.subject.appliedStereotype[self.stereotype] 
    965  
    966 weave_method(ApplyStereotypeAction.execute, UndoTransactionAspect) 
    967963 
    968964 
     
    10331029        new_rel.unlink() 
    10341030 
     1031    @undoable 
    10351032    def execute(self): 
    10361033        diagram_tab = self._window.get_current_diagram_tab() 
     
    10511048                                              DependencyItem) 
    10521049 
    1053 weave_method(CreateLinksAction.execute, UndoTransactionAspect) 
    10541050register_action(CreateLinksAction, 'ItemFocus', 'ItemSelect') 
    10551051 
     
    10721068            pass 
    10731069 
     1070    @undoable 
    10741071    def execute(self): 
    10751072        if self.active: 
    10761073            item = get_parent_focus_item(self._window) 
    10771074            item.set_ordering(self.ordering) 
    1078  
    1079 weave_method(ObjectNodeOrderingAction.execute, UndoTransactionAspect) 
    10801075 
    10811076 
     
    11331128                self.active = item.props.show_ordering 
    11341129 
     1130    @undoable 
    11351131    def execute(self): 
    11361132        item = get_parent_focus_item(self._window) 
    11371133        item.props.show_ordering = self.active 
    11381134 
    1139 weave_method(ObjectNodeOrderingVisibiltyAction.execute, UndoTransactionAspect) 
    11401135register_action(ObjectNodeOrderingVisibiltyAction, 'ItemFocus') 
    11411136 
     
    11581153            pass 
    11591154 
     1155    @undoable 
    11601156    def execute(self): 
    11611157        item = get_parent_focus_item(self._window) 
    11621158        item.rotate() 
    11631159 
    1164 weave_method(RotateAction.execute, UndoTransactionAspect) 
    11651160register_action(RotateAction, 'ItemFocus') 
    11661161 
     
    11821177            pass 
    11831178 
     1179    @undoable 
    11841180    def execute(self): 
    11851181        """ 
     
    12591255        fb._connector.subject.value = name 
    12601256 
    1261  
    1262 weave_method(SplitFlowAction.execute, UndoTransactionAspect) 
    12631257register_action(SplitFlowAction, 'ItemFocus') 
    1264  
    12651258 
    12661259 
     
    12801273            pass 
    12811274 
     1275    @undoable 
    12821276    def execute(self): 
    12831277        """ 
     
    13151309        fb.unlink() 
    13161310 
    1317 weave_method(MergeFlowAction.execute, UndoTransactionAspect) 
    13181311register_action(MergeFlowAction, 'ItemFocus') 
    13191312 
     
    13351328            self.active = isinstance(item, ConnectorEndItem) 
    13361329 
     1330    @undoable 
    13371331    def execute(self): 
    13381332        item = get_focused_item(self._window) 
     
    13411335        assembly.request_update() 
    13421336 
    1343 weave_method(DisconnectConnector.execute, UndoTransactionAspect) 
    13441337register_action(DisconnectConnector, 'ItemFocus') 
     1338 
    13451339 
    13461340class ApplyInterfaceAction(RadioAction, ObjectAction): 
     
    13641358                self.active = (self.interface == item.subject) 
    13651359 
     1360    @undoable 
    13661361    def execute(self): 
    13671362        item = get_focused_item(self._window) 
     
    13701365        else: 
    13711366            item.set_subject(None) 
    1372  
    1373 weave_method(ApplyInterfaceAction.execute, UndoTransactionAspect) 
    1374  
    13751367 
    13761368 
     
    13921384                self.active = item.props.has_lifetime 
    13931385 
     1386    @undoable 
    13941387    def execute(self): 
    13951388        item = get_parent_focus_item(self._window) 
    13961389        item.props.has_lifetime = self.active 
    13971390 
    1398 weave_method(LifelineHasLifetimeAction.execute, UndoTransactionAspect) 
    13991391register_action(LifelineHasLifetimeAction, 'ItemFocus') 
  • trunk/gaphor/gaphor/diagram/itemtool.py

    r448 r897  
    66from gtk.gdk import BUTTON_PRESS, _2BUTTON_PRESS, BUTTON_PRESS_MASK 
    77import diacanvas 
     8from gaphor.undomanager import get_undo_manager 
    89from nameditem import NamedItem 
    910from association import AssociationEnd 
     
    5556            # If Button1 is pressed, we're going to move the item. 
    5657            if event.button == 1: 
    57                 view.canvas.undo_manager.begin_transaction() 
     58                get_undo_manager().begin_transaction() 
    5859                self.grabbed_item = view_item 
    5960                self.old_pos = (event.x, event.y) 
     
    6162 
    6263        elif event.type == _2BUTTON_PRESS: 
    63             #view.canvas.undo_manager.begin_transaction() 
    6464            if isinstance(item, NamedItem): 
    6565                self.execute_action('RenameItem') 
     
    6969 
    7070    def do_button_release_event(self, view, event): 
    71         view.canvas.undo_manager.commit_transaction() 
     71        get_undo_manager().commit_transaction() 
    7272        if self.grabbed_item: 
    7373            self.grabbed_item = None 
  • trunk/gaphor/gaphor/diagram/nameditem.py

    r772 r897  
    99import diacanvas 
    1010from elementitem import ElementItem 
     11from gaphor.undomanager import get_undo_manager 
    1112from gaphor.diagram.groupable import GroupBase 
    1213from gaphor.diagram.diagramitem import DiagramItem 
     
    154155                    new_text = new_text[:-l2] 
    155156 
    156             self.canvas.get_undo_manager().begin_transaction() 
     157            get_undo_manager().begin_transaction() 
    157158            log.debug('setting %s to %s' % (self.subject_attr, new_text)) 
    158159            setattr(self.subject, self.subject_attr, new_text) 
    159             self.canvas.get_undo_manager().commit_transaction() 
     160            get_undo_manager().commit_transaction() 
    160161 
    161162 
  • trunk/gaphor/gaphor/diagram/placementtool.py

    r720 r897  
    55from gaphor import UML 
    66from gaphor import resource 
     7from gaphor.undomanager import get_undo_manager 
     8 
    79 
    810class PlacementTool(diacanvas.PlacementTool): 
     
    7880        view.unselect_all() 
    7981        #print 'Gaphor: on_button_press_event: %s' % self.__dict__ 
    80         view.canvas.get_undo_manager().begin_transaction() 
     82        get_undo_manager().begin_transaction() 
    8183        return diacanvas.PlacementTool.do_button_press_event(self, view, event) 
    8284 
     
    8587        if resource('reset-tool-after-create', False): 
    8688            view.set_tool(None) 
    87         view.canvas.get_undo_manager().commit_transaction() 
     89        get_undo_manager().commit_transaction() 
    8890        #print 'Gaphor: do_button_release_event: %s' % self.__dict__ 
    8991        return diacanvas.PlacementTool.do_button_release_event(self, view, event) 
  • trunk/gaphor/gaphor/ui/diagramactions.py

    r761 r897  
    99from gaphor import resource 
    1010from gaphor import UML 
    11 from gaphor.undomanager import UndoTransactionAspect, weave_method 
     11from gaphor.undomanager import get_undo_manager, undoable 
    1212from gaphor.misc.action import Action, CheckAction, RadioAction 
    1313from gaphor.misc.action import register_action as _register_action 
     
    6161    def update(self): 
    6262        diagram_tab = self._window.get_current_diagram_tab() 
    63         self.sensitive = diagram_tab and diagram_tab.get_canvas().undo_manager.can_undo() 
    64  
    65     def execute(self): 
    66         self._window.get_current_diagram_view().canvas.undo_manager.undo_transaction() 
     63        self.sensitive = diagram_tab and get_undo_manager().can_undo() 
     64 
     65    def execute(self): 
     66        get_undo_manager().undo_transaction() 
    6767        self.update() 
    6868        self._window.execute_action('EditUndoStack') 
     
    8282    def update(self): 
    8383        diagram_tab = self._window.get_current_diagram_tab() 
    84         self.sensitive = diagram_tab and diagram_tab.get_canvas().undo_manager.can_redo() 
    85  
    86     def execute(self): 
    87         self._window.get_current_diagram_view().canvas.undo_manager.redo_transaction() 
     84        self.sensitive = diagram_tab and get_undo_manager().can_redo() 
     85 
     86    def execute(self): 
     87        get_undo_manager().redo_transaction() 
    8888        self.update() 
    8989        self._window.execute_action('EditUndoStack') 
     
    200200 
    201201        if view.is_focus(): 
    202             view.canvas.undo_manager.begin_transaction() 
     202            get_undo_manager().begin_transaction() 
    203203            try: 
    204204                items = view.selected_items 
     
    206206                    i.item.unlink() 
    207207            finally: 
    208                 view.canvas.undo_manager.commit_transaction() 
     208                get_undo_manager().commit_transaction() 
    209209     
    210210    def mayRemoveFromModal(self, view): 
     
    334334            self._item.load(name, str(value)) 
    335335 
     336    @undoable 
    336337    def execute(self): 
    337338        view = self._window.get_current_diagram_view() 
     
    375376            view.select(view.find_view_item(item)) 
    376377 
    377 weave_method(PasteAction.execute, UndoTransactionAspect) 
    378378register_action(PasteAction, 'EditCopy') 
    379379 
  • trunk/gaphor/gaphor/ui/diagramtab.py

    r677 r897  
    4040        self.diagram = diagram 
    4141        if diagram: 
    42             #log.info('set diagram') 
    4342            diagram.canvas.set_property ('allow_undo', 1) 
    4443            diagram.connect(('name', '__unlink__'), self.__on_diagram_event) 
    45             #self.__undo_id = diagram.canvas.undo_manager.connect('begin_transaction', self.__on_diagram_undo) 
    46             # Set capabilities: 
    47             #self.__on_diagram_undo(diagram.canvas.undo_manager) 
    4844 
    4945            if hasattr(self, 'view'): 
     
    146142        self.owning_window.execute_action('ToolChange') 
    147143 
    148 #    def __on_diagram_undo(self, undo_manager): 
    149 #        #log.info('set undo stack %s' % (undo_manager)) 
    150 #        self.owning_window.execute_action('editundostack') 
    151  
    152144    def __on_diagram_event(self, element, pspec): 
    153145        if pspec == '__unlink__': 
  • trunk/gaphor/gaphor/ui/mainactions.py

    r733 r897  
    1414from gaphor import UML 
    1515from gaphor import diagram 
    16 from gaphor import undomanager 
    17 #from gaphor.undomanager import UndoTransactionAspect, weave_method 
     16from gaphor.undomanager import get_undo_manager 
    1817from gaphor.misc.action import Action, CheckAction, RadioAction, register_action 
    1918from gaphor.misc.action import DynamicMenu, ObjectAction, register_slot 
     
    140139            worker = GIdleThread(storage.load_generator(filename), queue) 
    141140            self._window.action_pool.insensivate_actions() 
    142             undomanager.get_undo_manager().clear_undo_stack() 
    143             undomanager.get_undo_manager().clear_redo_stack() 
     141            get_undo_manager().clear_undo_stack() 
     142            get_undo_manager().clear_redo_stack() 
    144143            worker.start() 
    145144            worker.wait() 
     
    625624 
    626625    def update(self): 
    627         self.sensitive = undomanager.get_undo_manager().can_undo() 
    628  
    629     def execute(self): 
    630         undomanager.get_undo_manager().undo_transaction() 
     626        self.sensitive = get_undo_manager().can_undo() 
     627 
     628    def execute(self): 
     629        get_undo_manager().undo_transaction() 
    631630        #self.update() 
    632631        self._window.execute_action('UndoStack') 
     
    645644 
    646645    def update(self): 
    647         self.sensitive = undomanager.get_undo_manager().can_redo() 
    648  
    649     def execute(self): 
    650         undomanager.get_undo_manager().redo_transaction() 
     646        self.sensitive = get_undo_manager().can_redo() 
     647 
     648    def execute(self): 
     649        get_undo_manager().redo_transaction() 
    651650        #self.update() 
    652651        self._window.execute_action('UndoStack') 
  • trunk/gaphor/gaphor/ui/mainwindow.py

    r772 r897  
    66from gaphor import resource 
    77from gaphor import UML 
    8 from gaphor import undomanager 
     8from gaphor.undomanager import get_undo_manager 
    99from gaphor.i18n import _ 
    1010from gaphor.ui import namespace 
     
    318318 
    319319        # Set some handles for the undo manager 
    320         undomanager.get_undo_manager().connect('begin_transaction', self.on_undo) 
    321         undomanager.get_undo_manager().connect('add_undo_action', self.on_undo) 
     320        #get_undo_manager().connect('begin_transaction', self.on_undo) 
     321        #get_undo_manager().connect('add_undo_action', self.on_undo) 
    322322 
    323323    def add_transient_window(self, window): 
  • trunk/gaphor/gaphor/undomanager.py

    r505 r897  
    22 
    33import gobject 
    4 import diacanvas 
    5  
    6 from gaphor.misc.aspects import Aspect, weave_method 
    74 
    85 
     
    1310 
    1411 
    15 class UndoTransactionAspect(Aspect): 
    16  
    17     def __init__(self, method): 
    18         self.method = method 
    19  
    20     def before(self): 
    21         get_undo_manager().begin_transaction() 
    22  
    23     def after(self, retval, exc): 
    24         if exc: 
    25             get_undo_manager().discard_transaction() 
    26         else: 
    27             get_undo_manager().commit_transaction() 
     12def undoable(func): 
     13    """Descriptor. Enables an undo transaction around the method/function. 
     14    """ 
     15    def wrapper(*args, **kwargs): 
     16        undo_manager = get_undo_manager() 
     17        undo_manager.begin_transaction() 
     18        try: 
     19            func(*args, **kwargs) 
     20        finally: 
     21            undo_manager.commit_transaction() 
    2822 
    2923 
     
    6862 
    6963 
    70 class UndoManager(gobject.GObject, diacanvas.UndoManager): 
     64class UndoManager(gobject.GObject): 
    7165    """Simple transaction manager for Gaphor. 
    7266    This transaction manager supports nested transactions. 
     
    9892#            self._short_circuit = False 
    9993 
    100     # UndoManager interface
    101  
    102     def on_begin_transaction(self): 
     94    def begin_transaction(self)
     95        """Add an action to the current transaction 
     96        """ 
    10397        if self._in_undo: 
    10498            return 
     
    114108        self._transaction_depth += 1 
    115109 
    116     def on_add_undo_action(self, action): 
     110    def add_undo_action(self, action): 
    117111        """Add an action to undo. An action 
    118112        """ 
     
    129123        self._current_transaction.add(action) 
    130124 
    131     def on_commit_transaction(self): 
     125    def commit_transaction(self): 
    132126        if self._in_undo: 
    133127            return 
     
    146140            self._current_transaction = None 
    147141 
    148     def on_discard_transaction(self): 
     142    def discard_transaction(self): 
    149143        if self._in_undo: 
    150144            return 
     
    157151            self._current_transaction = None 
    158152 
    159     def on_undo_transaction(self): 
     153    def undo_transaction(self): 
    160154        if not self._undo_stack: 
    161155            return 
     
    172166        self._redo_stack.append(transaction) 
    173167 
    174     def on_redo_transaction(self): 
     168    def redo_transaction(self): 
    175169        if not self._redo_stack: 
    176170            return 
     
    184178        self._undo_stack.append(transaction) 
    185179 
    186     def on_in_transaction(self): 
     180    def in_transaction(self): 
    187181        return self._current_transaction is not None 
    188182 
    189     def on_can_undo(self): 
     183    def can_undo(self): 
    190184        return bool(self._current_transaction or self._undo_stack) 
    191185 
    192     def on_can_redo(self): 
     186    def can_redo(self): 
    193187        return bool(self._redo_stack) 
    194188 
    195 gobject.type_register(UndoManager) 
    196 diacanvas.set_undo_manager(UndoManager) 
    197189 
    198190# Register as resource: 
  • trunk/gaphor/run-gaphor.sh

    r200 r897  
    11 
    2 python setup.py run "$@" 
     2python2.4 setup.py run "$@" 
  • trunk/gaphor/setup.py

    r770 r897  
    1818from glob import glob 
    1919from commands import getoutput, getstatus, getstatusoutput 
     20import py2app 
    2021from distutils.core import setup, Command 
    2122from distutils.command.build_py import build_py 
     
    416417                'install_mo': install_mo, 
    417418                'run': run_Gaphor 
    418       } 
     419      }, 
     420      app=['gaphor-osx.py'] 
    419421) 
    420422 
  • trunk/gaphor/utils/dist_mo.py

    r190 r897  
    11# vim:sw=4:et 
    22 
    3 from distutils.dist import Distribution as _Distribution 
     3#from distutils.dist import Distribution as _Distribution 
     4from distutils.core import Distribution as _Distribution 
    45 
    56class Distribution(_Distribution):