Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 18 Dec 2014, 00:11
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
A custom File & Folder selector.
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 7 Posts_count   Goto page: 1, 2, 3, 4, 5, 6, 7 Next
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Sat 10 Aug 2013, 04:33    Post_subject:  A custom File & Folder selector.  

I made this exec. popup selector to replace xdialog and GTK+ FileDialog.

It`s simple, but is more straightforward and not nearly as ugly as xDialog.
If there`s interest I`ll add filtering for: hidden, extensions, and file types.

Being as it`s a exec., I`m also going to add help ( none yet ).
One optional argument for the path the dialog starts in, defaults to $HOME

Usage: /path/FileDlg [dialog open /path]

BaCon web site: http://www.basic-converter.org/
BaCon forum: http://basic-converter.proboards.com/

### New version:
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: /(FileDlgPath)/path.conf
And added a /path label.
Still no cli help ( sorry ), or any file filtering.
0_FileDlg.png
 Description   
 Filesize   20.47 KB
 Viewed   1130 Time(s)

0_FileDlg.png

FileDlg.gz
Description 
gz

 Download 
Filename  FileDlg.gz 
Filesize  48.85 KB 
Downloaded  258 Time(s) 

Edited_times_total
Back to top
View user's profile Send_private_message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3982
Location: Kiel,Germany

PostPosted: Sat 10 Aug 2013, 05:45    Post_subject:  

I have learned to live with the Xdialog fileselect .

Problem was mainly that authors some hundred years ago, when Puppy was intended to run on 1-inch display smartphones, made it look crippled by putting in some too weird tiny screen dimensions in them .

Your exec looks ok to me - it's slightly bit big ( stripped 162KB ) - but that does not matter to me .

What I could not find out about was the input line and the Open button .
Back to top
View user's profile Send_private_message Visit_website 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Sat 10 Aug 2013, 13:17    Post_subject:  

Hey Karl; I guess I should have used an "OK" button.

And I`ll have to add a "selected /path(/file)" text box too for a visual.

The input line is for new file and folder names ( need a label for that...).
Back to top
View user's profile Send_private_message 
amigo

Joined: 02 Apr 2007
Posts: 2287

PostPosted: Sat 10 Aug 2013, 15:01    Post_subject:  

Xdialog simply calls the built-in GTK file-selector widget. How about posting your sources?
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Sun 11 Aug 2013, 01:09    Post_subject:  

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:

'###   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.!
.

Edited_times_total
Back to top
View user's profile Send_private_message 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Sun 11 Aug 2013, 05:18    Post_subject:  

@ Terry,

Useful little dialog. Thanks.

@ Karl

To make the binary smaller, use the following compile line:

Code:
 bacon -o -s -o -Os -o -fdata-sections -o -ffunction-sections -o -Wl,--gc-sections "$myfile"


Then use UPX to shrink the binary further. This yields a 32-bit executable of 22k. There is no run-time detriment or down side, except a nice, small size. Smile

With kind regards,
vovchik
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Sun 11 Aug 2013, 12:54    Post_subject:  

vovchik; Thanks for the "shrink bacon exec." pointer.
Could you post code to UPX it also?
And I noticed that my Puppy version doesn`t have UPX.

Also... Who at the BaCon site is best at understanding and importing GTK.?
Besides Peter himself that is...
I need code for the widget`s import lines and many of it`s useful properties.
We need hug type libraries of higher level widgets, and to add properties.
Gtk-Server has a lot in it, but I can`t get the GTK code to work in BaCon.
Main ones: menu, tree, table, popbuttons, ( rich text & charts, if exist...), etc.
.
Back to top
View user's profile Send_private_message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3982
Location: Kiel,Germany

PostPosted: Sun 11 Aug 2013, 13:31    Post_subject:  

http://upx.sourceforge.net/download/00-OLD-VERSIONS/
http://upx.sourceforge.net/
I remember It compiled fine .
Cannot remember
Source code (you will need UCL)
http://www.oberhumer.com/opensource/ucl/ anymore .

It's upx -9 binary .
Like any other packer (gzip, bzip2, ..)
Makes an exe 40-50% smaller in -9 mode . Some bins seem to run slower though ( busybox ) .
Back to top
View user's profile Send_private_message Visit_website 
mikeb


Joined: 23 Nov 2006
Posts: 9002

PostPosted: Sun 11 Aug 2013, 14:28    Post_subject:  

Hmm perhaps this might be of interest
http://code.google.com/p/yad/

Highly customisable file dialogs plus other goodies such as calender, list boxes, forms, systray icon, slider, progress etc.
Some interesting ideas on site for such as a usb automounter gui and a tail/log box. All done in c and gtk so same dependencies as other simple gtk apps. I knocked up a binary of 0.9.1 as this will work on gtk 2.12+ . It came out at 74k stripped. see --help for options or the website.

yad --file-selection --file-filter=*.c --geometry=500x400+50+5
sample command line produces the screenshot
and returns the selected file on ok.

mike

edit updated download to include a bugfix found in a later version that may affect use
Yad-v3.tar.gz
Description 
gz

 Download 
Filename  Yad-v3.tar.gz 
Filesize  31.9 KB 
Downloaded  245 Time(s) 
yad.png
 Description   
 Filesize   29.65 KB
 Viewed   940 Time(s)

yad.png


Edited_time_total
Back to top
View user's profile Send_private_message 
greengeek

Joined: 20 Jul 2010
Posts: 2739
Location: New Zealand

PostPosted: Sun 11 Aug 2013, 15:24    Post_subject:  

Does this permit "single-click" operation or is it still restricted to double-click use like previous file-choosers?
Back to top
View user's profile Send_private_message 
mikeb


Joined: 23 Nov 2006
Posts: 9002

PostPosted: Sun 11 Aug 2013, 16:54    Post_subject:  

Quote:
Does this permit "single-click" operation or is it still restricted to double-click use like previous file-choosers?


Well on Slax my gtk2 filebrowser shortcuts are single click but on puppy (same gtk version) they are double click so perhaps this is a system issue. A new thread entitled 'why is puppy odd?' would be a good idea.

mike
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Sun 11 Aug 2013, 17:15    Post_subject:  

Thanks mikeb, I`ve thought about yad but never looked at it.
My Puppy already has it.
Your pic shows the same "Recent", is it the default path at startup?

Karl; Thanks dude, I downloaded it, and I`ll look at it.
Back to top
View user's profile Send_private_message 
mikeb


Joined: 23 Nov 2006
Posts: 9002

PostPosted: Sun 11 Aug 2013, 20:17    Post_subject:  

Well after noticing your thread i decided to nosy around the net and came across it. It looks like a useful bag of tricks and fills in some blanks left by gtkdialog and others for script writers. I will have a play with some existing guis when I get a chance though gui from command line rather than xml seems quite appealing and simple. The form widget especially so. Ease of use and low requirements are the aim while providing a myriad of options.

I tested out an older release to get earlier gtk compatability but it also means its simpler (less gtk3 etc) as it seems to me something that could be forked for puppy purposes.... lose some features and add others.

Quote:
Your pic shows the same "Recent", is it the default path at startup?

opening folder (and file) is configurable as is extension filter and save file / folder only modes.... stuff I have wanted in the past with gtkdialog...though the latter can have a default folder setting as I discovered.

mike
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Sun 11 Aug 2013, 22:03    Post_subject:  

mikeb; Lots of possibilities, too many to notice them all.
I`m going to look at yad, looks like a possible replacement for GtkDialog.

Initial look at yad looks so so, yad --list is only a dialog with 2 buttons, no list.
And the file dialog doesn`t seem to have any startup other than "Recent".
I`ll go to the web site and see if there`s more to it.

My main thrust here is lack of control over even simple dialogs.
Building them yourself allows you to do almost anything.
GTK+ has lots of methods and properties, but only C can access them.
Back to top
View user's profile Send_private_message 
mikeb


Joined: 23 Nov 2006
Posts: 9002

PostPosted: Mon 12 Aug 2013, 08:51    Post_subject:  

Try yad --help-all .... all will unfold...the 2 button gui does make you wonder what its all about Very Happy

sample...
tail -f /tmp/tag.txt | /tmp/usr/bin/yad --text-info --tail
makes a log box like gtklogfileviewer.
You can pipe for the purposes of a non redrawing drive gui....
check out the site for some interesting uses.

Quote:
GTK+ has lots of methods and properties, but only C can access them.

which yad seems to provide just that framework...bear in mind my test sample is version 0.9.1 and its up to 0.22....
Not sure about replacing gtkdialog but it certainly would supply a good set of widgets to get as near to using c as possible for scripts and less problems with variable handling and function nestng and so on. Plus visually working with gtkdialog all would appear seamless... one to suck and see...
edit......perhaps a fresh thread is needed to give examples of usage rather than this serious hyjacking that seems to have occured...
mike
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 7 Posts_count   Goto page: 1, 2, 3, 4, 5, 6, 7 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1133s ][ Queries: 12 (0.0045s) ][ GZIP on ]