Changeset 1279

Show
Ignore:
Timestamp:
05/14/07 20:43:33 (1 year ago)
Author:
arj..@yirdis.nl
Message:

added about screen

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/gaphor/services/filemanager.py

    r1276 r1279  
    3232              <menuitem action="file-new" /> 
    3333              <menuitem action="file-open" /> 
     34              <menu name="recent" action="file-recent-files"> 
     35              </menu> 
    3436              <separator /> 
    3537              <menuitem action="file-save" /> 
     
    4850      </ui> 
    4951    """ 
    50 #              <menu name="recent" action="file-recent-files"> 
    51 #              </menu> 
    5252 
    5353    def __init__(self): 
     
    5757        self._app = app 
    5858        self.action_group = build_action_group(self) 
     59        for name, label in (('file-recent-files', '_Recent files'),): 
     60            a = gtk.Action(name, label, None, None) 
     61            # TODO: enable this line once we have a recent-files impl. 
     62            #a.set_property('hide-if-empty', False) 
     63            self.action_group.add_action(a) 
    5964 
    6065    def shutdown(self): 
  • gaphor/trunk/gaphor/ui/consolewindow.py

    r1268 r1279  
    2020        <ui> 
    2121          <menubar name="mainwindow"> 
    22             <menu action="window"> 
     22            <menu action="tools"> 
    2323              <menuitem action="ConsoleWindow:open" /> 
    2424            </menu> 
     
    5454            self.window.show_all() 
    5555 
    56     @action(name='ConsoleWindow:close', stock_id='gtk-close'
     56    @action(name='ConsoleWindow:close', stock_id='gtk-close', accel='<Control><Shift>w'
    5757    def close(self): 
    5858        self.window.destroy() 
  • gaphor/trunk/gaphor/ui/diagramtab.py

    r1276 r1279  
    7070 
    7171    def construct(self): 
    72         #title = self.diagram and self.diagram.name or _('<None>') 
     72        """ 
     73        Create the widget. 
     74         
     75        Returns: the newly created widget. 
     76        """ 
    7377 
    7478        table = gtk.Table(2,2, False) 
    75         #table.set_row_spacings(4) 
    76         #table.set_col_spacings(4) 
    7779 
    7880        frame = gtk.Frame() 
     
    103105 
    104106        table.show_all() 
    105  
    106         self.owning_window.add_tab(self, table, self.title) 
     107        self.widget = table 
     108        return table 
    107109 
    108110    @action(name='diagram-close', stock_id='gtk-close') 
     
    113115        """ 
    114116        # Set diagram to None, so all refrences to the diagram are destroyed. 
     117        #self.widget.destroy() 
     118 
    115119        self.owning_window.remove_tab(self) 
    116120        self.set_diagram(None) 
  • gaphor/trunk/gaphor/ui/mainwindow.py

    r1276 r1279  
    140140            ) 
    141141 
    142     toolbar =  ('FileOpen', 
    143                 'separator', 
    144                 'FileSave', 
    145                 'FileSaveAs', 
    146                 'separator', 
    147                 'Undo', 
    148                 'Redo', 
    149                 'separator', 
    150                 'ViewZoomIn', 
    151                 'ViewZoomOut', 
    152                 'ViewZoom100') 
    153     ns_popup = ('RenameModelElement', 
    154                 'OpenModelElement', 
    155                 'separator', 
    156                 'CreateDiagram', 
    157                 'DeleteDiagram', 
    158                 'separator', 
    159                 'RefreshNamespaceModel', 
    160                 '<NamespacePopupSlot>') 
    161142    # </old> 
    162143 
     
    169150      <ui> 
    170151        <menubar name="mainwindow"> 
    171           <menu name="file" action="file"> 
     152          <menu action="file"> 
    172153            <placeholder name="primary" /> 
    173154            <placeholder name="secondary" /> 
     
    176157            <menuitem action="file-quit" /> 
    177158          </menu> 
    178           <menu name="edit" action="edit"> 
     159          <menu action="edit"> 
    179160            <placeholder name="primary" /> 
    180161            <placeholder name="secondary" /> 
    181162            <placeholder name="ternary" /> 
    182163          </menu> 
    183           <menu name="diagram" action="diagram"> 
     164          <menu action="diagram"> 
    184165            <placeholder name="primary" /> 
    185166            <placeholder name="secondary" /> 
    186167            <placeholder name="ternary" /> 
    187168          </menu> 
    188           <menu name="window" action="window"> 
     169          <menu action="tools"> 
    189170            <placeholder name="primary" /> 
    190171            <placeholder name="secondary" /> 
    191172            <placeholder name="ternary" /> 
    192173          </menu> 
    193           <menu name="help" action="help"> 
     174          <menu action="window"> 
     175            <placeholder name="primary" /> 
     176            <placeholder name="secondary" /> 
     177            <placeholder name="ternary" /> 
     178          </menu> 
     179          <menu action="help"> 
    194180            <placeholder name="primary" /> 
    195181            <placeholder name="secondary" /> 
     
    204190          <menuitem action="tree-view-open" /> 
    205191          <menuitem action="tree-view-rename" /> 
     192          <separator /> 
     193          <menuitem action="tree-view-create-diagram" /> 
     194          <menuitem action="tree-view-delete-diagram" /> 
     195          <separator /> 
     196          <menuitem action="tree-view-refresh" /> 
    206197        </popup> 
    207198      </ui> 
    208199    """ 
    209 #            <menuitem name="New" action="FileNew" /> 
    210 #            <menuitem name="Open" action="FileOpen" /> 
    211 #            <menuitem name="Revert" action="FileRevert" /> 
    212 #            <menu name="Recent files" action="FileRecent"> 
    213 #              <placeholder action="RecentFiles" /> 
    214 #            </menu> 
    215 #            <separator /> 
    216 #            <menuitem action="FileSave" /> 
    217 #            <menuitem action="FileSaveAs" /> 
    218 #            <placeholder action="SaveSlot" /> 
    219 #            <separator /> 
    220 #            <menu action="Import"> 
    221 #              <placeholder action="FileImportSlot" /> 
    222 #            </menu> 
    223 #            <menu action="Export"> 
    224 #              <placeholder action="FileExportSlot" /> 
    225 #            </menu> 
    226 #            <separator /> 
    227 #            <menuitem action="FileCloseTab" /> 
    228 #            <placeholder action="FileSlot" /> 
    229 #            <separator /> 
    230  
    231 #          <toolitem action="FileOpen" /> 
    232 #          <toolitem action="separator" /> 
    233 #          <toolitem action="FileSave" /> 
    234 #          <toolitem action="FileSaveAs" /> 
    235 #          <separator /> 
    236 #          <toolitem action="Undo" /> 
    237 #          <toolitem action="Redo" /> 
    238 #          <separator /> 
    239 #          <toolitem action="ViewZoomIn" /> 
    240 #          <toolitem action="ViewZoomOut" /> 
    241 #          <toolitem action="ViewZoom100" /> 
    242  
    243 #        <popup action="NamespacePopup"> 
    244 #          <menuitem action="RenameModelElement" /> 
    245 #          <menuitem action="OpenModelElement" /> 
    246 #          <separator /> 
    247 #          <menuitem action="CreateDiagram" /> 
    248 #          <menuitem action="DeleteDiagram" /> 
    249 #          <separator /> 
    250 #          <menuitem action="RefreshNamespaceModel" /> 
    251 #          <placeholder action="namespacePopupSlot" /> 
    252 #        </popup> 
    253200 
    254201    def __init__(self): 
     
    264211                             ('edit', '_Edit'), 
    265212                             ('diagram', '_Diagram'), 
     213                             ('tools', '_Tools'), 
    266214                             ('window', '_Window'), 
    267215                             ('help', '_Help')): 
    268216            a = gtk.Action(name, label, None, None) 
    269             a.set_property('is-important', True) 
     217            a.set_property('hide-if-empty', False) 
    270218            self.action_group.add_action(a) 
    271219        self._tab_ui_settings = None 
     
    359307        tab = DiagramTab(self) 
    360308        tab.set_diagram(diagram) 
    361         tab.construct() 
     309        widget = tab.construct() 
     310        self.add_tab(tab, widget, tab.title) 
     311        self.set_current_page(tab) 
     312 
    362313        return tab 
    363314 
     
    385336         
    386337        notebook = gtk.Notebook() 
    387         #notebook.popup_enable() 
    388338        notebook.set_scrollable(True) 
    389339        notebook.set_show_border(False) 
    390         #notebook.set_size_request(-1, 10000) 
    391340 
    392341        notebook.connect_after('switch-page', self._on_notebook_switch_page) 
     
    435384        self.window.connect('destroy', self._on_window_destroy) 
    436385 
    437         # TODO: add action_groups and menu_xml from NamespaceView 
    438  
    439 #    def add_transient_window(self, window): 
    440 #        """Add a window as a sub-window of the main application. 
    441 #        """ 
    442 #        # Assign the window the accelerators od the main window too 
    443 #        pass #window.get_window().add_accel_group(self.accel_group) 
    444 #        #self._transient_windows.append(window) 
    445 #        #window.connect(self.on_transient_window_closed) 
    446386 
    447387    # Notebook methods: 
     
    453393        """ 
    454394        self.notebook_map[contents] = tab_id 
     395        #contents.connect('destroy', self._on_tab_destroy) 
    455396        l = gtk.Label(label) 
    456397        # Note: append_page() emits switch-page event 
     
    499440                self.notebook.remove_page(num) 
    500441                del self.notebook_map[p] 
    501                 if self._tab_ui_settings: 
    502                     action_group, ui_id = self._tab_ui_settings 
    503                     self.ui_manager.remove_action_group(action_group) 
    504                     self.ui_manager.remove_ui(ui_id) 
    505442                return 
    506443 
     
    532469        gtk.main_quit() 
    533470 
     471    def _on_tab_destroy(self, widget): 
     472        tab = self.notebook_map[widget] 
     473        assert isinstance(tab, DiagramTab) 
     474        self.remove_tab(tab) 
     475 
    534476    def _on_window_delete(self, window = None, event = None): 
    535477        return not self.ask_to_close() 
     
    563505        A dummy action is executed. 
    564506        """ 
     507        log.debug('Switching page to %d' % page_num) 
    565508        if self._tab_ui_settings: 
    566509            action_group, ui_id = self._tab_ui_settings 
    567510            self.ui_manager.remove_action_group(action_group) 
    568511            self.ui_manager.remove_ui(ui_id) 
     512            self.ui_manager.ensure_update() 
    569513 
    570514        content = self.notebook.get_nth_page(page_num) 
     
    575519        ui_id = self.ui_manager.add_ui_from_string(tab.menu_xml) 
    576520        self._tab_ui_settings = tab.action_group, ui_id 
     521        self.ui_manager.ensure_update() 
     522        log.debug('Menus updated with %s, %d' % self._tab_ui_settings) 
    577523 
    578524    def _on_window_size_allocate(self, window, allocation): 
     525        """ 
     526        Store the window size in a property. 
     527        """ 
    579528        self.properties.set('ui.window-size', (allocation.width, allocation.height)) 
    580  
    581     def _on_window_destroy(self, window): 
    582         self.quit() 
    583529 
    584530    def _on_object_inspector_notify_position(self, paned, arg): 
    585531        self.properties.set('ui.object-inspector-position', 
    586532                     paned.get_position()) 
    587  
    588 #    def on_transient_window_closed(self, window): 
    589 #        assert window in self._transient_windows 
    590 #        log.debug('%s closed.' % window) 
    591 #        self._transient_windows.remove(window) 
    592533 
    593534    # Actions: 
     
    617558        cell.set_property('editable', 0) 
    618559 
     560    @action(name='tree-view-create-diagram', label=_('_New diagram'), stock_id='gaphor-diagram') 
     561    def tree_view_create_diagram(self): 
     562        element = self._tree_view.get_selected_element() 
     563        diagram = self.element_factory.create(UML.Diagram) 
     564        diagram.package = element 
     565 
     566        diagram.name = '%s diagram' % element.name 
     567 
     568        self.select_element(diagram) 
     569        self.show_diagram(diagram) 
     570        self.tree_view_rename_selected() 
     571 
     572    @action(name='tree-view-delete-diagram', label=_('_Delete diagram'), stock_id='gtk-delete') 
     573    def tree_view_delete_diagram(self): 
     574        diagram = self._tree_view.get_selected_element() 
     575        assert isinstance(diagram, UML.Diagram) 
     576        m = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, 
     577                              gtk.BUTTONS_YES_NO, 
     578                              'Do you really want to delete diagram %s?\n\n' 
     579                              'This will possibly delete diagram items\n' 
     580                              'that are not shown in other diagrams.\n' 
     581                              'This operation is not undoable!' \ 
     582                              % (diagram.name or '<None>')) 
     583        if (m.run() == gtk.RESPONSE_YES): 
     584            diagram.unlink() 
     585        m.destroy() 
     586 
     587    @action(name='tree-view-refresh', label=_('_Refresh')) 
     588    def tree_view_refresh(self): 
     589        self._tree_view.get_model().refresh() 
     590 
    619591 
    620592gtk.accel_map_add_filter('gaphor') 
  • gaphor/trunk/setup.py

    r1277 r1279  
    8686            'gui_manager = gaphor.services.guimanager:GUIManager', 
    8787            'action_manager = gaphor.services.actionmanager:ActionManager', 
     88            'help = gaphor.services.helpservice:HelpService', 
    8889        ], 
    8990        'gaphor.uicomponents': [ 
     
    123124) 
    124125  
    125 # vim:se=4:et:ai 
     126# vim:sw=4:et:ai