[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: branch: master updated (2f6c636ffb4e2c143c6620b904bf823d0850d28d)



The branch, master has been updated
       via  2f6c636ffb4e2c143c6620b904bf823d0850d28d (commit)
      from  d7435b1c02f40a52f4875782166a55d9703d4314 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/gedamanager.py |  441 ++++++++++++++++++++++++++++++++++++----------------
 src/newproject.py  |    4 +-
 src/newproject.pyc |  Bin 8267 -> 8545 bytes
 src/project.py     |   87 ++++++++---
 src/project.pyc    |  Bin 2386 -> 3594 bytes
 src/settings.py    |   45 ++++--
 src/settings.pyc   |  Bin 4620 -> 5090 bytes
 src/utils.pyc      |  Bin 1154 -> 1222 bytes
 8 files changed, 400 insertions(+), 177 deletions(-)


=================
 Commit Messages
=================

commit 2f6c636ffb4e2c143c6620b904bf823d0850d28d
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Sun Jul 6 00:31:18 2008 -0700

    Fixed found bugs.  Started on tree view.

:100644 100644 cff7a0d... 2b58335... M	src/gedamanager.py
:100644 100644 2f7e913... 5c3d4d0... M	src/newproject.py
:100644 100644 86da592... 1e3fe14... M	src/newproject.pyc
:100644 100644 7fc8fc5... 36c8b7e... M	src/project.py
:100644 100644 feb94fc... 9e48ac4... M	src/project.pyc
:100644 100644 03d3d01... 9de8d77... M	src/settings.py
:100644 100644 b0555d9... 2329ac7... M	src/settings.pyc
:100644 100644 060fe3b... 6370409... M	src/utils.pyc

=========
 Changes
=========

commit 2f6c636ffb4e2c143c6620b904bf823d0850d28d
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Sun Jul 6 00:31:18 2008 -0700

    Fixed found bugs.  Started on tree view.

diff --git a/src/gedamanager.py b/src/gedamanager.py
index cff7a0d..2b58335 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -26,18 +26,19 @@ class gEDAManager:
         gEDAManager Constructor
         """
         # Initialize gEDA Manager
+        self.no_project_name = 'No project loaded...\n\n Select:\n  File->Open Project\n  or File->New Project'
         self.settings = Settings()
-        self.project = Project()
-        self.project.connect('saved', self.cb_project_changed)
-        self.project.connect('opened', self.cb_project_changed)
         if self.settings.project != None:
-            self.project.name = self.settings.project
+            self.project = Project(self.settings.project)
         else:
-            print "no project in config.yaml"
+            self.project = Project()
+        self.project.connect('closed', self.cb_project_closed)
+        self.project.connect('saved', self.cb_project_saved)
+        self.project.connect('opened', self.cb_project_opened)
         self.utils = Utils()
         # Create top-level window
         self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
-        self.window.connect('destroy', lambda w: gtk.main_quit())
+        self.window.connect('destroy', self.cb_destroy)
         self.window.set_title('gEDA Manager')
         self.merge_id = 0
         # TODO create gEDA Manager icon
@@ -108,7 +109,7 @@ class gEDAManager:
         actiongroup0_list = [('File', None, '_File'),
         ('New Project', None, 'Ne_w Project', None, 'Create New Project', self.cb_new_project),
         ('Open Project', None, 'Open P_roject', None, 'Open Existing Project', self.cb_open_project),
-        ('Close Project', None, 'Close Projec_t', None, 'Close Active Project'),
+        ('Close Project', None, 'Close Projec_t', None, 'Close Active Project', self.cb_close_project),
         ('Save Project As...', None, 'Save Pro_ject As...', None,
          'Save Active Project As...', self.cb_save_project_as),
         ('New', gtk.STOCK_NEW, '_New', '<Control>n', 'New File'),
@@ -151,7 +152,7 @@ class gEDAManager:
         ('Refresh', gtk.STOCK_REFRESH, 'R_efresh', 'F5'),
         ('Project', None, '_Project'),
         ('New Source...', None, '_New Source...'),
-        ('Add Source...', None, '_Add Source...'),
+        ('Add Source...', None, '_Add Source...', None, None, self.cb_add_source),
         ('Add Copy of Source...', None, 'Add _Copy of Source...'),
         ('Window', None, '_Window'),
         ('New Window', None, '_New Window'),
@@ -206,11 +207,7 @@ class gEDAManager:
         # Have to figure out if I really want toolbars in the gui or not
         toolbars_menu = self.uimanager.get_widget('/MenuBar/View/Toolbars')
         toolbars_menu.set_sensitive(False)
-        if self.project.name != None:
-            self.set_no_project_default()
-        else:
-            # load the project and all the files that it had            
-            pass
+        self.set_menu_defaults()
         
         self.vbox1 = gtk.VBox()
         self.vbox1.show()
@@ -235,7 +232,7 @@ class gEDAManager:
         vpaned1.show()
 
         hpaned1 = gtk.HPaned()
-        vpaned1.pack1(hpaned1, False, True)
+        vpaned1.pack1(hpaned1, True, True)
         hpaned1.set_position(250)
         hpaned1.show()
 
@@ -253,38 +250,107 @@ class gEDAManager:
         textview1.show()
         scrolled_window.add(textview1)
         
-        # TreeView
-        notebook1 = gtk.Notebook()
-        notebook1.show()
-        hpaned1.pack1(notebook1, False, True)
-        notebook1.set_tab_pos(gtk.POS_BOTTOM)
-
+        # Tree Views
+        # --
+        # 1) For treeviews you create a store (database)
+        # which is linked to the treeview
+        # 2) create columns and append this to the treeview
+        # 3) create CellRenders and pack them into the columns
+        # 4) Use column.add_attribute to 'show' the data in the store
+        # 5) Add data to the store
+        vpaned2 = gtk.VPaned()
+        vpaned2.show()
+        hpaned1.pack1(vpaned2, True, True)
+        sources_notebook = gtk.Notebook()
+        sources_notebook.show()
+        processes_notebook = gtk.Notebook()
+        processes_notebook.show()
+        vpaned2.pack1(sources_notebook, True, True)
+        vpaned2.pack2(processes_notebook, True, True)        
+        sources_notebook.set_tab_pos(gtk.POS_BOTTOM)
+        processes_notebook.set_tab_pos(gtk.POS_BOTTOM)
         scrolled_window1 = gtk.ScrolledWindow()
         scrolled_window1.show()
+        scrolled_window2 = gtk.ScrolledWindow()
+        scrolled_window2.show()
         scrolled_window1.set_shadow_type(gtk.SHADOW_IN)
-        notebook1.add(scrolled_window1)
+        scrolled_window2.set_shadow_type(gtk.SHADOW_IN)        
+        sources_notebook.add(scrolled_window1)
+        processes_notebook.add(scrolled_window2)        
 
+        # labels
         sources_label = gtk.Label('Sources')
         sources_label.show()
-        notebook1.set_tab_label(notebook1.get_nth_page(0), sources_label)
-
-        self.treestore = gtk.TreeStore(str)
-        self.treeview = gtk.TreeView(self.treestore)
-        self.treeview.show()
-        self.tvcolumn = gtk.TreeViewColumn(self.project.name)        
-        self.treeview.append_column(self.tvcolumn)
-        self.cell = gtk.CellRendererText()
-        self.tvcolumn.pack_start(self.cell, True)
-        # retrieve text
-        self.tvcolumn.add_attribute(self.cell, 'text', 0)
+        processes_label = gtk.Label('Processes')
+        processes_label.show()
+        sources_notebook.set_tab_label(sources_notebook.get_nth_page(0), sources_label)
+        processes_notebook.set_tab_label(processes_notebook.get_nth_page(0), processes_label)
+
+        # data stores
+##         self.sources = gtk.TreeStore(gtk.gdk.Pixbuf,
+##                                        gobject.TYPE_STRING,
+##                                        gobject.TYPE_OBJECT)
+##         self.processes = gtk.TreeStore(gtk.gdk.Pixbuf,
+##                                        gobject.TYPE_STRING,
+##                                        gobject.TYPE_OBJECT)
+
+        self.sources = gtk.TreeStore(str)
+        self.processes = gtk.TreeStore(str)
+        
+        # views
+        self.sources_tree = gtk.TreeView(self.sources)
+        self.sources_tree.show()
+        self.sources_tree.connect('button_press_event', self.cb_treeview_popup)
+        self.sources_tree.connect('row-activated', self.cb_row_activated)
+        self.processes_tree = gtk.TreeView(self.processes)
+        self.processes_tree.show()
+        if self.project.name == self.no_project_name: 
+            project_name = self.project.name
+        else:
+            project_name = self.project.name.split('.')[0] # do not display .gm
+
+        # column headings
+        self.sources_tvcolumn = gtk.TreeViewColumn(project_name)
+        self.processes_tvcolumn = gtk.TreeViewColumn('Processes for: ') # Need to add the name of the highlighted node
+
+        # associate columns with views
+        self.sources_tree.append_column(self.sources_tvcolumn)
+        self.processes_tree.append_column(self.processes_tvcolumn)
+
+        # set some properties
+        self.sources_tree.set_property('enable-tree-lines', True)
+        self.processes_tree.set_property('enable-tree-lines', True)
+
+        # cell renderers
+        sources_cell = gtk.CellRendererText()
+        processes_cell = gtk.CellRendererText()
+##         sources_pic = gtk.CellRendererPixbuf()
+##         processes_pic = gtk.CellRendererPixbuf()
+        self.sources_tvcolumn.pack_start(sources_cell, True)
+        self.processes_tvcolumn.pack_start(processes_cell, True)
+##         self.sources_tvcolumn.pack_start(sources_pic, True)
+##         self.processes_tvcolumn.pack_start(processes_pic, True)
+
+        # retrieve text and images
+        self.sources_tvcolumn.add_attribute(sources_cell, 'text', 0)
+        self.processes_tvcolumn.add_attribute(processes_cell, 'text', 0)
+
         # make it searchable
-        self.treeview.set_search_column(0)
+        self.sources_tree.set_search_column(0)
+        self.processes_tree.set_search_column(0)
+
         # allow sorting on the column
-        self.tvcolumn.set_sort_column_id(0)
+        self.sources_tvcolumn.set_sort_column_id(0)
+
         # allow drag and drop
-        self.treeview.set_reorderable(True)
+#        self.sources_tree.set_reorderable(True)
+
         # add to the scrolling window
-        scrolled_window1.add(self.treeview)
+        scrolled_window1.add(self.sources_tree)
+        scrolled_window2.add(self.processes_tree)        
+
+        # add data to the store to test things out
+        self.set_tree()
 
         # Lower Notebook Window
         notebook = gtk.Notebook()
@@ -329,32 +395,38 @@ class gEDAManager:
         textview4.show()
         scrolled_window5.add(textview4)
 
-        warnings_icon = gtk.image_new_from_stock('gtk-dialog-warning',
-                                                 gtk.ICON_SIZE_BUTTON)
-        warnings_icon.show()
-        notebook.set_tab_label(notebook.get_nth_page(2), warnings_icon)
-
-        scrolled_window6 = gtk.ScrolledWindow()
-        scrolled_window6.show()
-        scrolled_window6.set_shadow_type(gtk.SHADOW_IN)
-        notebook.add(scrolled_window6)
-
-        textview5 = gtk.TextView()
-        textview5.show()
-        scrolled_window6.add(textview5)
-
         terminal_icon = gtk.Image()
         terminal_icon.set_from_file('../icons/terminal.jpg')
         terminal_icon.show()
-        notebook.set_tab_label(notebook.get_nth_page(3), terminal_icon)
+        notebook.set_tab_label(notebook.get_nth_page(2), terminal_icon)
+
+    ####################################
+    # Methods 
+    ####################################
+
+    def set_menu_defaults(self):
+        """
+        Method to coordinate set_*_default methods below
+        """
+        # Project
+        if self.project.name == None:
+            self.set_no_project_default()
+        else:
+            self.set_project_default()
 
+        # Files
+        if self.project.file_list != None:
+            self.set_files_default()
+        else:
+            self.set_no_files_default()
+        
 
     def set_no_project_default(self):
         """
         Method to set the default sensitivity when no project is loaded
         """
         # File Menu
-        self.project.name = 'No project loaded...\n\n Select:\n  File->Open Project\n  or File->New Project'
+        self.project.name = self.no_project_name
         save_project_as_menuitem = self.uimanager.get_widget('/MenuBar/File/Save Project As...')
         close_project_menuitem = self.uimanager.get_widget('/MenuBar/File/Close Project')
         save_project_as_menuitem.set_sensitive(False)
@@ -364,14 +436,12 @@ class gEDAManager:
         project_menu = self.uimanager.get_widget('/MenuBar/Project')        
         project_menu.set_sensitive(False)
         
-        # Call other defaults
-        self.set_no_files_default()
-
 
     def set_project_default(self):
         """
         Method to set the default sensitivity when a project is loaded
         """
+        # File Menu
         save_project_as_menuitem = self.uimanager.get_widget('/MenuBar/File/Save Project As...')
         close_project_menuitem = self.uimanager.get_widget('/MenuBar/File/Close Project')
         save_project_as_menuitem.set_sensitive(True)
@@ -381,10 +451,6 @@ class gEDAManager:
         project_menu = self.uimanager.get_widget('/MenuBar/Project')        
         project_menu.set_sensitive(True)
         
-        # Call other defaults
-        if self.project.file_list != None:
-            self.set_files_default()
-        
         
     def set_no_files_default(self):
         """
@@ -504,6 +570,7 @@ class gEDAManager:
         window_menu = self.uimanager.get_widget('/MenuBar/Window')
         window_menu.set_sensitive(True)
 
+
     def set_project(self, path):
         """
         Method to set current project to the one on path
@@ -519,16 +586,112 @@ class gEDAManager:
         Method to set the tree to current Project object
         """
         # Set the project tree
-        self.tvcolumn.set_title(self.project.name)
+        if self.project.name == self.no_project_name:
+            project_name = self.project.name
+        else:
+            project_name = self.project.name.split('.')[0]
+        self.sources_tvcolumn.set_title(project_name)
+        self.sources.clear()
         if self.project.file_list != None:
-            # set up the tree
-            pass
+            self.load_tree(self.project.file_list)
+            self.sources_tree.expand_all()        
+
+
+    def load_tree(self, list, parent=None):
+        """
+        Method to the load the tree -- recursively
+        """
+        # TODO -- this will need to be changed whenver the datastore is changed
+        for f in list:
+            if f[0] == '/': # means this file is a parent
+                node = f.split('/')[-1]
+                n_parent = self.sources.append(parent, [node]) # next parent
+            else:
+                # recursion
+                self.load_tree(f, n_parent)
+
+
+    def save_tree(self):
+        """
+        Method to save the tree to the project.file_list
+        """
+        
+
+    def save_settings(self):
+        """
+        Method to save current settings to config.yaml file
+        """
+        if self.project.directory and self.project.name:
+            if not self.project.name.endswith('.gm'):
+                self.settings.project = self.project.directory + '/' + self.project.name + '.gm'
+            else:
+                self.settings.project = self.project.directory + '/' + self.project.name                 
         else:
-            # don't set up the tree
-            pass
+            self.settings.project = None
+        self.settings.create_config_file()
+        gtk.main_quit()
+
+
+    def add_node(self, path):
+        """
+        Method to add the filename path to the treestore
+        """
+        # TODO -- this will change if the data store changes
+        # TODO -- Need to see if a node with the same name already exists
+        # to do this I will need to loop through the file_list
+
+        if self.project.file_list != None:
+            self.project.file_list.append(path)
+        else:
+            self.project.file_list = [path]
+        node = path.split('/')[-1]                    
+        self.sources.append(None, [node])
+
+    def file_filters(self, dialog):
+        """
+        Method to abstract some redundant code
+        """
+        file_filter = gtk.FileFilter()
+        file_filter.set_name("All files")
+        file_filter.add_pattern('*')
+        dialog.add_filter(file_filter)
+
+        file_filter = gtk.FileFilter()
+        file_filter.set_name("Schematics (.sch)")
+        file_filter.add_pattern('*.sch')
+        dialog.add_filter(file_filter)
+        
+        file_filter = gtk.FileFilter()
+        file_filter.set_name("Symbols (.sym)")
+        file_filter.add_pattern('*.sym')
+        dialog.add_filter(file_filter)
 
+        file_filter = gtk.FileFilter()
+        file_filter.set_name("PCB (.pcb)")
+        file_filter.add_pattern('*.pcb')
+        dialog.add_filter(file_filter)
 
+        file_filter = gtk.FileFilter()
+        file_filter.set_name("Verilog (.v)")
+        file_filter.add_pattern('*.v')
+        dialog.add_filter(file_filter)
 
+        file_filter = gtk.FileFilter()
+        file_filter.set_name("VHDL (.vhd)")
+        file_filter.add_pattern('*.vhd')
+        dialog.add_filter(file_filter)
+
+        file_filter = gtk.FileFilter()
+        file_filter.set_name("BOM (.bom)")
+        file_filter.add_pattern('*.bom')
+        dialog.add_filter(file_filter)
+
+        file_filter = gtk.FileFilter()
+        file_filter.set_name("DRC (.drc)")
+        file_filter.add_pattern('*.drc')
+        dialog.add_filter(file_filter)
+
+    
     ######################################################
     # Callback Methods -- signal handlers are event driven
     ######################################################
@@ -578,24 +741,15 @@ class gEDAManager:
         """
         Event handler for New Project
         """
-        # This will open a new window which will help the user
-        # save a new project
-        # NewProject is an object that returns a Project object
-
-        # TODO check whether or not they would like to save any files
-        # that have not been saved yet.
-        # Then after this, save the project file regardless is one is
-        # currently active
-        # clear what is ever in the tree
-        # TODO We only need to save the settings when the program is exiting.
-        new_project = NewProject(self)
+        self.project.save()
+        NewProject(self)
 
         
     def cb_open_project(self, menuitem, data=None):
         """
         Event handler for Open Project
         """
-        # This will open a file dialog box that will search for .gm files
+        self.project.save()
         dialog = gtk.FileChooserDialog('Open...',
                                        self.window,
                                        gtk.FILE_CHOOSER_ACTION_OPEN,
@@ -619,15 +773,16 @@ class gEDAManager:
         """
         Event handler for Close Project
         """
-        # This will close the current project and take it out of the treeview
-
+        self.project.save()
+        self.project.close();
+        
         
     def cb_save_project_as(self, menuitem, date=None):
         """
         Event handler for Save Project As...
         """
         # This will open a Save dialog box
-        if not self.project.name == '':
+        if self.project.name != None:
                     dialog = gtk.FileChooserDialog('Save Project As...',
                                                    self.window,
                                                    gtk.FILE_CHOOSER_ACTION_SAVE,
@@ -653,8 +808,9 @@ class gEDAManager:
                         filename = dialog.get_filename()
                         if not filename.endswith('.gm'):
                             filename += '.gm'
-                            print filename
-                            self.project.save(filename)
+                        self.project.name = filename.rsplit('/')[-1].split('.')[0]
+                        self.project.directory = filename.rpartition('/')[0]
+                        self.project.save()
                     dialog.destroy()
 
 
@@ -678,30 +834,13 @@ class gEDAManager:
                                         gtk.STOCK_OPEN, gtk.RESPONSE_OK))
 
         dialog.set_default_response(gtk.RESPONSE_OK)
-
-        file_filter = gtk.FileFilter()
-        file_filter.set_name("All files")
-        file_filter.add_pattern('*')
-        dialog.add_filter(file_filter)
-
-        file_filter = gtk.FileFilter()
-        file_filter.set_name("Schematics (.sch)")
-        file_filter.add_pattern('*.sch')
-        dialog.add_filter(file_filter)
-        
-        file_filter = gtk.FileFilter()
-        file_filter.set_name("Symbols (.sym)")
-        file_filter.add_pattern('*.sym')
-        dialog.add_filter(file_filter)
-
+        self.file_filters(dialog)
         response = dialog.run()
         if response == gtk.RESPONSE_OK:
             filename = dialog.get_filename()
-            print filename
-        elif response == gtk.RESPONSE_CANCEL:
-            print 'Closed, no files selected'
         dialog.destroy()
 
+
     def cb_close(self, menuitem, date=None):
         """
         Event handler for Close
@@ -729,28 +868,10 @@ class gEDAManager:
 
         dialog.set_default_response(gtk.RESPONSE_OK)
         dialog.set_current_name('New Document')
-
-        file_filter = gtk.FileFilter()
-        file_filter.set_name("All files")
-        file_filter.add_pattern('*')
-        dialog.add_filter(file_filter)
-        
-        file_filter = gtk.FileFilter()
-        file_filter.set_name("Schematic (.sch)")
-        file_filter.add_pattern('*.sch')
-        dialog.add_filter(file_filter)
-        
-        file_filter = gtk.FileFilter()
-        file_filter.set_name("Symbols (.sym)")
-        file_filter.add_pattern('*.sym')
-        dialog.add_filter(file_filter)
-
+        self.file_filters(dialog)
         response = dialog.run()
         if response == gtk.RESPONSE_OK:
             filename = dialog.get_filename()
-            print filename
-        elif response == gtk.RESPONSE_CANCEL:
-            print 'Closed, no files selected'
         dialog.destroy()
 
 
@@ -773,9 +894,8 @@ class gEDAManager:
         """
         Event handler for Exit
         """
-        # TODO
-        # Check if there are any open files to save before exiting
-        gtk.main_quit()
+        self.project.save()
+        self.save_settings()
         
 
     # Edit Menu #
@@ -784,7 +904,6 @@ class gEDAManager:
         Event handler for Cut
         """
         
-        
 
     def cb_copy(self, menuitem, date=None):
         """
@@ -829,20 +948,61 @@ class gEDAManager:
         Event occurs when an expander is activated
         """
 
-    def cb_project_changed(self, widget, event):
+    # TODO -- decide if I want to combine the three functions below
+    def cb_project_closed(self, widget, event):
         """
-        Event occurs when a Project object is saved or opened
+        Event occurs when a Project object is closed
         """
-        # now that we have a saved project update the tree with the new name etc
-        #self.tvcolumn = gtk.TreeViewColumn(self.project.name)
+        print 'project closed'
+        self.set_menu_defaults()
+        self.set_tree()
+
+    def cb_project_saved(self, widget, event):
+        """
+        Event occurs when a Project object is saved 
+        """
+        print 'project saved'
+        self.set_menu_defaults()
+        self.set_tree()
+
+    def cb_project_opened(self, widget, event):
+        """
+        Event occurs when a Project object is opened
+        """
+        print 'project opened'
+        self.set_menu_defaults()
         self.set_tree()
-                
-    
-    def button_press_event(self, widget, event):
-        if event.type == gtk.gdk.BUTTON_PRESS:
-            print "Newell: this currently works"
 
-    def treeview_popup(self, widget, event):
+    def cb_add_source(self, menuitem, data=None):
+        """
+        Event occurs when the user wants to add a source to the project
+        """
+        dialog = gtk.FileChooserDialog('Add Source...',
+                                       self.window,
+                                       gtk.FILE_CHOOSER_ACTION_OPEN,
+                                       (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+                                        gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+
+        dialog.set_default_response(gtk.RESPONSE_OK)
+        self.file_filters(dialog)
+        response = dialog.run()
+        if response == gtk.RESPONSE_OK:
+            filename = dialog.get_filename()
+            self.add_node(filename)
+        dialog.destroy()
+
+        
+    def cb_row_activated(self, widget, path, view_column):
+        """
+        Event occurs when 'row-activated' signal is emitted or a user double
+        clicks on a treeview row.
+        """
+        # TODO I will use this call back to see what node is double clicked
+        # I will know this from the path
+        print widget, path, view_column
+        
+
+    def cb_treeview_popup(self, widget, event):
         """
         This signal handler will be called when the treeview emits
         a 'button_press_event' signal
@@ -851,10 +1011,17 @@ class gEDAManager:
 ##             menu1 = gtk.Menu()
 ##             # Create menu items for the popup
 
-        # I will need to connect the treeview to this signal handler later by
-        # doing treeview.connect('button_press_event', self.treeview_popup)
-        
-            
+        if event.button == 3:
+            # find out what type of file is selected and
+            # open up the appropriate context menu for this file
+            print 'testing for tree'
+
+    def cb_destroy(self, event):
+        """
+        Event handlder when the form is closed in any fashion
+        """
+        self.project.save()
+        self.save_settings()
 
 
     ########################################################
diff --git a/src/newproject.py b/src/newproject.py
index 2f7e913..5c3d4d0 100644
--- a/src/newproject.py
+++ b/src/newproject.py
@@ -24,6 +24,7 @@ class NewProject:
         NewProject Constructor
         """
         self.project = gedamanager.project
+        print 'gedamanager.project.name: ', gedamanager.project.name
         self.assistant = gtk.Assistant()
         self.assistant.connect('close', self.cb_close)
         self.assistant.connect('apply', self.cb_apply)
@@ -203,12 +204,10 @@ class NewProject:
                 no_overwrite = (overwrite_list == [])
                 if no_overwrite:
                     # No files will be overwritten, we are done
-                    print "no_overwrite: ", no_overwrite
                     self.overwrite_frame.hide_all()
                     self.assistant.set_page_complete(self.summary_page, True)
                 else:
                     # Need confirmation before overwriting files
-                    print "no_overwrite: ", no_overwrite
                     self.overwrite_frame.show_all()
                     self.confirm_overwrite.set_active(False)
 
@@ -229,6 +228,7 @@ class NewProject:
         try:
             self.project.name = self.get_filename()
             self.project.directory = self.get_path()
+            self.project.file_list = None
             self.project.save()
         except IOError, (errno, strerror):
             md = gtk.MessageDialog(self.assistant,
diff --git a/src/newproject.pyc b/src/newproject.pyc
index 86da592..1e3fe14 100644
Binary files a/src/newproject.pyc and b/src/newproject.pyc differ
diff --git a/src/project.py b/src/project.py
index 7fc8fc5..36c8b7e 100644
--- a/src/project.py
+++ b/src/project.py
@@ -19,38 +19,80 @@ class Project(gobject.GObject):
       -- directory
       -- file_list (list paths to files)
     """
-    __gsignals__ = {'saved': (gobject.SIGNAL_NO_RECURSE,
+    __gsignals__ = {'closed': (gobject.SIGNAL_NO_RECURSE,
+                                gobject.TYPE_NONE,
+                                (gobject.TYPE_BOOLEAN, )),
+                    'saved': (gobject.SIGNAL_NO_RECURSE,
                               gobject.TYPE_NONE,
                               (gobject.TYPE_BOOLEAN, )),
                     'opened': (gobject.SIGNAL_NO_RECURSE,
                                gobject.TYPE_NONE,
                                (gobject.TYPE_BOOLEAN, )),
                     }
+
     
-    def __init__(self, name=None, directory=None, file_list=None):
+    def __init__(self, path=None):
         """
         Default Constructor
         """
         gobject.GObject.__init__(self)
-        
-        self.name = name
-        self.directory = directory
-        self.file_list = file_list
+
+        if path != None:
+            try:
+                self.name = path.rsplit('/')[-1].split('.')[0]
+                self.directory = path.rpartition('/')[0]
+                # open up project file
+                project = yaml.load(open(path))
+            except IOError:
+                project = 0
+            except yaml.YAMLError, exc:
+                if hasattr(exc, 'problem_mark'):
+                    mark = exc.problem_mark
+                    print 'There is an error in the' + path  + 'file'
+                    print "Error position: (%s:%s)" % (mark.line+1, mark.column+1)
+                    exit(-1)
+
+            if project:
+                # parse the config object and get list of apps
+                stream = file(path, 'r')
+                for data in yaml.load_all(stream):
+                    self.file_list = data['file_list']
+                    stream.close()
+            elif not project:
+                self.file_list = None
+        else:
+            self.name = None
+            self.directory = None
+            self.file_list = None
         self.clean = False
 
+    def close(self):
+        """
+        Method to emit the 'close' signal
+        """
+        self.name = None
+        self.directory = None
+        self.file_list = None
+        self.emit('closed', True)
+
+
     def save(self):
         """
         Method to write out the project file
         This file will be a tree hierarchy file
         """
-        if self.directory != None and self.name != None:        
-            path = self.directory + '/' + self.name
-            stream = file(path, 'w')
-            yaml.dump({'project': path}, stream, default_flow_style=False)
-            if not self.file_list == []:
-                yaml.dump({'file_list': self.file_list}, stream,
-                          default_flow_style=False)
-            stream.close()
+        if self.name != None and self.directory != None:
+            if not self.name.endswith('.gm'):
+                path = self.directory + '/' + self.name + '.gm'
+            else:
+                path = self.directory + '/' + self.name
+            try:
+                stream = file(path, 'w')
+                yaml.dump({'project': path, 'file_list': self.file_list},
+                          stream, default_flow_style=False)
+                stream.close()
+            except IOError:
+                print sys.exc_info()[0]
             self.clean = True
             self.emit('saved', True)
         else:
@@ -61,15 +103,16 @@ class Project(gobject.GObject):
         Method to open up project from path and set as current project
         """
         self.name = path.rsplit('/')[-1]
-        print self.name
         self.directory = path.rpartition('/')[0]
-        print self.directory
-        stream = file(path, 'r')
-        for data in yaml.load_all(stream):
-            self.file_list = data['file_list']
-        self.clean = True
-        self.emit('opened', True)
-        
+        try:
+            stream = file(path, 'r')
+            for data in yaml.load_all(stream):
+                self.file_list = data['file_list']
+            self.clean = True
+            self.emit('opened', True)
+        except IOError:
+            print path
+            print sys.exc_info()[0]        
 
 gobject.type_register(Project)
 
diff --git a/src/project.pyc b/src/project.pyc
index feb94fc..9e48ac4 100644
Binary files a/src/project.pyc and b/src/project.pyc differ
diff --git a/src/settings.py b/src/settings.py
index 03d3d01..9de8d77 100644
--- a/src/settings.py
+++ b/src/settings.py
@@ -5,14 +5,14 @@
 #Create and update the gEDA Manager configuration file config.yaml
 #@author Newell Jensen
 
-import os, sys, string, signal, yaml
+import os, sys, gtk, string, signal, yaml
 
 
 class Settings:
     """
     Settings for the gEDA Manager.
     This class takes care of configuring
-    the applicaton.
+    the applicaton settings.
     """
     def __init__(self):
         """
@@ -20,27 +20,48 @@ class Settings:
         """
         self.version = 1.0
         self.installed_apps = []
-        self.project = ''
+        self.project = None
+        self.path = os.path.expanduser('~') + '/.gmrc'
         self.geda_apps = ['gschem','pcb','gsch2pcb','gnucap','ngspice',
                           'iverilog','gattrib','gtkwave','gwave','gnetlist',
                           'tragesym','grenum','gerbv','wcalc','mcalc','olib']
         try:
-            config = yaml.load(open('config.yaml'))
+            config = yaml.load(open(self.path))
         except IOError:
             config = 0
         except yaml.YAMLError, exc:
             if hasattr(exc, 'problem_mark'):
                 mark = exc.problem_mark
-                print "There is an error in the config.yaml file"
+                print "There is an error in the .gmrc file"
                 print "Error position: (%s:%s)" % (mark.line+1, mark.column+1)
             exit(-1)
 
         if config:
             # parse the config object and get list of apps
-            stream = file('config.yaml', 'r')
+            stream = file(self.path, 'r')
+            
             for data in yaml.load_all(stream):
                 self.installed_apps = data['programs']
                 self.project = data['project']
+                # Check to see if this file is still available
+                if self.project != None:
+                    try:
+                        f = open(self.project)
+                    except IOError:
+                        md = gtk.MessageDialog(None,
+                                               (gtk.DIALOG_MODAL |
+                                                gtk.DIALOG_DESTROY_WITH_PARENT),
+                                               gtk.MESSAGE_ERROR,
+                                               gtk.BUTTONS_OK)
+                        md.set_markup('<span weight="bold" size="larger">Could not open project: ' + self.project + '.</span>')
+                        error_image = gtk.image_new_from_stock('gtk-dialog-error',
+                                                               gtk.ICON_SIZE_DIALOG)
+                        error_image.show()
+                        md.set_image(error_image)
+                        md.show_all
+                        md.run()
+                        md.hide_all()
+                        self.project = None
             stream.close()
         elif not config:
             # find installed apps and create the config file
@@ -79,7 +100,7 @@ class Settings:
         Create the configuration file for the
         gEDA Manager
         """
-        stream = file('config.yaml', 'w')
+        stream = file(self.path, 'w')
         document = """
         purpose: |
         
@@ -109,15 +130,7 @@ class Settings:
         """
         yaml.dump(yaml.load(document), stream, default_flow_style=False)
         yaml.dump({'programs': self.installed_apps, 'version': self.version,
-                   'project': ''}, stream, default_flow_style=False)
+                   'project': self.project}, stream, default_flow_style=False)
         stream.close()
 
 
-    def update_config_file(self, config_file):
-        """
-        Update the configuration file
-        @param config_file is the config.yaml file to update
-        """
-
-
-
diff --git a/src/settings.pyc b/src/settings.pyc
index b0555d9..2329ac7 100644
Binary files a/src/settings.pyc and b/src/settings.pyc differ
diff --git a/src/utils.pyc b/src/utils.pyc
index 060fe3b..6370409 100644
Binary files a/src/utils.pyc and b/src/utils.pyc differ




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs