Changeset 1056
- Timestamp:
- 10/29/06 23:34:17 (2 years ago)
- Files:
-
- gaphor/branches/new-canvas/TODO (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/actions/diagramactions.py (modified) (9 diffs)
- gaphor/branches/new-canvas/gaphor/actions/itemactions.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/branches/new-canvas/TODO
r1027 r1056 1 1 2 !!! Create some example diagrams, 2 - Undo functionality 3 - Load / save regression testing 4 !!! Create some example diagrams, 5 3 6 - split DiagramItem in a stereotype support, SubjectSupport and some 4 7 other support classes. gaphor/branches/new-canvas/gaphor/actions/diagramactions.py
r1046 r1056 18 18 _action_dependencies(action, 'TabChange') 19 19 20 20 21 class CloseTabAction(Action): 21 22 id = 'FileCloseTab' … … 46 47 47 48 register_action(UndoStackAction) 49 48 50 49 51 class UndoAction(Action): … … 91 93 register_action(RedoAction, 'EditUndoStack') 92 94 95 93 96 class ToolChangeAction(Action): 94 97 """Dummy, triggered when a new tool is selected. … … 196 199 # Confirm deletion of last views to model objects 197 200 # They will be deleted along with their last view 198 if not self.may RemoveFromModel(view):201 if not self.may_remove_from_model(view): 199 202 return 200 203 … … 208 211 get_undo_manager().commit_transaction() 209 212 210 def mayRemoveFromModel(self, view): 211 ''' Check if there are items which will be deleted from the model (when their last views are deleted). If so request user confirmation before deletion. ''' 213 def may_remove_from_model(self, view): 214 ''' Check if there are items which will be deleted from the model 215 (when their last views are deleted). If so request user 216 confirmation before deletion. ''' 212 217 items = view.selected_items 213 218 for i in items: 214 if self.is LastView(i):215 return self.request Confirmation()219 if self.is_last_view(i): 220 return self.request_confirmation() 216 221 return True 217 222 218 def is LastView(self, item):223 def is_last_view(self, item): 219 224 ''' Check if the current view is the last view to its object ''' 220 225 if item.subject and len(item.subject.presentation)==1: … … 222 227 return False 223 228 224 def request Confirmation(self):229 def request_confirmation(self): 225 230 ''' Request user confirmation on deleting the item from the model ''' 226 231 dialog = gtk.MessageDialog( … … 311 316 def _load_element(self, name, value): 312 317 """Copy an element, preferbly from the list of new items, 313 otherwise from the element Factory.318 otherwise from the element factory. 314 319 If it does not exist there, do not copy it! 315 320 """ … … 416 421 def execute(self): 417 422 view = self._window.get_current_diagram_view() 418 #view.set_zoom(view.get_zoom() - 0.1)419 423 view.zoom(1 / 1.2) 420 424 … … 436 440 437 441 def execute(self): 438 self._window.get_current_diagram_view().set_zoom(1.0) 442 view = self._window.get_current_diagram_view() 443 # Fetch zoom factor from transformation matrix: 444 zx = view.matrix[0] 445 self._window.get_current_diagram_view().zoom(1 / zx) 439 446 440 447 register_action(Zoom100Action) gaphor/branches/new-canvas/gaphor/actions/itemactions.py
r1046 r1056 41 41 y = y + view.vadjustment.value 42 42 return x, y 43 44 class ItemActionSupport(object): 45 46 def init(self, window): 47 self._window = window 48 49 def get_pointer(self): 50 view = self._window.get_current_diagram_view() 51 x, y = view.get_pointer() 52 x = x + view.hadjustment.value 53 y = y + view.vadjustment.value 54 return x, y 55 56 pointer = property(get_pointer) 57 58 def get_focused_item(self): 59 """Get the focused item in the current diagram view. 60 """ 61 view = self._window.get_current_diagram_view() 62 if view: 63 item = view.focused_item 64 if item: 65 return item 66 raise NoFocusItemError, 'No item has focus.' 67 68 focused_item = property(get_focused_item) 69 43 70 44 71 class ItemNewSubjectAction(Action): … … 1291 1318 1292 1319 1293 class DisconnectConnector(Action ):1320 class DisconnectConnector(Action, ItemActionSupport): 1294 1321 id = 'DisconnectConnector' 1295 1322 label = '_Disconnect Connector' 1296 1323 tooltip = 'Disconnect connected item' 1297 1324 1298 def init(self, window):1299 self._window = window1300 1301 def update(self): 1302 try: 1303 item = get_focused_item(self._window)1325 # def init(self, window): 1326 # self._window = window 1327 1328 def update(self): 1329 try: 1330 item = self.focused_item 1304 1331 except NoFocusItemError: 1305 1332 pass … … 1309 1336 @undoable 1310 1337 def execute(self): 1311 item = get_focused_item(self._window)1338 item = self.focused_item 1312 1339 assembly = item.parent 1313 1340 item.unlink() … … 1317 1344 1318 1345 1319 class ApplyInterfaceAction(RadioAction, ObjectAction ):1346 class ApplyInterfaceAction(RadioAction, ObjectAction, ItemActionSupport): 1320 1347 1321 1348 def __init__(self, interface): … … 1330 1357 def update(self): 1331 1358 try: 1332 item = get_focused_item(self._window)1359 item = self.focused_item 1333 1360 except NoFocusItemError: 1334 1361 pass … … 1339 1366 @undoable 1340 1367 def execute(self): 1341 item = get_focused_item(self._window)1368 item = self.focused_item 1342 1369 if self.active: 1343 1370 item.subject = self.interface
