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

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



The branch, master has been updated
       via  c233e5779252c5660bc6f2dd4d57ed6c30b0fd5a (commit)
      from  7e2cfec1315a4e44c4cbe7b990dea67c3cc43545 (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  |    2 +-
 src/gedamanager.py    |   94 ++++++++++++++++++++++++++++++++++++------------
 src/lib/decorators.py |   10 +++---
 src/project_popup.xml |    2 +-
 src/settings.py       |    8 +++-
 src/utils.py          |   93 +++++++++++++++++++++++++++++++-----------------
 7 files changed, 144 insertions(+), 66 deletions(-)


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

commit c233e5779252c5660bc6f2dd4d57ed6c30b0fd5a
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Mon Aug 11 00:38:41 2008 -0700

    Added a bunch of functionality to the code base and fixed some bugs.

:100644 100644 c150500... e8f414a... M	src/file_popup.xml
:100644 100644 7bafa1f... 883f1c8... M	src/folder_popup.xml
:100644 100644 5bad900... 670d431... M	src/gedamanager.py
:100644 100644 70fbd5e... c5fa5e2... M	src/lib/decorators.py
:100644 100644 1f60f4c... a611254... M	src/project_popup.xml
:100644 100644 9785731... f9001f8... M	src/settings.py
:100644 100644 b3cc946... 900bd4f... M	src/utils.py

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

commit c233e5779252c5660bc6f2dd4d57ed6c30b0fd5a
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Mon Aug 11 00:38:41 2008 -0700

    Added a bunch of functionality to the code base and fixed some bugs.

diff --git a/src/file_popup.xml b/src/file_popup.xml
index c150500..e8f414a 100644
--- a/src/file_popup.xml
+++ b/src/file_popup.xml
@@ -3,6 +3,7 @@
     <separator/>
     <menuitem action="Delete"/>
     <menuitem action="Rename"/>
+    <menuitem action="Copy Existing Dependency..."/>
     <separator/>
   </popup>
 </ui>
diff --git a/src/folder_popup.xml b/src/folder_popup.xml
index 7bafa1f..883f1c8 100644
--- a/src/folder_popup.xml
+++ b/src/folder_popup.xml
@@ -4,7 +4,7 @@
     <menuitem action="New Folder"/>
     <menuitem action="Delete Folder"/>
     <menuitem action="New Source..."/>
-    <menuitem action="Add Copy of Source..."/>
+    <menuitem action="Copy Existing Source To Project..."/>
     <menuitem action="Rename"/>
     <separator/>
   </popup>
diff --git a/src/gedamanager.py b/src/gedamanager.py
index 5bad900..670d431 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -86,11 +86,8 @@ class gEDAManager:
         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
+        self.tools = {'sch': None, 'pcb': None, 'gbr': None, 'gattrib': None,
+                      'editor': None}
         
 
     def __init_menus__(self):
@@ -600,8 +597,11 @@ class gEDAManager:
         # e.g.
         # "You have open processes.  If you exit you may lose unsaved
         # changes.  Would you like to proceed? Okay or Cancel.
-        
+        for tool, value in self.tools.iteritems():
+            if value != None: # kill the process
+                os.kill(value.pid, signal.SIGKILL)
     
+
     ######################################################
     # Callback Methods -- signal handlers are event driven
     ######################################################
@@ -775,8 +775,8 @@ class gEDAManager:
             self.newsource = model.get_value(selection_iter, 1)
 
 
-        if self.editor != None:
-            old_editor = self.editor
+        if self.settings.editor != None:
+            old_editor = self.settings.editor
         else:
             old_editor = None
 
@@ -784,15 +784,18 @@ class gEDAManager:
             dialog.response(response)
             
         entry = gtk.Entry()
+        if self.settings.editor != None:
+            entry.set_text(self.settings.editor)
         entry.show()
 
         def cb_filebutton_selection_changed(filechooser, entry):
-            self.editor = filebutton.get_filename()
-            entry.set_text(self.editor)
+            self.settings.editor = filebutton.get_filename()
+            entry.delete_text(0,-1)
+            entry.set_text(self.settings.editor)
 
         dialog = gtk.MessageDialog(self.window,
                                    (gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
-                                   gtk.MESSAGE_QUESTION,
+                                   gtk.MESSAGE_OTHER,
                                    gtk.BUTTONS_OK_CANCEL,
                                    gtk.STOCK_DIRECTORY)
         dialog.set_markup('<b>Preference settings:</b>')
@@ -817,19 +820,14 @@ class gEDAManager:
         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
+        if old_editor != self.settings.editor: # A change was made
+            new_text = self.settings.editor
         else:
             new_text = entry.get_text()
-
         dialog.destroy()
 
-        print 'editor:',self.editor
-
         if new_text:
-            print new_text
-        else:
-            print 'empty'
+            self.settings.editor = new_text
 
 
     def cb_new_source(self, menuitem, data=None):
@@ -910,7 +908,7 @@ class gEDAManager:
         @param menuitem that threw the event.
         @param data optional to pass in.
         """
-        dialog = gtk.FileChooserDialog('Add Copy of Source...',
+        dialog = gtk.FileChooserDialog('Copy Existing Source To Project...',
                                        self.window,
                                        gtk.FILE_CHOOSER_ACTION_OPEN,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
@@ -922,10 +920,58 @@ class gEDAManager:
         if response == gtk.RESPONSE_OK:
             filename = dialog.get_filename()
             self.utils.update_file_list(self, 0, filename)
-            self.output_textbuffer.insert(self.output_textiter, 'Copy of source added: ' + filename + '.\n')                                
+            self.output_textbuffer.insert(self.output_textiter, 'Copy of existing source added: ' + filename + '.\n')                                
         dialog.destroy()
 
 
+    def cb_add_copy_dependency(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.
+        """
+        # Make the user choose which destination directory they want this
+        # dependency file to be in
+        # Then, make the user choose which file they want.
+        # Make a window that has a directory chooser like in the assistant
+        # and then a FileChooserDialog box
+        dialog = gtk.MessageDialog(self.window,
+                                   (gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
+                                   gtk.MESSAGE_OTHER,
+                                   gtk.BUTTONS_OK_CANCEL,
+                                   gtk.STOCK_DIRECTORY)
+        dialog.set_markup('<b>Select dependency file and its target location\nwithin the project.</b>')
+        dialog.set_title('Copy Existing Dependency...')
+        hbox = gtk.HBox()
+        hbox.show()
+        filebutton = gtk.FileChooserButton('Target Location')
+        filebutton.show()
+        filebutton.set_local_only(True)
+        filebutton.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
+        hbox.pack_end(filebutton)
+        label = gtk.Label('Target Location:')
+        label.show()
+        hbox.pack_end(label)
+        dialog.vbox.pack_end(hbox, True, True, 0)
+
+        hbox = gtk.HBox()
+        hbox.show()
+        embed_fc = gtk.FileChooserButton('Dependency File')
+        embed_fc.show()
+        embed_fc.set_local_only(True)
+        embed_fc.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
+        hbox.pack_end(embed_fc)
+        label = gtk.Label('Dependency File')
+        label.show()
+        hbox.pack_end(label)
+        dialog.vbox.pack_end(hbox, True, True, 0)
+        
+        dialog.show()
+        dialog.run()
+        new_text = filebutton.get_filename()
+        dialog.destroy()
+        
+
     @exceptions
     def cb_new_folder(self, action):
         """!
@@ -1133,9 +1179,10 @@ class gEDAManager:
             popup_menu = gtk.Menu()
             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),
+                                ('Delete', gtk.STOCK_DELETE, '_Delete', '<Control>d', None, self.cb_delete),
+                                ('Copy Existing Dependency...', None, 'Copy Existing _Dependency...', None, None, self.cb_add_copy_dependency),
                                 ('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),
+                                ('Copy Existing Source To Project...', gtk.STOCK_DND_MULTIPLE, '_Copy Existing Source To Project...', 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),]
 
@@ -1150,7 +1197,6 @@ class gEDAManager:
             elif '.' not in selected_node:
                 # Folder
                 merge_id = self.popup_uimanager.add_ui_from_file(self.utils.directory + '/folder_popup.xml')
-
                 popup_menu = self.popup_uimanager.get_widget('/popup')
             else:
                 # File
diff --git a/src/lib/decorators.py b/src/lib/decorators.py
index 70fbd5e..c5fa5e2 100644
--- a/src/lib/decorators.py
+++ b/src/lib/decorators.py
@@ -45,15 +45,15 @@ def exceptions(func):
                 try:
                     f = func(*args)
                 except IOError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IOError: ' +  str(sys.exc_info()) + '.\n')
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IOError: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')
                 except OSError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'OSError: ' +  str(sys.exc_info()) + '.\n')
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'OSError: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')
                 except IndexError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IndexError: ' +  str(sys.exc_info()) + '.\n')
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IndexError: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')
                 except TypeError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'TypeError: ' +  str(sys.exc_info()) + '.\n')                                        
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'TypeError: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')                                        
                 except:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'Unexpected error: ' +  str(sys.exc_info()) + '.\n')            
+                    arg.errors_textbuffer.insert(arg.errors_textiter, 'Unexpected error: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')            
                     raise
                 return f
             
diff --git a/src/project_popup.xml b/src/project_popup.xml
index 1f60f4c..a611254 100644
--- a/src/project_popup.xml
+++ b/src/project_popup.xml
@@ -3,7 +3,7 @@
     <separator/>
     <menuitem action="New Folder"/>
     <menuitem action="New Source..."/>
-    <menuitem action="Add Copy of Source..."/>
+    <menuitem action="Copy Existing Source To Project..."/>
     <menuitem action="Rename"/>
     <separator/>
   </popup>
diff --git a/src/settings.py b/src/settings.py
index 9785731..f9001f8 100644
--- a/src/settings.py
+++ b/src/settings.py
@@ -38,6 +38,7 @@ class Settings:
         self.version = 1.0
         self.installed_apps = []
         self.project = None
+        self.editor = None
         self.path = os.path.expanduser('~') + '/.gmrc'
         self.geda_apps = ['gschem','pcb','gsch2pcb','gnucap','ngspice',
                           'iverilog','gattrib','gtkwave','gwave','gnetlist',
@@ -56,10 +57,11 @@ class Settings:
         if config:
             # parse the config object and get list of apps
             stream = file(self.path, 'r')
-            
+
             for data in yaml.load_all(stream):
                 self.installed_apps = data['programs']
                 self.project = data['project']
+                self.editor = data['editor']
                 # Check to see if this file is still available
                 if self.project != None:
                     try:
@@ -104,6 +106,7 @@ class Settings:
                 apps.append(geda_app[1])
             except IndexError:
                 print 'IndexError:', sys.exc_info()[0]
+                print 'The application ' + app + ' is not installed.'
         return apps
 
     
@@ -131,7 +134,8 @@ class Settings:
         """
         yaml.dump(yaml.load(document), stream, default_flow_style=False)
         yaml.dump({'programs': self.installed_apps, 'version': self.version,
-                   'project': self.project}, stream, default_flow_style=False)
+                   'project': self.project,
+                   'editor': self.editor}, stream, default_flow_style=False)
         stream.close()
 
 
diff --git a/src/utils.py b/src/utils.py
index b3cc946..900bd4f 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -23,12 +23,14 @@
 #Utility class for the gEDA Manager
 #@author Newell Jensen
 
-import os, pygtk, gtk
+import os, pygtk, gtk, dbus
 pygtk.require('2.0')
 from lib.decorators import exceptions
 from project import *
 from settings import *
 from subprocess import *
+from stat import *
+from dbus.mainloop.glib import DBusGMainLoop
 
 
 class Utils:
@@ -39,6 +41,12 @@ class Utils:
         """ Constructor. """
         self.directory = os.getcwd()
         self.__icons__()
+        # Set up the DBUS session bus
+        dbus_loop = DBusGMainLoop()
+        self.session_bus = dbus.SessionBus(mainloop=dbus_loop)
+        self.dbus_obj = self.session_bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
+        self.dbus_iface = dbus.Interface(self.dbus_obj, 'org.freedesktop.DBus')
+        self.empty_char_array = dbus.Array('', signature='s')
 
 
     def __icons__(self):
@@ -240,9 +248,10 @@ class Utils:
             files = os.listdir(selected_node)
             extensions = []
             for f in files:
-                ext = self.get_node_ext(f)
-                if ext not in extensions:
-                    extensions.append(ext)
+                if not f.endswith(('~','-')):
+                    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:
@@ -323,11 +332,6 @@ class Utils:
             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)            
 
     
@@ -370,8 +374,9 @@ class Utils:
         model, selection_iter = selection.get_selected()
         selected_source = g.sources.get_value(selection_iter, 2)
         print 'selected_source:',selected_source
-        
 
+        
+    @exceptions
     def run_command(self, gedamanager, selected_node, highlighted_source=None, ext=None):
         """!
         Method to run commands for 'Processes' and 'Sources'.
@@ -382,36 +387,58 @@ class Utils:
         @param ext is the extension of the selected file.
         """
         g = gedamanager
-        files = ['net','log','bom','bom1','bom2']        
+        files = ['net','log','bom','bom1','bom2','v','vhd','gm','gafrc','txt']        
         # 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
+                if g.tools['sch'] == None or g.sch.poll() == 0:
+                    g.tools['sch'] = Popen(['gschem', selected_node], stdin=PIPE)
+                elif g.tools['sch'].poll() == None: # Process is still running
+##                     pcb_instances = self.dbus_iface.ListQueuedOwners('org.seul.geda.gschem')
+##                     for pcb in pcb_instances:
+##                         # Let's end it
+##                         pcb_obj = self.session_bus.get_object(pcb, '/org/seul/geda/gschem')
+##                     self.pcb_actions_iface = dbus.Interface(pcb_obj, 'org.seul.geda.gschem.actions')
+##                     print 'HEY'
+##                     self.pcb_actions_iface.ExecAction('Quit', self.empty_char_array)
+                    # Let's try to open a file
+                    try:
+                        st = os.stat(selected_node)
+                    except IOError:
+                        print 'IOError'
+                    else:
+                        print 'file size:', st[ST_SIZE]
+                        print 'file modified:', st[ST_MTIME]
             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
+                if g.tools['pcb'] == None or g.tools['pcb'].poll() == 0:
+                    g.tools['pcb'] = Popen(['pcb', selected_node])
+                elif g.tools['pcb'].poll() == None: # Process is still running
+                    pcb_instances = self.dbus_iface.ListQueuedOwners('org.seul.geda.pcb')
+                    for pcb in pcb_instances:
+                        # Let's end it
+                        pcb_obj = self.session_bus.get_object(pcb, '/org/seul/geda/pcb')
+                    self.pcb_actions_iface = dbus.Interface(pcb_obj, 'org.seul.geda.pcb.actions')
+                    self.pcb_actions_iface.ExecAction('Quit', self.empty_char_array)
             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
+                if g.tools['gbr'] == None or g.tools['gbr'].poll() == 0:
+                    g.tools['gbr'] = Popen(['gerbv', selected_node])
+                elif g.tools['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
+            elif ext in files and g.settings.editor != None:
+                if g.tools['editor'] == None or g.tools['editor'].poll() == 0:
+                    g.tools['editor'] = Popen([g.settings.editor, selected_node])
+                elif g.tools['editor'].poll() == None: # Process is still running
                     pass
+            elif g.settings.editor == None:
+                dialog = gtk.MessageDialog(g.window,
+                                           (gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
+                                           gtk.MESSAGE_INFO,
+                                           gtk.BUTTONS_OK,
+                                           gtk.STOCK_DIRECTORY)
+                dialog.set_markup('<b>Please go to Edit->Preferences and choose a default text editor.</b>')
+                dialog.show()
+                response = dialog.run()
+                dialog.destroy()
 
         else: # Processes
             pass




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