Menu

#189 nsDialogs: Initial folder for SelectFileDialog

closed-accepted
Plugin (47)
5
2008-09-16
2008-07-11
Tobbe
No

I've written a small patch for nsDialogs that enables one to specify the initial folder that will be used in a SelectFileDialog dialog.

The second parameter used to be a variable that would get the path to the file. Now this variable can also be used to specify the initial folder by setting it to the folder to use before calling SelectFileDialog. This is very similar to how Windows does it with its Open/Save dialogs.

Patch can be viewed here: http://paste2.org/followup/43756

Discussion

  • Tobbe

    Tobbe - 2008-07-11

    .patch file for browse.c

     
  • Tobbe

    Tobbe - 2008-07-20

    Logged In: YES
    user_id=1221788
    Originator: YES

    The link to view the patch should be http://paste2.org/p/43756

     
  • Amir Szekely

    Amir Szekely - 2008-08-15

    Logged In: YES
    user_id=584402
    Originator: NO

    This method of setting the initial working directory is too cumbersome for my taste. First of all, you've provided no documentation for it. It also requires a hidden switch - trailing backslash, to activate. And what if the user wants both initial directory and initial selection file?

     
  • Amir Szekely

    Amir Szekely - 2008-08-15
    • status: open --> pending
     
  • Tobbe

    Tobbe - 2008-08-17
    • status: pending --> open
     
  • Tobbe

    Tobbe - 2008-08-17

    Logged In: YES
    user_id=1221788
    Originator: YES

    Thanks for your reply

    > This method of setting the initial working directory is too cumbersome for
    > my taste.

    What do you mean "too cumbersome"? Could you elaborate?

    > First of all, you've provided no documentation for it.

    What kind of documentation are you looking for? Source code comments? Or a patch for Readme.html where I describe how this works? I'll be happy to write any kind of documentation for this patch you are looking for as soon as you are happy with the functionality

    > It also
    > requires a hidden switch - trailing backslash, to activate.

    One of the reasons I choose to implement it the way I did was to try to avoid breaking compatibility with existing scripts. I think this implementation satisfies that goal.

    > And what if the
    > user wants both initial directory and initial selection file?

    This is done the same way it already works. Just specify the full path to a file. If you set the parameter to "C:\Windows\System32\calc.exe" it will look for a file called "calc.exe" in the folder "C:\windows\system32\"

    The way the functionality is without any patch these three things works:
    "" - looks for any file
    "calc.exe" - looks for a file called calc.exe in the current folder
    "C:\Windows\System32\calc.exe" - looks for a file called "calc.exe" in the folder "C:\windows\system32\"

    My patch adds the possibility to do this
    "C:\windows\system32\" - looks for any file in the folder "C:\windows\system32\"

    Best Regards
    //Tobbe

     
  • Amir Szekely

    Amir Szekely - 2008-08-30

    Logged In: YES
    user_id=584402
    Originator: NO

    It's cumbersome due to the reasons I've listed - documentation, obscurity and being mutually exclusive with file selection option.

    For documentation I'm looking for a Readme.html patch or else the patch is not complete and I have to add stuff to it in order to apply it.

    As for the reset, you're right. You can't have both an initial file selection and and an initial folder selection and have them being different. But I still don't like the fact that you have to use a backslash to activate this. It's too obscure. It should probably check if the given path is a directory and act accordingly.

     
  • Tobbe

    Tobbe - 2008-09-16

    patch for browse.c and Readme.html

     
  • Tobbe

    Tobbe - 2008-09-16

    Of course I should check if the given path is a directory! Great idea! :)

    I've modified my patch to do just this and I've also updated the readme file. Please let me know if there's anything else you'd like me to change.

    I've attached the new patch, and it can also be viewed here: http://paste2.org/p/74793
    File Added: browse.patch

     
  • Amir Szekely

    Amir Szekely - 2008-09-16
    • status: open --> closed
     
  • Amir Szekely

    Amir Szekely - 2008-09-16

    Thanks, applied with some changes to make it compile.

     
  • Amir Szekely

    Amir Szekely - 2008-09-16
    • assigned_to: nobody --> kichik
    • status: closed --> closed-accepted
     
  • Tobbe

    Tobbe - 2008-09-16

    Eh? Compiles just fine here... I'm using vc9 to compile it

     
  • Tobbe

    Tobbe - 2008-09-16

    Ahh, I was compiling it as C++ while you are compiling it as C89. (It would have compiled as C99.)

    Good catch using INVALID_FILE_ATTRIBUTES instead of (DWORD)-1

     

Log in to post a comment.