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

gEDA-cvs: geda_manager.git: branch: master updated (ada59c0179fe56f9b959f18966ed639b16f3ccc2)



The branch, master has been updated
       via  ada59c0179fe56f9b959f18966ed639b16f3ccc2 (commit)
      from  003c1a0e29b8709af45db6291e343945440bc7d1 (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 |  108 ++++++++++++++++-----------
 src/gsch2pcb.py    |  210 ++++++++++++++++++++++++++++++++++++++++++----------
 src/newproject.py  |    2 +-
 3 files changed, 237 insertions(+), 83 deletions(-)


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

commit ada59c0179fe56f9b959f18966ed639b16f3ccc2
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Mon Aug 25 01:30:52 2008 -0700

    Routine checkin.

:100644 100644 7a3c1a5... 8c90012... M	src/gedamanager.py
:100644 100644 aad0f48... 1596144... M	src/gsch2pcb.py
:100644 100644 591a9e8... c355427... M	src/newproject.py

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

commit ada59c0179fe56f9b959f18966ed639b16f3ccc2
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Mon Aug 25 01:30:52 2008 -0700

    Routine checkin.

diff --git a/src/gedamanager.py b/src/gedamanager.py
index 7a3c1a5..8c90012 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -172,6 +172,7 @@ class gEDAManager:
         sources_notebook.show()
         processes_notebook = gtk.Notebook()
         processes_notebook.show()
+        sources_notebook.connect('switch-page', self.cb_switch_page)
         vpaned.pack1(sources_notebook, True, True)
         vpaned.pack2(processes_notebook, True, True)        
         sources_notebook.set_tab_pos(gtk.POS_BOTTOM)
@@ -459,14 +460,14 @@ class gEDAManager:
     def set_dependencies_tree_to_project(self):
         """ Method to set the tree to current project object. """
 
-##         self.dependencies.clear()
-##         if self.project.dependency_dict != None:
-##             self.depnum = 0
-##             self.load_dependencies_tree(self.project.dependency_dict)
-##             self.dependencies_tree.expand_all()        
+        self.dependencies.clear()
+        if self.project.dependency_dict != None:
+            self.depnum = 0
+            self.load_dependencies_tree(self.project.dependency_dict)
+            self.dependencies_tree.expand_all()        
 
-##         # Connect to the 'columns-changed' signal
-##         self.dependencies.connect('row-changed', self.cb_row_changed)
+        # Connect to the 'columns-changed' signal
+        self.dependencies.connect('row-changed', self.cb_row_changed)
 
 
     def set_sources_tree_to_new_project(self):
@@ -494,20 +495,20 @@ class gEDAManager:
     def set_dependencies_tree_to_new_project(self):
         """ Method to set the tree to newly created project object. """
 
- ##        self.dependencies.clear()
-##         # Parent Folder
-##         project_path = self.project.directory + '/' + self.project.name        
-##         project_file_path = project_path + '.gm'        
-##         output_file_path = self.project.directory + '/output.log'
-##         error_file_path = self.project.directory + '/error.log'
-##         self.dependencies.append(None, [self.project.name + '.gm', project_file_path])
-##         self.dependencies.append(None, ['output.log', output_file_path])
-##         self.dependencies.append(None, ['error.log', error_file_path])
-##         self.dependencies_tree.expand_all()
-
-##         # Connect to the 'columns-changed' signal
-##         self.dependencies.connect('row-changed', self.cb_row_changed)
-##         self.depnum = 3
+        self.dependencies.clear()
+        # Parent Folder
+        project_path = self.project.directory + '/' + self.project.name        
+        project_file_path = project_path + '.gm'        
+        output_file_path = self.project.directory + '/output.log'
+        error_file_path = self.project.directory + '/error.log'
+        self.dependencies.append(None, [self.project.name + '.gm', project_file_path])
+        self.dependencies.append(None, ['output.log', output_file_path])
+        self.dependencies.append(None, ['error.log', error_file_path])
+        self.dependencies_tree.expand_all()
+
+        # Connect to the 'columns-changed' signal
+        self.dependencies.connect('row-changed', self.cb_row_changed)        
+        self.depnum = 3
 
     def load_sources_tree(self, file_list, parent=None, parent_path=None):
         """!
@@ -860,7 +861,7 @@ class gEDAManager:
     @exceptions
     def cb_preferences(self, menuitem, data=None):
         """!
-        Event occurs when the user wants to add a source to the project
+        Event occurs when the user opens up the preferences menu.
         @param menuitem that threw the event.
         @param data optional to pass in.
         """
@@ -1363,28 +1364,47 @@ class gEDAManager:
         Event occurs when the columns change in the dependencies treeview.
         @param widget that threw the event
         """
-##         print 'model:',model
-##         print 'path:',path
-##         print '_iter:',_iter
-##         if len(self.dependencies) != self.depnum:
-##             print 'Not equal'
-##         # Iterate over the whole tree and create the project.depedency_dict
-##         for i, row in enumerate(self.dependencies):
-##             print 'i:',i
-##             print 'row[0]:',row[0]
-##             if i < self.depnum: 
-##                 for r in row:
-##                     print 'r:',r
-##             row_iter = row.iterchildren()
-##             print 'row_iter for row:',row_iter
-##             try:
-##                 for z in row_iter.next():
-##                     print 'z:',z
-##             except:
-##                 pass
-#                self.project.dependency_dict[row[0]] = lst.append(self.update_dependency_dict(row_iter))
-#        print 'self.project.dependency_dict:',self.project.dependency_dict
-
+        # I figured out that if len(self.dependencies) > self.depnum
+        # then a reordering took place but nothing happended.
+        # We want to ignore this case.
+
+        if len(self.dependencies) != self.depnum:
+            print 'len(self.dependencies):',len(self.dependencies)
+
+        print 'path:',path
+        print '_iter:',_iter
+        print 'model[path]:',model[path]
+        print 'model[path][0]:',model[path][0]
+        # This last print statement give me the file that was moved
+        # Path gives me where it was moved to.
+        # We can check for a match when iterating through, and if the path
+        # doesn't match the path of where it is moved we will ignore it
+        if len(self.dependencies) <= self.depnum:
+            # Iterate over the whole tree and create the project.depedency_dict
+            for i, row in enumerate(self.dependencies):
+                print 'i:',i
+                print 'row[0]:',row[0]
+                if row[0] == model[path][0]:
+                    print 'We have a match'
+                if i < self.depnum: 
+                    for r in row:
+                        print 'r:',r
+                        row_iter = row.iterchildren()
+                    try:
+                        for z in row_iter.next():
+                            print 'z:',z
+                    except:
+                        pass
+        # Need to update the dependency_dict -- put here
+        print 'self.project.dependency_dict:',self.project.dependency_dict
+
+
+    def cb_switch_page(self, notebook, page, page_num):
+        if page_num == 1: # Dependencies notebook tab
+            selection = self.sources_tree.get_selection()
+            selection.unselect_all()
+            self.processes.clear()
+            
         
     def update_dependency_dict(self, row_iter):
         """!
diff --git a/src/gsch2pcb.py b/src/gsch2pcb.py
index aad0f48..1596144 100644
--- a/src/gsch2pcb.py
+++ b/src/gsch2pcb.py
@@ -26,6 +26,7 @@
 import os, pygtk, gtk
 pygtk.require('2.0')
 from lib.decorators import exceptions
+from subprocess import Popen
 
 class Gsch2pcb:
     """
@@ -47,6 +48,10 @@ class Gsch2pcb:
         def response_to_dialog_name(entry, dialog, response):
             dialog.response(response)
 
+        def response_to_dialog_project(entry, dialog, response):
+            dialog.response(response)
+
+
         directory_entry = gtk.Entry()
         directory_entry.set_text(os.getcwd())
         directory_entry.show()
@@ -60,7 +65,7 @@ class Gsch2pcb:
                                    gtk.MESSAGE_OTHER,
                                    gtk.BUTTONS_OK_CANCEL,
                                    gtk.STOCK_DIRECTORY)
-        self.dialog.set_markup('<b>Select all the schematics from the project that\nyou would like to include in creating the target PCB.\nChoose PCB name and the target directory.\nIf there is a PCB with the same name in the target\ndirectory it will create a *.new.pcb file.</b>')
+        self.dialog.set_markup('<b>Select one of the options below:</b>')
         self.dialog.set_title('gsch2pcb workflow')
 
         # Target Directory
@@ -92,6 +97,18 @@ class Gsch2pcb:
         hbox.pack_end(label)
         self.dialog.vbox.pack_end(hbox, True, True, 0)
 
+        # Project file
+        hbox = gtk.HBox()
+        hbox.show()
+        self.project_entry = gtk.Entry()
+        self.project_entry.show()
+        self.project_entry.connect('activate', response_to_dialog_project, self.dialog, gtk.RESPONSE_OK)        
+        hbox.pack_end(self.project_entry)
+        label = gtk.Label('Project file (use full paths for schematics):')
+        label.show()
+        hbox.pack_end(label)
+        self.dialog.vbox.pack_end(hbox, True, True, 0)
+        
         # Schematic selections
         scrolled_window = gtk.ScrolledWindow()
         scrolled_window.show()
@@ -104,72 +121,189 @@ class Gsch2pcb:
         print 'len of self.schematics:', len(self.schematics)
         self.schematics_tree = gtk.TreeView(self.schematics)
         self.schematics_tree.show()
-        column = gtk.TreeViewColumn('File', gtk.CellRendererText(), text=0)
-        column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
+        column = gtk.TreeViewColumn('File', gtk.CellRendererText(), text=1)
         self.schematics_tree.append_column(column)
         toggle = gtk.CellRendererToggle()
         toggle.set_property('activatable', True)
-        toggle.connect('toggled', self.cb_toggled, self.schematics)
+        toggle.connect('toggled', self.cb_file_toggled, self.schematics)
         column = gtk.TreeViewColumn('Include', toggle)
-        column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
+        column.add_attribute(toggle, 'active', 2)
         self.schematics_tree.append_column(column)        
         scrolled_window.add(self.schematics_tree)
         self.dialog.vbox.pack_end(scrolled_window, True, True, 0)
+
+        # Radio buttons
+        self.project_radio_button = gtk.RadioButton(None, 'Use project file')
+        self.project_radio_button.connect('toggled', self.cb_rdobutton_toggled, 'Use project file')
+        self.dialog.vbox.pack_end(self.project_radio_button, True, True, 0)
+        self.project_radio_button.show()
+        self.schematics_radio_button = gtk.RadioButton(self.project_radio_button, 'Select schematics from project')
+        self.schematics_radio_button.set_active(True)
+        self.schematics_radio_button.connect('toggled', self.cb_rdobutton_toggled, 'Select schematics from project')
+        self.dialog.vbox.pack_end(self.schematics_radio_button, True, True, 0)
+        self.schematics_radio_button.show()
         
         self.dialog.show()
-        self.dialog.run()
+        response = self.dialog.run()
+        if response == gtk.RESPONSE_OK:
+            message = ''
+            schematics_list = []
+            schematics = ''
+            self.in_project = False
+
+            # Schematics or Project
+            if self.schematics_radio_button.get_active():
+                # Iterate over the gtk.TreeModel
+                for row in self.schematics:
+                    if row[2]:
+                        # Add the schematic to the schematic_list
+                        print 'adding row[1]:',row[1]
+                        schematics_list.append(row[1])
+                        schematics += row[1] + ' '
+                if not schematics_list:
+                    message = 'At least one schematic must be chosen.\n'
+            else:
+                project = self.project_entry.get_text()
+                if project == '' or project == None:
+                    message += 'Full path to project file must be specified.\n'
+
+            name = name_entry.get_text()
+            if name == '' or name == None:
+                message += 'A name for the PCB must be specified.\n'
+                    
+            self.directory = directory_entry.get_text()
+            if self.directory == '' or self.directory == None:
+                message += 'A target directory must be chosen.\n'
+            else:
+                # Check to see if the target directory is in the project
+                # If so, set in_project flag to true
+                os.path.walk(self.directory, self.directory_match, None)
+
+            print 'message:',message
+            if message != '': 
+                msg = message.rpartition('\n')[0]
+                dm = gtk.MessageDialog(self.g.window,
+                                       (gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
+                                           gtk.MESSAGE_INFO,
+                                           gtk.BUTTONS_OK,
+                                           gtk.STOCK_DIRECTORY)
+                dm.set_markup(msg)
+                dm.show()
+                dm.run()
+                dm.destroy()
+            else:
+                # Call the code to run the gsch2pcb workflow
+                if self.schematics_radio_button.get_active():
+                    subproc = Popen(['gsch2pcb', '-v','-v','-o',name,schematics])
+                else:
+                    subproc = Popen(['gsch2pcb', '-v','-v',project])
+
+                if in_project:
+                    print 'This is in the projects directory'
+                    # Add it to the sources tree view
+                    # Need to see what the selection_iter is and its parent
+                    selection = self.g.sources_tree.get_selection()
+                    model, selection_iter = selection.get_selected()
+                    parent_iter = self.g.sources.iter_parent(selection_iter)
+#                    selected_node = self.g.sources.get_value(selection_iter, 2)
+#                    self.g.sources.append(parent_iter
+                # be added to the file_list or dependency_dict or the treeview.
+        
         self.dialog.destroy()
 
-        # If the target directory is in the project, update tree view
-        # else do nothing but still write to disk
-    def cb_toggled(self, cell, path, model):
-        model[path][1] = not model[path][1]
-        print "Toggle '%s' to: %s" % (model[path][0], model[path][1],)
-        return
+
+    def directory_match(self, arg, dirname, filenames):
+        """!
+        Method to see whether or not the chosen directory for the gsch2pcb
+        workflow is in the project directory structure or not.
+        @param arg ??
+        @param dirname name of current directory
+        @param filenames name of files in the current directory
+        """
+        if self.directory == dirname:
+            self.in_project = True
+    
+
+    def cb_file_toggled(self, cellrenderertoggle, path, model):
+        """!
+        Event handler to handle the active state of the toggle buttons.
+        @param cellrenderertoggle that received the 'toggle' signal
+        @param path of the cellrenderertoggle represented as a string
+        @param model is the gtk.TreeStore model for the treeview
+        """
+        model[path][2] = not model[path][2]
+
+
+    def cb_rdobutton_toggled(self, widget, data=None):
+        """!
+        Event handler for the radio buttons.
+        @param widget the gtk.RadioButton that threw the event
+        @param data option user paramater
+        """
+        print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
+        if data == 'Use project file' and widget.get_active():
+            # Make the self.schematics_tree insensitive
+            self.schematics_tree.set_sensitive(False)
+            self.project_entry.set_sensitive(True)
+        else:
+            self.schematics_tree.set_sensitive(True)
+            self.project_entry.set_sensitive(False)
+            
 
 
     def get_schematics(self):
-        # Iterate over the 'Sources' tree view
-        # and return a gtk.TreeStore with the schematics
-        # that we want to display
-        self.schematics = gtk.TreeStore(str, str)
-        lst = []
+        """!
+        Method to get to populate the gtk.TreeStore object self.schematics
+        @return self.schematics (gtk.TreeStore object)
+        """
+        self.schematics = gtk.TreeStore(str, str, bool)
+        # Get back a list of rows that have '.sch'
         lst = self.search(self.g.sources, self.match_func, (1, '.sch'))
         if lst != None:
             for f in lst:
-                print f
-                self.schematics.append(None, [f[1], f[2]])
+                print 'f:',f
+                self.schematics.append(None, [f[1], f[2], True])
 
-        print 'self.schematics:',self.schematics
-        print 'len of self.schematics:', len(self.schematics)        
         return self.schematics
 
         
     def match_func(self, row, data):
-        column, key = data # data is a tuple containing column number, key
+        """!
+        Method to see whether or not there is a matching schematic with the
+        given row.
+        @param row gtk.TreeModelRow object under observation
+        @param data tuple used for the comparison criteria
+        @return True if match, otherwise False
+        """
+        column, key = data
+        print 'row[column]:',row[column]
         return row[column].endswith(key)
 
 
     def search(self, rows, func, data, lst=None):
-        print 'in search'
-        if lst == None:
-            lst = []
-        else:
-            print 'hhehreh'
+        """!
+        Method to search for schematics in the project.
+        @param rows gtk.TreeModel object or the object itself
+        @param func function pointer to the match_func method
+        @param data tuple used for comparison criteria
+        @param lst list used to store matching gtk.TreeModelRow objects
+        @return lst list of gtk.TreeModelRow objects
+        """
         if not rows:
+            print 'returning rows None'
             return None
         for row in rows:
-            print 'in in search'
             if func(row, data):
-                print 'in in in search'
-                print 'lst:',lst
-                if lst != None:
-                    lst.append(row)
-                    return lst
+                print 'we have a match!'
+                if lst == None:
+                    lst = []
+                lst.append(row)
+            print 'searching recursively'
             lst = self.search(row.iterchildren(), func, data, lst)
-            if lst:
-                return lst
-        return None
-
+        if lst:
+            print 'lst:',lst
+            return lst
+        else:
+            print 'returning None'
+            return None
 
-        
diff --git a/src/newproject.py b/src/newproject.py
index 591a9e8..c355427 100644
--- a/src/newproject.py
+++ b/src/newproject.py
@@ -285,7 +285,7 @@ class NewProject:
             # Set new project attributes
             self.project.name = self.get_filename().split('.')[0]
             self.project.directory = self.get_path() + '/' + self.project.name.split('.')[0]
-            self.project.dependency_dict = {self.project.name + '.gm': [], 'ouput.log': [], 'error.log': []}
+            self.project.dependency_dict = {self.project.name + '.gm': [], 'output.log': [], 'error.log': []}
             self.project.file_list = [self.project.name, [self.project.name + '.gm', 'output.log', 'error.log']]            
             # Remove directories with imported remove_tree
             if self.confirm_overwrite.get_active():




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