[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: branch: master updated (87054c7b5a7dcdd22e95d8cf0339b570f3301788)
The branch, master has been updated
via 87054c7b5a7dcdd22e95d8cf0339b570f3301788 (commit)
from 80aa80980a2b896380d7980f6b0b6b42156d7041 (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
=========
readme.txt | 29 ++++++++-
src/gedamanager.py | 162 +++++++++++++++++++++++++---------------------------
src/project.py | 1 -
src/settings.py | 23 ++------
src/utils.py | 137 ++++++++++++++++++++++++++++++++++++++------
5 files changed, 228 insertions(+), 124 deletions(-)
=================
Commit Messages
=================
commit 87054c7b5a7dcdd22e95d8cf0339b570f3301788
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Sun Jul 13 18:04:55 2008 -0700
Routine checkin. Updated readme.txt with Doxygen instructions.
:100644 100644 ca26350... 40373b2... M readme.txt
:100644 100644 a885877... ff2e816... M src/gedamanager.py
:100644 100644 fd46dfc... 9acc5ea... M src/project.py
:100644 100644 9de8d77... 7665941... M src/settings.py
:100644 100644 d4f361f... b38c308... M src/utils.py
=========
Changes
=========
commit 87054c7b5a7dcdd22e95d8cf0339b570f3301788
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Sun Jul 13 18:04:55 2008 -0700
Routine checkin. Updated readme.txt with Doxygen instructions.
diff --git a/readme.txt b/readme.txt
index ca26350..40373b2 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,6 +1,6 @@
-Welcome to the geda manager project!
+Welcome to the gEDA Manager project!
-INSTRUCTIONS
+----------------------------------------------------------------------------
gEDA Manager:
Dependencies-
@@ -13,8 +13,10 @@ pyyaml - http://pyyaml.org/
To run the program go to gEDA_Manager/src directory and run:
$ python gedamanager.py
+----------------------------------------------------------------------------
+
Doxygen:
-For doxygen generated documentation I followed this blog:
+To create doxygen generated documentation I followed this blog:
http://internetducttape.com/2007/03/20/automatic_documentation_python_doxygen/
@@ -29,3 +31,24 @@ My configuration file for the doxygen settings that I set up are located in
/docs in config.dox. This file can help give you an idea of what your settings
should be even though yours may be different.
+----------------------------------------------------------------------------
+
+Configuration:
+
+The gEDA Manager configuration file is a yaml file called .gmrc. This file
+will be created on initial startup of the program if this file is not located
+in your home directory. Currently, this file is used for letting the gEDA
+Manager know which gEDA tools you have installed on your system, the last
+project (if any) that you had loaded, etc.
+
+----------------------------------------------------------------------------
+
+Projects:
+-- simply overview --
+
+When you go to create a new project, the gEDA Manager will prompt you for
+a file and folder name (*project_name*) as well what directory you would like to
+create this project in. Once you have entered this information, the gEDA
+Manager creates a new folder called *project_name* in the directory that you
+specified with the project file called *project_name*.gm.
+
diff --git a/src/gedamanager.py b/src/gedamanager.py
index a885877..ff2e816 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -543,7 +543,7 @@ class gEDAManager:
"""
# Save current project
if not self.project.clean:
- self.save_tree()
+
self.project.save()
self.project.open(path)
@@ -565,19 +565,20 @@ class gEDAManager:
self.sources.clear()
# Parent Folder
- name = self.utils.get_node_name(self.project.name)
- image = self.utils.lut['project']
- path = self.project.directory + '/' + name
- parent = self.sources.append(None, [image, name, path])
+ name = self.project.name.split('.')[0]
+ image = self.utils.get_node_image('project')
+ parent = self.sources.append(None, [image, name, self.project.directory])
# Child Node
image = self.utils.get_node_image(self.project.name)
- self.sources.append(parent, [image, self.project.name, path + '.gm'])
+ path = self.project.directory + '/' + self.project.name
+ self.sources.append(parent, [image, self.project.name, path])
self.sources_tree.expand_all()
- # Add new sources to project's file_list
- self.project.file_list = [self.project.directory, [path + '.gm']]
-
+ # This is the only place in the gEDA Manager where we actually
+ # manipulate the project's file list. The rest is done in the Utils
+ # class.
+ self.project.file_list = [self.project.directory, [self.project.directory +'/' + self.project.name]]
def load_tree(self, list, parent=None):
"""
@@ -589,7 +590,7 @@ 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(name, self.project.directory)
+ image = self.utils.get_node_image('project')
else:
image = self.utils.get_node_image(name)
n_parent = self.sources.append(parent, [image, name, file_path])
@@ -598,15 +599,6 @@ class gEDAManager:
self.load_tree(file_path, n_parent)
- def save_tree(self):
- """
- Method to save the tree to the current project's file_list.
- """
- # TODO -- this method will need to be created once I start adding
- # nodes to the tree
- # TODO -- iterate through the tree and save to the project.file_list
-
-
def save_settings(self):
"""
Method to save current settings to .gmrc file.
@@ -637,18 +629,17 @@ class gEDAManager:
# 1. Find what node is selected. We know that it is a folder.
# 2. Move file into this directory
# 3. Add the new file path to the project's file list
- selected_node = self.get_sources_selected_node()
- if selected_node == self.project.file_list[0]: # Project Folder
- self.project.file_list[1].append(path)
- parent = self.sources.get_iter_root()
- else: # Folder
- # Find the folder's parent
- parent = self.sources.get_iter(selected_node)
- 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(name)
- self.sources.append(parent, [image, name, path])
-
+## selection = self.sources_tree.get_selection()
+## model, selection_iter = selection.get_selected()
+## selected_node = self.sources.get_value(selection_iter, 2)
+## if selected_node == self.project.file_list[0]: # Project Folder
+## self.project.file_list[1].append(path)
+## 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(name)
+## self.sources.append(selection_iter, [image, name, path])
+## self.utils.update_file_list(self, model)
+ self.utils.update_file_list(self, 0)
def add_copy_sources_node(self, path):
"""
@@ -658,26 +649,13 @@ class gEDAManager:
# TODO -- this will change if the data store changes
# TODO -- Need to see if a node with the same name already exists
# to do this I will need to loop through the file_list
- print 'path: ', path
- self.project.file_list.append(path)
- name = path.split('/')[-1]
- # Find out what file it is so we can pick an icon for it
- image = self.utils.get_node_image(name)
- self.sources.append(None, [image, name, path])
-
-
- def get_sources_selected_node(self):
- """
- Method to get the selected node in the 'Sources' treeview.
- @return path of the selected node.
- """
- selection = self.sources_tree.get_selection()
- model, selection_iter = selection.get_selected()
- if (selection_iter):
- return self.sources.get_value(selection_iter, 2)
- else:
- return None
-
+## print 'path: ', path
+## ## self.project.file_list.append(path)
+## name = path.split('/')[-1]
+## # Find out what file it is so we can pick an icon for it
+## image = self.utils.get_node_image(name)
+## self.sources.append(None, [image, name, path])
+ self.utils.update_file_list(self, 1)
def get_processes_selected_node(self):
"""
@@ -811,7 +789,6 @@ class gEDAManager:
@param menuitem that threw the event.
@param data optional to pass in.
"""
- self.save_tree()
self.project.save()
NewProject(self)
@@ -822,7 +799,6 @@ class gEDAManager:
@param menuitem that threw the event.
@param data optional to pass in.
"""
- self.save_tree()
self.project.save()
dialog = gtk.FileChooserDialog('Open...',
self.window,
@@ -849,7 +825,6 @@ class gEDAManager:
@param menuitem that threw the event.
@param data optional to pass in.
"""
- self.save_tree()
self.project.save()
self.project.close();
@@ -860,6 +835,9 @@ class gEDAManager:
@param menuitem that threw the event.
@param data optional to pass in.
"""
+ # TODO -- Disabling this for the moment.
+ # Don't know if I am going to have this anymore.
+ return
# This will open a Save dialog box
if self.project.name != None:
dialog = gtk.FileChooserDialog('Save Project As...',
@@ -889,7 +867,6 @@ class gEDAManager:
filename += '.gm'
self.project.name = self.utils.get_node_name(filename)
self.project.directory = filename.rpartition('/')[0]
- self.save_tree()
self.project.save()
dialog.destroy()
@@ -997,7 +974,7 @@ class gEDAManager:
@param menuitem that threw the event.
@param data optional to pass in.
"""
- self.save_tree()
+ print 'exiting'
self.project.save()
self.save_settings()
@@ -1132,7 +1109,7 @@ class gEDAManager:
response = dialog.run()
if response == gtk.RESPONSE_OK:
filename = dialog.get_filename()
- self.add_sources_node(filename)
+ self.utils.update_file_list(self, 0, filename)
dialog.destroy()
@@ -1165,8 +1142,16 @@ class gEDAManager:
def response_to_dialog(entry, dialog, response):
dialog.response(response)
print response
-
- selected_node = self.get_sources_selected_node()
+
+ selection = self.sources_tree.get_selection()
+ model, selection_iter = selection.get_selected()
+ selected_node = self.sources.get_value(selection_iter, 2)
+ if '.' in selected_node:
+ # This is not a folder
+ # YES, this is a hack and was put in place because
+ # we get some problems if the use right clicks on a node before
+ # it becomes highlighted. Add this to the TODO list.
+ return
os.chdir(selected_node)
dialog = gtk.MessageDialog(self.window,
(gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
@@ -1176,7 +1161,7 @@ class gEDAManager:
dialog.set_markup('<b>Please enter new folder name:</b>\nIf the node you selected already contains\na folder with this name it will be deleted.')
entry = gtk.Entry()
entry.show()
- entry.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK, gtk.RESPONSE_CANCEL)
+ entry.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)
hbox = gtk.HBox()
hbox.show()
hbox.pack_end(entry)
@@ -1192,33 +1177,36 @@ class gEDAManager:
try:
if f: # delete directory recursively
remove_tree(path)
+ flag = True
+ i = 0
+ while flag:
+ child_iter = self.sources.iter_nth_child(selection_iter, i)
+ child_node = self.sources.get_value(child_iter, 2)
+ if child_node == path:
+ if child_iter != None:
+ flag = self.sources.remove(child_iter)
+ if flag: # break out if flag is true
+ flag = False
+ i = i + 1
os.mkdir(path)
+ except IOError:
+ 'IOError: ', sys.exc_info()[0]
except:
- print 'JFLDJFJF'
- parent = self.sources.get_iter_from_string(selected_node)
+ print 'Unexpected error: ', sys.exc_info()[0]
+
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(name)
- self.sources.append(parent, [image, name, path])
-
-
-## if selected_node == self.project.file_list[0]: # Project Folder
-## self.project.file_list[1].append(path)
-## parent = self.sources.get_iter_root()
-## else: # Folder
-## # Find the folder's parent
-## parent = self.sources.get_iter(selected_node)
-## 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(name)
-## self.sources.append(parent, [image, name, ])
-
+ self.sources.append(selection_iter, [image, name, path])
+ # Add the new folder to project file list
+ self.utils.update_file_list(self)
def cb_delete_folder(self, widget):
"""
Event occurs when the user chooses to delete a folder from the project.
@param widget that threw the event.
"""
+ self.utils.update_file_list(self, 3)
def cb_row_activated(self, widget, path, view_column):
@@ -1243,12 +1231,15 @@ class gEDAManager:
Event occurs when the cursor changes in the treeview.
@param widget that threw the event.
"""
- selected_node = self.get_sources_selected_node()
+ 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)
# 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):
"""
Event occurs when the 'deactivate' signal is thrown from
@@ -1269,7 +1260,10 @@ class gEDAManager:
@param event that was thrown.
"""
if event.button == 3:
- selected_node = self.get_sources_selected_node()
+ selection = self.sources_tree.get_selection()
+ model, selection_iter = selection.get_selected()
+ if selection_iter != None:
+ selected_node = self.sources.get_value(selection_iter, 2)
popup_menu = gtk.Menu()
actiongroup = gtk.ActionGroup('Popup')
actiongroup_list = [('Save Project As...', None, 'Save Pro_ject As...', None, 'Save Active Project As...', self.cb_save_project_as),
@@ -1289,18 +1283,18 @@ class gEDAManager:
self.popup_uimanager.insert_action_group(actiongroup, 0)
# Choose Popup Menu
- if selected_node == self.project.name:
+ if selected_node == self.project.directory:
# Project Folder
- merge_id = self.popup_uimanager.add_ui_from_file('project_popup.xml')
+ merge_id = self.popup_uimanager.add_ui_from_file(self.utils.get_file('project_popup.xml'))
popup_menu = self.popup_uimanager.get_widget('/popup')
- elif not selected_node.count('.'):
+ elif '.' not in selected_node:
# Folder
- merge_id = self.popup_uimanager.add_ui_from_file(self.utils.lut['fd_pop'])
+ merge_id = self.popup_uimanager.add_ui_from_file(self.utils.get_file('folder_popup.xml'))
popup_menu = self.popup_uimanager.get_widget('/popup')
else:
# File
- merge_id = self.popup_uimanager.add_ui_from_file('file_popup.xml')
+ merge_id = self.popup_uimanager.add_ui_from_file(self.utils.get_file('file_popup.xml'))
popup_menu = self.popup_uimanager.get_widget('/popup')
popup_menu.connect('deactivate', self.cb_popup_deactivate, merge_id)
@@ -1313,7 +1307,7 @@ class gEDAManager:
Event handlder when the form is closed in any fashion.
@param event that was thrown.
"""
- self.save_tree()
+ print 'leaving'
self.project.save()
self.save_settings()
diff --git a/src/project.py b/src/project.py
index fd46dfc..9acc5ea 100644
--- a/src/project.py
+++ b/src/project.py
@@ -105,7 +105,6 @@ class Project(gobject.GObject):
print sys.exc_info()[0]
self.clean = True
if not silent:
- print 'sldfldsf'
self.emit('saved', True)
else:
self.emit('saved', False)
diff --git a/src/settings.py b/src/settings.py
index 9de8d77..7665941 100644
--- a/src/settings.py
+++ b/src/settings.py
@@ -2,7 +2,7 @@
##@package gEDA_Manager.src.settings
#Create and verify settings for the gEDA Manager
-#Create and update the gEDA Manager configuration file config.yaml
+#Create and update the gEDA Manager configuration file .gmrc
#@author Newell Jensen
import os, sys, gtk, string, signal, yaml
@@ -16,7 +16,7 @@ class Settings:
"""
def __init__(self):
"""
- Settings Default Constructor
+ Settings Default Constructor.
"""
self.version = 1.0
self.installed_apps = []
@@ -73,15 +73,11 @@ class Settings:
"""
Find all of the gEDA suite applications that are
installed on this machine and return list of these programs
- @return returns list of installed geda apps
+ @return list of installed geda apps
"""
- #def handler(signum, frame):
- #raise Exception
- #signal.signal(signal.SIGALRM, handler)
apps = []
for app in self.geda_apps:
# Check to see if program is installed
- #signal.alarm(5)
cmd = os.popen("which "+ app)
path = cmd.read()
#get name from path
@@ -91,20 +87,19 @@ class Settings:
apps.append(geda_app[1])
except IndexError:
pass
- #signal.alarm(0)
return apps
def create_config_file(self):
"""
Create the configuration file for the
- gEDA Manager
+ gEDA Manager.
"""
stream = file(self.path, 'w')
document = """
purpose: |
- config.yaml is a configuration file for the gEDA Manager.
+ .gmrc is the configuration file for the gEDA Manager.
It stores the list of geda programs that the user wants to
include in the manager. This file can be edited so that only
the programs of interest will be visible to the manager. To
@@ -114,14 +109,6 @@ class Settings:
If this program is not installed on your system, this will
cause errors and/or undesirable functionality.
- It is recommended that you create a directory that will contain
- all of you gEDA Manager projects because on initial startup the
- config.yaml file will be created by checking to see what geda
- applications you have installed. All other geda application
- specific files created by the other geda applications can be
- located anywhere on your system because the project files
- *project_name*.gm contain the paths to these files.
-
In the case that someone creates a new geda application and would
like it to be included in the gEDA Manager workflow, you will need
to update the geda_apps list located in the Settings.__init__
diff --git a/src/utils.py b/src/utils.py
index d4f361f..b38c308 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -4,20 +4,19 @@
#Utility class for the gEDA Manager
#@author Newell Jensen
-import os, sys, pygtk, gtk, yaml, gnomevfs
+import os, pygtk, gtk
pygtk.require('2.0')
from project import *
from settings import *
+from distutils.dir_util import remove_tree
class Utils:
"""
Utility class for the gEDA Manager.
"""
-
-
# Look Up Table used to look up static resources
- lut = {'project': '../icons/bitmaps/pn-project.bmp',
+ icon_lut = {'project': '../icons/bitmaps/pn-project.bmp',
'sch': '../icons/bitmaps/geda-gschem22.png',
'gm': '../icons/bitmaps/document.bmp',
'pcb': '../icons/bitmaps/pcb22.png',
@@ -46,10 +45,11 @@ class Utils:
'tex': '',
'gnumeric': '',
'spice': '',
- 'dwg': '',
- 'pj_pop': 'project_popup.xml',
- 'fd_pop': 'folder_popup.xml',
- 'f_pop': 'file_popup.xml'}
+ 'dwg': '',}
+
+ file_lut = {'project_popup': 'project_popup.xml',
+ 'folder_popup': 'folder_popup.xml',
+ 'file_popup': 'file_popup.xml'}
def __init__(self):
@@ -59,7 +59,23 @@ class Utils:
self.directory = os.getcwd()
- def get_node_image(self, name, project_node=None):
+ def get_file(self, filename):
+ """
+ Method to get the file from the file look up table.
+ @param filename is the file to find.
+ @returns path to the file.
+ """
+ print 'hokay'
+ current_directory = os.getcwd()
+ print 'hoday'
+ os.chdir(self.directory)
+ if '.' in filename:
+ key = filename.split('.')[0]
+ f = self.directory + '/' + self.file_lut[key]
+ os.chdir(current_directory)
+ return f
+
+ def get_node_image(self, name):
"""
Method to get the image for node with param name.
@param name of the file.
@@ -68,16 +84,19 @@ class Utils:
"""
current_directory = os.getcwd()
os.chdir(self.directory)
- if project_node != None:
- return gtk.gdk.pixbuf_new_from_file('../icons/bitmaps/pn-project.bmp')
- elif name.count('.'):
+ if name == 'project':
+ key = name
+ elif '.' in name:
key = name.split('.')[-1]
else:
+ image = gtk.gdk.pixbuf_new_from_file('../icons/bitmaps/gq-folder.png')
os.chdir(current_directory)
- return gtk.gdk.pixbuf_new_from_file('../icons/bitmaps/gq-folder.png')
- icon_type = self.lut[key]
+ return image
+ icon_type = self.icon_lut[key]
+ image = gtk.gdk.pixbuf_new_from_file(icon_type)
os.chdir(current_directory)
- return gtk.gdk.pixbuf_new_from_file(icon_type)
+ return image
+
def get_node_name(self, path):
@@ -91,7 +110,89 @@ class Utils:
return None
+ def update_file_list(self, gedamanager, index=None, filename=None):
+ """
+ Method to update the gEDA Manager's project file list any time
+ the 'Sources' tree view is changed.
+ @param gedamanager is the the gEDAManager instance.
+ @param index (0 = add source, 1 = add copy of source, 2 = delete
+ source, 3 = delete folder)
+ @param filename is the the filename of the source to add or copy.
+ """
+ # TODO -- Code clean up is possible with the back of the envelope
+ # algorithm that I am using below to recursively iterate over the
+ # tree view. For some reason, I am appending None to the lists and
+ # I later have to remove them. If anyone can clean this up, that
+ # would be nice.
+ g = gedamanager
+ def child_recurse(row_iter):
+ """
+ Internal function to iterate recursively over child nodes.
+ @param row_iter is the gtk.TreeModelRowIter object.
+ @return a list of child nodes.
+ """
+ child_list = []
+ while True:
+ try:
+ child_row = row_iter.next()
+ child_list.append(child_row[2])
+ child_row_iter = child_row.iterchildren()
+ if child_row_iter != None:
+ child_list.append(child_recurse(child_row_iter))
+ except StopIteration:
+ break
+ for x in child_list:
+ if x == None:
+ child_list.remove(x)
+ if child_list != []:
+ return child_list
+
+
+ selection = g.sources_tree.get_selection()
+ model, selection_iter = selection.get_selected()
+ selected_node = g.sources.get_value(selection_iter, 2)
+ name = self.get_node_name(selected_node)
+ if filename != None:
+ name = self.get_node_name(filename)
+ image = self.get_node_image(name)
+ path = selected_node + '/' + name
-
-
-
+ if index == 0:
+ g.sources.append(selection_iter, [image, name, path])
+ # Logic here for moving the file to the selected_node's folder
+ elif index == 1:
+ g.sources.append(selection_iter, [image, name, path])
+ # Logic here for copying the file to the selected_node's folder
+ elif index == 2:
+ g.sources.remove(selection_iter)
+ # Logic here to delete the selected file
+ elif index == 3:
+ # Logic here to delete the folder
+ print selected_node
+ f = os.path.exists(selected_node)
+ try:
+ if f: # delete directory recursively
+ remove_tree(selected_node)
+ g.sources.remove(selection_iter)
+ except IOError:
+ 'IOError: ', sys.exc_info()[0]
+ except:
+ print 'Unexpected error: ', sys.exc_info()[0]
+
+ # Project's File List
+ project_file = g.project.directory + '/' + g.project.name
+ g.project.file_list = []#[g.project.directory, [project_file]]
+ for row in g.sources:
+ # Get the name of the node
+ if row[2] == g.project.directory: # Project Folder
+ g.project.file_list.append(row[2])
+ row_iter = row.iterchildren() # This will be True for the root
+ if row_iter != None: # We have children in this row
+ child_list = child_recurse(row_iter)
+ for x in child_list:
+ if x == None:
+ child_list.remove(None)
+ g.project.file_list.append(child_list)
+
+ g.sources_tree.expand_all()
+
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs