*** empty log message ***
git-svn-id: file:///Users/arjan/backup/gaphor/trunk/gaphor@418 a8418922-720d-0410-834f-a69b97ada669
This commit is contained in:
parent
da5c420c89
commit
7298c609ab
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2004-10-07 Arjan Molenaar <arjanmolenaar@hetnet.nl>
|
||||
|
||||
* gaphor/diagram/itemtool.py, gaphor/ui/*: updated to use new
|
||||
UndoManager interface of DiaCanvas2 0.14.0. Requires CVS version
|
||||
of diacanvas2 to work.
|
||||
|
||||
2004-10-01 Arjan Molenaar <arjanmolenaar@hetnet.nl>
|
||||
|
||||
Release 0.6.0
|
||||
|
||||
2004-09-28 Arjan Molenaar <arjanmolenaar@hetnet.nl>
|
||||
|
||||
* gaphor/diagram/itemtool.py, itemactions.py, nameditem.py:
|
||||
|
3
TODO
3
TODO
@ -5,6 +5,9 @@ As always, there is much to do...
|
||||
Problem: the existing <Placeholder> stuff works only on constrcution time.
|
||||
For this we need a menu that can change during the life of the application.
|
||||
|
||||
- confirmation window when creating a new model.
|
||||
|
||||
- An option that shows the selected item (in the namespace view) in a diagram.
|
||||
|
||||
- How to figure out if a module exists without loading it?
|
||||
|
||||
|
@ -74,7 +74,7 @@ class Diagram(Namespace, PackageableElement):
|
||||
def __init__(self, id=None, factory=None):
|
||||
super(Diagram, self).__init__(id, factory)
|
||||
self.canvas = DiagramCanvas(self)
|
||||
self.canvas.set_undo_stack_depth(10)
|
||||
#self.canvas.set_undo_stack_depth(10)
|
||||
self.canvas.set_property ("allow_undo", 1)
|
||||
|
||||
def save(self, save_func):
|
||||
|
@ -21,6 +21,7 @@ class diagramassociation(association):
|
||||
|
||||
# TODO: Maybe we should not break our side of the association...
|
||||
# Since signals are still connected as the diagram item is unlinked.
|
||||
# TODO: Add undo/redo statements.
|
||||
|
||||
def unlink(self, obj):
|
||||
#print 'diagramassociation.unlink', obj, value
|
||||
@ -30,9 +31,10 @@ class diagramassociation(association):
|
||||
def _set2(self, obj, value):
|
||||
#print 'diagramassociation._set2', obj, value
|
||||
obj.preserve_property(self.name)
|
||||
if obj.canvas and obj.canvas.in_undo and len(value.presentation) == 0:
|
||||
print 'diagramassociation._set2(): relinking!'
|
||||
value.relink()
|
||||
#if obj.canvas and obj.canvas.in_undo and len(value.presentation) == 0:
|
||||
# if obj.canvas and len(value.presentation) == 0:
|
||||
# print 'diagramassociation._set2(): relinking!'
|
||||
# value.relink()
|
||||
return association._set2(self, obj, value)
|
||||
|
||||
def _del(self, obj, value):
|
||||
@ -100,6 +102,7 @@ class DiagramItem(Presentation):
|
||||
def do_set_property(self, pspec, value):
|
||||
if pspec.name == 'subject':
|
||||
#print 'set subject:', value
|
||||
# TODO: make property undo-able
|
||||
if value:
|
||||
self.subject = value
|
||||
elif self.subject:
|
||||
|
@ -54,6 +54,7 @@ class ItemTool(diacanvas.view.Tool):
|
||||
if event.type == BUTTON_PRESS:
|
||||
# If Button1 is pressed, we're going to move the item.
|
||||
if event.button == 1:
|
||||
view.canvas.undo_manager.begin_transaction()
|
||||
self.grabbed_item = view_item
|
||||
self.old_pos = (event.x, event.y)
|
||||
item.request_update()
|
||||
@ -71,6 +72,7 @@ class ItemTool(diacanvas.view.Tool):
|
||||
else:
|
||||
self.execute_action('AssociationEndRenameMult')
|
||||
else:
|
||||
view.canvas.undo_manager.begin_transaction()
|
||||
if isinstance(item, NamedItem):
|
||||
self.execute_action('RenameItem')
|
||||
elif hasattr(item, 'is_editable') and item.is_editable():
|
||||
@ -78,6 +80,7 @@ class ItemTool(diacanvas.view.Tool):
|
||||
return True
|
||||
|
||||
def do_button_release_event(self, view, event):
|
||||
view.canvas.undo_manager.commit_transaction()
|
||||
if self.grabbed_item:
|
||||
self.grabbed_item = None
|
||||
return True
|
||||
|
@ -97,11 +97,12 @@ class UndoAction(Action):
|
||||
|
||||
def update(self):
|
||||
diagram_tab = self._window.get_current_diagram_tab()
|
||||
self.sensitive = diagram_tab and diagram_tab.get_canvas().get_undo_depth() > 0
|
||||
self.sensitive = diagram_tab and diagram_tab.get_canvas().undo_manager.can_undo()
|
||||
|
||||
def execute(self):
|
||||
self._window.get_current_diagram_view().canvas.pop_undo()
|
||||
self._window.get_current_diagram_view().canvas.undo_manager.undo_transaction()
|
||||
self.update()
|
||||
self._window.execute_action('EditUndoStack')
|
||||
|
||||
register_action(UndoAction, 'EditUndoStack')
|
||||
|
||||
@ -117,11 +118,12 @@ class RedoAction(Action):
|
||||
|
||||
def update(self):
|
||||
diagram_tab = self._window.get_current_diagram_tab()
|
||||
self.sensitive = diagram_tab and diagram_tab.get_canvas().get_redo_depth() > 0
|
||||
self.sensitive = diagram_tab and diagram_tab.get_canvas().undo_manager.can_redo()
|
||||
|
||||
def execute(self):
|
||||
self._window.get_current_diagram_view().canvas.pop_redo()
|
||||
self._window.get_current_diagram_view().canvas.undo_manager.redo_transaction()
|
||||
self.update()
|
||||
self._window.execute_action('EditUndoStack')
|
||||
|
||||
register_action(RedoAction, 'EditUndoStack')
|
||||
|
||||
@ -211,10 +213,13 @@ class DeleteAction(Action):
|
||||
|
||||
def execute(self):
|
||||
view = self._window.get_current_diagram_view()
|
||||
view.canvas.push_undo('delete')
|
||||
items = view.selected_items
|
||||
for i in items:
|
||||
i.item.unlink()
|
||||
view.canvas.undo_manager.begin_transaction()
|
||||
try:
|
||||
items = view.selected_items
|
||||
for i in items:
|
||||
i.item.unlink()
|
||||
finally:
|
||||
view.canvas.undo_manager.commit_transaction()
|
||||
|
||||
register_action(DeleteAction, 'ItemSelect')
|
||||
|
||||
|
@ -31,11 +31,12 @@ class DiagramTab(object):
|
||||
#self.diagram.canvas.disconnect(self.__snap_to_grid_id)
|
||||
self.diagram = diagram
|
||||
if diagram:
|
||||
log.info('set diagram')
|
||||
diagram.canvas.set_property ('allow_undo', 1)
|
||||
diagram.connect(('name', '__unlink__'), self.__on_diagram_event)
|
||||
self.__undo_id = diagram.canvas.connect('undo', self.__on_diagram_undo)
|
||||
self.__undo_id = diagram.canvas.undo_manager.connect('begin_transaction', self.__on_diagram_undo)
|
||||
# Set capabilities:
|
||||
self.__on_diagram_undo(diagram.canvas)
|
||||
self.__on_diagram_undo(diagram.canvas.undo_manager)
|
||||
|
||||
def construct(self):
|
||||
title = self.diagram and self.diagram.name or '<None>'
|
||||
@ -93,8 +94,8 @@ class DiagramTab(object):
|
||||
# handle mouse button 3 (popup menu):
|
||||
if event.type == gtk.gdk.BUTTON_PRESS:
|
||||
# First push the undo stack...
|
||||
view.canvas.push_undo(None)
|
||||
|
||||
#view.canvas.push_undo(None)
|
||||
pass
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
vitem = view.focus_item
|
||||
if vitem:
|
||||
@ -115,7 +116,8 @@ class DiagramTab(object):
|
||||
def __on_view_notify_tool(self, view, pspec):
|
||||
self.owning_window.execute_action('ToolChange')
|
||||
|
||||
def __on_diagram_undo(self, canvas):
|
||||
def __on_diagram_undo(self, undo_manager):
|
||||
log.info('set undo stack %s' % (undo_manager))
|
||||
self.owning_window.execute_action('EditUndoStack')
|
||||
|
||||
def __on_diagram_event(self, element, pspec):
|
||||
|
@ -81,9 +81,10 @@ class DiagramWindow(AbstractWindow):
|
||||
self.get_window().set_title(diagram.name or 'NoName')
|
||||
self.view.set_diagram(diagram)
|
||||
if diagram:
|
||||
log.info('setting diagram')
|
||||
diagram.canvas.set_property ('allow_undo', 1)
|
||||
diagram.connect(('name', '__unlink__'), self.__on_diagram_event)
|
||||
self.__undo_id = diagram.canvas.connect('undo', self.__on_diagram_undo)
|
||||
self.__undo_id = diagram.canvas.undo_manager.connect('begin_transaction', self.__on_diagram_undo)
|
||||
#self.__snap_to_grid_id = diagram.canvas.connect('notify::snap-to-grid', self.__on_diagram_notify_snap_to_grid)
|
||||
# Set capabilities:
|
||||
self.__on_diagram_undo(diagram.canvas)
|
||||
@ -151,7 +152,8 @@ class DiagramWindow(AbstractWindow):
|
||||
# handle mouse button 3 (popup menu):
|
||||
if event.type == gtk.gdk.BUTTON_PRESS:
|
||||
# First push the undo stack...
|
||||
view.canvas.push_undo(None)
|
||||
#view.canvas.push_undo(None)
|
||||
pass
|
||||
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
vitem = view.focus_item
|
||||
@ -171,6 +173,7 @@ class DiagramWindow(AbstractWindow):
|
||||
#self.set_capability('select', len (view.selected_items) > 0)
|
||||
|
||||
def __on_diagram_undo(self, canvas):
|
||||
log.info ('diagram undo')
|
||||
self.execute_action('EditUndoStack')
|
||||
# self.set_capability('undo', canvas.get_undo_depth() > 0)
|
||||
# self.set_capability('redo', canvas.get_redo_depth() > 0)
|
||||
|
2
setup.py
2
setup.py
@ -75,7 +75,7 @@ class config_Gaphor(Command):
|
||||
self.module_check('gnome')
|
||||
self.module_check('gnome.canvas')
|
||||
#self.module_check('gconf')
|
||||
self.module_check('diacanvas', ('diacanvas_version', (0, 13, 0)))
|
||||
self.module_check('diacanvas', ('diacanvas_version', (0, 14, 0)))
|
||||
|
||||
print ''
|
||||
if self.config_failed:
|
||||
|
Loading…
x
Reference in New Issue
Block a user