• Index
  •  » Support
  •  » File dialog path for multiple image fields

#1 2017-08-03 21:49:59

zzarko
New member
Registered: 2017-08-03
Posts: 3

File dialog path for multiple image fields

I have created custom gcm file for retro computer collection (screenshot also in attachment):

https://image.ibb.co/gGkC6a/GCStar.png

As I have several images (one on first tab, four more on the second), when adding a new item, I usually need to add several images that are on the same path. The problem is that for every image there is separate file dialog path, which means that if I have to add 5 pictures, I need to navigate to the same path 5 times, once for each image. Is there a possibility that file dialogs for different images share the same path, so that I can navigate only for first image, and to just select the images for the rest?

The relevant description from gcm file is this:

    <field default="view" displayed="Image" group="General" init="" label="Image" type="image" value="gcsfield10" />
    <field default="view" displayed="Image 1" group="Images" init="" label="Image 1" type="image" value="gcsfield11" />
    <field default="view" displayed="Image 2" group="Images" init="" label="Image 2" type="image" value="gcsfield12" />
    <field default="view" displayed="Image 3" group="Images" init="" label="Image 3" type="image" value="gcsfield13" />
    <field default="view" displayed="Image 4" group="Images" init="" label="Image 4" type="image" value="gcsfield14" />

Also, I have tried to find more information about gcm file structure, but I haven't found much. Can someone direct me where to look? I have made my gcm file mostly by experimenting and looking at included gcm files, but it would be nice to see complete documentation.

Offline

 

#2 2017-08-08 09:50:32

kerenoc
Member
Registered: 2016-03-19
Posts: 88

Re: File dialog path for multiple image fields

Hello

Could you try this little patch to see if it improves the situation?

In file lib/gcstar/GCGraphicComponents/GCPictureWidgets.pm
change

Code:

            if ($currentFile)
            {
                $imageDialog->set_filename($currentFile);
            }
            else
            {
                $imageDialog->set_filename($self->{previousDirectory});
            }

to

Code:

            if ($currentFile && -r $currentFile)
            {
                $imageDialog->set_filename($currentFile);
            }
            else
            {
                $imageDialog->set_filename($self->{previousDirectory});
            }

Offline

 

#3 2017-08-08 10:42:46

zzarko
New member
Registered: 2017-08-03
Posts: 3

Re: File dialog path for multiple image fields

kerenoc wrote:

Hello

Could you try this little patch to see if it improves the situation?

Thanks for looking into this!!!

The patch allows to set the directory to currently selected image, and works OK for that part. If I add a new item, current path for the image is empty, and I need to navigate to the image (which is OK). Unfortunately, when I want to add another new image (where previous path also doesn't exist), navigation has to be repeated.

But, you showed me where to look and I made a solution that works for me. If something like this is generally OK for others, maybe it can be included in the next version...

My version of GCStar (1.7.0) didn't have GCPictureWidgets.pm, but the relevant code was in GCBaseWidgets.pm.

Here is what I changed: I added a global variable to the beginning of the file (just below @audioExtensions definition):

Code:

our $globalPath = '';

and this is the modified dialog code (I marked my changes with comment #ADDED):

Code:

            if ($currentFile && -r $currentFile)
            {
                $imageDialog->set_filename($currentFile);
            }
            else
            {
                # ADDED: check global path
                if ($globalPath eq '')
                {
                        $imageDialog->set_filename($self->{previousDirectory});
                }
                else
                {
                        $imageDialog->set_filename($globalPath);
                }
            }
            my $response = $imageDialog->run;
            $fileName = $imageDialog->get_filename;
            $imageDialog->destroy;

            $self->{parent}->showMe;
            if ($response eq 'ok')
            {
                $self->{previousDirectory} = dirname($fileName);
                $self->setChanged if $self->{trackState};
                # ADDED: set global path
                $globalPath = $self->{previousDirectory};
            }
            else
            {
                return;
            }

Disclaimer: I don't know Perl and I'm not sure if this is the right way to do it...

Do you maybe know where I can find the documentation about GCM filke structure?

Last edited by zzarko (2017-08-08 10:56:00)

Offline

 

#4 2017-08-08 14:14:51

kerenoc
Member
Registered: 2016-03-19
Posts: 88

Re: File dialog path for multiple image fields

Hello zzarko,

It's great that you were able to patch GCstar to meet your needs. Thanks for sharing : I'll add that to the candidate changes for the next version, to be submitted to the official maintainers.

Some simple documentation is available on the official wiki but I suppose you already went through it. I'm afraid further knowledge requires to dive into existing GCM files or into the source code itself!

Offline

 

#5 2017-08-08 16:30:43

zzarko
New member
Registered: 2017-08-03
Posts: 3

Re: File dialog path for multiple image fields

Yes, I went through that, but thanks!

BTW, if there is interest for GCM file for retro computer collection to be included in GCStar, I'll gladly send it. I made it 'by hand', as I was unable to make layout that I wanted using GCStar GUI, so it may be non-strandard...

Last edited by zzarko (2017-08-08 16:32:25)

Offline

 
  • Index
  •  » Support
  •  » File dialog path for multiple image fields



Should you have a problem using GCstar, you can open a bug report or request some support on GCstar forums.