[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: xgsch2pcb.git: branch: master updated (rel_0.1.3-6-g43a7475)
The branch, master has been updated
via 43a74752fc2d23bad2c36356ca4975489d134dc6 (commit)
via 1b3e718027239191f4663be92e215e822f27cf4b (commit)
via 8d204a3991754a4893220d687ccd8d9cd4e5eff7 (commit)
via 5276a9d81908fcd480e29b86e990e830370aa1f9 (commit)
from 9850e3addcb252407d048e7cd595acda787393db (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
=========
lib/xgsch2pcb/config.py.in | 1 +
lib/xgsch2pcb/gsch2pcbproject.py | 184 ++++++++++++++++++++++-----
lib/xgsch2pcb/gui.py | 260 ++++++++++++++++++++++++++++++++++++--
lib/xgsch2pcb/pcbmanager.py | 1 +
xgsch2pcb.in | 1 +
5 files changed, 405 insertions(+), 42 deletions(-)
=================
Commit Messages
=================
commit 43a74752fc2d23bad2c36356ca4975489d134dc6
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Add Copyright "gEDA contributors" in various places
:100644 100644 2f55f92... c5203d7... M lib/xgsch2pcb/config.py.in
:100644 100644 44dac20... b296ad2... M lib/xgsch2pcb/gsch2pcbproject.py
:100644 100644 d11f81b... 3488d18... M lib/xgsch2pcb/gui.py
:100644 100644 5e81361... efda4c7... M lib/xgsch2pcb/pcbmanager.py
:100644 100644 f9efcf3... 611d813... M xgsch2pcb.in
commit 1b3e718027239191f4663be92e215e822f27cf4b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Add Andrey Smirnov to list of authors for the about dialog.
:100644 100644 69b66cc... d11f81b... M lib/xgsch2pcb/gui.py
commit 8d204a3991754a4893220d687ccd8d9cd4e5eff7
Author: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Third draft version of options dialog support.
Comments by Peter Clifton:
Refactors writing of config file options to be much more generic.
Provides real functionality to the options dialog.
:100644 100644 bb75428... 44dac20... M lib/xgsch2pcb/gsch2pcbproject.py
:100644 100644 f1ec0fe... 69b66cc... M lib/xgsch2pcb/gui.py
commit 5276a9d81908fcd480e29b86e990e830370aa1f9
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Add an options dialog for editing various gsch2pcb project options
So far, this is just a GUI mockup, and is not functional.
:100644 100644 962f493... f1ec0fe... M lib/xgsch2pcb/gui.py
=========
Changes
=========
commit 43a74752fc2d23bad2c36356ca4975489d134dc6
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Add Copyright "gEDA contributors" in various places
diff --git a/lib/xgsch2pcb/config.py.in b/lib/xgsch2pcb/config.py.in
index 2f55f92..c5203d7 100644
--- a/lib/xgsch2pcb/config.py.in
+++ b/lib/xgsch2pcb/config.py.in
@@ -4,6 +4,7 @@
# xgsch2pcb - a GUI for gsch2pcb
# Copyright (C) 2006 University of Cambridge
+# Copyright (C) 2006-2009 xgsch2pcb contributors (See ChangeLog for details)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/lib/xgsch2pcb/gsch2pcbproject.py b/lib/xgsch2pcb/gsch2pcbproject.py
index 44dac20..b296ad2 100644
--- a/lib/xgsch2pcb/gsch2pcbproject.py
+++ b/lib/xgsch2pcb/gsch2pcbproject.py
@@ -2,6 +2,7 @@
# xgsch2pcb - a GUI for gsch2pcb
# Copyright (C) 2006 University of Cambridge
+# Copyright (C) 2006-2009 xgsch2pcb contributors (See ChangeLog for details)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/lib/xgsch2pcb/gui.py b/lib/xgsch2pcb/gui.py
index d11f81b..3488d18 100644
--- a/lib/xgsch2pcb/gui.py
+++ b/lib/xgsch2pcb/gui.py
@@ -2,6 +2,7 @@
# xgsch2pcb - a GUI for gsch2pcb
# Copyright (C) 2006 University of Cambridge
+# Copyright (C) 2006-2009 xgsch2pcb contributors (See ChangeLog for details)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -183,7 +184,7 @@ class MonitorWindow(gtk.Window):
self.aboutdialog.set_name(_("xgsch2pcb"))
self.aboutdialog.set_comments(_("a GUI for gsch2pcb"))
self.aboutdialog.set_version(config.VERSION)
- self.aboutdialog.set_copyright("University of Cambridge 2006")
+ self.aboutdialog.set_copyright("University of Cambridge 2006\nxgsch2pcb Contributors 2006-2009 (See ChangeLog)")
self.aboutdialog.set_authors(['Peter Brett', 'Peter Clifton', 'Andrey Smirnov'])
gtk.about_dialog_set_url_hook(about_url_cb, None)
self.aboutdialog.set_website('http://geda.seul.org/')
diff --git a/lib/xgsch2pcb/pcbmanager.py b/lib/xgsch2pcb/pcbmanager.py
index 5e81361..efda4c7 100644
--- a/lib/xgsch2pcb/pcbmanager.py
+++ b/lib/xgsch2pcb/pcbmanager.py
@@ -2,6 +2,7 @@
# xgsch2pcb - a GUI for gsch2pcb
# Copyright (C) 2006 University of Cambridge
+# Copyright (C) 2006-2009 xgsch2pcb contributors (See ChangeLog for details)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/xgsch2pcb.in b/xgsch2pcb.in
index f9efcf3..611d813 100644
--- a/xgsch2pcb.in
+++ b/xgsch2pcb.in
@@ -3,6 +3,7 @@
# xgsch2pcb - a GUI for gsch2pcb
# Copyright (C) 2006 University of Cambridge
+# Copyright (C) 2006-2009 xgsch2pcb contributors (See ChangeLog for details)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
commit 1b3e718027239191f4663be92e215e822f27cf4b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Add Andrey Smirnov to list of authors for the about dialog.
diff --git a/lib/xgsch2pcb/gui.py b/lib/xgsch2pcb/gui.py
index 69b66cc..d11f81b 100644
--- a/lib/xgsch2pcb/gui.py
+++ b/lib/xgsch2pcb/gui.py
@@ -184,7 +184,7 @@ class MonitorWindow(gtk.Window):
self.aboutdialog.set_comments(_("a GUI for gsch2pcb"))
self.aboutdialog.set_version(config.VERSION)
self.aboutdialog.set_copyright("University of Cambridge 2006")
- self.aboutdialog.set_authors(['Peter Brett', 'Peter Clifton'])
+ self.aboutdialog.set_authors(['Peter Brett', 'Peter Clifton', 'Andrey Smirnov'])
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'))
commit 8d204a3991754a4893220d687ccd8d9cd4e5eff7
Author: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Third draft version of options dialog support.
Comments by Peter Clifton:
Refactors writing of config file options to be much more generic.
Provides real functionality to the options dialog.
diff --git a/lib/xgsch2pcb/gsch2pcbproject.py b/lib/xgsch2pcb/gsch2pcbproject.py
index bb75428..44dac20 100644
--- a/lib/xgsch2pcb/gsch2pcbproject.py
+++ b/lib/xgsch2pcb/gsch2pcbproject.py
@@ -19,6 +19,86 @@
import os, gobject
+class Gsch2PCBOption(object):
+ """Gsch2PCBOption - class representing project's option
+
+This class represents single option which can be added to the gsch2pcb's
+project file. Each option created must have at least two attributes:
+`name` - name of the option that is used in project file,
+`attr_name` - name of the corresponding attribute of Gsch2PCBProject instance
+which holds option's value. Additional three parameters `read_func`, `write_func` and
+`default_value` which are function to read option's value from config,
+function to write option's value to the config and default option's value correspondingly.
+"""
+ def __init__(self, **kwargs):
+ def default_read_function(option, project, parts):
+ value = getattr(project, option.attr_name)
+ if value == option.default_value and len(parts) > 1:
+ setattr(project, option.attr_name, parts[1])
+
+ def default_write_function(option, project, save_file):
+ value = getattr(project, option.attr_name)
+ if value:
+ save_file.write(option.name + ' %s\n' % value)
+
+ self.name=kwargs['name']
+ self.attr_name=kwargs['attr_name']
+ self.read_func=kwargs.get('read_func', default_read_function)
+ self.write_func=kwargs.get('write_func', default_write_function)
+ self.default_value=kwargs.get('default_value', None)
+ self.emitted = False
+
+ # Each write function must have following signature:
+ # write_function(option, project, save_file)
+ # where `option` is instance of the option that is being written by that function,
+ # `project` is instance of a project which this option is used in, and
+ # `save_file` is the file the aforementioned project is saved to.
+
+ @staticmethod
+ def join_then_write(option, project, save_file):
+ values = getattr(project, option.attr_name)
+ if values:
+ save_file.write(option.name + ' %s\n' % ' '.join(values))
+ @staticmethod
+ def write_if_equal(value):
+ def func(option, project, save_file):
+ if getattr(project, option.attr_name) == value:
+ save_file.write(option.name + '\n')
+ return func
+
+ # Every read function must have the following signatue:
+ # read_function(option, project, parts)
+ # where `option` is instance of the option that is being read by that function,
+ # `project` is instance of a project which this option is used in, and
+ # `parts` is the array that have option's name as its first value and
+ # for some commands string corresponding to option as second(see Gsch2PCBProject's load function).
+
+ @staticmethod
+ def read_multiple_values(option, project, parts):
+ if len(parts) > 1:
+ value = parts[1].split()
+ else:
+ value = []
+ setattr(project, option.attr_name, value)
+ @staticmethod
+ def read_and_set_value(value):
+ def func(option, project, parts):
+ setattr(project, option.attr_name, value)
+ return func
+
+
+class Gsch2PCBOptionStore(dict):
+ """Gsch2PCBOptionStore - slightly augmented dictionary class
+
+This is augmented dictionary class. The only difference
+between it and standrad `dict` class is in added `add` function
+which is used to create and add options to associative array that
+this class represents.
+"""
+ def add(self, **kwargs):
+ option = Gsch2PCBOption(**kwargs)
+ self[option.name] = option
+
class Gsch2PCBProject(gobject.GObject):
__gsignals__ = { 'dirty-flag-changed' :
@@ -35,12 +115,51 @@ class Gsch2PCBProject(gobject.GObject):
(gobject.TYPE_STRING, )),
}
+ PREFER_M4_FOOTPRINTS = 0
+ PREFER_FILE_FOOTPRINTS = 1
+ USE_ONLY_FILE_FOOTPRINTS = 2
+
+ options = Gsch2PCBOptionStore()
+ options.add(name='schematics', attr_name= 'pages',
+ read_func=Gsch2PCBOption.read_multiple_values,
+ write_func=Gsch2PCBOption.join_then_write,
+ default_value=[])
+
+ options.add(name='output-name', attr_name='output_name')
+
+ options.add(name='preserve-unfound', attr_name='preserve_unfound',
+ read_func=Gsch2PCBOption.read_and_set_value(True),
+ write_func=Gsch2PCBOption.write_if_equal(True),
+ default_value=False)
+
+ options.add(name='skip-m4', attr_name='footprint_type_choice',
+ read_func=Gsch2PCBOption.read_and_set_value(USE_ONLY_FILE_FOOTPRINTS),
+ write_func=Gsch2PCBOption.write_if_equal(USE_ONLY_FILE_FOOTPRINTS),
+ default_value=PREFER_M4_FOOTPRINTS)
+
+ options.add(name='use-files', attr_name='footprint_type_choice',
+ read_func=Gsch2PCBOption.read_and_set_value(PREFER_FILE_FOOTPRINTS),
+ write_func=Gsch2PCBOption.write_if_equal(PREFER_FILE_FOOTPRINTS),
+ default_value=PREFER_M4_FOOTPRINTS)
+
+ options.add(name='elements-dir', attr_name='elements_dir',
+ read_func=Gsch2PCBOption.read_multiple_values,
+ write_func=Gsch2PCBOption.join_then_write,
+ default_value=[])
+
+ options.add(name='m4-command', attr_name='m4_command')
+ options.add(name='m4-file', attr_name='m4_file')
+ options.add(name='m4-pcbdir', attr_name='m4_pcbdir')
+ options.add(name='gnetlist-arg', attr_name='gnetlist_arg')
+
def __init__(self, filename=None, output_name=None):
gobject.GObject.__init__(self)
+ for _, option in self.options.items():
+ setattr(self, option.attr_name, option.default_value)
+
self.filename = filename
self.dirty = False
- self.pages = []
self.lines = []
if output_name != None:
@@ -72,24 +191,19 @@ class Gsch2PCBProject(gobject.GObject):
self.lines.append(line)
parts = line.strip().split(None, 1)
- opt = None
+ option_name = None
if parts:
- opt = parts[0]
+ option_name = parts[0]
# Skip blank lines and comment lines (like gsch2pcb)
- if not opt or opt[0] == '#' or opt[0] == '/' or opt[0] == ';':
+ if not option_name or option_name in ('#', '/', ';'):
pass
- # Pick out the list of schematics
- elif opt == 'schematics':
- if len(parts) > 1:
- self.pages = parts[1].split()
- else:
- self.pages = []
- # Pick out the output filename
- elif opt == 'output-name':
- self.output_name = parts[1]
else:
- print 'Warning: Unsupported project file line "%s"' % line.strip()
+ try:
+ option = self.options[option_name]
+ option.read_func(option, self, parts)
+ except KeyError:
+ print 'Warning: Unsupported project file line "%s"' % line.strip()
fp.close()
if fromfile == self.filename:
self.set_dirty(False)
@@ -99,30 +213,33 @@ class Gsch2PCBProject(gobject.GObject):
destfile = self.filename
if destfile == None:
raise Exception, 'No filename specified for project'
-
- emitted_schematics = False
- emitted_output_name = False
-
+ # Write values of options that were previously found
+ # in project file
fp = open(destfile, 'wb')
for line in self.lines:
parts = line.strip().split(None, 1)
- opt = None
+
+ option_name = None
if parts:
- opt = parts[0]
-
- if opt == 'schematics':
- fp.write('schematics %s\n' % ' '.join(self.pages))
- emitted_schematics = True
- elif opt == 'output-name':
- fp.write('output-name %s\n' % self.output_name)
- emitted_output_name = True
- else:
- fp.write(line)
+ option_name = parts[0]
- if not emitted_schematics:
- fp.write('schematics %s\n' % ' '.join(self.pages))
- if not emitted_output_name:
- fp.write('output-name %s\n' % self.output_name)
+ try:
+ option = self.options[option_name]
+ # If project file contains more than one line corresponding to the
+ # same option first one will be overwritten and all the rest ones will be
+ # left unchanged
+ if not option.emitted:
+ option.write_func(option, self, fp)
+ option.emitted = True
+ else:
+ fp.write(line)
+ except KeyError:
+ fp.write(line)
+ # Write values of newly added options
+ for _, option in self.options.items():
+ if not option.emitted:
+ option.write_func(option, self, fp)
+ option.emitted = False # Reset emitted field for next save() call
fp.close()
if destfile == self.filename:
diff --git a/lib/xgsch2pcb/gui.py b/lib/xgsch2pcb/gui.py
index f1ec0fe..69b66cc 100644
--- a/lib/xgsch2pcb/gui.py
+++ b/lib/xgsch2pcb/gui.py
@@ -190,11 +190,6 @@ class MonitorWindow(gtk.Window):
self.aboutdialog.set_translator_credits(_('translator-credits'))
self.aboutdialog.set_transient_for( self )
- # Options dialog
- # ------------
- self.optionsdialog = ProjectOptionsDialog( self )
- self.optionsdialog.set_name(_("TODO: Options dialog"))
- self.optionsdialog.set_transient_for( self )
self.pcbmanager = None
self.set_project(project)
@@ -537,9 +532,24 @@ class MonitorWindow(gtk.Window):
self.handle_quit()
def event_options_button_clicked(self, button):
- self.optionsdialog.show_all()
- self.optionsdialog.run()
- self.optionsdialog.hide_all()
+ options_dialog = ProjectOptionsDialog( self )
+ options_dialog.set_name(_("Options dialog"))
+ options_dialog.set_transient_for( self )
+
+ options_dialog.show_all()
+ options_dialog.run()
+ options_dialog.hide_all()
+
+ self.project.elements_dir = []
+ options_dialog.path_chooser.path_model.foreach(
+ lambda m, p, i, ud: self.project.elements_dir.append(m.get_value(i, 0)),
+ None)
+
+ self.project.m4_command = options_dialog.m4_command_entry.get_text()
+ self.project.m4_pcbdir = options_dialog.m4_pcbpath_entry.get_text()
+ self.project.m4_file = options_dialog.m4_extra_file_entry.get_text()
+ self.project.gnetlist_arg = options_dialog.gnetlist_arg_entry.get_text()
+
def event_about_button_clicked(self, button):
self.aboutdialog.show_all()
@@ -989,47 +999,39 @@ class PathChooser(gtk.VBox):
model.remove(iter)
- def selection_changed_cb(self, treeselection):
- [model, iter] = treeselection.get_selected()
+ def add_clicked_cb(self, button, pathmodel):
+ filedialog = gtk.FileChooserDialog(action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ buttons= (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
+ gtk.STOCK_ADD, gtk.RESPONSE_ACCEPT))
- if not iter:
- self.hbox.set_sensitive(False)
- return
- else:
- self.hbox.set_sensitive(True)
+ filedialog.show_all()
+ response = filedialog.run()
+ filedialog.hide_all()
- path = model.get_path(iter)
+ if response == gtk.RESPONSE_ACCEPT:
+ for path in filedialog.get_filenames():
+ it = pathmodel.get_iter_first()
+ unique = True
+ while it is not None:
+ if pathmodel.get_value(it, 0) == path:
+ unique = False
+ break
+ it = pathmodel.iter_next(it)
+ if unique:
+ pathmodel.append([path, "black"])
- if path[0] == 0:
- # Do something for the "New search path mode"
- self.remove_button.set_sensitive(False)
- else:
- self.remove_button.set_sensitive(True)
- searchpath = model.get(iter, 0)[0]
- self.file_button.set_current_folder(searchpath)
- def __init__(self):
- gtk.VBox.__init__(self, False, 0)
- # GUI Spacing
- self.set_spacing(6)
-
- hbox = gtk.HBox()
- self.pack_start(hbox, False, True)
-
- # GUI Spacing
- hbox.set_spacing(6)
+ def selection_changed_cb(self, treeselection):
+ [model, iter] = treeselection.get_selected()
+ self.remove_button.set_sensitive(True if iter else False)
- self.hbox = hbox
- filebutton = gtk.FileChooserButton(_("Choose path"))
- filebutton.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
- hbox.pack_start(filebutton, True, True)
- self.file_button = filebutton
+ def __init__(self, directories):
+ gtk.VBox.__init__(self, False, 0)
- removebutton = gtk.Button(stock=gtk.STOCK_REMOVE)
- hbox.pack_start(removebutton, False, True)
- self.remove_button = removebutton
+ # GUI Spacing
+ self.set_spacing(6)
frame = gtk.Frame()
frame.set_shadow_type(gtk.SHADOW_IN)
@@ -1039,10 +1041,9 @@ class PathChooser(gtk.VBox):
frame.add(hbox)
pathmodel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
- pathmodel.append(["[Insert new path]", "#808080"])
- pathmodel.append(["/usr/local/share/pcb_footprints", "black"])
- pathmodel.append(["/usr/local/share/pcb_footprints_vetted", "black"])
- pathmodel.append(["/usr/local/share/pcb_footprints_untested", "black"])
+ for path in directories:
+ pathmodel.append([path, "black"])
+ self.path_model = pathmodel
treeview = gtk.TreeView(pathmodel)
hbox.pack_start(treeview, True, True)
@@ -1058,8 +1059,25 @@ class PathChooser(gtk.VBox):
treeview.set_headers_visible(False)
treeview.set_size_request(1,1)
+ hbox = gtk.HBox()
+ self.pack_start(hbox, False, True)
+
+ # GUI Spacing
+ hbox.set_spacing(6)
+
+ addbutton = gtk.Button(stock=gtk.STOCK_ADD)
+ hbox.pack_start(addbutton, False, True)
+ self.add_button = addbutton
+
+ removebutton = gtk.Button(stock=gtk.STOCK_REMOVE)
+ removebutton.set_sensitive(False)
+ hbox.pack_start(removebutton, False, True)
+ self.remove_button = removebutton
+
+
treeview.get_selection().connect("changed", self.selection_changed_cb)
self.remove_button.connect("clicked", self.remove_clicked_cb, treeview)
+ self.add_button.connect("clicked", self.add_clicked_cb, pathmodel)
gobject.type_register( PathChooser )
@@ -1069,6 +1087,8 @@ class ProjectOptionsDialog(gtk.Dialog):
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
( gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE ))
+ self.project = parent.project
+
# GUI Spacing
self.set_has_separator(False)
#self.set_border_width(12)
@@ -1095,16 +1115,18 @@ class ProjectOptionsDialog(gtk.Dialog):
generalvbox.set_spacing(6)
checkbutton = gtk.CheckButton(_("Preserve PCB elements not in the schematic"))
+ checkbutton.set_active(parent.project.preserve_unfound)
generalvbox.pack_start(checkbutton, False, True)
+ checkbutton.connect('toggled', self.preserve_pcb_checkbox_toggled)
- radiobutton1 = gtk.RadioButton(None, _("Prefer M4 footprints to file footprints"))
- generalvbox.pack_start(radiobutton1, False, True)
-
- radiobutton2 = gtk.RadioButton(radiobutton1, _("Prefer file footprints to M4 footprints"))
- generalvbox.pack_start(radiobutton2, False, True)
-
- radiobutton3 = gtk.RadioButton(radiobutton1, _("Only use file footprints"))
- generalvbox.pack_start(radiobutton3, False, True)
+ radiobutton = None
+ for choice, label in [(Gsch2PCBProject.PREFER_M4_FOOTPRINTS, _("Prefer M4 footprints to file footprints")),
+ (Gsch2PCBProject.PREFER_FILE_FOOTPRINTS, _("Prefer file footprints to M4 footprints")),
+ (Gsch2PCBProject.USE_ONLY_FILE_FOOTPRINTS, _("Only use file footprints"))]:
+ radiobutton = gtk.RadioButton(radiobutton, label)
+ radiobutton.set_active(parent.project.footprint_type_choice == choice)
+ generalvbox.pack_start(radiobutton, False, True)
+ radiobutton.connect('toggled', self.footprints_radio_toggled, choice)
label = gtk.Label(_("<b>Footprint search paths</b>"))
label.set_use_markup(True)
@@ -1115,8 +1137,9 @@ class ProjectOptionsDialog(gtk.Dialog):
alignment.set_padding( 6, 6, 12, 0 )
vbox.pack_start(alignment, True, True)
- pathchooser = PathChooser()
+ pathchooser = PathChooser(parent.project.elements_dir)
alignment.add (pathchooser)
+ self.path_chooser = pathchooser
advancedoptions = gtk.Expander(_("Advanced options"))
advancedoptions.set_spacing(6)
@@ -1146,33 +1169,39 @@ class ProjectOptionsDialog(gtk.Dialog):
table.set_row_spacings(6)
table.set_col_spacings(6)
- label = gtk.Label(_("M4 command :"))
- label.set_alignment(0, 0.5)
- table.attach (label, 0, 1, 0, 1, gtk.FILL)
-
- entry = gtk.Entry()
- table.attach (entry, 1, 2, 0, 1)
-
- label = gtk.Label(_("M4 PCB path :"))
- label.set_alignment(0, 0.5)
- table.attach (label, 0, 1, 1, 2, gtk.FILL)
+ self.m4_command_entry = gtk.Entry()
+ self.m4_pcbpath_entry = gtk.Entry()
+ self.m4_extra_file_entry = gtk.Entry()
- entry = gtk.Entry()
- table.attach (entry, 1, 2, 1, 2)
+ for i, (entry, label_text, entry_contents) in enumerate([
+ (self.m4_command_entry, _("M4 command :"), parent.project.m4_command),
+ (self.m4_pcbpath_entry, _("M4 PCB path :"), parent.project.m4_pcbdir),
+ (self.m4_extra_file_entry, _("M4 extra file :"), parent.project.m4_file)]):
+ label = gtk.Label(label_text)
+ label.set_alignment(0, 0.5)
+ table.attach (label, 0, 1, i, i + 1, gtk.FILL)
- label = gtk.Label(_("M4 extra file :"))
- label.set_alignment(0, 0.5)
- table.attach (label, 0, 1, 2, 3, gtk.FILL)
+ if entry_contents:
+ entry.set_text(entry_contents)
- entry = gtk.Entry()
- table.attach (entry, 1, 2, 2, 3)
+ table.attach (entry, 1, 2, i, i + 1)
label = gtk.Label(_("<b>Extra gnetlist arguments</b>"))
label.set_use_markup(True)
label.set_alignment(0, 0.5)
advancedvbox.pack_start(label, False, True)
- entry = gtk.Entry()
- advancedvbox.pack_start(entry, False, True)
+ self.gnetlist_arg_entry = gtk.Entry()
+ if parent.project.gnetlist_arg:
+ self.gnetlist_arg_entry.set_text(parent.project.gnetlist_arg)
+
+ advancedvbox.pack_start(self.gnetlist_arg_entry, False, True)
+
+ def preserve_pcb_checkbox_toggled(self, widget, data=None):
+ self.project.preserve_unfound = widget.get_active()
+ # self.parent.project.set_dirty(True)
+ def footprints_radio_toggled(self, widget, data=None):
+ self.project.footprint_type_choice = data
+ # self.parent.project.set_dirty(True)
gobject.type_register( ProjectOptionsDialog )
commit 5276a9d81908fcd480e29b86e990e830370aa1f9
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Add an options dialog for editing various gsch2pcb project options
So far, this is just a GUI mockup, and is not functional.
diff --git a/lib/xgsch2pcb/gui.py b/lib/xgsch2pcb/gui.py
index 962f493..f1ec0fe 100644
--- a/lib/xgsch2pcb/gui.py
+++ b/lib/xgsch2pcb/gui.py
@@ -190,6 +190,12 @@ class MonitorWindow(gtk.Window):
self.aboutdialog.set_translator_credits(_('translator-credits'))
self.aboutdialog.set_transient_for( self )
+ # Options dialog
+ # ------------
+ self.optionsdialog = ProjectOptionsDialog( self )
+ self.optionsdialog.set_name(_("TODO: Options dialog"))
+ self.optionsdialog.set_transient_for( self )
+
self.pcbmanager = None
self.set_project(project)
@@ -236,13 +242,15 @@ class MonitorWindow(gtk.Window):
button.connect("clicked", self.event_close_button_clicked)
self.toolbar_buttons['close'] = button
- #button = gtk.ToolButton(gtk.STOCK_PROPERTIES)
- #button.set_tooltip_text(_("Project options"))
- #toolbar.insert(button, -1)
- #button.connect("clicked",
- # self.event_properties_button_clicked)
- #self.toolbar_buttons['close'] = button
- #button.set_sensitive(False) #FIXME
+# toolbar.insert(gtk.SeparatorToolItem(), -1)
+
+ icon = gtk.Image()
+ icon.set_from_stock(gtk.STOCK_PROPERTIES, toolbar.get_icon_size())
+ button = gtk.ToolButton(icon, _("Options"))
+ button.set_tooltip_text(_("Project options"))
+ toolbar.insert(button, -1)
+ button.connect("clicked", self.event_options_button_clicked)
+ self.toolbar_buttons['options'] = button
toolbar.insert(gtk.SeparatorToolItem(), -1)
@@ -528,6 +536,11 @@ class MonitorWindow(gtk.Window):
def event_quit_button_clicked(self, button):
self.handle_quit()
+ def event_options_button_clicked(self, button):
+ self.optionsdialog.show_all()
+ self.optionsdialog.run()
+ self.optionsdialog.hide_all()
+
def event_about_button_clicked(self, button):
self.aboutdialog.show_all()
self.aboutdialog.run()
@@ -565,6 +578,7 @@ class MonitorWindow(gtk.Window):
widget_list = ( self.toolbar_buttons['save'],
#self.toolbar_buttons['saveas'],
self.toolbar_buttons['close'],
+ self.toolbar_buttons['options'],
self.pagelist,
self.addpagebutton )
@@ -964,3 +978,201 @@ class NewProjectDialog(gtk.FileChooserDialog):
return gtk.FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME
gobject.type_register( NewProjectDialog )
+
+
+class PathChooser(gtk.VBox):
+ def remove_clicked_cb(self, button, treeview):
+ [model, iter] = treeview.get_selection().get_selected()
+
+ if not iter:
+ return
+
+ model.remove(iter)
+
+ def selection_changed_cb(self, treeselection):
+ [model, iter] = treeselection.get_selected()
+
+ if not iter:
+ self.hbox.set_sensitive(False)
+ return
+ else:
+ self.hbox.set_sensitive(True)
+
+ path = model.get_path(iter)
+
+ if path[0] == 0:
+ # Do something for the "New search path mode"
+ self.remove_button.set_sensitive(False)
+ else:
+ self.remove_button.set_sensitive(True)
+ searchpath = model.get(iter, 0)[0]
+ self.file_button.set_current_folder(searchpath)
+
+ def __init__(self):
+ gtk.VBox.__init__(self, False, 0)
+
+ # GUI Spacing
+ self.set_spacing(6)
+
+ hbox = gtk.HBox()
+ self.pack_start(hbox, False, True)
+
+ # GUI Spacing
+ hbox.set_spacing(6)
+
+ self.hbox = hbox
+
+ filebutton = gtk.FileChooserButton(_("Choose path"))
+ filebutton.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ hbox.pack_start(filebutton, True, True)
+ self.file_button = filebutton
+
+ removebutton = gtk.Button(stock=gtk.STOCK_REMOVE)
+ hbox.pack_start(removebutton, False, True)
+ self.remove_button = removebutton
+
+ frame = gtk.Frame()
+ frame.set_shadow_type(gtk.SHADOW_IN)
+ self.pack_start(frame, True, True)
+
+ hbox = gtk.HBox()
+ frame.add(hbox)
+
+ pathmodel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
+ pathmodel.append(["[Insert new path]", "#808080"])
+ pathmodel.append(["/usr/local/share/pcb_footprints", "black"])
+ pathmodel.append(["/usr/local/share/pcb_footprints_vetted", "black"])
+ pathmodel.append(["/usr/local/share/pcb_footprints_untested", "black"])
+
+ treeview = gtk.TreeView(pathmodel)
+ hbox.pack_start(treeview, True, True)
+
+ scrollbar = gtk.VScrollbar()
+ hbox.pack_start(scrollbar, False, True)
+
+ renderer = gtk.CellRendererText()
+ treeview.insert_column_with_attributes(0, "", renderer, text=0, foreground=1)
+ treeview.set_headers_visible(False)
+
+ treeview.set_vadjustment(scrollbar.get_adjustment())
+ treeview.set_headers_visible(False)
+ treeview.set_size_request(1,1)
+
+ treeview.get_selection().connect("changed", self.selection_changed_cb)
+ self.remove_button.connect("clicked", self.remove_clicked_cb, treeview)
+
+gobject.type_register( PathChooser )
+
+class ProjectOptionsDialog(gtk.Dialog):
+ def __init__(self, parent):
+ gtk.Dialog.__init__(self, _('Project options'), parent,
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ ( gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE ))
+
+ # GUI Spacing
+ self.set_has_separator(False)
+ #self.set_border_width(12)
+
+ alignment = gtk.Alignment( 0, 0, 1, 1 )
+ alignment.set_padding( 12, 12, 12, 12 )
+ self.vbox.pack_start(alignment)
+
+ vbox = gtk.VBox()
+ alignment.add(vbox)
+ vbox.set_spacing(6)
+
+ label = gtk.Label(_("<b>General</b>"))
+ label.set_use_markup(True)
+ label.set_alignment(0, 0.5)
+ vbox.pack_start(label, False, True)
+
+ alignment = gtk.Alignment( 0, 0, 0, 0 )
+ alignment.set_padding( 6, 6, 12, 0 )
+ vbox.pack_start(alignment, False, True)
+
+ generalvbox = gtk.VBox()
+ alignment.add(generalvbox)
+ generalvbox.set_spacing(6)
+
+ checkbutton = gtk.CheckButton(_("Preserve PCB elements not in the schematic"))
+ generalvbox.pack_start(checkbutton, False, True)
+
+ radiobutton1 = gtk.RadioButton(None, _("Prefer M4 footprints to file footprints"))
+ generalvbox.pack_start(radiobutton1, False, True)
+
+ radiobutton2 = gtk.RadioButton(radiobutton1, _("Prefer file footprints to M4 footprints"))
+ generalvbox.pack_start(radiobutton2, False, True)
+
+ radiobutton3 = gtk.RadioButton(radiobutton1, _("Only use file footprints"))
+ generalvbox.pack_start(radiobutton3, False, True)
+
+ label = gtk.Label(_("<b>Footprint search paths</b>"))
+ label.set_use_markup(True)
+ label.set_alignment(0, 0.5)
+ vbox.pack_start(label, False, True)
+
+ alignment = gtk.Alignment( 0, 0, 1, 1 )
+ alignment.set_padding( 6, 6, 12, 0 )
+ vbox.pack_start(alignment, True, True)
+
+ pathchooser = PathChooser()
+ alignment.add (pathchooser)
+
+ advancedoptions = gtk.Expander(_("Advanced options"))
+ advancedoptions.set_spacing(6)
+ label = advancedoptions.get_label_widget()
+ label.set_padding(6,6)
+ vbox.pack_start(advancedoptions, False, True)
+
+ advancedvbox = gtk.VBox()
+ advancedoptions.add(advancedvbox)
+
+ # GUI Spacing
+ advancedvbox.set_spacing(6)
+
+ label = gtk.Label(_("<b>M4 Options</b>"))
+ label.set_use_markup(True)
+ label.set_alignment(0, 0.5)
+ advancedvbox.pack_start(label)
+
+ alignment = gtk.Alignment( 0, 0, 1, 0 )
+ alignment.set_padding( 0, 0, 12, 0 )
+ advancedvbox.pack_start(alignment)
+
+ table = gtk.Table(3, 2)
+ alignment.add( table )
+
+ # GUI Spacing
+ table.set_row_spacings(6)
+ table.set_col_spacings(6)
+
+ label = gtk.Label(_("M4 command :"))
+ label.set_alignment(0, 0.5)
+ table.attach (label, 0, 1, 0, 1, gtk.FILL)
+
+ entry = gtk.Entry()
+ table.attach (entry, 1, 2, 0, 1)
+
+ label = gtk.Label(_("M4 PCB path :"))
+ label.set_alignment(0, 0.5)
+ table.attach (label, 0, 1, 1, 2, gtk.FILL)
+
+ entry = gtk.Entry()
+ table.attach (entry, 1, 2, 1, 2)
+
+ label = gtk.Label(_("M4 extra file :"))
+ label.set_alignment(0, 0.5)
+ table.attach (label, 0, 1, 2, 3, gtk.FILL)
+
+ entry = gtk.Entry()
+ table.attach (entry, 1, 2, 2, 3)
+
+ label = gtk.Label(_("<b>Extra gnetlist arguments</b>"))
+ label.set_use_markup(True)
+ label.set_alignment(0, 0.5)
+ advancedvbox.pack_start(label, False, True)
+
+ entry = gtk.Entry()
+ advancedvbox.pack_start(entry, False, True)
+
+gobject.type_register( ProjectOptionsDialog )
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs