DOCUMENTATION

SYNOPSIS PERL PERL PROGRAM NAME: file_dialog.pm AUTHOR: Juan Lorenzo DATE: May 16 2018

DESCRIPTION 
    
BASED ON:

previous version (V 0.0.1) of the main L_SU.pl (V 0.3)
 

USE

NOTES

Examples

CHANGES and their DATES

V 0.0.3refactoring of 2017 version of L_SU.pl

Feb 24 2020
V 0.0.4 incldue PL_SEISMIC as a file_dialog_type
This new file dialog type automatically opens
PL_SEISMIC path.

August 2021
initialize default values

V 0.0.5 
flow-selection is detectable with a subroutine
hool _SelHook

Declare local variables

private hash

private variables

sub _FileDialog

	Collects name of file to be opened
	Mega-widget
	
     print ("my file is $file_dialog->{_selected_file_name}\n");
     will NOT:
        print ("1. label is @{$file_dialog->{_ref_labels_w}}[$first]->cget('-text') \n");

    WILL print:
     print ("2. label is  $out\n");

     $who[$first] = $parameter_values_frame->focusCurrent;
     print("who is $who[$first]\n");
     if ($who[$first] eq @{$file_dialog->{_ref_values_w}}[$first]) { 
       print("who is also @{$file_dialog->{_ref_values_w}}[$first]\n");
       print ("2. label is  $out\n");
     }

   Assume that file name in labels is always first
   print ("1. Full path is  $file_dialog->{_selected_file_name}\n");

	'Cancel' returns undefined file name

sub _SelHook

confirm that a file was selected print( "file_dialog,_FileDialog,last path is $file_dialog->{_last_path_touched} \n" );

_big_stream_Home

_big_stream_last_dir_in_path

sub _big_stream_Home_close

 re-organizing the display after a directory (path) is selected

   TODO: CASE of opening a pre-existing superflow configuration file
       or previously scripted flow by this GUI
       BEFORE or While the menubutton OR Frame are selected
       

sub _big_stream_last_dir_in_path_close

 re-organizing the display after a directory (path) is selected

   TODO: CASE of opening a pre-existing superflow configuration file
       or previously scripted flow by this GUI
       BEFORE or While the menubutton OR Frame are selected
       

sub _get_dialog_type

Open as Open ( in GUI (perl programs of user-built flows)

Save/seen as Save  in GUI ((perl program of user-built flow and pre-built superflows)

SaveAs/seen as SaveAs   in GUI ((perl program of pre-built superflows)

Delete/see as Delete in GUI (user-built flows or any file in $PL_SEISMIC)

sub _get_path

_dialog_type can be seen in GUI as
	 'Data'/open, 
	 'SaveAs' or 
	 'Save'
	 'Open'/open
	 
	 within program we also have 'Path' or directory

sub _set_file_path

_dialog_type, which can be seen in GUI as
	 'Data'/open, 
	 'SaveAs' or 
	 'Save'
	 'Open'/open
	 Only used by _user_built_flow_SaveAs_perl_file

sub _get_flow_type

user_built_flow
or
pre_built_superflow

sub _pre_built_superflow_close_data_file

  reorganizing the display after a file is selected

  'menubutton' is for our macro sunix tools
  'frame' is for the regular sunix programs

  TODO: CASE of opening a pre-existing superflow configuration file
        or previously scripted flow  by this GUI
        BEFORE or While the menubutton OR Frame are selected

    # if(entry_button_chosen('file_name') != $failure) {
    # if($file_dialog->{_current_widget} eq 'menubutton' ||  $file_dialog->{_current_widget} eq 'frame' ) { 
		print("file_dialog,_pre_built_superflow_close_data_file, is superflow? $file_dialog->{_is_superflow_select_button}\n");
		print("file_dialog,_pre_built_superflow_close_data_file, is flow? left lstbox:$file_dialog->{_is_flow_listbox_grey_w},right:$file_dialog->{_is_flow_listbox_green_w} \n");

 # Seen as DATA
 Open/data is used to open a data file
 

sub _pre_built_superflow_close_path

 re-organizing the display after a directory (path) is selected

   TODO: CASE of opening a pre-existing superflow configuration file
       or previously scripted flow by this GUI
       BEFORE or While the menubutton OR Frame are selected
       

_pre_built_superflow_open_data_file

		print("file_dialog, _pre_built_superflow_open_data_file, flow_item_up_arrow_button: $file_dialog->{_flow_item_up_arrow_button}\n");
	 	foreach my $key (sort keys %$file_dialog) {
 		print (" file_dialog,key is $key, value is $file_dialog->{$key}\n");
    }

_pre_built_superflow_open_path

a directory path

sub _set_FileDialog2user_built_flow

{_Data}  	...	open pre-existing data file
{_Open} 		...	open pre-existing user-built flow
{_SaveAs} 	...	save a new user-built flow
{_Save} 	    ...	re-save a user-built flow 
{_Delete} 	...	delete a user-built flow, but any file can be removed

sub _set_selected_file_name

sub _user_built_flow_Delete_perl_file

	foreach my $key (sort keys %$file_dialog) {
		print (" file_dialog,key is $key, value is $file_dialog->{$key}\n");
   }

sub _user_built_flow_SaveAs_perl_file

	foreach my $key (sort keys %$file_dialog) {
		print (" file_dialog,key is $key, value is $file_dialog->{$key}\n");
   }

sub _user_built_flow_close_data_file

	if ($topic eq  'Data') {   # Seen as DATA
	Select was used to open a data file
	But now the _FileDialog is closing
	If we are in here it is because we are adding
	a data-file name to the entry widget under a parameter value
	
   We are already inside an Entry Widget!!
   
   		    foreach my $key (sort keys %$gui_history) {
   		print (" file_dialog key is $key, value is $file_dialog->{$key}\n");
  	}
  				

sub _user_built_flow_close_path

if ($topic eq  'Path') {   
Select was used to open a diretory path
But now the _FileDialog is closing
	

sub _user_built_flow_close_perl_file

sub _user_built_flow_open_data_file

	seen in the GUI as "File/Data"
	opens data sets for a user_built_flow
	aka Data
 	Select is for pre-existing Data Sets
 	Then updates the GUI param widgets
 	The updated param values should be saved the next time that the flow is selected
 	
 	TODO make sure that when a differently-colored flow is selected the updated widgets
 	are stored
 	
 			foreach my $key (sort keys %$file_dialog) {
           		print (" file_dialog,key is $key, value is $file_dialog->{$key}\n");
    		}
 	

sub _user_built_flow_open_path find and get a directory path

sub _user_built_flow_open_perl_file Open flows written in Perl

foreach my $key (sort keys %$file_dialog) { print (" file_dialog,key is $key, value is $file_dialog->{$key}\n"); }

get_selected_Entry_widget

get_current_index

sub get_file_path

obtain the full PATH needed to read and write Perl files

sub get_hash_ref

 bring gui history parameters in to share
 and update
 initialize default parameter values from gui_history
 needed herein

	 

sub get_is_file_selected

return whether a file was selected
by FileDialog

sub _clear_perl_flow_name_in

sub get_perl_flow_name_in

sub get_perl_flow_name_out

sub get_last_parameter_index_touched_color

sub get_selected_file_name

sub get_values_aref

return reference to array of values
belonging to one program 
(parameter values in Entry widgets within GUI)

sub set_dialog_type

open (data for user-built and pre-built superflows)

open (perl programs of user-built flows)

save (perl program of user-built flow)

sub set_prog_name_sref

in order to know what
_spec file to read for
behaviors

sub set_flow_color

sub set_flow_type

user_built_flow
or
pre_built_superflow

sub set_hash_ref

bring in important values and their keys 

sub FileDialog_director

Associates the type of file-opening process with the correct module

Cleans previously used variables such as file names and file paths

sub set_file_dialog_sub_ref