[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: geda_manager.git: branch: master updated (955b7a29b76dbda267a08fa70205b2fb2a147ace)
The branch, master has been updated
via 955b7a29b76dbda267a08fa70205b2fb2a147ace (commit)
from 9402249344dc249612cd39eb4b6d5225e125f224 (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 | 4 -
src/gedamanager.py | 676 ++++++++-----------------------------------------
src/lib/decorators.py | 41 +++
src/menu.xml | 78 ------
src/newproject.py | 4 +-
src/project.py | 22 +-
src/project_popup.xml | 1 -
src/settings.py | 8 +-
src/utils.py | 126 ++++-----
9 files changed, 227 insertions(+), 733 deletions(-)
create mode 100644 src/lib/__init__.py
create mode 100644 src/lib/decorators.py
=================
Commit Messages
=================
commit 955b7a29b76dbda267a08fa70205b2fb2a147ace
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Sun Jul 27 11:19:53 2008 -0700
Lots of dead weight deleted since scope of tool is becoming clearer.
This can be added back if need be.
:100644 100644 f2efceb... 0513f72... M src/file_popup.xml
:100644 100644 e947d1c... 736a3d7... M src/gedamanager.py
:000000 100644 0000000... e69de29... A src/lib/__init__.py
:000000 100644 0000000... 5c1ff8a... A src/lib/decorators.py
:100644 100644 3633957... 8996e59... M src/menu.xml
:100644 100644 667234a... b996201... M src/newproject.py
:100644 100644 9f177f9... d0f492a... M src/project.py
:100644 100644 16bf761... 6d8f518... M src/project_popup.xml
:100644 100644 d0f9847... 3aede1c... M src/settings.py
:100644 100644 ad54ce7... 45bd67f... M src/utils.py
=========
Changes
=========
commit 955b7a29b76dbda267a08fa70205b2fb2a147ace
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Sun Jul 27 11:19:53 2008 -0700
Lots of dead weight deleted since scope of tool is becoming clearer.
This can be added back if need be.
diff --git a/src/file_popup.xml b/src/file_popup.xml
index f2efceb..0513f72 100644
--- a/src/file_popup.xml
+++ b/src/file_popup.xml
@@ -1,10 +1,6 @@
<ui>
<popup>
<separator/>
- <menuitem action="Save"/>
- <menuitem action="Save As..."/>
- <menuitem action="Open"/>
- <menuitem action="Close"/>
<menuitem action="Delete"/>
<separator/>
</popup>
diff --git a/src/gedamanager.py b/src/gedamanager.py
index e947d1c..736a3d7 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -1,12 +1,13 @@
#! /usr/bin/env python
-##@package gEDA_Manager.src.gedamanager
+##@package src.gedamanager
#Top-level window for the gEDA Manager
#@author Newell Jensen
import os, sys, gtk, pygtk, yaml, gnomevfs
import gobject, shutil, vte, logging, subprocess
pygtk.require('2.0')
+from lib.decorators import exceptions
from project import *
from settings import *
from utils import *
@@ -60,44 +61,6 @@ class gEDAManager:
# Initializer Methods -- methods to create the window
#####################################################
- def __init_about_dialog__(self):
- """ Method to create the about dialog. """
-
- def about_url_cb(dialog, link, user_data):
- """!
- Call back function to test url for the about dialog
- @param dialog is the about dialog object.
- @param link is the the url link that was clicked.
- @param user_data is user data that was passed in.
- """
- try:
- gnomevfs.url_show(link)
- except:
- self.errors_textbuffer.insert(self.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
- raise
-
- self.aboutdialog = gtk.AboutDialog()
- self.aboutdialog.set_name("gEDA Manager")
- try:
- f = open(os.path.expanduser('~') + '/.gmrc')
- y = yaml.load(f)
- version = y['version']
- self.aboutdialog.set_version(str(version))
- f.close()
- except OSError:
- self.errors_textbuffer.insert(self.errors_textiter, 'OSError: ' + sys.exc_info()[0] + '.\n')
- except:
- self.errors_textbuffer.insert(self.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
- raise
- self.aboutdialog.set_copyright("gEDA Manager 2008")
- self.aboutdialog.set_authors(['Newell Jensen', '--',
- 'Before Enlightenment, chop wood and carry water',
- 'After Enlightenment, code and build circuits'])
- gtk.about_dialog_set_url_hook(about_url_cb, None)
- self.aboutdialog.set_website('http://geda.seul.org')
- self.aboutdialog.set_translator_credits('translator-credits')
- self.aboutdialog.set_transient_for(self.window)
-
def __init_menus__(self):
""" Method to create the menu bar. """
@@ -107,62 +70,10 @@ class gEDAManager:
('New Project', None, 'Ne_w Project', None, 'Create New Project', self.cb_new_project),
('Open Project', None, 'Open P_roject', None, 'Open Existing Project', self.cb_open_project),
('Close Project', None, 'Close Projec_t', None, 'Close Active Project', self.cb_close_project),
- ('Save Project As...', None, 'Save Pro_ject As...', None,
- 'Save Active Project As...', self.cb_save_project_as),
- ('New', gtk.STOCK_NEW, '_New', '<Control>n', 'New File'),
- ('Open', gtk.STOCK_OPEN, '_Open', '<Control>o', 'Open File',
- self.cb_open),
- ('Close', gtk.STOCK_CLOSE, '_Close', '<Control>w', 'Close File'),
- ('Save', gtk.STOCK_SAVE, '_Save', '<Control>s', 'Save File'),
- ('Save As...', gtk.STOCK_SAVE_AS, 'Save _As...', '<Control><alt>s',
- 'Save Active File As...', self.cb_save_as),
- ('Save All', None, 'Save Al_l', None, 'Save All Files'),
- ('Print Preview...', gtk.STOCK_PRINT_PREVIEW, 'Print Pre_view', None,
- 'Preview Active Item For Printing'),
- ('Print', gtk.STOCK_PRINT, '_Print', '<Control>p', 'Print Active Item'),
- ('Recent Files', None, '_Recent Files'),
- ('Recent Projects', None, 'R_ecent Projects'),
('Exit', gtk.STOCK_QUIT, 'E_xit', '<Control>q', 'Exit gEDA Manager', self.cb_exit),
('Edit', None, '_Edit'),
- ('Undo', gtk.STOCK_UNDO, '_Undo', '<Control>z', 'Undo Last'),
- ('Redo', gtk.STOCK_REDO, '_Redo', '<Control>y', 'Redo Last'),
- ('Cut', gtk.STOCK_CUT, 'Cu_t', '<Control>x'),
- ('Copy', gtk.STOCK_COPY, '_Copy', '<Control>c'),
- ('Paste', gtk.STOCK_PASTE, '_Paste', '<Control>v'),
- ('Delete', gtk.STOCK_DELETE),
- ('Find', gtk.STOCK_FIND, '_Find', '<Control>f'),
- ('Find And Replace', gtk.STOCK_FIND_AND_REPLACE, 'Find An_d Replace'),
- ('Find In Files...', None, 'Find _In Files...'),
- ('Select All', gtk.STOCK_SELECT_ALL, 'Select _All', '<Control>a'),
('Preferences...', gtk.STOCK_PREFERENCES, 'Pr_eferences', None,
'gEDA Manager Preferences'),
- ('View', None, '_View'),
- ('Toolbars', None, 'T_oolbars'),
- ('Zoom', None, '_Zoom'),
- ('Reset Zoom', None, '_Reset Zoom', '<Control>r'),
- ('Go Forward', gtk.STOCK_GO_FORWARD, 'Go _Forward'),
- ('Go Back', gtk.STOCK_GO_BACK, 'Go _Back'),
- ('In', gtk.STOCK_ZOOM_IN, '_In', 'F8'),
- ('Out', gtk.STOCK_ZOOM_OUT, '_Out', 'F7'),
- ('To Full View', gtk.STOCK_ZOOM_100, 'To F_ull View', 'F6'),
- ('Fit', gtk.STOCK_ZOOM_FIT, '_Fit', 'F9'),
- ('Refresh', gtk.STOCK_REFRESH, 'R_efresh', 'F5'),
- ('Project', None, '_Project'),
- ('New Source...', None, '_New Source...'),
- ('Add Copy of Source...', None, 'Add _Copy of Source...'),
- ('New Folder...', None, 'New _Folder', None, None, self.cb_new_folder),
- ('Window', None, '_Window'),
- ('New Window', None, '_New Window'),
- ('Close Window', None, '_Close Window'),
- ('Close All Windows', None, 'Close _All Windows'),
- ('Next', None, 'N_ext'),
- ('Previous', None, '_Previous'),
- ('Maximize', None, '_Maximize', '<Control>t'),
- ('Minimize All', None, 'Minimi_ze All'),
- ('Cascade', None, 'Ca_scade'),
- ('Tile Horizontally', None, 'Tile _Horizontally'),
- ('Tile Vertically', None, 'Tile _Vertically'),
- ('Float', None, '_Float'),
('Help', None, '_Help'),
('gEDA Wiki', None, 'gEDA _Wiki', None, 'Opens link in browser',
self.cb_url_geda_wiki),
@@ -176,34 +87,8 @@ class gEDAManager:
actiongroup0.add_actions(actiongroup0_list)
self.menu_uimanager.insert_action_group(actiongroup0, 0)
-
- actiongroup1 = gtk.ActionGroup('gEDAManager')
- actiongroup1_list = [('Line Numbers', None, '_Line Numbers', None, None, None, True),
- ('Large Icons', None, 'L_arge Icons', None, None, None, True),
- ('Standard', None, '_Standard', None, None, None, True),
- ('Editor', None, '_Editor', None, None, None, True),
- ('Zoom(s)', None, '_Zoom', None, None, None, True),
- ('Window(s)', None, '_Window', None, None, None, True),
- ('Help', None, '_Help', None, None, None, True),
- ('Find(s)', None, '_Find', None, None, None, True),
- ('Project Navigator', None, '_Project Navigator', None, None, None, True),
- ('Language Templates', None, '_Language Templates', None, None, None, True),
- ('Design Summary', None, '_Design Summary', None, None, None, True),
- ('Sources', None, '_Sources', None, None, None, True),
- ('Processes', None, '_Processes', None, None, None, True),
- ('Transcript', None, '_Transcript', None, None, None, True),
- ('Status Bar', None, '_Status Bar', None, None, None, True),
- ('File Names', None, '_File Names', None, None, None, True),]
-
-
- actiongroup1.add_toggle_actions(actiongroup1_list)
- self.menu_uimanager.insert_action_group(actiongroup1, 1)
merge_id = self.menu_uimanager.add_ui_from_file('menu.xml')
menubar = self.menu_uimanager.get_widget('/MenuBar')
- # For now I am setting the Toolbar menu under /MenuBar/View as disabled
- # Have to figure out if I really want toolbars in the gui or not
- toolbars_menu = self.menu_uimanager.get_widget('/MenuBar/View/Toolbars')
- toolbars_menu.set_sensitive(False)
self.vbox1 = gtk.VBox()
self.vbox1.show()
@@ -230,37 +115,6 @@ class gEDAManager:
# Main Window
- # Do plugs and sockets here
-
- # New window
-## pid = subprocess.Popen(["/usr/bin/gschem"]).pid
-## print pid
-
-## self.plug_window = gtk.Window(gtk.WINDOW_POPUP)
-## self.plug_window.connect('destroy', self.cb_destroy)
-## self.plug_window.show()
-## socket = gtk.Socket()
-## socket.show()
-## self.plug_window.add(socket)
-## vbox2.pack_start(self.plug_window, True, True)
-## sockect.add_id(
-## plug = gtk.Plug(window_id)
-## print 'plugid:',plug.get_id()
-## print 'socketid:',socket.get_id()
-
-
-
-## socket = gtk.Socket()
-## socket.show()
-## vbox2.pack_start(socket, True, True)
-## scrolled_window = gtk.ScrolledWindow()
-## scrolled_window.show()
-## scrolled_window.set_shadow_type(gtk.SHADOW_IN)
-## scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
-## vbox2.pack_start(scrolled_window, True, True)
-## textview1 = gtk.TextView()
-## textview1.show()
-## scrolled_window.add(textview1)
# Notebook
vpaned2 = gtk.VPaned()
@@ -321,7 +175,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)
@@ -331,8 +185,6 @@ class gEDAManager:
scrolled_window1.add(self.sources_tree)
scrolled_window2.add(self.processes_tree)
- # add data to the store
- self.set_sources_tree_to_project()
######################################
# Lower Notebook Window
@@ -350,19 +202,15 @@ class gEDAManager:
try:
os.chdir(self.project.directory)
except:
- print 'Unable to switch to directory:', self.project.directory
- terminal = vte.Terminal()
- terminal.connect('child-exited', lambda term: gtk.main_quit())
- terminal.fork_command()
- terminal.show()
- try:
- os.chdir(current_directory)
- except:
- print 'Unable to switch to directory:', current_directory
-
+ pass
+ self.terminal = vte.Terminal()
+ self.terminal.connect('child-exited', lambda term: gtk.main_quit())
+ self.terminal.fork_command()
+ self.terminal.show()
+ os.chdir(current_directory)
terminal_scrolled_window.set_shadow_type(gtk.SHADOW_IN)
terminal_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- terminal_scrolled_window.add_with_viewport(terminal)
+ terminal_scrolled_window.add_with_viewport(self.terminal)
notebook.add(terminal_scrolled_window)
terminal_icon = gtk.Image()
@@ -408,6 +256,46 @@ class gEDAManager:
errors_icon.show()
notebook.set_tab_label(notebook.get_nth_page(2), errors_icon)
+ # Finally add data to the store
+ self.set_sources_tree_to_project()
+
+
+ def __init_about_dialog__(self):
+ """ Method to create the about dialog. """
+
+ def about_url_cb(dialog, link, user_data):
+ """!
+ Call back function to test url for the about dialog
+ @param dialog is the about dialog object.
+ @param link is the the url link that was clicked.
+ @param user_data is user data that was passed in.
+ """
+ gnomevfs.url_show(link)
+
+ self.aboutdialog = gtk.AboutDialog()
+ self.aboutdialog.set_name("gEDA Manager")
+ try:
+ f = open(os.path.expanduser('~') + '/.gmrc')
+ y = yaml.load(f)
+ version = y['version']
+ self.aboutdialog.set_version(str(version))
+ f.close()
+ except OSError:
+ print 'OSError:', sys.exc_info()[0]
+ except IOError:
+ print 'IOError:', sys.exc_info()[0]
+ except:
+ print sys.exc_info()[0]
+
+ self.aboutdialog.set_copyright("gEDA Manager 2008")
+ self.aboutdialog.set_authors(['Newell Jensen', '--',
+ 'Before Enlightenment, chop wood and carry water',
+ 'After Enlightenment, code and build circuits'])
+ gtk.about_dialog_set_url_hook(about_url_cb, None)
+ self.aboutdialog.set_website('http://geda.seul.org')
+ self.aboutdialog.set_translator_credits('translator-credits')
+ self.aboutdialog.set_transient_for(self.window)
+
####################################
# Methods
@@ -424,12 +312,6 @@ class gEDAManager:
else:
self.set_project_default()
- # Files
- if self.project.file_list != None:
- self.set_files_default()
- else:
- self.set_no_files_default()
-
def set_no_project_default(self):
"""
@@ -442,13 +324,8 @@ class gEDAManager:
column.set_title(self.project.name)
save_project_as_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Save Project As...')
close_project_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Close Project')
- save_project_as_menuitem.set_sensitive(False)
close_project_menuitem.set_sensitive(False)
- # Project Menu
-## project_menu = self.menu_uimanager.get_widget('/MenuBar/Project')
-## project_menu.set_sensitive(False)
-
def set_project_default(self):
"""
@@ -458,132 +335,8 @@ class gEDAManager:
self.sources_tree.set_property('headers-visible', False)
save_project_as_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Save Project As...')
close_project_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Close Project')
- save_project_as_menuitem.set_sensitive(True)
close_project_menuitem.set_sensitive(True)
- # Project Menu
-## project_menu = self.menu_uimanager.get_widget('/MenuBar/Project')
-## project_menu.set_sensitive(True)
-
-
- def set_no_files_default(self):
- """
- Method to set the default sensitivity when no files are open.
- """
- # File Menu
- close_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Close')
- save_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Save')
- save_as_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Save As...')
- save_all_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Save All')
- print_preview_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Print Preview...')
- print_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Print')
- close_menuitem.set_sensitive(False)
- save_menuitem.set_sensitive(False)
- save_as_menuitem.set_sensitive(False)
- save_all_menuitem.set_sensitive(False)
- print_preview_menuitem.set_sensitive(False)
- print_menuitem.set_sensitive(False)
-
- # Edit Menu
- undo_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Undo')
- redo_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Redo')
- cut_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Cut')
- copy_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Copy')
- paste_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Paste')
- delete_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Delete')
- find_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Find')
- find_and_replace_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Find And Replace')
- find_in_files_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Find In Files...')
- select_all_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Select All')
- undo_menuitem.set_sensitive(False)
- redo_menuitem.set_sensitive(False)
- cut_menuitem.set_sensitive(False)
- copy_menuitem.set_sensitive(False)
- paste_menuitem.set_sensitive(False)
- delete_menuitem.set_sensitive(False)
- find_menuitem.set_sensitive(False)
- find_and_replace_menuitem.set_sensitive(False)
- find_in_files_menuitem.set_sensitive(False)
- select_all_menuitem.set_sensitive(False)
-
- # View Menu
- file_names_toggleitem = self.menu_uimanager.get_widget('/MenuBar/View/File Names')
- line_numbers_toggleitem = self.menu_uimanager.get_widget('/MenuBar/View/Line Numbers')
- go_forward_menuitem = self.menu_uimanager.get_widget('/MenuBar/View/Go Forward')
- go_back_menuitem = self.menu_uimanager.get_widget('/MenuBar/View/Go Back')
- zoom_menu = self.menu_uimanager.get_widget('/MenuBar/View/Zoom')
- refresh_menu = self.menu_uimanager.get_widget('/MenuBar/View/Refresh')
- file_names_toggleitem.set_sensitive(False)
- line_numbers_toggleitem.set_sensitive(False)
- go_forward_menuitem.set_sensitive(False)
- go_back_menuitem.set_sensitive(False)
- zoom_menu.set_sensitive(False)
- refresh_menu.set_sensitive(False)
-
- # Window Menu
- window_menu = self.menu_uimanager.get_widget('/MenuBar/Window')
- window_menu.set_sensitive(False)
-
-
- def set_files_default(self):
- """
- Method to set the default sensitivity when there is at least one file
- open.
- """
- # File Menu
- close_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Close')
- save_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Save')
- save_as_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Save As...')
- save_all_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Save All')
- print_preview_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Print Preview...')
- print_menuitem = self.menu_uimanager.get_widget('/MenuBar/File/Print')
- close_menuitem.set_sensitive(True)
- save_menuitem.set_sensitive(True)
- save_as_menuitem.set_sensitive(True)
- save_all_menuitem.set_sensitive(True)
- print_preview_menuitem.set_sensitive(True)
- print_menuitem.set_sensitive(True)
-
- # Edit Menu
- undo_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Undo')
- redo_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Redo')
- cut_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Cut')
- copy_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Copy')
- paste_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Paste')
- delete_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Delete')
- find_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Find')
- find_and_replace_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Find And Replace')
- find_in_files_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Find In Files...')
- select_all_menuitem = self.menu_uimanager.get_widget('/MenuBar/Edit/Select All')
- undo_menuitem.set_sensitive(True)
- redo_menuitem.set_sensitive(True)
- cut_menuitem.set_sensitive(True)
- copy_menuitem.set_sensitive(True)
- paste_menuitem.set_sensitive(True)
- delete_menuitem.set_sensitive(True)
- find_menuitem.set_sensitive(True)
- find_and_replace_menuitem.set_sensitive(True)
- find_in_files_menuitem.set_sensitive(True)
- select_all_menuitem.set_sensitive(True)
-
- # View Menu
- file_names_toggleitem = self.menu_uimanager.get_widget('/MenuBar/View/File Names')
- line_numbers_toggleitem = self.menu_uimanager.get_widget('/MenuBar/View/Line Numbers')
- go_forward_menuitem = self.menu_uimanager.get_widget('/MenuBar/View/Go Forward')
- go_back_menuitem = self.menu_uimanager.get_widget('/MenuBar/View/Go Back')
- zoom_menu = self.menu_uimanager.get_widget('/MenuBar/View/Zoom')
- refresh_menu = self.menu_uimanager.get_widget('/MenuBar/View/Refresh')
- file_names_toggleitem.set_sensitive(True)
- line_numbers_toggleitem.set_sensitive(True)
- go_forward_menuitem.set_sensitive(True)
- go_back_menuitem.set_sensitive(True)
- zoom_menu.set_sensitive(True)
- refresh_menu.set_sensitive(True)
-
- # Window Menu
- window_menu = self.menu_uimanager.get_widget('/MenuBar/Window')
- window_menu.set_sensitive(True)
-
def set_project(self, path):
"""!
@@ -612,21 +365,21 @@ class gEDAManager:
self.sources.clear()
# Parent Folder
- name = self.project.name.split('.')[0]
+ name = self.project.name
image = self.utils.get_node_image(self, 'project')
parent = self.sources.append(None, [image, name, self.project.directory])
# Child Node
- image = self.utils.get_node_image(self, self.project.name)
- path = self.project.directory + '/' + self.project.name
- self.sources.append(parent, [image, self.project.name, path])
+ image = self.utils.get_node_image(self, self.project.name + '.gm')
+ path = self.project.directory + '/' + self.project.name + '.gm'
+ self.sources.append(parent, [image, self.project.name + '.gm', path])
self.sources_tree.expand_all()
""" 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. The reason we do it here is because it is a brand new project
and it is not a bid deal to push out a utility just for this. """
- self.project.file_list = [self.project.directory, [self.project.directory +'/' + self.project.name]]
+ self.project.file_list = [self.project.directory, [self.project.directory +'/' + self.project.name + '.gm']]
def load_tree(self, list, parent=None):
@@ -653,10 +406,7 @@ class gEDAManager:
""" Method to save current settings to .gmrc file. """
if self.project.directory and self.project.name:
- if not self.project.name.endswith('.gm'):
- self.settings.project = self.project.directory + '/' + self.project.name + '.gm'
- else:
- self.settings.project = self.project.directory + '/' + self.project.name
+ self.settings.project = self.project.directory + '/' + self.project.name + '.gm'
else:
self.settings.project = None
self.settings.create_config_file()
@@ -756,10 +506,7 @@ class gEDAManager:
@param menuitem that threw the event.
@param data optional to pass in.
"""
- try:
- gnomevfs.url_show('http://geda.seul.org/wiki/')
- except:
- self.errors_textbuffer.insert(self.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
+ gnomevfs.url_show('http://geda.seul.org/wiki/')
def cb_url_geda_documentation(self, menuitem, data=None):
@@ -768,11 +515,8 @@ class gEDAManager:
@param menuitem that threw the event.
@param data optional to pass in.
"""
- try:
- gnomevfs.url_show('http://geda.seul.org/wiki/geda:documentation')
- except:
- self.errors_textbuffer.insert(self.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
-
+ gnomevfs.url_show('http://geda.seul.org/wiki/geda:documentation')
+
def cb_url_geda_manager(self, menuitem, data=None):
"""!
@@ -780,12 +524,7 @@ class gEDAManager:
@param menuitem that threw the event.
@param data optional to pass in.
"""
- try:
- gnomevfs.url_show('http://www.gempillar.com')
- except:
- self.errors_textbuffer.insert(self.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
-
-
+ gnomevfs.url_show('http://www.gempillar.com')
# File Menu #
@@ -834,149 +573,6 @@ class gEDAManager:
self.project.save()
self.project.close();
-
- def cb_save_project_as(self, menuitem, data=None):
- """!
- Event handler for 'Save Project As...'.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
- # TODO -- This is currently disabled because in the FileChooseDialog
- # it allow the user to change the directory in which they want to
- # save the project as...and I only wanted them to rename it.
- # Need to make a way to rename the nodes...but this could cause problems
- # b/c if a user changes the name and doesn't have the file extension
- # they won't be able to locate the icons etc.
- return
- # This will open a Save dialog box
- if self.project.name != None:
- dialog = gtk.FileChooserDialog('Save Project As...',
- self.window,
- gtk.FILE_CHOOSER_ACTION_SAVE,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_SAVE, gtk.RESPONSE_OK))
-
- dialog.set_default_response(gtk.RESPONSE_OK)
- dialog.set_current_name('New Project')
-
- file_filter = gtk.FileFilter()
-
- file_filter.set_name("Project files (*.gm)")
- file_filter.add_pattern('*.gm')
- dialog.add_filter(file_filter)
-
- file_filter = gtk.FileFilter()
- file_filter.set_name("All files")
- file_filter.add_pattern('*')
- dialog.add_filter(file_filter)
-
- response = dialog.run()
- if response == gtk.RESPONSE_OK:
- filename = dialog.get_filename()
- if not filename.endswith('.gm'):
- filename += '.gm'
- self.project.name = self.utils.get_node_name(filename)
- self.project.directory = filename.rpartition('/')[0]
- self.project.save()
- dialog.destroy()
-
-
- def cb_new(self, menuitem, data=None):
- """!
- Event handler for a 'New' file.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
- # TODO
- # This will open a New file window which will allow the user to choose
- # which type of new file it will open
-
-
- def cb_open(self, menuitem, data=None):
- """!
- Event handler to 'Open' a file.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
- dialog = gtk.FileChooserDialog('Open...',
- self.window,
- gtk.FILE_CHOOSER_ACTION_OPEN,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OPEN, gtk.RESPONSE_OK))
-
- dialog.set_default_response(gtk.RESPONSE_OK)
- self.file_filters(dialog)
- response = dialog.run()
- if response == gtk.RESPONSE_OK:
- filename = dialog.get_filename()
- dialog.destroy()
- self.output_textbuffer.insert(self.output_textiter, 'File opened: ' + filename + '.\n')
-
- def cb_close(self, menuitem, data=None):
- """!
- Event handler to 'Close' a file.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
- # TODO
- # See if file needs to be saved first
- # to do this we will get the selected node from the sources tree
- # then we will see if the file has changes and needs to be saved
- selected_node = self.get_sources_selected_node()
-
-
- def cb_save(self, menuitem, data=None):
- """!
- Event handler to 'Save' a file.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
-
- def cb_save_as(self, menuitem, data=None):
- """!
- Event handler for 'Save As...'.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
- dialog = gtk.FileChooserDialog('Save As...',
- self.window,
- gtk.FILE_CHOOSER_ACTION_SAVE,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_SAVE, gtk.RESPONSE_OK))
-
- dialog.set_default_response(gtk.RESPONSE_OK)
- dialog.set_current_name('New Document')
- self.file_filters(dialog)
- response = dialog.run()
- if response == gtk.RESPONSE_OK:
- filename = dialog.get_filename()
- dialog.destroy()
- self.output_textbuffer.insert(self.output_textiter, 'File saved as: ' + filename + '.\n')
-
- def cb_save_all(self, menuitem, data=None):
- """!
- Event handler for 'Save All'.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
-
- def cb_print_preview(self, menuitem, data=None):
- """!
- Event handler for 'Print Preview'.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
-
- def cb_print(self, menuitem, data=None):
- """!
- Event handler for 'Print'
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
def cb_exit(self, menuitem, data=None):
"""!
@@ -989,30 +585,6 @@ class gEDAManager:
self.save_settings()
- # Edit Menu #
- def cb_cut(self, menuitem, data=None):
- """!
- Event handler for 'Cut'.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
-
- def cb_copy(self, menuitem, data=None):
- """!
- Event handler for 'Copy'.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
- def cb_paste(self, menuitem, data=None):
- """!
- Event handler for 'Paste'.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
-
def cb_delete(self, menuitem, data=None):
"""!
Event handler for 'Delete'.
@@ -1022,43 +594,6 @@ class gEDAManager:
self.utils.update_file_list(self, 1)
- def cb_output_toggled(self, menuitem, data=None):
- """!
- Event occurs when the 'Output' check box is toggled.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
- def cb_errors_toggled(self, menuitem, data=None):
- """!
- Event occurs when the 'Errors' check box is toggled.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
- def cb_warnings_toggled(self, menuitem, data=None):
- """!
- Event occurs when the 'Warnings' check box is toggled.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
-
- def cb_terminal_toggled(self, menuitem, data=None):
- """!
- Event occurs when the 'Terminal' check box is toggled.
- @param menuitem that threw the event.
- @param data optional to pass in.
- """
-
-
- def cb_expander_activate(self, expander, data=None):
- """!
- Event occurs when an expander is activated
- @param expander that threw the event.
- @param data optional to pass in.
- """
-
def cb_project_closed(self, widget, event):
"""!
Event occurs when a Project object is closed
@@ -1131,6 +666,7 @@ class gEDAManager:
self.output_textbuffer.insert(self.output_textiter, 'Copy of source added: ' + filename + '.\n')
+ @exceptions
def cb_new_folder(self, action):
"""!
Event occurs when the user chooses to add a new folder to the project.
@@ -1146,7 +682,7 @@ class gEDAManager:
# 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.
+ # it becomes highlighted.
return
os.chdir(selected_node)
dialog = gtk.MessageDialog(self.window,
@@ -1170,27 +706,20 @@ class gEDAManager:
# See if this directory already exists
f = os.path.exists(path)
- try:
- if f: # delete directory recursively
- shutil.rmtree(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)
- self.output_textbuffer.insert(self.output_textiter, 'Created directory: ' + path + '.\n')
- except IOError, detail:
- self.errors_textbuffer.insert(self.errors_textiter, 'IOError: ' + detail + '.\n')
- except:
- self.errors_textbuffer.insert(self.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
- raise
+ if f: # delete directory recursively
+ shutil.rmtree(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)
name = self.utils.get_node_name(path)
# Find out what file it is so we can pick an icon for it
@@ -1207,6 +736,7 @@ class gEDAManager:
self.utils.update_file_list(self, 2)
+ @exceptions
def cb_cell_edited(self, cell, path, new_text, model):
"""!
Event handler to catch the event of the user editing a cell in the
@@ -1219,17 +749,35 @@ class gEDAManager:
"""
old_path = model[path][2]
new_path = old_path.rpartition('/')[0] + '/' + new_text
- try:
+
+ if old_path == self.project.directory: # Project Folder
+ os.rename(old_path, new_path)
+ model[path][1] = new_text
+ model[path][2] = new_path
+ project_file = new_path + '/' + self.project.name + '.gm'
+ 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.save()
+ model[(0,0)][1] = new_text + '.gm'
+ model[(0,0)][2] = new_path + '/' + new_text + '.gm'
+ 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)
+ 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
os.rename(old_path, new_path)
model[path][1] = new_text
model[path][2] = new_path
- self.utils.update_file_list(self) # update file list
- except OSError:
- self.errors_textbuffer.insert(self.errors_textiter, 'OSError: ' + str(sys.exc_info()[0]) + '.\n')
- except IOError:
- self.errors_textbuffer.insert(self.errors_textiter, 'IOError: ' + str(sys.exc_info()[0]) + '.\n')
- except:
- self.errors_textbuffer.insert(self.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
+
+ self.utils.update_file_list(self) # update file list
def cb_row_activated(self, widget, path, view_column):
@@ -1246,6 +794,11 @@ class gEDAManager:
# 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.
+
def cb_cursor_changed(self, widget):
"""!
@@ -1264,7 +817,7 @@ class gEDAManager:
else: # We have a folder
# Logic to call the functions to populate the 'Processes' tree
# view.
- pass
+ 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)
@@ -1280,7 +833,8 @@ class gEDAManager:
# Remove the ui from the uimanager
self.popup_uimanager.remove_ui(merge_id)
-
+
+ @exceptions
def cb_button_press(self, widget, event):
"""!
This signal handler will be called when the treeview emits
@@ -1297,13 +851,7 @@ class gEDAManager:
return
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),
- ('New', gtk.STOCK_NEW, '_New', '<Control>n', 'New File', self.cb_new),
- ('Open', gtk.STOCK_OPEN, '_Open', '<Control>o', 'Open File', self.cb_open),
- ('Delete', gtk.STOCK_DELETE, '_Delete', '<Control>d', 'Delete File', self.cb_delete),
- ('Close', gtk.STOCK_CLOSE, '_Close', '<Control>w', 'Close File', self.cb_close),
- ('Save', gtk.STOCK_SAVE, '_Save', '<Control>s', 'Save File'),
- ('Save As...', gtk.STOCK_SAVE_AS, 'Save _As...', '<Control><alt>s', 'Save Active File As...', self.cb_save_as),
+ actiongroup_list = [('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),
diff --git a/src/lib/__init__.py b/src/lib/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/lib/decorators.py b/src/lib/decorators.py
new file mode 100644
index 0000000..5c1ff8a
--- /dev/null
+++ b/src/lib/decorators.py
@@ -0,0 +1,41 @@
+#! /usr/bin/env python
+
+##@package lib.decorators
+#Library file for decorators
+#@author Newell Jensen
+
+from src.gedamanager import *
+
+def exceptions(func):
+ """!
+ Exceptions decorator for functions that are in the Utils or gEDAManager
+ class. Decorator to decorate functions for generic exception handling
+ and logging this to the errors text buffer.
+ @param func is the function that will be decorated.
+ @return func_to_decorate which is the decorated function.
+ """
+ def func_to_decorate(*args):
+ """!
+ New function that is returned by exceptions decorator.
+ @param *args is the arguments that are passed to the the function that
+ is being decorated (func).
+ """
+ f = None
+ for arg in args:
+ if hasattr(arg, 'errors_textbuffer'):
+ try:
+ f = func(*args)
+ except IOError:
+ arg.errors_textbuffer.insert(arg.errors_textiter, 'IOError: ' + str(sys.exc_info()[0]) + '.\n')
+ except OSError:
+ arg.errors_textbuffer.insert(arg.errors_textiter, 'OSError: ' + str(sys.exc_info()[0]) + '.\n')
+ except IndexError:
+ arg.errors_textbuffer.insert(arg.errors_textiter, 'IndexError: ' + str(sys.exc_info()[0]) + '.\n')
+ except TypeError:
+ arg.errors_textbuffer.insert(arg.errors_textiter, 'TypeError: ' + str(sys.exc_info()[0]) + '.\n')
+ except:
+ arg.errors_textbuffer.insert(arg.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
+ raise
+ return f
+
+ return func_to_decorate
diff --git a/src/menu.xml b/src/menu.xml
index 3633957..8996e59 100644
--- a/src/menu.xml
+++ b/src/menu.xml
@@ -4,90 +4,12 @@
<menuitem action="New Project"/>
<menuitem action="Open Project"/>
<menuitem action="Close Project"/>
- <menuitem action="Save Project As..."/>
- <separator/>
- <menuitem action="New"/>
- <menuitem action="Open"/>
- <menuitem action="Close"/>
- <separator/>
- <menuitem action="Save"/>
- <menuitem action="Save As..."/>
- <menuitem action="Save All"/>
- <separator/>
- <menuitem action="Print Preview..."/>
- <menuitem action="Print"/>
- <separator/>
- <menu action="Recent Files">
- </menu>
- <separator/>
- <menu action="Recent Projects">
- </menu>
<separator/>
<menuitem action="Exit"/>
</menu>
<menu action="Edit">
- <menuitem action="Undo"/>
- <menuitem action="Redo"/>
- <separator/>
- <menuitem action="Cut"/>
- <menuitem action="Copy"/>
- <menuitem action="Paste"/>
- <menuitem action="Delete"/>
- <separator/>
- <menuitem action="Find"/>
- <menuitem action="Find And Replace"/>
- <menuitem action="Find In Files..."/>
- <separator/>
- <menuitem action="Select All"/>
<menuitem action="Preferences..."/>
</menu>
- <menu action="View">
- <menu action="Toolbars">
- <menuitem action="Large Icons"/>
- <menuitem action="Standard"/>
- <menuitem action="Editor"/>
- <menuitem action="Zoom(s)"/>
- <menuitem action="Window(s)"/>
- <menuitem action="Help"/>
- <menuitem action="Find(s)"/>
- <menuitem action="Project Navigator"/>
- <menuitem action="Language Templates"/>
- <menuitem action="Design Summary"/>
- </menu>
- <menuitem action="Sources"/>
- <menuitem action="Processes"/>
- <menuitem action="Transcript"/>
- <menuitem action="Status Bar"/>
- <menuitem action="File Names"/>
- <separator/>
- <menuitem action="Line Numbers"/>
- <separator/>
- <menuitem action="Go Forward"/>
- <menuitem action="Go Back"/>
- <separator/>
- <menu action="Zoom">
- <menuitem action="In"/>
- <menuitem action="Out"/>
- <menuitem action="To Full View"/>
- <menuitem action="Fit"/>
- </menu>
- <menuitem action="Refresh"/>
- </menu>
- <menu action="Window">
- <menuitem action="New Window"/>
- <menuitem action="Close Window"/>
- <menuitem action="Close All Windows"/>
- <separator/>
- <menuitem action="Next"/>
- <menuitem action="Previous"/>
- <separator/>
- <menuitem action="Maximize"/>
- <menuitem action="Minimize All"/>
- <menuitem action="Cascade"/>
- <menuitem action="Tile Horizontally"/>
- <menuitem action="Tile Vertically"/>
- <menuitem action="Float"/>
- </menu>
<menu action="Help">
<menu action="Web Resources">
<menuitem action="gEDA Wiki"/>
diff --git a/src/newproject.py b/src/newproject.py
index 667234a..b996201 100644
--- a/src/newproject.py
+++ b/src/newproject.py
@@ -1,6 +1,6 @@
#! /usr/bin/env python
-##@package gEDA_Manager.src.newproject
+##@package src.newproject
#New Project window for the gEDA Manager
#@author Newell Jensen
@@ -264,7 +264,7 @@ class NewProject:
"""
try:
# Set new project attributes
- self.project.name = self.get_filename()
+ self.project.name = self.get_filename().split('.')[0]
self.project.directory = self.get_path() + '/' + self.project.name.split('.')[0]
# Remove directories with imported remove_tree
if self.confirm_overwrite.get_active():
diff --git a/src/project.py b/src/project.py
index 9f177f9..d0f492a 100644
--- a/src/project.py
+++ b/src/project.py
@@ -1,13 +1,12 @@
#! /usr/bin/env python
-##@package gEDA_Manager.src.project
+##@package src.project
# Project class for the gEDA Manager project objects
#@author Newell Jensen
import os, sys, yaml, gtk, pygtk, gobject
pygtk.require('2.0')
-
# i18n TODO
import gettext
@@ -67,6 +66,7 @@ class Project(gobject.GObject):
self.file_list = None
self.clean = False
+
def close(self):
"""
Method to close the current project and then
@@ -77,6 +77,7 @@ class Project(gobject.GObject):
self.file_list = None
self.emit('closed', True)
+
def create(self):
"""
Method to save the project and then emit the
@@ -84,36 +85,35 @@ class Project(gobject.GObject):
"""
self.save(True)
self.emit('created', True)
-
+
+
def save(self, silent=None):
"""
Method to save the project file and then emit the
'saved' signal if succesful.
"""
if self.name != None and self.directory != None:
- if not self.name.endswith('.gm'):
- path = self.directory + '/' + self.name + '.gm'
- else:
- path = self.directory + '/' + self.name
+ path = self.directory + '/' + self.name + '.gm'
try:
stream = file(path, 'w')
yaml.dump({'project': path, 'file_list': self.file_list},
- stream, default_flow_style=False)
+ stream, default_flow_style=False)
stream.close()
except IOError:
- print sys.exc_info()[0]
+ print 'IOError:', sys.exc_info()[0]
self.clean = True
if not silent:
self.emit('saved', True)
else:
self.emit('saved', False)
+
def open(self, path):
"""!
Method to open up project from path and set as current project.
@param path is the path of the project file to open.
"""
- self.name = path.rsplit('/')[-1]
+ self.name = path.rsplit('/')[-1].split('.')[0]
self.directory = path.rpartition('/')[0]
try:
stream = file(path, 'r')
@@ -122,7 +122,7 @@ class Project(gobject.GObject):
self.clean = True
self.emit('opened', True)
except IOError:
- print sys.exc_info()[0]
+ print 'IOError:', sys.exc_info()[0]
gobject.type_register(Project)
diff --git a/src/project_popup.xml b/src/project_popup.xml
index 16bf761..6d8f518 100644
--- a/src/project_popup.xml
+++ b/src/project_popup.xml
@@ -4,7 +4,6 @@
<menuitem action="New Folder"/>
<menuitem action="New Source..."/>
<menuitem action="Add Copy of Source..."/>
- <menuitem action="Save Project As..."/>
<separator/>
</popup>
</ui>
diff --git a/src/settings.py b/src/settings.py
index d0f9847..3aede1c 100644
--- a/src/settings.py
+++ b/src/settings.py
@@ -1,6 +1,6 @@
#! /usr/bin/env python
-##@package gEDA_Manager.src.settings
+##@package src.settings
#Create and verify settings for the gEDA Manager
#Create and update the gEDA Manager configuration file .gmrc
#@author Newell Jensen
@@ -66,12 +66,12 @@ class Settings:
self.installed_apps = self.find_installed_apps()
self.create_config_file()
-
+
def find_installed_apps(self):
"""!
Find all of the gEDA suite applications that are
- installed on this machine and return list of these programs
- @return list of installed geda apps
+ installed on this machine and return list of these programs.
+ @return list of installed geda apps.
"""
apps = []
for app in self.geda_apps:
diff --git a/src/utils.py b/src/utils.py
index ad54ce7..45bd67f 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -1,18 +1,17 @@
#! /usr/bin/env python
-##@package gEDA_Manager.src.utils
+##@package src.utils
#Utility class for the gEDA Manager
#@author Newell Jensen
import os, pygtk, gtk
pygtk.require('2.0')
-from gedamanager import gEDAManager
+from lib.decorators import exceptions
from project import *
from settings import *
-from distutils.dir_util import remove_tree
-class Utils(gEDAManager):
+class Utils:
"""
Utility class for the gEDA Manager.
"""
@@ -59,6 +58,7 @@ class Utils(gEDAManager):
self.directory = os.getcwd()
+ @exceptions
def get_file(self, gedamanager, filename):
"""!
Method to get the file from the file look up table.
@@ -66,15 +66,7 @@ class Utils(gEDAManager):
@param filename is the file to find.
@returns path to the file.
"""
- g = gedamanager
- try:
- current_directory = os.getcwd()
- except OSError:
- g.errors_textbuffer.insert(g.errors_textiter, 'OSError: ' + str(sys.exc_info()[0]) + '.\n')
- except:
- g.errors_textbuffer.insert(g.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
- raise
-
+ current_directory = os.getcwd()
os.chdir(self.directory)
if '.' in filename:
key = filename.split('.')[0]
@@ -82,6 +74,8 @@ class Utils(gEDAManager):
os.chdir(current_directory)
return f
+
+ @exceptions
def get_node_image(self, gedamanager, name):
"""!
Method to get the image for node with param name.
@@ -89,16 +83,8 @@ class Utils(gEDAManager):
@param name of the file.
@return a gtk.Pixbuf image is returned
"""
- g = gedamanager
- try:
- current_directory = os.getcwd()
- except OSError:
- g.errors_textbuffer.insert(g.errors_textiter, 'OSError: ' + str(sys.exc_info()[0]) + '.\n')
- except:
- g.errors_textbuffer.insert(g.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
- raise
-
- os.chdir(self.directory)
+ current_directory = os.getcwd()
+ os.chdir(self.directory)
if name == 'project':
key = name
elif '.' in name:
@@ -128,7 +114,8 @@ class Utils(gEDAManager):
else:
return None
-
+
+ @exceptions
def update_file_list(self, gedamanager, index=None, filename=None):
"""!
Method to update the gEDA Manager's project file list any time
@@ -170,42 +157,32 @@ class Utils(gEDAManager):
image = self.get_node_image(g, name)
path = selected_node + '/' + name
- try:
- 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
- files = os.listdir(selected_node)
- if name not in files:
- os.system('cp ' + filename + ' ' + selected_node)
- g.sources.append(selection_iter, [image, name, path])
- g.output_textbuffer.insert(g.output_textiter, 'Added copy of source:' + filename + ' to ' + selected_node + '.\n')
- else:
- g.output_textbuffer.insert(g.output_textiter, 'This file is already present in the directory.\n')
- elif index == 1:
- # Logic here to delete the selected file
- f = os.path.exists(selected_node)
- if f:
- os.system('rm ' + selected_node)
- g.sources.remove(selection_iter)
- g.output_textbuffer.insert(g.output_textiter, 'Deleted: ' + selected_node + '.\n')
- elif index == 2:
- # Logic here to delete the folder
- f = os.path.exists(selected_node)
- if f: # delete directory recursively
- os.system('rm -rf ' + selected_node)
- g.sources.remove(selection_iter)
- g.output_textbuffer.insert(g.output_textiter, 'Folder deleted: ' + selected_node + '.\n')
- except IOError:
- g.errors_textbuffer.insert(g.errors_textiter, 'IOError: ' + str(sys.exc_info()[0]) + '.\n')
- except OSError:
- g.errors_textbuffer.insert(g.errors_textiter, 'OSError: ' + str(sys.exc_info()[0]) + '.\n')
- except:
- g.errors_textbuffer.insert(g.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
- raise
-
+ 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
+ files = os.listdir(selected_node)
+ if name not in files:
+ os.system('cp ' + filename + ' ' + selected_node)
+ g.sources.append(selection_iter, [image, name, path])
+ g.output_textbuffer.insert(g.output_textiter, 'Added copy of source:' + filename + ' to ' + selected_node + '.\n')
+ else:
+ g.output_textbuffer.insert(g.output_textiter, 'This file is already present in the directory.\n')
+ elif index == 1:
+ # Logic here to delete the selected file
+ f = os.path.exists(selected_node)
+ if f:
+ os.system('rm ' + selected_node)
+ g.sources.remove(selection_iter)
+ g.output_textbuffer.insert(g.output_textiter, 'Deleted: ' + selected_node + '.\n')
+ elif index == 2:
+ # Logic here to delete the folder
+ f = os.path.exists(selected_node)
+ if f: # delete directory recursively
+ 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
- project_file = g.project.directory + '/' + g.project.name
- g.project.file_list = [] #[g.project.directory, [project_file]]
+ g.project.file_list = []
for row in g.sources:
# Get the name of the node
if row[2] == g.project.directory: # Project Folder
@@ -221,6 +198,7 @@ class Utils(gEDAManager):
g.sources_tree.expand_all()
+ @exceptions
def get_processes_tree(self, gedamanager, ext=None):
"""!
Method to populate the 'Processes' tree view in the gEDA Manager.
@@ -229,18 +207,9 @@ class Utils(gEDAManager):
in the 'Sources' tree view.
"""
g = gedamanager
- try:
- current_directory = os.getcwd()
- except OSError:
- g.errors_textbuffer.insert(g.errors_textiter, 'OSError: ' + str(sys.exc_info()[0]) + '.\n')
- except:
- g.errors_textbuffer.insert(g.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
- raise
-
+ current_directory = os.getcwd()
os.chdir(self.directory)
-
g.processes.clear()
- print ext
if ext == 'sch':
icon_type = self.icon_lut['g2p']
image = gtk.gdk.pixbuf_new_from_file(icon_type)
@@ -273,3 +242,22 @@ class Utils(gEDAManager):
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')
+
+
+
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs