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

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



The branch, master has been updated
       via  58d0432aef00eb322a1e560b97fb670d8183eece (commit)
      from  1092956eabfaaaedb18b39217dbc13f720920028 (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 |  255 +++++++++++++++++++++++++++++++++++++++++-----------
 src/utils.py       |  147 ++++++++++++++++++++++++++++--
 2 files changed, 339 insertions(+), 63 deletions(-)


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

commit 58d0432aef00eb322a1e560b97fb670d8183eece
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Fri Aug 8 00:47:06 2008 -0700

    Made several changes.  Namely, added a preferences message box and also a
    new sources message box.  Also took care of file preferences.  Now I need to
    tie all the apps together with DBUS and get the dependency updates working.

:100644 100644 6674db8... cf31ef6... M	src/gedamanager.py
:100644 100644 e03cad4... 8aae6a0... M	src/utils.py

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

commit 58d0432aef00eb322a1e560b97fb670d8183eece
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Fri Aug 8 00:47:06 2008 -0700

    Made several changes.  Namely, added a preferences message box and also a
    new sources message box.  Also took care of file preferences.  Now I need to
    tie all the apps together with DBUS and get the dependency updates working.

diff --git a/src/gedamanager.py b/src/gedamanager.py
index 6674db8..cf31ef6 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -31,6 +31,7 @@ from project import *
 from settings import *
 from utils import *
 from newproject import *
+from newsource import *
 
 
 class gEDAManager:
@@ -67,6 +68,7 @@ class gEDAManager:
         self.menu_accel_group = self.menu_uimanager.get_accel_group()
         self.window.add_accel_group(self.menu_accel_group)
         self.popup_accel_group = self.popup_uimanager.get_accel_group()
+        self.__init_tools__()
         self.__init_menus__()
         self.__init_gui_sections__()
         self.__init_about_dialog__()        
@@ -78,6 +80,18 @@ class gEDAManager:
     # Initializer Methods -- methods to create the window
     #####################################################
 
+    def __init_tools__(self):
+        """
+        Method to initialize attributes that will be used for the
+        subprocess instances of the gEDA tools.
+        """
+        # More to be added
+        self.sch = None
+        self.pcb = None
+        self.gbr = None
+        self.editor = None
+        self.gattrib = None
+        
 
     def __init_menus__(self):
         """ Method to create the menu bar. """
@@ -90,7 +104,7 @@ class gEDAManager:
         ('Exit', gtk.STOCK_QUIT, 'E_xit', '<Control>q', 'Exit gEDA Manager', self.cb_exit),
         ('Edit', None, '_Edit'),
         ('Preferences...', gtk.STOCK_PREFERENCES, 'Pr_eferences', None,
-         'gEDA Manager Preferences'),
+         'gEDA Manager Preferences', self.cb_preferences),
         ('Help', None, '_Help'),
         ('gEDA Wiki', None, 'gEDA _Wiki', None, 'Opens link in browser',
          self.cb_url_geda_wiki),
@@ -131,7 +145,7 @@ class gEDAManager:
         hpaned1.pack2(vbox2, True, True)
 
         # Main Window
-        # TODO
+        # TODO -- once I know what we are going to put there
 
         # Notebook
         vpaned2 = gtk.VPaned()
@@ -164,26 +178,31 @@ class gEDAManager:
         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)
+
+        # Models for the Tree Views
         self.sources = gtk.TreeStore(gtk.gdk.Pixbuf, str, str)
         self.processes = gtk.TreeStore(str, gtk.gdk.Pixbuf)
         
-        # Tree views
+        # Tree Views
         self.sources_tree = gtk.TreeView(self.sources)
         self.sources_tree.show()
         self.sources_tree.connect('button_press_event', self.cb_button_press)
-        self.sources_tree.connect('row-activated', self.cb_row_activated)
+        self.sources_tree.connect('row-activated', self.utils.cb_sources_row_activated, self)
         self.sources_tree.connect('cursor-changed', self.cb_cursor_changed)
 
         self.processes_tree = gtk.TreeView(self.processes)
         self.processes_tree.show()
+        self.processes_tree.connect('row-activated', self.utils.cb_processes_row_activated, self)
 
         # column headings
         column = gtk.TreeViewColumn(None, gtk.CellRendererPixbuf(), pixbuf=0)
         self.sources_tree.append_column(column)
         sources_cell = gtk.CellRendererText()
         column = gtk.TreeViewColumn(None, sources_cell, text=1)
+        column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
         self.sources_tree.append_column(column)
         column = gtk.TreeViewColumn('Processes for: ', gtk.CellRendererText(), text=0)
+        column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
         self.processes_tree.append_column(column)
         processes_pixbuf = gtk.CellRendererPixbuf()
         processes_pixbuf.set_property('xalign', 0)
@@ -194,7 +213,6 @@ class gEDAManager:
         self.sources_tree.set_property('enable-tree-lines', True)
         self.processes_tree.set_property('enable-tree-lines', True)
 
-
         # make it searchable
         self.sources_tree.set_search_column(0)
         self.processes_tree.set_search_column(0)
@@ -402,32 +420,40 @@ class gEDAManager:
         self.project.file_list = [self.project.name, [self.project.name + '.gm']]
 
 
-    def load_tree(self, file_list, parent=None):
+    def load_tree(self, file_list, parent=None, parent_path=None):
         """!
         Method to the load the tree -- recursively.
         @param list of paths in the project's file_list.
         @param parent node to help setup the gtk.TreeView object.
+        @param parent_path is a parameter to help in writing the paths
+        to the self.sources gtk.TreeStore object.
         """
         # parent == None is for the 'Project' node
         icon = gtk.IconTheme() # The icon used throughout the function
         if parent == None:
             image = icon.load_icon(self.utils.icon_lut['project'], 22, 0)
-            n_parent = self.sources.append(parent, [image, file_list[0], self.project.directory])
-            file_list = file_list[1]
-            parent = n_parent
+            n_parent = self.sources.append(None, [image, file_list[0], self.project.directory])
+            parent = n_parent # parent used below
+            file_list = file_list[1] # Now pointing to the nested list
 
         # In the file_list we have folders, nodes, and lists to recurse over
         for index, f in enumerate(file_list):
             if (index + 1) < len(file_list): # Check for folder
                 if isinstance(file_list[index+1], list):
-                    file_path = self.project.directory + '/' + f
+                    if parent_path != None:
+                        file_path = parent_path + '/' + f
+                    else:
+                        file_path = self.project.directory + '/' + f
                     image = icon.load_icon(self.utils.icon_lut['folder'], 22, 0)
                     n_parent = self.sources.append(parent, [image, f, file_path])
                     continue # jump to next iterator
             if isinstance(f, list): # Check for lists and use recursion
-                self.load_tree(f, n_parent)
+                self.load_tree(f, n_parent, file_path)
             else: # We have a node
-                file_path = self.project.directory + '/' + f
+                if parent_path != None:
+                    file_path = parent_path + '/' + f
+                else:
+                    file_path = self.project.directory + '/' + f
                 image = icon.load_icon(self.utils.icon_lut[self.utils.get_node_ext(f)], 22, 0)
                 n_parent = self.sources.append(parent, [image, f, file_path])
 
@@ -533,6 +559,19 @@ class gEDAManager:
         f = file('errors.log', 'w')
         f.writelines(errors)
         f.close()
+
+
+    @exceptions
+    def kill_processes(self):
+        """
+        Method to kill all the open processes if there are still any
+        open when the gEDAManager is closed.
+        """
+        # TODO - if open processes's prompt the user to save work
+        # before exiting
+        # e.g.
+        # "You have open processes.  If you exit you may lose unsaved
+        # changes.  Would you like to proceed? Okay or Cancel.
         
     
     ######################################################
@@ -578,7 +617,6 @@ class gEDAManager:
         gnomevfs.url_show('http://www.gempillar.com')
 
 
-    # File Menu #
     def cb_new_project(self, menuitem, data=None):
         """!
         Event handler for 'New Project'.
@@ -635,6 +673,7 @@ class gEDAManager:
         self.project.save()
         self.save_settings()
         self.write_logs()
+        self.kill_processes()
         
 
     def cb_delete(self, menuitem, data=None):
@@ -696,6 +735,147 @@ class gEDAManager:
         self.set_sources_tree_to_new_project()
 
 
+    def cb_preferences(self, menuitem, data=None):
+        """!
+        Event occurs when the user wants to add a source to the project
+        @param menuitem that threw the event.
+        @param data optional to pass in.
+        """
+        def new_source_cursor_changed(newsources_tree):
+            selection = newsources_tree.get_selection()
+            model, selection_iter = selection.get_selected()
+            self.newsource = model.get_value(selection_iter, 1)
+
+
+        if self.editor != None:
+            old_editor = self.editor
+        else:
+            old_editor = None
+
+        def response_to_dialog(entry, dialog, response):
+            dialog.response(response)
+            
+        entry = gtk.Entry()
+        entry.show()
+
+        def cb_filebutton_selection_changed(filechooser, entry):
+            self.editor = filebutton.get_filename()
+            entry.set_text(self.editor)
+
+        dialog = gtk.MessageDialog(self.window,
+                                   (gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
+                                   gtk.MESSAGE_QUESTION,
+                                   gtk.BUTTONS_OK_CANCEL,
+                                   gtk.STOCK_DIRECTORY)
+        dialog.set_markup('<b>Preference settings:</b>')
+        dialog.set_title('Preferences')
+        hbox = gtk.HBox()
+        hbox.show()
+
+        filebutton = gtk.FileChooserButton('Text Editor')
+        filebutton.show()
+        filebutton.connect('selection-changed',
+                                cb_filebutton_selection_changed, entry)
+        filebutton.set_local_only(True)
+        filebutton.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
+        hbox.pack_end(filebutton)
+
+        entry.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)
+        hbox.pack_end(entry)
+        label = gtk.Label('Text Editor:')
+        label.show()
+        hbox.pack_end(label)
+
+        dialog.vbox.pack_end(hbox, True, True, 0)
+        dialog.show()
+        dialog.run()
+        if old_editor != self.editor: # A change was made
+            new_text = self.editor
+        else:
+            new_text = entry.get_text()
+
+        dialog.destroy()
+
+        print 'editor:',self.editor
+
+        if new_text:
+            print new_text
+        else:
+            print 'empty'
+
+
+    def cb_new_source(self, menuitem, data=None):
+        """!
+        Event occurs when the user wants to add a source to the project
+        @param menuitem that threw the event.
+        @param data optional to pass in.
+        """
+        def new_source_cursor_changed(newsources_tree):
+            selection = newsources_tree.get_selection()
+            model, selection_iter = selection.get_selected()
+            self.newsource = model.get_value(selection_iter, 1)
+        
+        def response_to_dialog(entry, dialog, response):
+            dialog.response(response)
+            print response
+
+        dialog = gtk.MessageDialog(self.window,
+                                   (gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
+                                   gtk.MESSAGE_QUESTION,
+                                   gtk.BUTTONS_OK_CANCEL,
+                                   gtk.STOCK_DIRECTORY)
+        dialog.set_markup('<b>Please enter the new file name (extension will be added):</b>')
+        entry = gtk.Entry()
+        entry.show()
+        entry.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)
+        hbox = gtk.HBox()
+        hbox.show()
+        hbox.pack_end(entry)
+        label = gtk.Label('File name:')
+        label.show()
+        hbox.pack_end(label)
+        
+        # Models for the Tree View
+        newsources = gtk.TreeStore(gtk.gdk.Pixbuf, str)
+        # Tree View
+        newsources_tree = gtk.TreeView(newsources)
+        newsources_tree.show()
+        newsources_tree.connect('cursor-changed', new_source_cursor_changed)
+        # column headings
+        newsources_pixbuf = gtk.CellRendererPixbuf()
+        newsources_pixbuf.set_property('xalign', 0)
+        column = gtk.TreeViewColumn(None, newsources_pixbuf, pixbuf=0)
+        newsources_tree.append_column(column)
+        newsources_cell = gtk.CellRendererText()
+        column = gtk.TreeViewColumn('Source Type', newsources_cell, text=1)
+        column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
+        newsources_tree.append_column(column)
+        # populate the tree view
+        icon = gtk.IconTheme()
+        image = icon.load_icon(self.utils.icon_lut['pcb'], 22, 0)
+        newsources.append(None, [image, 'PCB'])
+        image = icon.load_icon(self.utils.icon_lut['sch'], 22, 0)
+        newsources.append(None, [image, 'Schematic'])
+        image = icon.load_icon(self.utils.icon_lut['v'], 22, 0)
+        newsources.append(None, [image, 'Verilog'])
+        image = icon.load_icon(self.utils.icon_lut['vhd'], 22, 0)
+        newsources.append(None, [image, 'VHDL'])
+
+        # add to the hbox
+        hbox.pack_start(newsources_tree, False, False)
+        dialog.vbox.pack_end(hbox, True, True, 0)
+        
+        dialog.show()
+        dialog.run()
+        new_text = entry.get_text()
+        dialog.destroy()
+
+        if new_text:
+            print self.newsource
+            print new_text
+        else:
+            print 'empty'
+
     def cb_add_copy_source(self, menuitem, data=None):
         """!
         Event occurs when the user wants to add a source to the project
@@ -808,7 +988,7 @@ class gEDAManager:
                                    gtk.MESSAGE_QUESTION,
                                    gtk.BUTTONS_OK_CANCEL,
                                    gtk.STOCK_DIRECTORY)
-        dialog.set_markup('<b>Please enter the new name:</b>\nExtension (if applicable) will be added.')
+        dialog.set_markup('<b>Please enter the new name\n(including proper extension if applicable):</b>')
         entry = gtk.Entry()
         entry.show()
         entry.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)
@@ -822,7 +1002,7 @@ class gEDAManager:
         dialog.destroy()
         new_path = old_path.rpartition('/')[0] + '/' + new_text
 
-        if old_path == self.project.directory: 
+        if old_path == self.project.directory and '.' not in new_text: 
             # Project Folder
             os.rename(old_path, new_path)
             model[path][1] = new_text
@@ -831,10 +1011,12 @@ class gEDAManager:
             os.remove(project_file)
             self.project.directory = new_path
             self.project.name = new_text
-##             self.project.file_list[0] = new_path
-##             self.project.file_list[1][0] = new_path + '/' + new_text + '.gm'
+            self.project.file_list[0] = new_text
+            self.project.file_list[1][0] = new_text + '.gm'
             self.project.save()
 
+            model[(0)][1] = new_text
+            model[(0)][2] = new_path + '/' + new_text
             model[(0,0)][1] = new_text + '.gm'
             model[(0,0)][2] = new_path + '/' + new_text + '.gm'
             self.output_textbuffer.insert(self.output_textiter, 'Project changed from ' + old_path + ' to ' + new_path + '.\n')                        
@@ -865,41 +1047,7 @@ class gEDAManager:
             self.output_textbuffer.insert(self.output_textiter, old_path + ' changed to ' + new_path + '.\n')            
 
         self.utils.update_file_list(self) # update file list
-        
 
-    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.
-        @param widget that threw the event.
-        @param path of the row of the cell to be activated in the gtk.TreeView
-        object.
-        @param view_column is the gtk.TreeViewColumn of the cell to be
-        activated.
-        """
-        # TODO I will use this call back to see what node is double clicked
-        # I will know this from the path
-        # this callback will be used when a user double clicks on a node
-
-        # find out what type of file was double clicked
-        # from this, execute the command of opening this with the appropriate
-        # program but first check to see if it is already open (the program)
-        # we only want one instance of each program running at the same time.
-##         selection_iter = self.sources.get_iter(path)
-##         selected_node = self.sources.get_value(selection_iter, 2)
-##         print selected_node
-##         print self.sources[path][2]
-        selected_node = self.sources[path][2]
-        if '.' in selected_node: # We have a file
-            name = self.sources[path][1]
-            ext = name.split('.')[-1]
-            if ext == 'sch' and selected_node != None:
-                print 'selected_node:',selected_node
-                cmd = 'gschem -v ' + selected_node
-                pid = subprocess.Popen([cmd]).pid
-
-        
-                
 
     def cb_cursor_changed(self, widget):
         """!
@@ -922,7 +1070,7 @@ class gEDAManager:
             else: # We have a folder
                 # Logic to call the functions to populate the 'Processes' tree
                 # view.
-                self.utils.get_processes_tree(self)
+                self.utils.get_processes_tree(self, None, True)
                 # Update 'Processes: ' for the 'Processes' tree
                 column = self.processes_tree.get_column(0)
                 column.set_title('Processes for all files in: ' + name)
@@ -958,7 +1106,7 @@ class gEDAManager:
             actiongroup = gtk.ActionGroup('Popup')
             actiongroup_list = [('Rename', None, '_Rename', None, None, self.cb_rename),
                                 ('Delete', gtk.STOCK_DELETE, '_Delete', '<Control>d', 'Delete File', self.cb_delete),
-                                ('New Source...', gtk.STOCK_FILE, '_New Source...'),
+                                ('New Source...', gtk.STOCK_FILE, '_New Source...', None, None, self.cb_new_source),
                                 ('Add Copy of Source...', gtk.STOCK_DND_MULTIPLE, 'Add _Copy of Source...', None, None, self.cb_add_copy_source),
                                 ('New Folder', gtk.STOCK_DIRECTORY, 'New _Folder', None, None, self.cb_new_folder),
                                 ('Delete Folder', gtk.STOCK_DELETE, '_Delete Folder', None, None, self.cb_delete_folder),]
@@ -997,6 +1145,7 @@ class gEDAManager:
         self.project.save()
         self.save_settings()
         self.write_logs()
+        self.kill_processes()
 
 
     ########################################################
diff --git a/src/utils.py b/src/utils.py
index e03cad4..8aae6a0 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -28,6 +28,7 @@ pygtk.require('2.0')
 from lib.decorators import exceptions
 from project import *
 from settings import *
+from subprocess import *
 
 
 class Utils:
@@ -99,12 +100,18 @@ class Utils:
         gtk.icon_theme_add_builtin_icon('other', 22, image)        
         image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/plot_singleplot.png')
         gtk.icon_theme_add_builtin_icon('spice', 22, image)        
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/background-logo-icon.png')
+        gtk.icon_theme_add_builtin_icon('icarus', 22, image)        
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/GHDL_logo-22.png')
+        gtk.icon_theme_add_builtin_icon('ghdl', 22, image)        
 
 
 
         self.icon_lut = {'gattrib': 'geda-gattrib',
                          'gschem': 'geda-gschem',
                          'spice': 'spice',
+                         'icarus': 'icarus',
+                         'ghdl': 'ghdl',
                          'other': 'other',
                          'vhd': 'vhd',
                          'vhdl': 'vhdl',
@@ -200,7 +207,7 @@ class Utils:
         if index == 0:
             # Logic here for copying the file to the selected_node's folder
             # First check that a file with the same name does not exist
-            print 'selected_node:',selected_node
+
             files = os.listdir(selected_node)
             if name not in files:
                 os.system('cp ' + filename + ' ' + selected_node)
@@ -222,7 +229,7 @@ class Utils:
                 os.system('rm -rf ' + selected_node)
                 g.sources.remove(selection_iter)
                 g.output_textbuffer.insert(g.output_textiter, 'Folder deleted: ' + selected_node + '.\n')                                                                        
-        # Project's File List
+        # Create Project's File List
         g.project.file_list = [] 
         for row in g.sources:
             # Get the name of the node
@@ -251,8 +258,9 @@ class Utils:
         """
         g = gedamanager
         current_directory = os.getcwd()
-        os.chdir(self.directory)            
-        g.processes.clear()
+        os.chdir(self.directory)
+        if folder == None:
+            g.processes.clear()
         icon = gtk.IconTheme()
         
         if ext == None and folder != None:
@@ -263,20 +271,25 @@ class Utils:
             # Iterate over the folder to see what types of files they have
             # and build the tree this way.
             files = os.listdir(selected_node)
+            extensions = []
             for f in files:
                 ext = self.get_node_ext(f)
+                if ext not in extensions:
+                    extensions.append(ext)
+            for ext in extensions:
                 # recursively structure the tree
                 if ext in self.icon_lut:
-                    self.get_processes_tree(self, g, ext, True)
+                    self.get_processes_tree(g, ext, True)
                 else:
                     print 'self.icon_lut does not contain:', ext
+            return
             
         if ext == 'sch':
             # Parent folders
-            simulation = g.processes.append(None, ['Simulation', None])
-            create_pcb = g.processes.append(None, ['Create pcb', None])
-            create_netlist = g.processes.append(None, ['Create netlist', None])
-            modify_attributes = g.processes.append(None, ['Modify attributes', None])
+            simulation = g.processes.append(None, ['Simulate Schematic(s)', None])
+            create_pcb = g.processes.append(None, ['Create PCB for Schematic(s)', None])
+            create_netlist = g.processes.append(None, ['Create Netlist for Schematic(s)', None])
+            modify_attributes = g.processes.append(None, ['Modify Attributes for Schematic(s)', None])
 
             # Simulate
             image = icon.load_icon(self.icon_lut['spice'], 22, 0) 
@@ -315,14 +328,128 @@ class Utils:
 
         elif ext == 'sym':
             # Parent folders
-            check_symbols = g.processes.append(None, ['Check symbols', None])
+            check_symbols = g.processes.append(None, ['Check Symbols', None])
             image = icon.load_icon(self.icon_lut['sym'], 22, 0) 
             g.processes.append(check_symbols, ['gsymcheck', image])
 
+        elif ext == 'v':
+            # Parent folders
+            compile_source = g.processes.append(None, ['Compile Verilog', None])
+            
+            comsim_source = g.processes.append(None, ['Compile and Simulate Verilog', None])
+            image = icon.load_icon(self.icon_lut['icarus'], 22, 0) 
+            g.processes.append(compile_source, ['icarus-compile', image])
+            g.processes.append(comsim_source, ['icarus-compile->simulate', image])
+
+        elif ext == 'vcd':
+            # Parent folders
+            simulate = g.processes.append(None, ['Simulate', None])
+            image = icon.load_icon(self.icon_lut['icarus'], 22, 0) 
+            g.processes.append(simulate, ['icarus verilog', image])
+
+        elif ext == 'vhd' or ext == 'vhdl':
+            # Parent folders
+            compile_source = g.processes.append(None, ['Compile VHDL', None])
+            
+            comsim_source = g.processes.append(None, ['Compile and Simulate VHDL', None])
+            image = icon.load_icon(self.icon_lut['ghdl'], 22, 0) 
+            g.processes.append(compile_source, ['ghdl-compile', image])
+            g.processes.append(comsim_source, ['ghdl-compile->simulate', image])
+            
         # There is obviously more to put in here
         if ext == None: # We have a folder, so we will need to look through
+            
             pass
         
         os.chdir(current_directory)            
 
     
+    def cb_sources_row_activated(self, widget, path, view_column, gedamanager):
+        """!
+        Event occurs when 'row-activated' signal is emitted or a user double
+        clicks on a treeview row.
+        @param widget that threw the event.
+        @param path of the row of the cell to be activated in the gtk.TreeView
+        object.
+        @param view_column is the gtk.TreeViewColumn of the cell to be
+        activated.
+        @param gedamanager is the current gEDAManager instance.
+        """
+        g = gedamanager
+        selected_node = g.sources[path][2]
+        if '.' in selected_node: # We have a file
+            name = g.sources[path][1]
+            ext = name.split('.')[-1]
+        else: # We have a folder
+            ext = 'folder'
+        self.run_command(g, selected_node, None, ext)
+        
+
+    def cb_processes_row_activated(self, widget, path, view_column, gedamanager):
+        """!
+        Event occurs when 'row-activated' signal is emitted or a user double
+        clicks on a treeview row.
+        @param widget that threw the event.
+        @param path of the row of the cell to be activated in the gtk.TreeView
+        object.
+        @param view_column is the gtk.TreeViewColumn of the cell to be
+        activated.
+        @param gedamanager is the current gEDAManager instance.
+        """
+        g = gedamanager
+        selected_node = g.processes[path][0]
+        print 'selected_node:',selected_node
+        selection = g.sources_tree.get_selection()
+        model, selection_iter = selection.get_selected()
+        selected_source = g.sources.get_value(selection_iter, 2)
+        print 'selected_source:',selected_source
+        
+
+    def run_command(self, gedamanager, selected_node, highlighted_source=None, ext=None):
+        """!
+        Method to run commands for 'Processes' and 'Sources'.
+        @param gedamanager is the current gEDAManager instance.
+        @param selected_node is the selected 'Sources' or 'Processes' node.
+        @param highlighted_source is the highlighted 'Sources' node that
+        is being used for the current process.
+        @param ext is the extension of the selected file.
+        """
+        g = gedamanager
+        files = ['net','log','bom','bom1','bom2']        
+        # Sources
+        if ext != None:
+            if ext == 'sch' or ext == 'sym':
+                if g.sch == None or g.sch.poll() == 0:
+                    g.sch = Popen(['gschem', selected_node], stdin=PIPE)
+                elif g.sch.poll() == None: # Process is still running
+                    print 'we are in'
+                    test = 'fn'
+                    g.sch.stdin.write(test)
+                    print 'we are out'
+##                     o, e = g.sch.communicate(input='fo ' + selected_node)
+##                     print 'o,e:',o,e
+            elif ext == 'pcb':
+                if g.pcb == None or g.pcb.poll() == 0:
+                    g.pcb = Popen(['pcb', selected_node])
+                elif g.pcb.poll() == None: # Process is still running
+                    pass
+            elif ext == 'gbr':
+                if g.gbr == None or g.gbr.poll() == 0:
+                    g.gbr = Popen(['gerbv', selected_node])
+                elif g.gbr.poll() == None: # Process is still running
+                    pass
+            elif ext in files:
+                if g.editor == None or g.editor.poll() == 0:
+                    g.editor = Popen(['gedit', selected_node])
+                    # Need to set a preferences global for the editor that
+                    # the user would like to use such as 'emacs' or 'vim' etc
+                elif g.editor.poll() == None: # Process is still running
+                    pass
+
+        else: # Processes
+            pass
+        
+        
+
+
+    




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