← Back to team overview

kicad-developers team mailing list archive

Re: PlEditor issues

 

On 08/29/2013 09:33 AM, Wayne Stambaugh wrote:
> On 8/29/2013 10:17 AM, jp charras wrote:
>> Le 29/08/2013 16:06, Dick Hollenbeck a écrit :
>>> On 08/29/2013 08:02 AM, Wayne Stambaugh wrote:
>>>> On 8/29/2013 2:16 AM, Lorenzo Marcantonio wrote:
>>>>> On Wed, Aug 28, 2013 at 11:05:34PM +0100, Brian Sidebotham wrote:
>>>>>> (4) When saving a page layout the .kicad_wks extension doesn't get
>>>>>> added to
>>>>>> the filename.
>>>>>
>>>>> This is common to many file dialogs, by the way...
>>>>
>>>> This is a known problem with the GTK+ version wxWidgets 2.8.  It's been
>>>> this way since I got started with the project.  I'm not sure it's been
>>>> fixed in 2.9.  The solution is to create a wxFileName object using the
>>>> path returned from the file dialog and check if it has a file extension.
>>>>   If it doesn't, set the file extension to the appropriate value.
>>>
>>> This is good behaviour to have in a dialog.  "Extension enforcement."
>>>
>>> We should do it more often.  I vaguely remember adding it to the save
>>> board code (and its
>>> a miracle that I remember), something like what Wayne is saying.  For
>>> without that, the
>>> user cannot know if he's working with a *.brd file or a *.kicad_pcb
>>> file, nor can KiCad
>>> easily know next time loading.
>>>
>>> But as I think of it now, just checking that it has an extension is
>>> probably not enough,
>>> verifying that the extension is the correct one is more correct.
>>>
>>> wxFileName may have the notion that the last segment after a period is
>>> the extension, when
>>> in fact it could be part of a base filename with a period in it.  So
>>> if perfection is desired:
>>>
>>> Simply over writing the last thing falsely known as the extension
>>> within the wxFileName
>>> would be munging the basename inappropriately.  So maybe the best
>>> algorithm is to use
>>> wxFileName to parse the filename, see if the extension *matches*, and
>>> if not, go back to
>>> the original full filename string outside the wxFileName, and then
>>> concatonate the correct
>>> extension.  This leaves the user's full filename with more than one
>>> period in it.
>>>
>>> Superimposing a restriction on base filenames seems inappropriate and
>>> unnecessary with the
>>> above strategy.
>>
>> Good idea.
>> I'll commit this change in Pl_Editor in my next commit.
>>
>>
> 
> It might be a good idea to make this a helper function or member of an
> appropriate object so that it can easily be reused for other file
> dialogs rather having to cut and paste the code.


Excellent idea.

Maybe both:

a) a context free utility function.

b) a wrapper class that extends wx filename dialog (spelling?) that calls the utility
function towards the end of the choosing process.



Then, we are simply in the business of changing the name of the filename dialog class
everywhere.  It is sort of like DIALOG_SHIM, but rather than a shim, its a wrapper.

I also have felt we need to do this for error reporting also, being able to establish
policy in one place is nice.  Maybe someday we can add a stack trace in the debug builds,
or encapsulate logging in that window also.



> 
> 
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 



References