Changeset 119

Show
Ignore:
Timestamp:
08/29/02 08:45:42 (6 years ago)
Author:
arjanmol
Message:

*** empty log message ***

Files:

Legend:

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

    r117 r119  
     12002-08-28  Arjan Molenaar  <arjanmolenaar@hetnet.nl> 
     2 
     3        * Makefile.am: Now require Automake 1.6 
     4 
    152002-08-26  Arjan Molenaar  <arjanmolenaar@hetnet.nl> 
    26 
  • trunk/gaphor/Makefile.am

    r117 r119  
    1 # Require automake-1.5 
    2 AUTOMAKE_OPTIONS = 1.5 
     1# Require automake-1.6 
     2AUTOMAKE_OPTIONS = 1.6 
    33 
    44SUBDIRS = 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 
     3from gaphor import Gaphor 
  • trunk/gaphor/gaphor/gaphor.py

    r117 r119  
    22 
    33# 
    4 # GModeler main application 
     4# Gaphor main application 
    55# 
    66# vim:sw=4 
    77 
    88from misc.singleton import Singleton 
    9 import gtk 
    10 import gnome 
    11 import gnome.ui 
    12 import ui 
     9import config 
    1310 
    1411class Gaphor(Singleton): 
    1512    NAME='gaphor' 
    16     VERSION='0.1' 
     13    VERSION=config.GAPHOR_VERSION 
    1714    TITLE='Gaphor v' + VERSION 
    1815 
    1916    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) 
    2721 
    2822    def main(self): 
     23        import gtk 
    2924        gtk.main() 
    3025 
    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  
    11 
    2 __all__ = [ 'singleton', 'command', 'signal', 'storage'
     2__all__ = [ 'singleton', 'command', 'signal', 'storage', 'menufactory'
    33 
    44from gaphorerror import GaphorError 
  • trunk/gaphor/gaphor/misc/command.py

    r105 r119  
    1616    def execute (self): 
    1717        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  
    11__all__ = [ 'command', 'namespace' ] 
    22from mainwindow import * 
     3from diagramwindow import * 
    34from diagramview import * 
    45from treeview import * 
  • trunk/gaphor/gaphor/ui/command/Files

    r117 r119  
    11__init__.py 
    22about.py 
    3 loadsave.py 
     3file.py 
    44tree.py 
  • trunk/gaphor/gaphor/ui/command/__init__.py

    r108 r119  
    77""" 
    88 
    9 __all__ = [ 'loadsave' ] 
     9__all__ = [ 'file', 'tree' ] 
  • trunk/gaphor/gaphor/ui/command/tree.py

    r108 r119  
    1111    def __init__(self, element): 
    1212        Command.__init__(self) 
    13         self.element = element 
     13        self.__element = element 
    1414 
    1515    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) 
    1824        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  
    77from gaphor.misc.storage import Storage 
    88from placementtool import PlacementTool 
    9 import command.loadsav
     9import command.fil
    1010import command.about 
    1111 
     
    213213        self.diagram = dia 
    214214        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  
    33 
    44import gtk 
     5import gnome.ui 
    56import namespace 
     7import command.file 
    68import gaphor.UML as UML 
    7 from abstractwindow import AbstractWindow 
     9import gaphor.config 
     10from gaphor.misc.menufactory import MenuFactory, MenuItem, MenuSeparator 
    811 
    9 class MainWindow(AbstractWindow)
     12class MainWindow
    1013    """ 
    1114    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. 
    1516    """ 
    1617 
    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                    ,)) 
    1838        win = gtk.Window () 
    1939        accelgroup = gtk.AccelGroup() 
     
    2141        model = namespace.NamespaceModel(UML.ElementFactory()) 
    2242        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() 
    2446 
    2547        vbox = gtk.VBox(homogeneous=gtk.FALSE) 
     
    4062        win.show_all() 
    4163         
    42         self.statusbar.push (0, 'Welcome...'
     64        statusbar.push (0, 'Gaphor v%s' % gaphor.config.GAPHOR_VERSION
    4365 
    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) 
    4795 
    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() 
    5399 
     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  
    286286        OpenModelElementCommand(item).execute() 
    287287 
    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) 
     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) 
    297297             
    298298gobject.type_register(NamespaceModel) 
  • trunk/gaphor/test-diagram.py

    r117 r119  
    66import sys 
    77import gtk 
     8from gaphor.gaphor import Gaphor 
    89import gaphor.diagram as diagram 
    910import diacanvas 
     
    7879#usecase.name = 'aap' 
    7980 
    80 ui.MainWindow(); 
     81#ui.MainWindow(); 
     82gaphorMain = Gaphor() 
    8183 
    8284print 'Going into main'