[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: branch: master updated (bc0c8b92984117807e94f0bd721d40524abb302c)
The branch, master has been updated
via bc0c8b92984117807e94f0bd721d40524abb302c (commit)
from 86582a23057c1e850c1bb27c1ba49792e842e164 (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 | 11 ++
src/folder_popup.xml | 11 ++
src/gedamanager.py | 338 ++++++++++++++++++++++++++-------------
src/{uimanager.xml => menu.xml} | 2 +-
src/newproject.py | 82 +++++-----
src/project_popup.xml | 11 ++
6 files changed, 298 insertions(+), 157 deletions(-)
create mode 100644 src/file_popup.xml
create mode 100644 src/folder_popup.xml
rename src/{uimanager.xml => menu.xml} (100%)
create mode 100644 src/project_popup.xml
=================
Commit Messages
=================
commit bc0c8b92984117807e94f0bd721d40524abb302c
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Fri Jul 11 00:31:22 2008 -0700
Checking in some new files and code changes.
:000000 100644 0000000... f2efceb... A src/file_popup.xml
:000000 100644 0000000... 5b4d048... A src/folder_popup.xml
:100644 100644 c6ce4c0... 78395a7... M src/gedamanager.py
:000000 100644 0000000... a025ee0... A src/menu.xml
:100644 100644 29625c0... 43ae8ab... M src/newproject.py
:000000 100644 0000000... 0f5625a... A src/project_popup.xml
:100644 000000 6f0977a... 0000000... D src/uimanager.xml
=========
Changes
=========
commit bc0c8b92984117807e94f0bd721d40524abb302c
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Fri Jul 11 00:31:22 2008 -0700
Checking in some new files and code changes.
diff --git a/src/file_popup.xml b/src/file_popup.xml
new file mode 100644
index 0000000..f2efceb
--- /dev/null
+++ b/src/file_popup.xml
@@ -0,0 +1,11 @@
+<ui>
+ <popup>
+ <separator/>
+ <menuitem action="Save"/>
+ <menuitem action="Save As..."/>
+ <menuitem action="Open"/>
+ <menuitem action="Close"/>
+ <menuitem action="Delete"/>
+ <separator/>
+ </popup>
+</ui>
diff --git a/src/folder_popup.xml b/src/folder_popup.xml
new file mode 100644
index 0000000..5b4d048
--- /dev/null
+++ b/src/folder_popup.xml
@@ -0,0 +1,11 @@
+<ui>
+ <popup>
+ <separator/>
+ <menuitem action="New Folder"/>
+ <menuitem action="Delete Folder"/>
+ <menuitem action="New Source..."/>
+ <menuitem action="Add Source..."/>
+ <menuitem action="Add Copy of Source..."/>
+ <separator/>
+ </popup>
+</ui>
diff --git a/src/gedamanager.py b/src/gedamanager.py
index c6ce4c0..78395a7 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -25,16 +25,8 @@ class gEDAManager:
"""
gEDAManager Constructor
"""
- # Splash Screen
-## splash_screen = gtk.Window(gtk.WINDOW_POPUP)
-## splash_image = gtk.Image()
-## splash_image.set_from_file('../icons/geda-xgsch2pcb-48.png')
-## splash_image.show()
-## splash_box = gtk.VBox()
-## splash_box.show()
-## splash_box.pack_start(splash_image, True, True)
-## splash_box.add(splash_box)
-## splash_screen.show()
+ # TODO -- will be able to get rid of the below if I create
+ # a global icon table
# Save current directory
self.directory = os.getcwd()
@@ -58,10 +50,12 @@ class gEDAManager:
# TODO create gEDA Manager icon
self.window.set_icon_from_file('../icons/geda-xgsch2pcb-48.png')
self.window.set_size_request(900,700)
- # Create a UIManager
- self.uimanager = gtk.UIManager()
- self.accel_group = self.uimanager.get_accel_group()
- self.window.add_accel_group(self.accel_group)
+ # Create a Menu UIManager and a Popup UIManager
+ self.menu_uimanager = gtk.UIManager()
+ self.popup_uimanager = gtk.UIManager()
+ self.menu_accel_group = self.menu_uimanager.get_accel_group()
+ self.window.add_accel_group(self.menu_accel_group)
+ self.popup_accel_group = self.popup_uimanager.get_accel_group()
self.__init_menus__()
self.__init_about_dialog__()
self.__init_gui_sections__()
@@ -112,7 +106,7 @@ class gEDAManager:
Method to create the menu bar.
"""
- self.actiongroup0 = gtk.ActionGroup('gEDAManager')
+ actiongroup0 = gtk.ActionGroup('gEDAManager')
actiongroup0_list = [('File', None, '_File'),
('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),
@@ -185,10 +179,10 @@ class gEDAManager:
('About', gtk.STOCK_ABOUT, '_About', None, None,
self.cb_show_about_dialog),]
- self.actiongroup0.add_actions(actiongroup0_list)
- self.uimanager.insert_action_group(self.actiongroup0, 0)
+ actiongroup0.add_actions(actiongroup0_list)
+ self.menu_uimanager.insert_action_group(actiongroup0, 0)
- self.actiongroup1 = gtk.ActionGroup('gEDAManager')
+ 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),
@@ -207,13 +201,13 @@ class gEDAManager:
('File Names', None, '_File Names', None, None, None, True),]
- self.actiongroup1.add_toggle_actions(actiongroup1_list)
- self.uimanager.insert_action_group(self.actiongroup1, 1)
- merge_id = self.uimanager.add_ui_from_file('uimanager.xml')
- menubar = self.uimanager.get_widget('/MenuBar')
+ 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.uimanager.get_widget('/MenuBar/View/Toolbars')
+ toolbars_menu = self.menu_uimanager.get_widget('/MenuBar/View/Toolbars')
toolbars_menu.set_sensitive(False)
self.vbox1 = gtk.VBox()
@@ -245,6 +239,7 @@ class gEDAManager:
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()
@@ -271,11 +266,14 @@ class gEDAManager:
sources_notebook.set_tab_pos(gtk.POS_BOTTOM)
processes_notebook.set_tab_pos(gtk.POS_BOTTOM)
scrolled_window1 = gtk.ScrolledWindow()
+
scrolled_window1.show()
scrolled_window2 = gtk.ScrolledWindow()
scrolled_window2.show()
scrolled_window1.set_shadow_type(gtk.SHADOW_IN)
- scrolled_window2.set_shadow_type(gtk.SHADOW_IN)
+ scrolled_window1.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ scrolled_window2.set_shadow_type(gtk.SHADOW_IN)
+ scrolled_window2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sources_notebook.add(scrolled_window1)
processes_notebook.add(scrolled_window2)
@@ -335,14 +333,15 @@ class gEDAManager:
vpaned1.pack2(notebook, True, True)
notebook.set_tab_pos(gtk.POS_BOTTOM)
- scrolled_window2 = gtk.ScrolledWindow()
- scrolled_window2.show()
- scrolled_window2.set_shadow_type(gtk.SHADOW_IN)
- notebook.add(scrolled_window2)
+ scrolled_window3 = gtk.ScrolledWindow()
+ scrolled_window3.show()
+ scrolled_window3.set_shadow_type(gtk.SHADOW_IN)
+ scrolled_window3.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ notebook.add(scrolled_window3)
textview2 = gtk.TextView()
textview2.show()
- scrolled_window2.add(textview2)
+ scrolled_window3.add(textview2)
output_icon = gtk.image_new_from_stock('gtk-justify-fill',
gtk.ICON_SIZE_BUTTON)
@@ -352,6 +351,7 @@ class gEDAManager:
scrolled_window4 = gtk.ScrolledWindow()
scrolled_window4.show()
scrolled_window4.set_shadow_type(gtk.SHADOW_IN)
+ scrolled_window4.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
notebook.add(scrolled_window4)
textview3 = gtk.TextView()
@@ -366,6 +366,7 @@ class gEDAManager:
scrolled_window5 = gtk.ScrolledWindow()
scrolled_window5.show()
scrolled_window5.set_shadow_type(gtk.SHADOW_IN)
+ scrolled_window5.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
notebook.add(scrolled_window5)
textview4 = gtk.TextView()
@@ -404,18 +405,17 @@ class gEDAManager:
Method to set the default sensitivity when no project is loaded.
"""
# File Menu
- print 'No project'
self.project.name = self.no_project_name
self.sources_tree.set_property('headers-visible', True)
- column = self.sources_tree.get_column(1)
+ column = self.sources_tree.get_column(0)
column.set_title(self.project.name)
- save_project_as_menuitem = self.uimanager.get_widget('/MenuBar/File/Save Project As...')
- close_project_menuitem = self.uimanager.get_widget('/MenuBar/File/Close Project')
+ 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.uimanager.get_widget('/MenuBar/Project')
+ project_menu = self.menu_uimanager.get_widget('/MenuBar/Project')
project_menu.set_sensitive(False)
@@ -424,16 +424,14 @@ class gEDAManager:
Method to set the default sensitivity when a project is loaded.
"""
# File Menu
- print 'Project'
- print self.project.name
self.sources_tree.set_property('headers-visible', False)
- save_project_as_menuitem = self.uimanager.get_widget('/MenuBar/File/Save Project As...')
- close_project_menuitem = self.uimanager.get_widget('/MenuBar/File/Close Project')
+ 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.uimanager.get_widget('/MenuBar/Project')
+ project_menu = self.menu_uimanager.get_widget('/MenuBar/Project')
project_menu.set_sensitive(True)
@@ -442,12 +440,12 @@ class gEDAManager:
Method to set the default sensitivity when no files are open.
"""
# File Menu
- close_menuitem = self.uimanager.get_widget('/MenuBar/File/Close')
- save_menuitem = self.uimanager.get_widget('/MenuBar/File/Save')
- save_as_menuitem = self.uimanager.get_widget('/MenuBar/File/Save As...')
- save_all_menuitem = self.uimanager.get_widget('/MenuBar/File/Save All')
- print_preview_menuitem = self.uimanager.get_widget('/MenuBar/File/Print Preview...')
- print_menuitem = self.uimanager.get_widget('/MenuBar/File/Print')
+ 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)
@@ -456,16 +454,16 @@ class gEDAManager:
print_menuitem.set_sensitive(False)
# Edit Menu
- undo_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Undo')
- redo_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Redo')
- cut_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Cut')
- copy_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Copy')
- paste_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Paste')
- delete_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Delete')
- find_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Find')
- find_and_replace_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Find And Replace')
- find_in_files_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Find In Files...')
- select_all_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Select All')
+ 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)
@@ -478,12 +476,12 @@ class gEDAManager:
select_all_menuitem.set_sensitive(False)
# View Menu
- file_names_toggleitem = self.uimanager.get_widget('/MenuBar/View/File Names')
- line_numbers_toggleitem = self.uimanager.get_widget('/MenuBar/View/Line Numbers')
- go_forward_menuitem = self.uimanager.get_widget('/MenuBar/View/Go Forward')
- go_back_menuitem = self.uimanager.get_widget('/MenuBar/View/Go Back')
- zoom_menu = self.uimanager.get_widget('/MenuBar/View/Zoom')
- refresh_menu = self.uimanager.get_widget('/MenuBar/View/Refresh')
+ 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)
@@ -492,7 +490,7 @@ class gEDAManager:
refresh_menu.set_sensitive(False)
# Window Menu
- window_menu = self.uimanager.get_widget('/MenuBar/Window')
+ window_menu = self.menu_uimanager.get_widget('/MenuBar/Window')
window_menu.set_sensitive(False)
@@ -502,12 +500,12 @@ class gEDAManager:
open.
"""
# File Menu
- close_menuitem = self.uimanager.get_widget('/MenuBar/File/Close')
- save_menuitem = self.uimanager.get_widget('/MenuBar/File/Save')
- save_as_menuitem = self.uimanager.get_widget('/MenuBar/File/Save As...')
- save_all_menuitem = self.uimanager.get_widget('/MenuBar/File/Save All')
- print_preview_menuitem = self.uimanager.get_widget('/MenuBar/File/Print Preview...')
- print_menuitem = self.uimanager.get_widget('/MenuBar/File/Print')
+ 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)
@@ -516,16 +514,16 @@ class gEDAManager:
print_menuitem.set_sensitive(True)
# Edit Menu
- undo_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Undo')
- redo_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Redo')
- cut_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Cut')
- copy_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Copy')
- paste_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Paste')
- delete_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Delete')
- find_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Find')
- find_and_replace_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Find And Replace')
- find_in_files_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Find In Files...')
- select_all_menuitem = self.uimanager.get_widget('/MenuBar/Edit/Select All')
+ 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)
@@ -538,12 +536,12 @@ class gEDAManager:
select_all_menuitem.set_sensitive(True)
# View Menu
- file_names_toggleitem = self.uimanager.get_widget('/MenuBar/View/File Names')
- line_numbers_toggleitem = self.uimanager.get_widget('/MenuBar/View/Line Numbers')
- go_forward_menuitem = self.uimanager.get_widget('/MenuBar/View/Go Forward')
- go_back_menuitem = self.uimanager.get_widget('/MenuBar/View/Go Back')
- zoom_menu = self.uimanager.get_widget('/MenuBar/View/Zoom')
- refresh_menu = self.uimanager.get_widget('/MenuBar/View/Refresh')
+ 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)
@@ -552,10 +550,21 @@ class gEDAManager:
refresh_menu.set_sensitive(True)
# Window Menu
- window_menu = self.uimanager.get_widget('/MenuBar/Window')
+ window_menu = self.menu_uimanager.get_widget('/MenuBar/Window')
window_menu.set_sensitive(True)
+ def set_new_folder(self):
+ """
+ Method to add a new folder to the treeview.
+ """
+ os.chdir(self.directory)
+ image = gtk.gdk.pixbuf_new_from_file('../icons/bitmaps/gq-folder.png')
+ # Need to also handle the situation when from the context menu
+ # this is where this should actually be from so that we can add folders
+ # to differnt parts of the tree
+
+
def set_project(self, path):
"""
Method to set current project to the one on path.
@@ -590,7 +599,7 @@ class gEDAManager:
name = self.project.name.split('.')[0]
image = gtk.gdk.pixbuf_new_from_file('../icons/bitmaps/pn-project.bmp')
path = self.project.directory + '/' + name
- parent = self.sources.append(None, [image, name, path])
+ return self.sources.append(None, [image, name, path])
# Child Node
image = self.get_node_image(self.project.name)
@@ -601,26 +610,19 @@ class gEDAManager:
self.project.file_list = [self.project.directory, [path + '.gm']]
- def set_new_folder(self):
- """
- Method to add a new folder to the treeview
- """
- image = gtk.gdk.pixbuf_new_from_file('../icons/bitmaps/gq-folder.bmp')
- # Need to also handle the situation when from the context menu
- # this is where this should actually be from so that we can add folders
- # to differnt parts of the tree
-
def load_tree(self, list, parent=None):
"""
Method to the load the tree -- recursively.
@param list of paths in the project's file_list.
@param parent node to help setup the gtk.TreeView object.
"""
- # TODO -- this will need to be changed whenver the datastore is changed
for file_path in list:
if file_path[0] == '/': # means this file is a parent
name = file_path.split('/')[-1]
- image = self.get_node_image(name)
+ if file_path == self.project.directory:
+ image = self.get_node_image(name, self.project.directory)
+ else:
+ image = self.get_node_image(name)
n_parent = self.sources.append(parent, [image, name, file_path])
else:
# recursion
@@ -631,11 +633,9 @@ class gEDAManager:
"""
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
-## print 'Now'
-## for child in range(self.sources.iter_n_children()):
-## print child
-## print 'Done'
def save_settings(self):
@@ -653,17 +653,20 @@ class gEDAManager:
gtk.main_quit()
- def get_node_image(self, name):
+ def get_node_image(self, name, project_node=None):
"""
Method to get the image for node with param name.
@param name of the file.
+ @param project_node is the top-level node
@return a gtk.Pixbuf image is returned
"""
- # This is my lookup table that will return the proper Pixbuf
- # to be used for the file with 'name'
- # Dictionary with the images in them
+ # TODO -- if I create a data structure that holds the icons in memory
+ # I can do away with always having to figure out what directory we are
+ # in as well as this method maybe and writing paths all the time
os.chdir(self.directory)
- if name.count('.'):
+ if project_node != None:
+ return gtk.gdk.pixbuf_new_from_file('../icons/bitmaps/pn-project.bmp')
+ elif name.count('.'):
key = name.split('.')[-1]
else:
return gtk.gdk.pixbuf_new_from_file('../icons/bitmaps/gq-folder.png')
@@ -710,6 +713,15 @@ class gEDAManager:
# 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
+ # First thing to do is move the file into our new directory by moving it
+ # However, we need to know where we are in our directory
+ # So,
+ # 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()
+ print 'path: ', path
+ print 'selected node: ', selected_node
if self.project.file_list != None:
self.project.file_list.append(path)
else:
@@ -720,9 +732,29 @@ class gEDAManager:
self.sources.append(None, [image, name, path])
+ def add_copy_sources_node(self, path):
+ """
+ Method to add the filename path to the treestore.
+ @param path of file.
+ """
+ # 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
+ if self.project.file_list != None:
+ self.project.file_list.append(path)
+ else:
+ self.project.file_list = [path]
+ name = path.split('/')[-1]
+ # Find out what file it is so we can pick an icon for it
+ image = self.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 name of the selected node.
"""
selection = self.sources_tree.get_selection()
model, selection_iter = selection.get_selected()
@@ -730,8 +762,22 @@ class gEDAManager:
return self.sources.get_value(selection_iter, 1)
else:
return None
-
+
+ def get_processes_selected_node(self):
+ """
+ Method to get the selected node in the 'Processes' treeview.
+ @return name of the selected node.
+ """
+ selection = self.processes_tree.get_selection()
+ model, selection_iter = selection.get_selected()
+ if (selection_iter):
+ return self.processes.get_value(selection_iter, 1)
+ else:
+ return None
+
+
+
def file_filters(self, dialog):
"""
Method to abstract some redundant code that is used in the message
@@ -1174,6 +1220,28 @@ class gEDAManager:
self.add_sources_node(filename)
dialog.destroy()
+
+ def cb_add_copy_source(self, menuitem, data=None):
+ """
+ Event occurs when the user wants to add a source to the project
+ @param menuitem that threw the event.
+ @param data optional to pass in.
+ """
+ dialog = gtk.FileChooserDialog('Add Copy of Source...',
+ 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()
+ self.add_copy_sources_node(filename)
+ dialog.destroy()
+
+
def cb_new_folder(self, widget):
"""
Event occurs when the user chooses to add a new folder to the project
@@ -1205,10 +1273,22 @@ class gEDAManager:
@param widget that threw the event.
"""
selected_node = self.get_sources_selected_node()
- print selected_node
+
# Update 'Processes: ' for the 'Processes' tree
column = self.processes_tree.get_column(0)
column.set_title('Processes for: ' + selected_node)
+
+ def cb_popup_deactivate(self, popup_menu, merge_id):
+ """
+ Event occurs when the 'deactivate' signal is thrown from
+ the popup menu.
+ @param popup_menu is the popup_menu.
+ @param merge_id is the merge id from the popup uimanager.
+ This needs to be removed so that ui's don't combine.
+ """
+ # Remove the ui from the uimanager
+ self.popup_uimanager.remove_ui(merge_id)
+
def cb_treeview_popup(self, widget, event):
"""
@@ -1217,15 +1297,43 @@ class gEDAManager:
@param widget that threw the event.
@param event that was thrown.
"""
-## if event.button == 3:
-## menu1 = gtk.Menu()
-## # Create menu items for the popup
-
if event.button == 3:
- # find out what type of file is selected and
- # open up the appropriate context menu for this file
selected_node = self.get_sources_selected_node()
- print selected_node
+ 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),
+ ('New Source...', gtk.STOCK_FILE, '_New Source...'),
+ ('Add Source...', gtk.STOCK_JUSTIFY_FILL, '_Add Source...', None, None, self.cb_add_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),]
+
+ actiongroup.add_actions(actiongroup_list)
+ self.popup_uimanager.insert_action_group(actiongroup, 0)
+
+ # Choose Popup Menu
+ if selected_node == self.project.name:
+ # Project Folder
+ merge_id = self.popup_uimanager.add_ui_from_file('project_popup.xml')
+ popup_menu = self.popup_uimanager.get_widget('/popup')
+ elif not selected_node.count('.'):
+ # Folder
+ merge_id = self.popup_uimanager.add_ui_from_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')
+ popup_menu = self.popup_uimanager.get_widget('/popup')
+
+ popup_menu.connect('deactivate', self.cb_popup_deactivate, merge_id)
+ popup_menu.show()
+ popup_menu.popup(None, None, None, event.button, event.time)
+
def cb_destroy(self, event):
"""
diff --git a/src/menu.xml b/src/menu.xml
new file mode 100644
index 0000000..a025ee0
--- /dev/null
+++ b/src/menu.xml
@@ -0,0 +1,107 @@
+<ui>
+ <menubar name="MenuBar">
+ <menu action="File">
+ <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="Project">
+ <menuitem action="New Folder..."/>
+ <menuitem action="New Source..."/>
+ <menuitem action="Add Source..."/>
+ <menuitem action="Add Copy of Source..."/>
+ </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"/>
+ <menuitem action="gEDA Documentation"/>
+ <menuitem action="gEDA Manager"/>
+ </menu>
+ <separator/>
+ <menuitem action="About"/>
+ </menu>
+ </menubar>
+</ui>
diff --git a/src/newproject.py b/src/newproject.py
index 29625c0..43ae8ab 100644
--- a/src/newproject.py
+++ b/src/newproject.py
@@ -7,6 +7,7 @@
import os, sys, pygtk, gtk, yaml
pygtk.require('2.0')
from project import *
+from distutils.dir_util import remove_tree
class NewProject:
"""
@@ -14,11 +15,6 @@ class NewProject:
the gEDA Manager. This form is called
when the user wants to create a new project.
"""
-
- #######################################
- # Constructor
- #######################################
-
def __init__(self, gedamanager):
"""
NewProject Constructor.
@@ -100,8 +96,8 @@ class NewProject:
def cb_filename_changed(filename_entry):
"""
Function to handle when the filename is changed.
- @param filename_entry is the text entered for the file to be
- created.
+ @param filename_entry is the text entered for the file and
+ directory to be created.
"""
self.assistant.set_page_complete(self.filename_page,
(filename_entry != ""))
@@ -133,24 +129,24 @@ class NewProject:
explanation.show()
align.add(explanation)
- self.newfiles_frame = gtk.Frame('')
- self.newfiles_frame.get_label_widget().set_markup('<b>New files to be created:</b>')
- self.newfiles_frame.set_shadow_type(gtk.SHADOW_NONE)
- explanation.pack_start(self.newfiles_frame, False, False)
+ self.new_directory_frame = gtk.Frame('')
+ self.new_directory_frame.get_label_widget().set_markup('<b>New files to be created:</b>')
+ self.new_directory_frame.set_shadow_type(gtk.SHADOW_NONE)
+ explanation.pack_start(self.new_directory_frame, False, False)
align = gtk.Alignment(0, 0, 1, 1)
align.set_padding(0, 12, 12, 12)
align.show()
- self.newfiles_frame.add(align)
+ self.new_directory_frame.add(align)
- self.newfiles_list = gtk.Label()
- self.newfiles_list.set_alignment(0, 0.5)
- self.newfiles_list.set_padding(0, 12)
- self.newfiles_list.show()
- align.add(self.newfiles_list)
+ self.new_directory = gtk.Label()
+ self.new_directory.set_alignment(0, 0.5)
+ self.new_directory.set_padding(0, 12)
+ self.new_directory.show()
+ align.add(self.new_directory)
self.overwrite_frame = gtk.Frame('')
- self.overwrite_frame.get_label_widget().set_markup('<b>The following files would be over written:</b>')
+ self.overwrite_frame.get_label_widget().set_markup('<b>The following directory would be over written:</b>')
self.overwrite_frame.set_shadow_type(gtk.SHADOW_NONE)
self.overwrite_frame.show()
explanation.pack_start(self.overwrite_frame, False, False)
@@ -193,23 +189,23 @@ class NewProject:
self.assistant.show()
self.summary_page = vbox
- def check_overwrites():
+ def check_directory_overwrite():
"""
- Function to see if a project file is already located
- in this directory for some reason. It should never be, since
- I changed the implementation by creating a new directory.
- Thus, I may delete this funciton.
- @return returns a list
+ Function to check whether or not the directory to be created
+ already exists.
+ @return returns a list
"""
- file_list = [self.get_filename()]
- newfiles_list = []
+ name = self.get_filename().split('.')[0]
+ f = os.path.exists(self.get_path() + '/' + name)
+ new_directory = []
overwrite_list = []
- for f in file_list:
- if os.path.exists(f):
- overwrite_list.append(f)
- else:
- newfiles_list.append(f)
- return [newfiles_list, overwrite_list]
+
+ if f:
+ overwrite_list.append(name)
+ else:
+ new_directory.append(name)
+ return [new_directory, overwrite_list]
+
def cb_prepare(assistant, page):
"""
@@ -219,15 +215,15 @@ class NewProject:
"""
if page is self.summary_page:
# Summary page before creating the new project on disk
- [newfiles_list, overwrite_list] = check_overwrites()
- self.newfiles_list.set_text('\n'.join(newfiles_list))
+ [new_directory, overwrite_list] = check_directory_overwrite()
+ self.new_directory.set_text('\n'.join(new_directory))
self.overwrite_list.set_text('\n'.join(overwrite_list))
- no_newfiles = (newfiles_list == [])
- if no_newfiles:
- self.newfiles_frame.hide_all()
+ no_new_directory = (new_directory == [])
+ if no_new_directory:
+ self.new_directory_frame.hide_all()
else:
- self.newfiles_frame.show_all()
+ self.new_directory_frame.show_all()
no_overwrite = (overwrite_list == [])
if no_overwrite:
@@ -270,8 +266,12 @@ class NewProject:
# First try to create a new directory
self.project.name = self.get_filename()
self.project.directory = self.get_path() + '/' + self.project.name.split('.')[0]
- print self.project.directory
+ # Remove directories with imported remove_tree
+ if self.confirm_overwrite.get_active():
+ remove_tree(self.project.directory)
+
os.mkdir(self.project.directory)
+ # The file_list is populated in the gedamanager
self.project.file_list = None
self.project.create()
except IOError, (errno, strerror):
@@ -306,7 +306,7 @@ class NewProject:
def get_path(self):
"""
- Get path of new project.
+ Method to get path of new project.
@return path for file.
"""
path = self.filebutton.get_filename()
@@ -314,7 +314,7 @@ class NewProject:
def get_filename(self):
"""
- Get file name of the new project.
+ Method to get file name of the new project.
@return file name.
"""
filename = self.filename.get_text()
diff --git a/src/project_popup.xml b/src/project_popup.xml
new file mode 100644
index 0000000..0f5625a
--- /dev/null
+++ b/src/project_popup.xml
@@ -0,0 +1,11 @@
+<ui>
+ <popup>
+ <separator/>
+ <menuitem action="New Folder"/>
+ <menuitem action="New Source..."/>
+ <menuitem action="Add Source..."/>
+ <menuitem action="Add Copy of Source..."/>
+ <menuitem action="Save Project As..."/>
+ <separator/>
+ </popup>
+</ui>
diff --git a/src/uimanager.xml b/src/uimanager.xml
deleted file mode 100644
index 6f0977a..0000000
--- a/src/uimanager.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<ui>
- <menubar name="MenuBar">
- <menu action="File">
- <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="Project">
- <menuitem action="New Source..."/>
- <menuitem action="Add Source..."/>
- <menuitem action="Add Copy of Source..."/>
- <menuitem action="New Folder..."/>
- </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"/>
- <menuitem action="gEDA Documentation"/>
- <menuitem action="gEDA Manager"/>
- </menu>
- <separator/>
- <menuitem action="About"/>
- </menu>
- </menubar>
-</ui>
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs