Changeset 119
- Timestamp:
- 08/29/02 08:45:42 (6 years ago)
- Files:
-
- trunk/gaphor/ChangeLog (modified) (1 diff)
- trunk/gaphor/Makefile.am (modified) (1 diff)
- trunk/gaphor/gaphor/__init__.py (modified) (1 diff)
- trunk/gaphor/gaphor/gaphor.py (modified) (1 diff)
- trunk/gaphor/gaphor/misc/__init__.py (modified) (1 diff)
- trunk/gaphor/gaphor/misc/command.py (modified) (1 diff)
- trunk/gaphor/gaphor/misc/menufactory.py (added)
- trunk/gaphor/gaphor/ui/__init__.py (modified) (1 diff)
- trunk/gaphor/gaphor/ui/command/Files (modified) (1 diff)
- trunk/gaphor/gaphor/ui/command/__init__.py (modified) (1 diff)
- trunk/gaphor/gaphor/ui/command/file.py (added)
- trunk/gaphor/gaphor/ui/command/tree.py (modified) (1 diff)
- trunk/gaphor/gaphor/ui/diagramview.py (modified) (2 diffs)
- trunk/gaphor/gaphor/ui/diagramwindow.py (added)
- trunk/gaphor/gaphor/ui/mainwindow.py (modified) (3 diffs)
- trunk/gaphor/gaphor/ui/namespace.py (modified) (1 diff)
- trunk/gaphor/test-diagram.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gaphor/ChangeLog
r117 r119 1 2002-08-28 Arjan Molenaar <arjanmolenaar@hetnet.nl> 2 3 * Makefile.am: Now require Automake 1.6 4 1 5 2002-08-26 Arjan Molenaar <arjanmolenaar@hetnet.nl> 2 6 trunk/gaphor/Makefile.am
r117 r119 1 # Require automake-1. 52 AUTOMAKE_OPTIONS = 1. 51 # Require automake-1.6 2 AUTOMAKE_OPTIONS = 1.6 3 3 4 4 SUBDIRS = utils doc tests trunk/gaphor/gaphor/__init__.py
r109 r119 1 __all__ = [ 'gaphor', 'UML', 'diagram', 'tree', 'ui', 'misc' ] 1 __all__ = [ 'UML', 'diagram', 'tree', 'ui', 'misc' ] 2 3 from gaphor import Gaphor trunk/gaphor/gaphor/gaphor.py
r117 r119 2 2 3 3 # 4 # G Modeler main application4 # Gaphor main application 5 5 # 6 6 # vim:sw=4 7 7 8 8 from misc.singleton import Singleton 9 import gtk 10 import gnome 11 import gnome.ui 12 import ui 9 import config 13 10 14 11 class Gaphor(Singleton): 15 12 NAME='gaphor' 16 VERSION= '0.1'13 VERSION=config.GAPHOR_VERSION 17 14 TITLE='Gaphor v' + VERSION 18 15 19 16 def init(self): 20 #gnome.init(Gaphor.NAME, Gaphor.VERSION + 21 self.app = gnome.ui.App(Gaphor.NAME, Gaphor.TITLE) 22 self.app_bar = gnome.ui.AppBar (0, 1, gnome.ui.USER) 23 self.app.set_menubar(self.app_bar) 24 #view = gnome.ui.MDIGenericChild('window1') 25 #self.app.add_view(view) 26 pass 17 import gnome 18 import ui 19 gnome.program_init(Gaphor.NAME, Gaphor.VERSION) 20 self.__mainwindow = ui.MainWindow(Gaphor.NAME, Gaphor.TITLE) 27 21 28 22 def main(self): 23 import gtk 29 24 gtk.main() 30 25 31 32 #app = Gaphor() 33 #app.main() 34 26 def get_mainwindow(self): 27 return self.__mainwindow trunk/gaphor/gaphor/misc/__init__.py
r101 r119 1 1 2 __all__ = [ 'singleton', 'command', 'signal', 'storage' ]2 __all__ = [ 'singleton', 'command', 'signal', 'storage', 'menufactory' ] 3 3 4 4 from gaphorerror import GaphorError trunk/gaphor/gaphor/misc/command.py
r105 r119 16 16 def execute (self): 17 17 pass 18 19 def is_valid (self): 20 """ 21 Tells us if a command is reasy to be executed. 22 In menu's this method is called when a menu is opened. Non-valid 23 commands will be grayed out when the menu appears. 24 """ 25 return 1 trunk/gaphor/gaphor/ui/__init__.py
r117 r119 1 1 __all__ = [ 'command', 'namespace' ] 2 2 from mainwindow import * 3 from diagramwindow import * 3 4 from diagramview import * 4 5 from treeview import * trunk/gaphor/gaphor/ui/command/Files
r117 r119 1 1 __init__.py 2 2 about.py 3 loadsave.py3 file.py 4 4 tree.py trunk/gaphor/gaphor/ui/command/__init__.py
r108 r119 7 7 """ 8 8 9 __all__ = [ ' loadsave' ]9 __all__ = [ 'file', 'tree' ] trunk/gaphor/gaphor/ui/command/tree.py
r108 r119 11 11 def __init__(self, element): 12 12 Command.__init__(self) 13 self. element = element13 self.__element = element 14 14 15 15 def execute(self): 16 if isinstance(self.element, UML.Diagram): 17 print 'Opening Diagram', self.element.name 16 if isinstance(self.__element, UML.Diagram): 17 # Import here to avoid cyclic references 18 from gaphor.ui import DiagramWindow 19 from gaphor.gaphor import Gaphor 20 print 'Opening Diagram', self.__element.name 21 new_diagram = DiagramWindow(self.__element) 22 gaphor = Gaphor() 23 gaphor.get_mainwindow().add_window(new_diagram) 18 24 else: 19 print 'No action defined for element', self. element.__class__.__name__25 print 'No action defined for element', self.__element.__class__.__name__ trunk/gaphor/gaphor/ui/diagramview.py
r116 r119 7 7 from gaphor.misc.storage import Storage 8 8 from placementtool import PlacementTool 9 import command. loadsave9 import command.file 10 10 import command.about 11 11 … … 213 213 self.diagram = dia 214 214 self.item_factory = item_factory 215 self.save_command = command. loadsave.SaveCommand()216 self.load_command = command. loadsave.LoadCommand()217 215 self.save_command = command.file.SaveCommand() 216 self.load_command = command.file.OpenCommand() 217 trunk/gaphor/gaphor/ui/mainwindow.py
r117 r119 3 3 4 4 import gtk 5 import gnome.ui 5 6 import namespace 7 import command.file 6 8 import gaphor.UML as UML 7 from abstractwindow import AbstractWindow 9 import gaphor.config 10 from gaphor.misc.menufactory import MenuFactory, MenuItem, MenuSeparator 8 11 9 class MainWindow (AbstractWindow):12 class MainWindow: 10 13 """ 11 14 The main window for the application. It contains a Namespace-based tree 12 view and a menu and a statusbar. The statusbar can be populated by messages 13 with different levels of sevirity, from 0 (debug) to 9 (error). 14 Stuff like that should be defined in a AbstractWindow class. 15 view and a menu and a statusbar. 15 16 """ 16 17 17 def __init__(self): 18 def __2init__(self): 19 # Menu items have the following structure: 20 # ( Name, Comment, (ctrl) + Modifier, Command or Submenu ) 21 menu = MenuItem(submenu=( 22 MenuItem(name='_File', submenu=( 23 MenuItem(stock=gtk.STOCK_NEW, 24 comment='Create a new model', 25 command=command.file.NewCommand()), 26 MenuItem(stock=gtk.STOCK_OPEN, 27 comment='Open an existing model', 28 command=command.file.OpenCommand()), 29 MenuItem(stock=gtk.STOCK_SAVE, 30 comment='Save current model', 31 command=command.file.SaveCommand()), 32 MenuSeparator(), 33 MenuItem(stock=gtk.STOCK_QUIT, 34 comment='Exit Gaphor', 35 command=command.file.QuitCommand()) 36 ,)) 37 ,)) 18 38 win = gtk.Window () 19 39 accelgroup = gtk.AccelGroup() … … 21 41 model = namespace.NamespaceModel(UML.ElementFactory()) 22 42 view = namespace.NamespaceView(model) 23 menubar = gtk.MenuBar() 43 44 menu_factory = MenuFactory(menu=menu, accelgroup=accelgroup, statusbar=statusbar) 45 menubar = menu_factory.create_menu() 24 46 25 47 vbox = gtk.VBox(homogeneous=gtk.FALSE) … … 40 62 win.show_all() 41 63 42 s elf.statusbar.push (0, 'Welcome...')64 statusbar.push (0, 'Gaphor v%s' % gaphor.config.GAPHOR_VERSION) 43 65 44 def push(self, message): 45 self.statusbar.push (0, message) 46 # TODO: create timeout 66 def __init__(self, name, title): 67 # Menu items have the following structure: 68 # ( Name, Comment, (ctrl) + Modifier, Command or Submenu ) 69 menu = MenuItem(submenu=( 70 MenuItem(name='_File', submenu=( 71 MenuItem(stock=gtk.STOCK_NEW, 72 comment='Create a new model', 73 command=command.file.NewCommand()), 74 MenuItem(stock=gtk.STOCK_OPEN, 75 comment='Open an existing model', 76 command=command.file.OpenCommand()), 77 MenuItem(stock=gtk.STOCK_SAVE, 78 comment='Save current model', 79 command=command.file.SaveCommand()), 80 MenuSeparator(), 81 MenuItem(stock=gtk.STOCK_QUIT, 82 comment='Exit Gaphor', 83 command=command.file.QuitCommand()) 84 ,)) 85 ,)) 86 app = gnome.ui.App (name, title) 87 app.set_default_size (200, 300) 88 accelgroup = gtk.AccelGroup() 89 app.add_accel_group (accelgroup) 90 app_bar = gnome.ui.AppBar (has_progress=0, has_status=1, 91 interactivity=gnome.ui.PREFERENCES_USER) 92 app.set_statusbar(app_bar) 93 model = namespace.NamespaceModel(UML.ElementFactory()) 94 view = namespace.NamespaceView(model) 47 95 48 def __execute_command(self, menu_item, command): 49 try: 50 command.execute() 51 except Exception, e: 52 self.push('Operation failed: ' + e) 96 menu_factory = MenuFactory(menu=menu, accelgroup=accelgroup, 97 statusbar=app_bar) 98 menubar = menu_factory.create_menu() 53 99 100 app.set_menus(menubar) 101 app.set_contents(view) 102 103 self.__app = app 104 self.__model = model 105 self.__view = view 106 self.__menubar = menubar 107 self.__windows = [] 108 app.show_all() 109 110 def add_window(self, window): 111 self.__windows.append(window) 112 trunk/gaphor/gaphor/ui/namespace.py
r114 r119 286 286 OpenModelElementCommand(item).execute() 287 287 288 def _event(self, event):289 if event.type == gtk.gdk._2BUTTON_PRESS:290 def handle_selection(model, path, iter):291 print 'Handling:', model, path, iter292 element = model.get_value(iter, 0)293 OpenModelElementCommand(element).execute()294 295 selection = self.get_selection()296 selection.selected_foreach(handle_selection)288 # def _event(self, event): 289 # if event.type == gtk.gdk._2BUTTON_PRESS: 290 # def handle_selection(model, path, iter): 291 # print 'Handling:', model, path, iter 292 # element = model.get_value(iter, 0) 293 # OpenModelElementCommand(element).execute() 294 # 295 # selection = self.get_selection() 296 # selection.selected_foreach(handle_selection) 297 297 298 298 gobject.type_register(NamespaceModel) trunk/gaphor/test-diagram.py
r117 r119 6 6 import sys 7 7 import gtk 8 from gaphor.gaphor import Gaphor 8 9 import gaphor.diagram as diagram 9 10 import diacanvas … … 78 79 #usecase.name = 'aap' 79 80 80 ui.MainWindow(); 81 #ui.MainWindow(); 82 gaphorMain = Gaphor() 81 83 82 84 print 'Going into main'
