amigo; I`d love to use some of GTK`s higher level widgets.
But BaCon doesn`t have them, although it can import GTK code.
I`ve tried a few times to make that work, but I have fits with the GTK code.
Gtk-Server does a lot of widgets and properties, also by the BaCon author.
GtkDialog has many widgets and properties, but it`s Puppy only.
This file selector simply uses 2 list boxes. At least I can control all of it.
As I said, the GTK FileDialog looks and works good, but it opens to the
OS`s "recently used files" and there seems to be no controlling it.
BaCon web site:
http://www.basic-converter.org/
BaCon forum:
http://basic-converter.proboards.com/
I`ve added to it using a path.conf file so it can remember it`s /path.
To use this feature, make a blank file: (appPath)/path.conf
And added a /path label.
Still no cli help ( sorry ), or any file filtering.
Here`s the new "FileDlg.bac", I didn`t post it because it`s fairly long.
Code: Select all
'### FileDlg.bac File open, save, new file, and new folder.
'# Terry Becker SunBurnt Aug. 9 2013
INCLUDE "/root/0_BaCon/BaCon/hug.bac",INIT,DISPLAY,WINDOW,LIST,STOCK,BUTTON \
,HUGENTRY,MARK,FRAME,FONT,ATTACH,CALLBACK,TEXT,GRAB$
INIT
'############### NEED File & Folder Filtering: Hidden, Extensions, & Type.
' # Close button.
SUB btnClose
END
END SUB
' # Ok button.
SUB btnOk
PRINT GRAB$(txtPF_)
' write /path to path.conf
IF FILEEXISTS(confP$) THEN
OPEN confP$ FOR WRITING AS file_
WRITELN path$ TO file_
CLOSE FILE file_
END IF
END
END SUB
' # Refresh ListBox.
SUB refLists
LOCAL p$
p$ = path$
PRINT p$
IF p$ != "/" THEN p$ = LEFT$(p$, LEN(p$)-1)
TEXT(txtPF_, p$)
TEXT(lstDir_, "")
IF path$ != "/" THEN TEXT(lstDir_, "..")
TEXT(lstFile_, "")
cmd$ = "find " & path$ & " -maxdepth 1 -type d |sed s'#^.*/##;1,1d' |sort"
SPLIT CHOP$(EXEC$(cmd$)) BY NL$ TO dirs$ SIZE dirSz
FOR i = 0 TO dirSz-1
TEXT(lstDir_, dirs$[i])
NEXT
cmd$ = "find " & path$ & " -maxdepth 1 -type f |sed s'#^.*/##' |sort"
SPLIT CHOP$(EXEC$(cmd$)) BY NL$ TO files$ SIZE fileSz
FOR i = 0 TO fileSz-1
TEXT(lstFile_, files$[i])
NEXT
END SUB
' # Dir. list click.
SUB lstDir
LOCAL d$
IF lstFlg = 1 THEN
lstFlg = 0
EXIT SUB
END IF
d$ = GRAB$(lstDir_)
lstFlg = 1
IF RIGHT$(path$, 1) != "/" THEN path$ = path$ & "/"
IF d$ != ".." THEN
path$ = path$ & d$ & "/"
ELSE
path$ = LEFT$(path$, INSTRREV(path$, "/", 2))
END IF
refLists
' PRINT " Dir.: ", d$, " ", path$
END SUB
' # File list click.
SUB lstFile
LOCAL f$
f$ = GRAB$(lstFile_)
' PRINT " File: ", f$
END SUB
' # New dir. button.
SUB btnNewDir
LOCAL d$
d$ = GRAB$(txtNew_)
PRINT d$
IF d$ = "" THEN
PRINT NL$, "### ERROR: No new folder input.", NL$
ELIF FILEEXISTS(path$ & d$) THEN
PRINT NL$, "### ERROR: Folder already exists: ", d$, NL$
ELSE
MAKEDIR path$ & d$
TEXT(txtNew_, "")
refLists
END IF
END SUB
' # New file button.
SUB btnNewFile
LOCAL f$
f$ = GRAB$(txtNew_)
PRINT f$
IF f$ = "" THEN
PRINT NL$, "### ERROR: No new file name input.", NL$
ELIF FILEEXISTS(path$ & f$) THEN
PRINT NL$, "### ERROR: File already exists: ", f$, NL$
ELSE
OPEN path$ & f$ FOR WRITING AS file_
WRITELN "" TO file_
CLOSE FILE file_
TEXT(txtNew_, "")
refLists
END IF
END SUB
' cmd. args.: dialog path
SPLIT ARGUMENT$ BY " " TO arg$ SIZE argSz
appP$ = LEFT$(arg$[0], INSTRREV(arg$[0], "/")) : ' get app`s /path
' file path.conf exists
IF argSz = 1 THEN
confP$ = appP$ & "path.conf"
IF FILEEXISTS(confP$) THEN
OPEN confP$ FOR READING AS file_
READLN path$ FROM file_
CLOSE FILE file_
IF NOT(FILEEXISTS(path$)) THEN
path$ = GETENVIRON$("HOME")
END IF
ELSE : ' no conf., get $HOME
path$ = GETENVIRON$("HOME")
END IF : ' command arg. /path
ELIF argSz > 1 THEN
IF FILEEXISTS(arg$[1]) THEN
path$ = arg$[1]
ELSE
path$ = GETENVIRON$("HOME")
PRINT NL$, "### ERROR: Bad /path argument.", NL$
END IF
END IF
IF RIGHT$(path$, 1) != "/" THEN path$ = path$ & "/"
winW = 500 : winH = 400
win_ = WINDOW(" Filer Dialog", winW, winH)
per = winW / 10 : panH = winH - 110
lstDir_ = LIST(per*4, panH)
ATTACH(win_, lstDir_, 0, 0) : CALLBACK(lstDir_, lstDir)
lstFile_ = LIST(per*6, panH)
ATTACH(win_, lstFile_, per*4, 0) : CALLBACK(lstFile_, lstFile)
frmY = winH - 100
frm_ = FRAME(winW-20, 55)
ATTACH(win_, frm_, 10, frmY)
TEXT(frm_, " Make New Files and Folders ")
y = frmY + 20
txtNew_ = HUGENTRY("", winW-205, 25) : ATTACH(win_, txtNew_, 20, y)
btnNewFile_ = BUTTON("New File", 65, 25)
ATTACH(win_, btnNewFile_, winW-175, y) : CALLBACK(btnNewFile_, btnNewFile)
btnNewDir_ = BUTTON("New Folder", 80, 25)
ATTACH(win_, btnNewDir_, winW-100, y) : CALLBACK(btnNewDir_, btnNewDir)
y = winH - 35
'txtPF_ = ENTRY("", winW-180, 25) : ATTACH(win_, txtPF_, 10, y)
txtPF_ = MARK("", winW-180, 25) : ATTACH(win_, txtPF_, 10, y)
FONT(txtPF_, "Arial 15 bold")
btnOk_ = STOCK("gtk-ok", 60, 25)
ATTACH(win_, btnOk_, winW-160, y) : CALLBACK(btnOk_, btnOk)
btnClose_ = STOCK("gtk-close", 80, 25)
ATTACH(win_, btnClose_, winW-90, y) : CALLBACK(btnClose_, btnClose)
refLists
DISPLAY
### NOTE: There
must be a blank line at the end of BaCon files.!
.