Changeset 241
- Timestamp:
- 03/22/04 07:15:14 (5 years ago)
- Files:
-
- trunk/gaphor/TODO (modified) (1 diff)
- trunk/gaphor/doc/aspects-en.txt (added)
- trunk/gaphor/gaphor/UML/diagram.py (modified) (1 diff)
- trunk/gaphor/gaphor/UML/elementfactory.py (modified) (2 diffs)
- trunk/gaphor/gaphor/UML/properties.py (modified) (2 diffs)
- trunk/gaphor/gaphor/__init__.py (modified) (2 diffs)
- trunk/gaphor/gaphor/diagram/modelelement.py (modified) (1 diff)
- trunk/gaphor/gaphor/diagram/operation.py (modified) (1 diff)
- trunk/gaphor/gaphor/misc/action.py (modified) (2 diffs)
- trunk/gaphor/gaphor/misc/aspects.py (added)
- trunk/gaphor/gaphor/ui/diagramtab.py (modified) (4 diffs)
- trunk/gaphor/gaphor/ui/diagramview.py (modified) (3 diffs)
- trunk/gaphor/gaphor/ui/mainwindow.py (modified) (5 diffs)
- trunk/gaphor/gaphor/ui/menufactory.py (modified) (4 diffs)
- trunk/gaphor/gaphor/ui/namespace.py (modified) (3 diffs)
- trunk/gaphor/setup.py (modified) (3 diffs)
- trunk/gaphor/src (added)
- trunk/gaphor/src/gtkhwrapbox.c (added)
- trunk/gaphor/src/gtkhwrapbox.h (added)
- trunk/gaphor/src/gtkvwrapbox.c (added)
- trunk/gaphor/src/gtkvwrapbox.h (added)
- trunk/gaphor/src/gtkwrapbox.c (added)
- trunk/gaphor/src/gtkwrapbox.h (added)
- trunk/gaphor/src/wrapbox.defs (added)
- trunk/gaphor/src/wrapbox.override (added)
- trunk/gaphor/src/wrapboxmodule.c (added)
- trunk/gaphor/tests/menu.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gaphor/TODO
r220 r241 7 7 the canvas item once a reference is destroyed. 8 8 9 - Define a proper scheme for flushing models. Currently a lot of elements 10 have references around. This has to do with how PyGtk references python 11 and C objects. We should do something like: clean all diagram items, 12 then clean the rest of the elements in the ElementFactory. 13 9 14 - Class: Association end properties are shown in the tree view 10 15 - Undo/redo functionality doesn;t work as espected 11 - Implement and test attribute/operation parser.16 #- Implement and test attribute/operation parser. 12 17 - Convert Data model to use the parsed attributes + operations. 13 18 - Attributes are not added to classes that are loaded. 14 - Operation is not part of namespace (assoc. should be bi-dir.)19 #- Operation is not part of namespace (assoc. should be bi-dir.) 15 20 16 21 - Make sure than, when a model is loaded and saved again, both save files do trunk/gaphor/gaphor/UML/diagram.py
r231 r241 87 87 self.canvas.clear_undo() 88 88 self.canvas.clear_redo() 89 def dispose(item): 90 try: 91 for i in item.groupable_iter(): 92 dispose(i) 93 except AttributeError: 94 pass 95 try: 96 item.unlink() 97 except: 98 pass 99 # Clear all references on a C-level 100 item.dispose() 101 102 #for i in self.canvas.root.children: 103 # dispose(i) 104 89 105 Namespace.unlink(self) 90 for i in self.canvas.root.children:91 i.unlink()trunk/gaphor/gaphor/UML/elementfactory.py
r231 r241 3 3 """ 4 4 5 from diagram import Diagram6 5 import gaphor 7 6 import gaphor.misc.uniqueid as uniqueid 8 7 #import weakref 9 8 from element import Element 9 from diagram import Diagram 10 10 #from gaphor.misc.weakmethod import WeakMethod 11 11 … … 79 79 """Flush all elements (remove them from the factory).""" 80 80 self.notify(None, 'flush') 81 # First flush all diagrams: 82 for value in self.select(lambda e: isinstance(e, Diagram)): 83 value.unlink() 84 81 85 for key, value in self._elements.items(): 82 86 #print 'ElementFactory: unlinking', value 83 87 #print 'references:', gc.get_referrers(value) 84 88 value.unlink() 89 85 90 assert len(self._elements) == 0, 'Still items in the factory: %s' % str(self._elements.values()) 91 86 92 import gc 87 93 for i in range(4): gc.collect() trunk/gaphor/gaphor/UML/properties.py
r231 r241 80 80 obj.notify(self.name, pspec=self) 81 81 except Exception, e: 82 log.error(str(e) )82 log.error(str(e), e) 83 83 84 84 # we need to check if a deriviate is part of the current object: … … 98 98 d.notify(obj) 99 99 except Exception, e: 100 log.error(e )100 log.error(e, e) 101 101 102 102 trunk/gaphor/gaphor/__init__.py
r225 r241 77 77 78 78 example: Get the element factory: 79 elemfact= gaphor.resource(gaphor.UML.ElementFactory)79 factory = gaphor.resource(gaphor.UML.ElementFactory) 80 80 81 81 Also builtin resources are 'Name', 'Version' and 'DataDir'. In case main() … … 108 108 __builtin__.__dict__['log'] = misc.logger.Logger() 109 109 110 try: 111 # Keep track of all model elements that are created 112 from misc.aspects import ReferenceAspect, weave_method 113 import UML.elementfactory 114 import UML.diagram 115 refs = [] 116 weave_method(UML.elementfactory.ElementFactory.create, ReferenceAspect, refs) 117 weave_method(UML.diagram.Diagram.create, ReferenceAspect, refs) 118 except ImportError: 119 pass 120 trunk/gaphor/gaphor/diagram/modelelement.py
r225 r241 61 61 62 62 def on_glue(self, handle, wx, wy): 63 #import sys 64 #print self, handle, '=>', sys.getrefcount(self), sys.getrefcount(handle) 63 65 return self._on_glue(handle, wx, wy, diacanvas.CanvasElement) 64 66 trunk/gaphor/gaphor/diagram/operation.py
r221 r241 22 22 def on_subject_notify__name(self, subject, pspec): 23 23 self._expression.set_text(self.subject.render()) 24 #self.request_update()24 self.request_update() 25 25 26 26 on_subject_notify__visibility = on_subject_notify__name trunk/gaphor/gaphor/misc/action.py
r231 r241 149 149 def execute(self, action_id): 150 150 global _dependent_actions 151 print 'ActionPool: executing', action_id151 #print 'ActionPool: executing', action_id 152 152 action = self.get_action(action_id) 153 153 action.execute() … … 155 155 for d in _dependent_actions.get(action_id) or (): 156 156 dep_action = self.get_action(d) 157 print 'ActionPool: updating', d157 #print 'ActionPool: updating', d 158 158 dep_action.update() 159 159 trunk/gaphor/gaphor/ui/diagramtab.py
r231 r241 12 12 self.owning_window = owning_window 13 13 14 #def set_owning_window(self, owning_window):15 #self.owning_window = owning_window16 17 14 def get_diagram(self): 18 15 return self.diagram 19 16 20 17 def get_view(self): 21 #self._check_state(AbstractWindow.STATE_ACTIVE)22 18 return self.view 23 19 … … 84 80 #toolbar.show() 85 81 #vbox.show_all() 86 self.table = table82 #self.table = table 87 83 #self._construct_window(name='diagram', 88 84 # title=title, … … 98 94 self.owning_window.remove_tab(self) 99 95 self.set_diagram(None) 96 # We need this to get the view deleted properly: 97 del self.view.diagram 100 98 del self.view 101 99 del self.diagram 102 100 103 101 def __on_view_event_after(self, view, event): 104 #self._check_state(AbstractWindow.STATE_ACTIVE)105 102 # handle mouse button 3 (popup menu): 106 103 if event.type == gtk.gdk.BUTTON_PRESS: … … 114 111 self.owning_window._construct_popup_menu(menu_def=item.get_popup_menu(), 115 112 event=event) 116 #self.stop_emission('event-after')117 113 return True 118 114 return False trunk/gaphor/gaphor/ui/diagramview.py
r215 r241 6 6 from diacanvas import CanvasView 7 7 import gaphor 8 from gaphor.diagram import get_diagram_item 8 9 9 10 class DiagramView(CanvasView): … … 47 48 48 49 def on_drag_data_received(self, context, x, y, data, info, time): 49 print 'drag_data_received'50 #rint 'drag_data_received' 50 51 if data and data.format == 8 and info == DiagramView.TARGET_ELEMENT_ID: 51 from gaphor.diagram import get_diagram_item 52 print 'drag_data_received:', data.data, info 52 #print 'drag_data_received:', data.data, info 53 53 elemfact = gaphor.resource('ElementFactory') 54 54 element = elemfact.lookup(data.data) … … 70 70 71 71 def do_drag_drop(self, context, x, y, time): 72 print 'drag_drop'72 #print 'drag_drop' 73 73 return 1 74 74 trunk/gaphor/gaphor/ui/mainwindow.py
r231 r241 52 52 'separator', 53 53 'FileSave', 54 'FileSaveAs' ,55 'separator', 56 'Pointer',54 'FileSaveAs') 55 56 wrapbox = ('Pointer', 57 57 'separator', 58 58 'InsertClass', … … 112 112 scrolled_window = gtk.ScrolledWindow() 113 113 scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 114 scrolled_window.set_shadow_type(gtk.SHADOW_ETCHED_IN)114 #scrolled_window.set_shadow_type(gtk.SHADOW_ETCHED_IN) 115 115 scrolled_window.add(view) 116 116 … … 121 121 122 122 #scrolled_window.show_all() 123 #ns_paned = gtk.VPaned() 124 #ns_paned.pack1(scrolled_window)#, expand=True) 125 vbox = gtk.VBox() 126 vbox.pack_start(scrolled_window, expand=True) 123 127 124 128 paned = gtk.HPaned() 125 paned.pack1(scrolled_window) 126 129 #paned.pack1(scrolled_window) 130 #paned.pack1(ns_paned) 131 paned.pack1(vbox) 127 132 notebook = gtk.Notebook() 128 133 #notebook.popup_enable() … … 144 149 contents=paned) 145 150 #contents=scrolled_window) 151 wrapbox = self.menu_factory.create_wrapbox(self.wrapbox) 152 #wrapbox.set_aspect_ratio(1/256) 153 vbox.pack_start(wrapbox, expand=False) 154 wrapbox.show() 155 #vbox.set_resize_mode(gtk.RESIZE_QUEUE) 156 #wrapbox.set_resize_mode(gtk.RESIZE_QUEUE) 157 #scrolled_window = gtk.ScrolledWindow() 158 #scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) 159 #scrolled_window.set_shadow_type(gtk.SHADOW_ETCHED_IN) 160 #scrolled_window.add_with_viewport(wrapbox) 161 #scrolled_window.show() 162 #ns_paned.pack2(scrolled_window)#, expand=False) 163 #wrapbox.queue_resize() 164 #wrapbox.set_size_request(0,0) 165 166 #def print_me(wrapbox, rect, mutex): 167 # print wrapbox, rect, mutex 168 # if not mutex: 169 # mutex.append(1) 170 # wrapbox.queue_resize() 171 # mutex.remove(1) 172 173 #paned.connect('motion-notify-event', print_me) 174 #wrapbox.connect('size-allocate', print_me, []) 146 175 147 176 def add_transient_window(self, window): … … 175 204 return page_num 176 205 177 current = self.notebook.get_current_page()178 content = self.notebook.get_nth_page(current)179 return self.notebook_map[content]180 181 206 def get_current_tab(self): 182 207 current = self.notebook.get_current_page() trunk/gaphor/gaphor/ui/menufactory.py
r225 r241 9 9 import gtk 10 10 from gaphor.misc.action import ActionError, Action, CheckAction, RadioAction 11 import gaphor.misc.wrapbox 11 12 12 13 #from logilab.aspects.weaver import weaver … … 46 47 except ActionError: 47 48 return None 49 50 def get_icon_and_label(self, action, icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR): 51 if action.stock_id: 52 # Fetch stock icon, and probably a text and tooltip: 53 stock_info = gtk.stock_lookup(action.stock_id) 54 #print stock_info # (id, label, mod, key, translationdomain) 55 try: 56 label = stock_info[1].replace('_', '') 57 except TypeError: 58 label = action.label.replace('_', '') 59 icon = gtk.Image() 60 icon.set_from_stock(action.stock_id, icon_size) 61 else: 62 label = action.label.replace('_', '') 63 icon = None 64 return icon, label 48 65 49 66 def on_item_activate(self, menu_item, action_id): … … 225 242 user_data=None) 226 243 else: 227 if action.stock_id: 228 # Fetch stock icon, and probably a text and tooltip: 229 stock_info = gtk.stock_lookup(action.stock_id) 230 #print stock_info # (id, label, mod, key, translationdomain) 231 try: 232 label = stock_info[1].replace('_', '') 233 except TypeError: 234 label = action.label.replace('_', '') 235 icon = gtk.Image() 236 icon.set_from_stock(action.stock_id, toolbar.get_icon_size()) 237 else: 238 label = action.label.replace('_', '') 239 icon = None 244 icon, label = self.get_icon_and_label(action, toolbar.get_icon_size()) 240 245 if isinstance(action, RadioAction): 241 246 try: … … 279 284 return toolbar 280 285 286 def create_wrapbox(self, menu_def): 287 """Create a Wrapbox. items in menu_def should not be nested as 288 they are when creating a normal menu. 289 """ 290 wrapbox = gaphor.misc.wrapbox.HWrapBox() 291 groups = { } 292 for id in menu_def: 293 action = self.get_action(id) 294 if not action: 295 if id == 'separator': 296 sep = gtk.HSeparator() 297 wrapbox.add(sep) 298 sep.show() 299 continue 300 label = id 301 icon = None 302 item = gtk.Button() 303 else: 304 icon, label = self.get_icon_and_label(action) 305 if isinstance(action, RadioAction): 306 try: 307 group = groups[action.group] 308 except KeyError: 309 group = None 310 item = gtk.RadioButton(group) 311 item.set_mode(False) 312 item.connect('toggled', self.on_radio_item_activate, action.id) 313 self.connect_item_to_action('notify::active', action, item, 314 self.on_radio_menu_item_notify_active) 315 self.in_activation = True 316 if not group: 317 groups[action.group] = item 318 #else: 319 # item.set_group(group) 320 item.set_active(action.active) 321 self.in_activation = False 322 elif isinstance(action, CheckAction): 323 item = gtk.CheckButton() 324 item.set_mode(False) 325 item.connect('toggled', self.on_check_item_activate, action.id) 326 self.connect_item_to_action('notify::active', action, item, 327 self.on_menu_item_notify_action) 328 self.in_activation = True 329 item.set_active(action.active) 330 self.in_activation = False 331 else: 332 #if action.stock_id: 333 #item = gtk.Button(action.stock_id) 334 #item.set_property('use-stock', True) 335 #else: 336 item = gtk.Button() 337 if action.stock_id: 338 #item.set_property('stock-id', action.stock_id) 339 item.add(icon) 340 icon.show() 341 pass 342 else: 343 item.set_label(label) 344 item.set_property('visible', action.visible) 345 item.set_property('sensitive', action.sensitive) 346 self.connect_item_to_action('notify::visible', action, item, 347 self.on_menu_item_notify_action) 348 self.connect_item_to_action('notify::sensitive', action, item, 349 self.on_menu_item_notify_action) 350 wrapbox.pack(item, False, False, False, False) 351 item.show() 352 return wrapbox 353 trunk/gaphor/gaphor/ui/namespace.py
r225 r241 10 10 11 11 import gaphor.UML as UML 12 13 # The following items will not be shown in the treeview, although they 14 # are UML.Namespace elements. 15 _default_exclude_list = ( UML.Parameter, UML.Association ) 12 16 13 17 class NamespaceModel(gtk.GenericTreeModel): … … 34 38 self.root = (None, []) 35 39 40 self.exclude = _default_exclude_list 36 41 37 42 def new_node_from_element(self, element, parent): 38 43 """Create a new node for an element. Owned members are also created.""" 44 if isinstance(element, self.exclude): 45 return 39 46 node = (element, []) 40 47 parent[1].append(node) … … 155 162 node_members = map(lambda e: e[0], node[1]) 156 163 # The elements that are now children of the element 157 owned_members = element.ownedMember 164 owned_members = filter(lambda e: not isinstance(e, self.exclude), element.ownedMember) 165 #owned_members = element.ownedMember 158 166 if len(node_members) < len(owned_members): 159 167 # element added trunk/gaphor/setup.py
r228 r241 298 298 299 299 300 from dsextras import TemplateExtension, BuildExt, GLOBAL_INC 301 302 pygtkincludedir = getoutput('pkg-config --variable pygtkincludedir pygtk-2.0') 303 codegendir = getoutput('pkg-config --variable codegendir pygtk-2.0') 304 defsdir = getoutput('pkg-config --variable defsdir pygtk-2.0') 305 306 sys.path.append(codegendir) 307 308 GLOBAL_INC.append(pygtkincludedir) 309 GLOBAL_INC.append('.') 310 GTKDEFS = [os.path.join(defsdir, 'gtk-types.defs')] 311 312 ext_modules = [] 313 gtkwrapbox = TemplateExtension(name='wrapbox', 314 pkc_name='gtk+-2.0', 315 pkc_version='2.0.0', 316 output='gaphor.misc.wrapbox', 317 defs='src/wrapbox.defs', 318 sources=['src/gtkwrapbox.c', 319 'src/gtkhwrapbox.c', 320 'src/wrapbox.c', 321 'src/wrapboxmodule.c'], 322 register=GTKDEFS, 323 override='src/wrapbox.override') 324 325 if gtkwrapbox.can_build(): 326 ext_modules.append(gtkwrapbox) 327 else: 328 pass 329 300 330 setup(name='gaphor', 301 331 version=VERSION, … … 315 345 'gaphor.misc' 316 346 ], 347 ext_modules=ext_modules, 317 348 # data files are relative to <prefix>/share/gaphor (see setup.cfg) 318 349 data_files=[('', ['data/gaphor-main-ui.xml', … … 329 360 #'install_schemas': install_schemas, 330 361 'build': build, 362 'build_ext': BuildExt, 331 363 'build_mo': build_mo, 332 364 'build_pot': build_pot, trunk/gaphor/tests/menu.py
r225 r241 214 214 vbox.pack_start(event_box, expand=gtk.TRUE) 215 215 216 wrap_box = menu_factory.create_wrapbox(('FileNew', 'FileCheck', 'separator', 'Green', 'Yellow', 'Blue')) 217 vbox.pack_start(wrap_box, expand=gtk.TRUE) 218 wrap_box.show() 219 216 220 vbox.pack_end(statusbar, expand=gtk.FALSE) 217 221 vbox.show()
