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

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



The branch, master has been updated
       via  512afc310b1314c0b13c10e2a830c6bcba4c79ed (commit)
      from  955b7a29b76dbda267a08fa70205b2fb2a147ace (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/file_popup.xml    |    1 +
 src/folder_popup.xml  |    1 +
 src/gedamanager.py    |  167 +++++++++++++++++++++++-------
 src/lib/decorators.py |   29 +++++-
 src/newproject.py     |   19 ++++
 src/project.py        |   19 ++++
 src/project_popup.xml |    1 +
 src/settings.py       |   19 ++++
 src/utils.py          |  269 ++++++++++++++++++++++++++++---------------------
 9 files changed, 364 insertions(+), 161 deletions(-)


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

commit 512afc310b1314c0b13c10e2a830c6bcba4c79ed
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Mon Jul 28 00:47:25 2008 -0700

    Icon changes done for the most part. Routine check in.

:100644 100644 0513f72... c150500... M	src/file_popup.xml
:100644 100644 5f6042b... 7bafa1f... M	src/folder_popup.xml
:100644 100644 736a3d7... 7ceb890... M	src/gedamanager.py
:100644 100644 5c1ff8a... 70fbd5e... M	src/lib/decorators.py
:100644 100644 b996201... ac95ac6... M	src/newproject.py
:100644 100644 d0f492a... 14823a3... M	src/project.py
:100644 100644 6d8f518... 1f60f4c... M	src/project_popup.xml
:100644 100644 3aede1c... 9785731... M	src/settings.py
:100644 100644 45bd67f... 3cce376... M	src/utils.py

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

commit 512afc310b1314c0b13c10e2a830c6bcba4c79ed
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Mon Jul 28 00:47:25 2008 -0700

    Icon changes done for the most part. Routine check in.

diff --git a/src/file_popup.xml b/src/file_popup.xml
index 0513f72..c150500 100644
--- a/src/file_popup.xml
+++ b/src/file_popup.xml
@@ -2,6 +2,7 @@
   <popup>
     <separator/>
     <menuitem action="Delete"/>
+    <menuitem action="Rename"/>
     <separator/>
   </popup>
 </ui>
diff --git a/src/folder_popup.xml b/src/folder_popup.xml
index 5f6042b..7bafa1f 100644
--- a/src/folder_popup.xml
+++ b/src/folder_popup.xml
@@ -5,6 +5,7 @@
     <menuitem action="Delete Folder"/>
     <menuitem action="New Source..."/>
     <menuitem action="Add Copy of Source..."/>
+    <menuitem action="Rename"/>
     <separator/>
   </popup>
 </ui>
diff --git a/src/gedamanager.py b/src/gedamanager.py
index 736a3d7..7ceb890 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -1,5 +1,24 @@
 #! /usr/bin/env python
 
+# gEDA Manager
+# Copyright (C) 2008 Newell Jensen
+# Copyright (C) 2008 gEDA Contributors (see ChangeLog for details)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
 ##@package src.gedamanager
 #Top-level window for the gEDA Manager
 #@author Newell Jensen
@@ -13,8 +32,6 @@ from settings import *
 from utils import *
 from newproject import *
 
-# i18n TODO
-import gettext
 
 class gEDAManager:
     """
@@ -114,7 +131,7 @@ class gEDAManager:
         hpaned1.pack2(vbox2, True, True)
 
         # Main Window
-
+        # TODO
 
         # Notebook
         vpaned2 = gtk.VPaned()
@@ -164,8 +181,6 @@ class gEDAManager:
         column = gtk.TreeViewColumn(None, gtk.CellRendererPixbuf(), pixbuf=0)
         self.sources_tree.append_column(column)
         sources_cell = gtk.CellRendererText()
-        sources_cell.set_property('editable', True)
-        sources_cell.connect('edited', self.cb_cell_edited, self.sources)
         column = gtk.TreeViewColumn(None, sources_cell, text=1)
         self.sources_tree.append_column(column)
         column = gtk.TreeViewColumn('Processes for: ', gtk.CellRendererPixbuf(), pixbuf=0)
@@ -175,7 +190,7 @@ class gEDAManager:
         
         # set some properties
         self.sources_tree.set_property('enable-tree-lines', True)
-        #self.processes_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)
@@ -366,11 +381,13 @@ class gEDAManager:
         
         # Parent Folder
         name = self.project.name
-        image = self.utils.get_node_image(self, 'project')
+        icon = gtk.IconTheme()
+        image = icon.load_icon(self.utils.icon_lut['project'], 22, 0)
         parent = self.sources.append(None, [image, name, self.project.directory])
 
         # Child Node
-        image = self.utils.get_node_image(self, self.project.name + '.gm')
+        icon = gtk.IconTheme()
+        image = icon.load_icon(self.utils.icon_lut['gm'], 22, 0)
         path = self.project.directory + '/' + self.project.name + '.gm'     
         self.sources.append(parent, [image, self.project.name + '.gm', path])
         self.sources_tree.expand_all()
@@ -393,9 +410,11 @@ class gEDAManager:
             if file_path[0] == '/': # means this file is a parent
                 name = self.utils.get_node_name(file_path)
                 if file_path == self.project.directory:
-                    image = self.utils.get_node_image(self, 'project')
+                    icon = gtk.IconTheme()
+                    image = icon.load_icon(self.utils.icon_lut['project'], 22, 0)
                 else:
-                    image = self.utils.get_node_image(self, name)
+                    icon = gtk.IconTheme()
+                    image = icon.load_icon(self.utils.icon_lut[self.utils.get_node_ext(name)], 22, gtk.ICON_LOOKUP_NO_SVG)
                 n_parent = self.sources.append(parent, [image, name, file_path])
             else:
                 # recursion
@@ -482,6 +501,27 @@ class gEDAManager:
         file_filter.set_name("spice (.spice)")
         file_filter.add_pattern('*.spice')
         dialog.add_filter(file_filter)
+
+
+    @exceptions
+    def write_logs(self):
+        """!
+        Method to write out the error and output logs with what is in
+        the textbuffers.
+        """
+        startiter, enditer = self.output_textbuffer.get_bounds()
+        output = self.output_textbuffer.get_text(startiter, enditer)
+        os.chdir(self.project.directory)
+        f = file('output.txt', 'w')
+        f.writelines(output)
+        f.close()
+
+        startiter, enditer = self.errors_textbuffer.get_bounds()
+        errors = self.errors_textbuffer.get_text(startiter, enditer)
+        os.chdir(self.project.directory)
+        f = file('errors.txt', 'w')
+        f.writelines(errors)
+        f.close()
         
     
     ######################################################
@@ -583,6 +623,7 @@ class gEDAManager:
         self.output_textbuffer.insert(self.output_textiter, 'Exiting gEDA Manager.\n')
         self.project.save()
         self.save_settings()
+        self.write_logs()
         
 
     def cb_delete(self, menuitem, data=None):
@@ -661,9 +702,9 @@ class gEDAManager:
         response = dialog.run()
         if response == gtk.RESPONSE_OK:
             filename = dialog.get_filename()
-            self.utils.update_file_list(self, 0, filename)            
+            self.utils.update_file_list(self, 0, filename)
+            self.output_textbuffer.insert(self.output_textiter, 'Copy of source added: ' + filename + '.\n')                                
         dialog.destroy()
-        self.output_textbuffer.insert(self.output_textiter, 'Copy of source added: ' + filename + '.\n')                    
 
 
     @exceptions
@@ -723,7 +764,8 @@ class gEDAManager:
         
         name = self.utils.get_node_name(path)
         # Find out what file it is so we can pick an icon for it
-        image = self.utils.get_node_image(self, name)
+        icon = gtk.IconTheme()
+        image = icon.load_icon(self.utils.icon_lut[self.utils.get_node_ext(name)], 22, 0)
         self.sources.append(selection_iter, [image, name, path])
         # Add the new folder to project file list
         self.utils.update_file_list(self)
@@ -737,17 +779,36 @@ class gEDAManager:
 
 
     @exceptions
-    def cb_cell_edited(self, cell, path, new_text, model):
+    def cb_rename(self, action):
         """!
-        Event handler to catch the event of the user editing a cell in the
-        'Sources' tree view.
-        @param cell is the gtk.CellRendererText that was changed.
-        @param path is the tree path (as a string) to the row containing the
-        edited cell.
-        @param new_text is the edited text.
-        @param model is the gtk.TreeStore model for the tree view.
-        """
-        old_path = model[path][2]
+        Event handler for renaming a file, folder, or project.
+        @param action is the gtk.Action object involved with this event.
+        """
+        def response_to_dialog(entry, dialog, response):
+            dialog.response(response)
+
+        selection = self.sources_tree.get_selection()
+        model, selection_iter = selection.get_selected()
+        old_path = self.sources.get_value(selection_iter, 2)
+        path = self.sources.get_path(selection_iter)
+
+        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 name:</b>\nExtension (if applicable) will be added.')
+        entry = gtk.Entry()
+        entry.show()
+        entry.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)
+        hbox = gtk.HBox()
+        hbox.show()
+        hbox.pack_end(entry)
+        dialog.vbox.pack_end(hbox, True, True, 0)
+        dialog.show()
+        dialog.run()
+        new_text = entry.get_text()
+        dialog.destroy()
         new_path = old_path.rpartition('/')[0] + '/' + new_text
 
         if old_path == self.project.directory: # Project Folder
@@ -763,22 +824,29 @@ class gEDAManager:
             self.project.save()
             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')                        
         elif '.' in new_text and '.' in old_path: # File
             os.rename(old_path, new_path)
             model[path][1] = new_text
             model[path][2] = new_path
-            model[path][0] = self.utils.get_node_image(new_text)
+            icon = gtk.IconTheme()
+            model[path][0] = icon.load_icon(self.utils.icon_lut[self.utils.get_node_ext(new_text)], 22, 0)
+            self.output_textbuffer.insert(self.output_textiter, old_path + ' changed to ' + new_path + '.\n')            
         elif '.' in new_text and '.' not in old_path: # Folder being changed
             pass # don't allow it to change names
         elif '.' not in new_text and '.' in old_path: # File being changed
             pass # don't allow it to change names
         else: # Folder -- so image does not need to be changed
+            if os.path.exists(new_path):
+                self.output_textbuffer.insert(self.output_textiter, 'Folder already exists with this name.  Cannot rename.\n')
+                return
             os.rename(old_path, new_path)
             model[path][1] = new_text
             model[path][2] = new_path
+            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):
         """!
@@ -798,7 +866,21 @@ class gEDAManager:
         # 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):
         """!
@@ -807,20 +889,21 @@ class gEDAManager:
         """
         selection = self.sources_tree.get_selection()
         model, selection_iter = selection.get_selected()
-        selected_node = self.sources.get_value(selection_iter, 2)
-        name = self.utils.get_node_name(selected_node)
-        if '.' in name:
-            # Logic to call function to find what type of file it is
-            # and then to populate the according tree view
-            ext = name.split('.')[-1]
-            self.utils.get_processes_tree(self, ext)
-        else: # We have a folder
-            # Logic to call the functions to populate the 'Processes' tree
-            # view.
-            self.utils.get_processes_tree(self)
-        # Update 'Processes: ' for the 'Processes' tree
-        column = self.processes_tree.get_column(0)
-        column.set_title('Processes for: ' + name)
+        if selection_iter != None:
+            selected_node = self.sources.get_value(selection_iter, 2)
+            name = self.utils.get_node_name(selected_node)
+            if '.' in name:
+                # Logic to call function to find what type of file it is
+                # and then to populate the according tree view
+                ext = name.split('.')[-1]
+                self.utils.get_processes_tree(self, ext)
+            else: # We have a folder
+                # Logic to call the functions to populate the 'Processes' tree
+                # view.
+                self.utils.get_processes_tree(self)
+            # Update 'Processes: ' for the 'Processes' tree
+            column = self.processes_tree.get_column(0)
+            column.set_title('Processes for: ' + name)
 
 
     def cb_popup_deactivate(self, popup_menu, merge_id):
@@ -851,7 +934,8 @@ class gEDAManager:
                 return
             popup_menu = gtk.Menu()
             actiongroup = gtk.ActionGroup('Popup')
-            actiongroup_list = [('Delete', gtk.STOCK_DELETE, '_Delete', '<Control>d', 'Delete File', self.cb_delete),
+            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...'),
                                 ('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),
@@ -872,6 +956,8 @@ class gEDAManager:
                 popup_menu = self.popup_uimanager.get_widget('/popup')
             else:
                 # File
+                if selected_node.endswith('.gm'):
+                    return
                 merge_id = self.popup_uimanager.add_ui_from_file(self.utils.get_file(self, 'file_popup.xml'))
                 popup_menu = self.popup_uimanager.get_widget('/popup')
                 
@@ -888,6 +974,7 @@ class gEDAManager:
         self.output_textbuffer.insert(self.output_textiter, 'Exiting gEDA Manager.\n')        
         self.project.save()
         self.save_settings()
+        self.write_logs()
 
 
     ########################################################
diff --git a/src/lib/decorators.py b/src/lib/decorators.py
index 5c1ff8a..70fbd5e 100644
--- a/src/lib/decorators.py
+++ b/src/lib/decorators.py
@@ -1,5 +1,24 @@
 #! /usr/bin/env python
 
+# gEDA Manager
+# Copyright (C) 2008 Newell Jensen
+# Copyright (C) 2008 gEDA Contributors (see ChangeLog for details)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
 ##@package lib.decorators
 #Library file for decorators
 #@author Newell Jensen
@@ -26,15 +45,15 @@ def exceptions(func):
                 try:
                     f = func(*args)
                 except IOError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IOError: ' +  str(sys.exc_info()[0]) + '.\n')
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IOError: ' +  str(sys.exc_info()) + '.\n')
                 except OSError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'OSError: ' +  str(sys.exc_info()[0]) + '.\n')
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'OSError: ' +  str(sys.exc_info()) + '.\n')
                 except IndexError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IndexError: ' +  str(sys.exc_info()[0]) + '.\n')
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IndexError: ' +  str(sys.exc_info()) + '.\n')
                 except TypeError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'TypeError: ' +  str(sys.exc_info()[0]) + '.\n')                                        
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'TypeError: ' +  str(sys.exc_info()) + '.\n')                                        
                 except:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'Unexpected error: ' +  str(sys.exc_info()[0]) + '.\n')            
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'Unexpected error: ' +  str(sys.exc_info()) + '.\n')            
                     raise
                 return f
             
diff --git a/src/newproject.py b/src/newproject.py
index b996201..ac95ac6 100644
--- a/src/newproject.py
+++ b/src/newproject.py
@@ -1,5 +1,24 @@
 #! /usr/bin/env python
 
+# gEDA Manager
+# Copyright (C) 2008 Newell Jensen
+# Copyright (C) 2008 gEDA Contributors (see ChangeLog for details)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
 ##@package src.newproject
 #New Project window for the gEDA Manager
 #@author Newell Jensen
diff --git a/src/project.py b/src/project.py
index d0f492a..14823a3 100644
--- a/src/project.py
+++ b/src/project.py
@@ -1,5 +1,24 @@
 #! /usr/bin/env python
 
+# gEDA Manager
+# Copyright (C) 2008 Newell Jensen
+# Copyright (C) 2008 gEDA Contributors (see ChangeLog for details)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
 ##@package src.project
 # Project class for the gEDA Manager project objects
 #@author Newell Jensen
diff --git a/src/project_popup.xml b/src/project_popup.xml
index 6d8f518..1f60f4c 100644
--- a/src/project_popup.xml
+++ b/src/project_popup.xml
@@ -4,6 +4,7 @@
     <menuitem action="New Folder"/>
     <menuitem action="New Source..."/>
     <menuitem action="Add Copy of Source..."/>
+    <menuitem action="Rename"/>
     <separator/>
   </popup>
 </ui>
diff --git a/src/settings.py b/src/settings.py
index 3aede1c..9785731 100644
--- a/src/settings.py
+++ b/src/settings.py
@@ -1,5 +1,24 @@
 #! /usr/bin/env python
 
+# gEDA Manager
+# Copyright (C) 2008 Newell Jensen
+# Copyright (C) 2008 gEDA Contributors (see ChangeLog for details)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
 ##@package src.settings
 #Create and verify settings for the gEDA Manager
 #Create and update the gEDA Manager configuration file .gmrc
diff --git a/src/utils.py b/src/utils.py
index 45bd67f..3cce376 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -1,5 +1,24 @@
 #! /usr/bin/env python
 
+# gEDA Manager
+# Copyright (C) 2008 Newell Jensen
+# Copyright (C) 2008 gEDA Contributors (see ChangeLog for details)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
 ##@package src.utils
 #Utility class for the gEDA Manager
 #@author Newell Jensen
@@ -16,46 +35,98 @@ class Utils:
     Utility class for the gEDA Manager.
     """
     # Look Up Table used to look up static resources
-    icon_lut = {'project': '../images/bitmaps/pn-project.bmp',
-                'sch': '../images/bitmaps/geda-gschem22.png',
-                'gm': '../images/bitmaps/document.bmp',
-                'pcb': '../images/bitmaps/pcb22.png',
-                'v': '../images/bitmaps/verilog-module.bmp',
-                'vhd': '../images/bitmaps/vhdl-module.bmp',
-                'log': '../images/bitmaps/page_white.png',
-                'gbr': '../images/bitmaps/gerbv-icon26.png',
-                'cnc': '',
-                'gerbv': '',
-                'g2p': '../images/bitmaps/geda-xgsch2pcb-26.png',
-                'gafrc': '',
-                'gschemrc': '',
-                'gnetlistrc': '',
-                'gattribrc': '../images/bitmaps/geda-gattrib22.png',
-                'attribs': '',
-                'net': '',
-                'cmd': '',
-                'new.pcb': '../images/bitmaps/application-x-pcb-layout-22.png',
-                'scm': '',
-                'drc': '',
-                'sym': '../images/bitmaps/schematic-module.bmp',
-                'ps': '',
-                'png': '../images/bitmaps/image.png',
-                'bom': '../images/bitmaps/money.png',
-                'bom2': '../images/bitmaps/money_add.png',
-                'tex': '',
-                'gnumeric': '',
-                'spice': '../images/bitmaps/plot_singleplot.png',
-                'dwg': '',
-                'other': '../images/bitmaps/page_white_error.png',}
 
-    file_lut = {'project_popup': 'project_popup.xml',
-                'folder_popup': 'folder_popup.xml',
-                'file_popup': 'file_popup.xml'}
+##     icon_lut = {'project': '../images/bitmaps/pn-project.bmp',
+##                 'sch': '../images/bitmaps/geda-gschem22.png',
+##                 'gm': '../images/bitmaps/document.bmp',
+##                 'pcb': '../images/bitmaps/pcb22.png',
+##                 'v': '../images/bitmaps/verilog-module.bmp',
+##                 'vhd': '../images/bitmaps/vhdl-module.bmp',
+##                 'log': '../images/bitmaps/page_white.png',
+##                 'gbr': '../images/bitmaps/gerbv-icon26.png',
+##                 'cnc': '',
+##                 'gerbv': '',
+##                 'g2p': '../images/bitmaps/geda-xgsch2pcb-26.png',
+##                 'gafrc': '',
+##                 'gschemrc': '',
+##                 'gnetlistrc': '',
+##                 'gattribrc': '../images/bitmaps/geda-gattrib22.png',
+##                 'attribs': '',
+##                 'net': '',
+##                 'cmd': '',
+##                 'new.pcb': '../images/bitmaps/application-x-pcb-layout-22.png',
+##                 'scm': '',
+##                 'drc': '',
+##                 'sym': '../images/bitmaps/schematic-module.bmp',
+##                 'ps': '',
+##                 'png': '../images/bitmaps/image.png',
+##                 'bom': '../images/bitmaps/money.png',
+##                 'bom2': '../images/bitmaps/money_add.png',
+##                 'tex': '',
+##                 'gnumeric': '',
+##                 'spice': '../images/bitmaps/plot_singleplot.png',
+##                 'dwg': '',
+##                 'other': '../images/bitmaps/page_white_error.png',}
 
 
     def __init__(self):
         """ Constructor. """
         self.directory = os.getcwd()
+        self.__lut__()
+
+
+    def __lut__(self):
+        """ Method to load the look up tables. """
+        image = gtk.gdk.pixbuf_new_from_file('../images/icons/geda-xgsch2pcb-48.png')
+        gtk.icon_theme_add_builtin_icon('gEDAManager', 22, image)
+        image = gtk.gdk.pixbuf_new_from_file('../images/icons/terminal.jpg')
+        gtk.icon_theme_add_builtin_icon('terminal', 22, image)
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/gq-folder.png')
+        gtk.icon_theme_add_builtin_icon('folder', 22, image)
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/pn-project.bmp')
+        gtk.icon_theme_add_builtin_icon('project', 22, image)
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/document.bmp')
+        gtk.icon_theme_add_builtin_icon('gm', 22, image)
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/page_white.png')
+        gtk.icon_theme_add_builtin_icon('log', 22, image)        
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/verilog-module.bmp')
+        gtk.icon_theme_add_builtin_icon('v', 22, image)                
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/vhdl-module.bmp')
+        gtk.icon_theme_add_builtin_icon('vhd', 22, image)                
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/vhdl-module.bmp')
+        gtk.icon_theme_add_builtin_icon('vhdl', 22, image)                
+        image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/page_white_error.png')
+        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)        
+
+
+
+        self.icon_lut = {'spice': 'spice',
+                         'other': 'other',
+                         'vhd': 'vhd',
+                         'vhdl': 'vhdl',
+                         'v': 'v',
+                         'log': 'log',
+                         'gm': 'gm',
+                         'project': 'project',
+                         'folder': 'folder',
+                         'terminal': 'terminal',
+                         'gEDAManager': 'gEDAManager',
+                         'sch': 'application-x-geda-schematic',
+                         'sym': 'application-x-geda-symbol',
+                         'net': 'application-x-geda-netlist',
+                         'gsch2pcb': 'application-x-geda-gsch2pcb-project',
+                         'g2p': 'application-x-geda-gsch2pcb-project',
+                         'fp': 'application-x-pcb-footprint',
+                         'pcb': 'application-x-pcb-layout',
+                         'pcb.net': 'application-x-pcb-netlist',
+                         'gbr': 'application-x-gerber',
+                         'cnc': 'application-x-excellon'}
+                         
+        self.file_lut = {'project_popup': 'project_popup.xml',
+                         'folder_popup': 'folder_popup.xml',
+                         'file_popup': 'file_popup.xml'}
 
 
     @exceptions
@@ -75,46 +146,30 @@ class Utils:
         return f
 
 
-    @exceptions
-    def get_node_image(self, gedamanager, name):
-        """!
-        Method to get the image for node with param name.
-        @param gedamanager is the current gEDAManager instance.        
-        @param name of the file.
-        @return a gtk.Pixbuf image is returned
-        """
-        current_directory = os.getcwd()
-        os.chdir(self.directory)
-        if name == 'project':
-            key = name
-        elif '.' in name:
-            key = name.split('.')[-1]
-        else:
-            image = gtk.gdk.pixbuf_new_from_file('../images/bitmaps/gq-folder.png')
-            os.chdir(current_directory)
-            return image
-        if self.icon_lut.has_key(key):
-            icon_type = self.icon_lut[key]
-        else:
-            icon_type = self.icon_lut['other']
-
-        image = gtk.gdk.pixbuf_new_from_file(icon_type)            
-        os.chdir(current_directory)
-        return image
-
-    
     def get_node_name(self, path):
         """!
         Method to return the node name from the path.
         @param path to the node.
         @return name of the node without an extension.
         """
-        if path.count('/'):
+        if '/' in path:
             return path.split('/')[-1]
         else:
             return None
 
 
+    def get_node_ext(self, path):
+        """!
+        Method to return the extension for the path.
+        @param path to the node.
+        @return extension of the node.
+        """
+        if '.' in path:
+            return path.split('.')[-1]
+        else:
+            return 'folder' 
+
+
     @exceptions
     def update_file_list(self, gedamanager, index=None, filename=None):
         """!
@@ -154,7 +209,8 @@ class Utils:
         name = self.get_node_name(selected_node)
         if filename != None:
             name = self.get_node_name(filename)
-        image = self.get_node_image(g, name)        
+        icon = gtk.IconTheme()
+        image = icon.load_icon(self.icon_lut[self.get_node_ext(name)], 22, 0)
         path = selected_node + '/' + name
 
         if index == 0:
@@ -206,58 +262,39 @@ class Utils:
         @param ext is the filename extension for the currently selected node
         in the 'Sources' tree view.
         """
-        g = gedamanager
-        current_directory = os.getcwd()
-        os.chdir(self.directory)            
-        g.processes.clear()
-        if ext == 'sch':
-            icon_type = self.icon_lut['g2p']
-            image = gtk.gdk.pixbuf_new_from_file(icon_type)
-            g.processes.append(None, [image, 'gsch2pcb'])
-            icon_type = self.icon_lut['other']#icon_type = self.icon_lut['net']
-            image = gtk.gdk.pixbuf_new_from_file(icon_type)
-            parent = g.processes.append(None, [image, 'gnetlist'])
-            netlists = ['bom2','calay','mathematica','vipec','geda','systemc','allegro','redac','drc2','cascade','pads','bae','pcbpins','vams','drc','gsch2pcb','partslist2','partslist3','partslist-common','gossip','maxascii','PCB','vhdl','tango','spice-sdb','partstlist1','PCBboard','switchcap','osmond','spice','verilog','bom','eagle','protelII','futurenet2']
-            for netlist in sorted(netlists):
-                g.processes.append(parent, [None, netlist])
-            icon_type = self.icon_lut['other']
-            image = gtk.gdk.pixbuf_new_from_file(icon_type)
-            g.processes.append(None, [image, 'refdes_renum'])
-            icon_type = self.icon_lut['other']
-            image = gtk.gdk.pixbuf_new_from_file(icon_type)
-            g.processes.append(None, [image, 'grenum'])
-            icon_type = self.icon_lut['spice']
-            image = gtk.gdk.pixbuf_new_from_file(icon_type)
-            g.processes.append(None, [image, 'gspiceui'])
-            icon_type = self.icon_lut['gattribrc']
-            image = gtk.gdk.pixbuf_new_from_file(icon_type)
-            g.processes.append(None, [image, 'gattrib'])
-        elif ext == 'v':
-            pass
-        elif ext == 'pcb':
-            pass
-            # add more
-        if ext == None: # We have a folder, so we will need to look through
-            pass
-        
-        os.chdir(current_directory)            
-
-
-##     @exceptions
-##     def change_terminal_directory(self, gedamanager, path=None):
-##         """!
-##         Method to change the directory of the terminal window to path if given
-##         or to the project's directory if path is null.
-##         @param gedamanager is the current gEDAManager instance.
-##         @param path is the path to change directories too if supplied.
-##         """
 ##         g = gedamanager
-##         if path == None and g.project.directory != None:
-##             #g.terminal.fork_command('cd ' + g.project.directory + '\r')
-##             g.terminal.feed('cd ' + g.project.directory + '\r')
-##         elif path != None:
-##             #g.terminal.fork_command('cd ' + path + '\r')
-##             g.terminal.feed('cd ' + path + '\r')
-
+##         current_directory = os.getcwd()
+##         os.chdir(self.directory)            
+##         g.processes.clear()
+##         if ext == 'sch':
+##             icon_type = self.icon_lut['g2p']
+##             g.processes.append(None, [image, 'gsch2pcb'])
+##             icon_type = self.icon_lut['other']#icon_type = self.icon_lut['net']
+##             image = gtk.gdk.pixbuf_new_from_file(icon_type)
+##             parent = g.processes.append(None, [image, 'gnetlist'])
+##             netlists = ['bom2','calay','mathematica','vipec','geda','systemc','allegro','redac','drc2','cascade','pads','bae','pcbpins','vams','drc','gsch2pcb','partslist2','partslist3','partslist-common','gossip','maxascii','PCB','vhdl','tango','spice-sdb','partstlist1','PCBboard','switchcap','osmond','spice','verilog','bom','eagle','protelII','futurenet2']
+##             for netlist in sorted(netlists):
+##                 g.processes.append(parent, [None, netlist])
+##             icon_type = self.icon_lut['other']
+##             image = gtk.gdk.pixbuf_new_from_file(icon_type)
+##             g.processes.append(None, [image, 'refdes_renum'])
+##             icon_type = self.icon_lut['other']
+##             image = gtk.gdk.pixbuf_new_from_file(icon_type)
+##             g.processes.append(None, [image, 'grenum'])
+##             icon_type = self.icon_lut['spice']
+##             image = gtk.gdk.pixbuf_new_from_file(icon_type)
+##             g.processes.append(None, [image, 'gspiceui'])
+##             icon_type = self.icon_lut['gattribrc']
+##             image = gtk.gdk.pixbuf_new_from_file(icon_type)
+##             g.processes.append(None, [image, 'gattrib'])
+##         elif ext == 'v':
+##             pass
+##         elif ext == 'pcb':
+##             pass
+##             # add more
+##         if ext == None: # We have a folder, so we will need to look through
+##             pass
+        
+##         os.chdir(current_directory)            
 
     




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