Dialog save file

Post your Gambas programming questions here.
Post Reply
User avatar
sadams54
Posts: 139
Joined: Monday 9th July 2018 3:43am
Contact:

Dialog save file

Post by sadams54 »

I am stumped on what should be simple. I call the dialog to save a file but I want a default file name to save as in the dialog in case the person doesn't feel like typing in a filename an automatically generated one is available if they just hit ok. It should work similar to the inputbox command where you can have a default already for the user.
Anybody know how to make this happen?
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Dialog save file

Post by Cedron »

If I am understanding you right, it is simple.

Have you tried setting "Dialog.Path" to the full file specification?

Yeah, "Path" in Gambas seems to refer to file/dir specifiers, not necessarily just directories.

Ced
.... and carry a big stick!
Online
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Dialog save file

Post by cogier »

I had a look at this but it seems that the Dialogue wont let you do this. However you can do it with a FileChooser. Have a look at the attached code.

Image
File_Save.tar.gz
(79.37 KiB) Downloaded 406 times
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Dialog save file

Post by Cedron »

I tested this before I replied.
Dialog.Path = User.Home &/ "Pictures/test.jpg"
This left "test.jpg" in the filename slot.

Am I misunderstanding something?
.... and carry a big stick!
Online
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Dialog save file

Post by cogier »

Further investigation discovered that the Dialog.Path works as required using gb.qt.gui but not if using gb.gui in a GTK desktop (Linux Mint 19.1 Cinnamon).

Now why is that?
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Dialog save file

Post by Cedron »

Nice sleuthing.

I don't know, maybe should be reported as a bug. I do know from the mailing list that qt is less "troublesome" for lack of a better word, perhaps more supported/preferred, than gtk. I do all my desktop projects as qt.
.... and carry a big stick!
User avatar
sadams54
Posts: 139
Joined: Monday 9th July 2018 3:43am
Contact:

Re: Dialog save file

Post by sadams54 »

nobody is missing anything. I did it with the dialog.path but it still does not work. I am using gtk which I have found to be the least troublesome.
The idea behind this is that I want to save a file from a program. I want to provide a default name for the user that includes date information in the file name, but still want the user to be able to name it as they wish and just leave a suggestion. I have discounted the idea of extra questions for default names. The user may not be all that smart and I prefer to keep it as simple as I can.
Online
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Dialog save file

Post by cogier »

As you want to use 'gtk' the only way I could find to do what you want is to use a FileChooser. Have a look at the attached code which is similar to the code I posted above. I hope it helps.
SaveFile.tar.gz
(13.28 KiB) Downloaded 396 times
Post Reply