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 Wed 26 Apr 2017, 12:05
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Building a universal file viewer
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 8 [114 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8 Next
Author Message
drunkjedi


Joined: 24 May 2015
Posts: 676

PostPosted: Fri 03 Feb 2017, 07:39    Post subject:  

In latest Fatdog64 710, when you click a button, say 'b'.
Rox will select all files that has 'b' in it's name, also a dialogue appears at bottom of rox window showing, "Reg Select (i):" and 'b' is typed in it.

Then say you type 'u', it gets typed into that dialogue after 'b' and the selection gets shorter to show files with 'bu' in their name.

I have not seen this function in rox in other pups.
MochiMoppel wrote:
I find it hard to believe that this works. ROX-Filer uses single characters !,? or = as shortcuts and the user can define more single letters as menu shortcuts. It has to be either jump to file or honor shortcut. ROX-Filer can hardly do both at the same time.
How to set shortcuts in Rox? In what file do they get saved? So that I can inspect that file in Fatdog.
I read somewhere I can set a shortcut in rox by hovering mouse pointer over a menu item and clicking key or combination of keys you want to assign as shortcut.



Anyway I found this accidentally....
Now that I have /bin open in rox and files with 'bu' in their names selected...

Now If I middle click mouse any text field, I get...

/bin/bashbug /bin/bunzip2 /bin/busybox /bin/busybox-applet-list /bin/busybox-cron /bin/busybox-init /bin/busybox-inotifyd /bin/busybox-logger /bin/busybox-login

The selected files with their path... I didn't know that. Lol.


Edit: Just adding gif screen capture of rox. Sorry for image quality. Just learning to make gif.

Last edited by drunkjedi on Fri 03 Feb 2017, 09:24; edited 2 times in total
Back to top
View user's profile Send private message 
drunkjedi


Joined: 24 May 2015
Posts: 676

PostPosted: Fri 03 Feb 2017, 07:46    Post subject:  

MochiMoppel wrote:
@drunkjedi: Thanks for testing in 64bit Puppies.
I only tested in Fatdog.

In Fatdog xclip is not present.
But still it works.

Only thing is when I open the wallpaper folder on my drive and browse 1920x1080 images, the previews are shown zoomed original size, so only part of image is viewed.
Is it because of xclip?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1246
Location: Japan

PostPosted: Fri 03 Feb 2017, 09:00    Post subject:  

drunkjedi wrote:
How to set shortcuts in Rox?
Explained by disciple here (a thread you visited and bookmarked Wink )
Quote:
In what file do they get saved?
/root/.config/rox.sourceforge.net/ROX-Filer/menus2
Quote:
Only thing is when I open the wallpaper folder on my drive and browse 1920x1080 images, the previews are shown zoomed original size, so only part of image is viewed.
I tried to explain that in the Technical Notes and I also tried to explain why I don't scale images to fit the viewer pane. Nothing is zoomed. You will see more/less of the image when you resize the QuickViewer window.
Back to top
View user's profile Send private message 
drunkjedi


Joined: 24 May 2015
Posts: 676

PostPosted: Fri 03 Feb 2017, 09:20    Post subject:  

How silly of me.

Sorry I forgot that.
Back to top
View user's profile Send private message 
drunkjedi


Joined: 24 May 2015
Posts: 676

PostPosted: Fri 03 Feb 2017, 09:37    Post subject:  

Ok In Fatdog's /root/.config/rox.sourceforge.net/ROX-Filer/menus2 I see following line
Code:
; (gtk_accel_path "<filer>/Select/Reg Select..." "asciicircum")
Do you think that's it?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1246
Location: Japan

PostPosted: Fri 03 Feb 2017, 11:23    Post subject:  

It solves the mystery. Doesn't match your earlier explanation ("when you click a button, say 'b'. Rox will select all files that has 'b' in it's name"). Your code shows that Fatdog has an additional menu entry Select > Reg Select... which can be accessed with shortcut '^' (aka asciicircum). This will open the Reg Select box. I don't know what you mean by "click a button b".
It is very different from the "jump to file" functionality and is very similar to Select > Select by name... , a standard feature in ROX. If you like you can assign the same '^' shortcut to it and it should give you exactly the same result. You only have to go to the trouble and type *bu* instead of bu.

drunkjedi, I think we should not follow up on this any more. At least I get the idea what makes Fatdog fat Laughing
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 822

PostPosted: Fri 03 Feb 2017, 18:54    Post subject:  

@drunkjedi, Fatdog-710 ships with two ROX filer versions, the "legacy" version, and the enhanced "jun7" ROX filer. Enhanced "jun7" is set as system default. You can switch to the "legacy" ROX version this way:
1. Add this line to /root/.fatdog/defaultprograms
Code:

  DEF_ROX="/usr/local/apps/ROX-Filer/AppRun"

2. Restart X or reboot.

This change is permanent until you revert /root/.fatdog/defaultprograms and reboot.

_________________
Fatdog64-710|+Packages|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1246
Location: Japan

PostPosted: Sat 04 Feb 2017, 09:38    Post subject:  

Update 2017-02-04 (see also initial post)

Shift+Click opens file in editor
There is no elegant way to achieve this with gtkdialog but I tried to keep the code simple. It now functions (almost) the same as in ROX-Filer.

ID3 metadata (MP3 tags)
This requires ffprobe and displays the ffprobe output in the viewer pane. The output normally looks jagged with a proportional font. I tinkered with a combination of wide unicode spaces and most of the metada now line up vertically. May not work with all Puppies.

Autoplay
This requires ffplay and plays audio tracks in the background. This is largely functional but not yet final. Regard it as experimental. It is disabled by default. To hear this in action change the AUTOPLAY variable at the beginning to '1'.
To stop the audio: Press ESC key or change to non-audio file or close the window or dbl-click the file, which will stop ffplay and start to play the file in the default player.
Audio keeps playing when the user selects a different directory with the path-bar (that's the button row at the top). Look at it as feature: The music doesn't stop until the user selects a new song Laughing
mm_quickview.png
 Description   QuickView has no problems with Japanese MP3 tags. MPlayer failed.
 Filesize   86.28 KB
 Viewed   394 Time(s)

mm_quickview.png

Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1347
Location: The other Mr. 305

PostPosted: Sat 04 Feb 2017, 15:05    Post subject:  

Interesting. The auto-play seems to work okay on MP3's and also seems to play the audio of MP4 files.
Back to top
View user's profile Send private message 
dejan555


Joined: 30 Nov 2008
Posts: 2794
Location: Montenegro

PostPosted: Sat 04 Feb 2017, 19:02    Post subject:  

I see how this can be usefull, nice script. I might add some stuff. Works on dpup 487, I don't have the "pkill" command here though.
For bigger images maybe adding scrollbars for start? This could be solved with some external programs which would check for image dimensions first but it's a lot to require just for a little script. ffplay is ok since it comes with a lot of puppies I think but there isn't really some light and common app that would do it for images too. Does someone know if new mtpaint cmd feature can print image dimensions?

EDIT: Also scale could be a user-set variable, because if you turn it "off" you can just set width/height variable to -1 and it will ignore scaling.

_________________
Dpup 487 | Puppy Gallery | My photo gallery | mtPaint works
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
some1

Joined: 17 Jan 2013
Posts: 70

PostPosted: Sun 05 Feb 2017, 09:52    Post subject:
Subject description: Suggestion:Maintain/publish a barebone script
 

MochiMoppel:
Thanks for the fish
Well constructed,coded.

I can imagine a lot of add-ons,implemented in various ways

For various reasons it may not be convenient to stuff everything into one script.
So to please everyone I think that it would be nice - if you ALSO maintained and published a barebone/blueprint-script- somewhat like your original script.
Just a suggestion.Its your thread/baby.
----
I gleaned the original code,and it seem rather puppy-distro agnostic.
Needs:
1)A Bash that can do regex
2)A newish MIME-database - thats woofed,I guess
3)The usuak busybox,no busybox problem - i.e. pkill
4) GTKCHOOSER seems ok.Nice digging,implementation
5)32 or 64 MB is irrelevant

I gave the code a spin on an oldish puppy:
1)I could not access the proc-dir,because proc did not have a MIME-type.
Thats a distroimplementation thing.Your script just hang,polling.No sweat - that was not a normal,newish puppy.
2)More important:
Clicking a header in the TREEVIEW-part of CHOOSER - i.e. sorting the column- had the result that afterwards I was unable to make a selection,the script became unusable.
RESORT - and the script was back to normal.
CHOOSER is a composite widget involving the TREEVIEW-widget.
In TREEVIEW we have the possibility of setting header-clickable="false".
That possibility seem to have been lost in construction of the composite
widget.Check it out.
--
You wrote,that you thought,that bash has a 128Kb limit.
The constraint is MAX_ARG - which nowadays is big enough to handle everything in normal usage.Max-content-size in a bash-variable is rather unrestricted.
The closest culprit is GTK/GTKDIALOG - which have various memoryconstraints.Try to view a big-enough-file in the viewpane - and your scripts crashes gracefully.
Big files load very slowly into the viewpane.
So - to reduce stutter/avoid crashes implementing a test for filesize
could be relevant for some uses/users - but that overhead is probably not needed generally.
---
Level up for everyone.
Thanks.
Back to top
View user's profile Send private message 
some1

Joined: 17 Jan 2013
Posts: 70

PostPosted: Sun 05 Feb 2017, 15:37    Post subject:
Subject description: Imagehandling
 

I once did what dejan555 indicated,but in a different context.

The codepieces below works in your original script.

EDIT: 8-2
Correcting some sloppyness:
1) we obviously need to export the MAXUNSCALED-vars
2) we dont need x=$(NF-2) y=$NF in the "image"-awk-code - so the cruft is deleted
---------


1. Globalvars - inject f.x after GEOMETRY
Code:

PR_X=500
PR_Y=500
export MAXUNSCALED_X="400"
export MAXUNSCALED_Y="400"

2. Make 2 pixmaps -instead of 1
Code:


      <pixmap width-request="'$PR_X'" height-request="'$PR_Y'">
      <variable>vPMAP</variable>
      <input file>'"$IMGELNK"'</input>
      <width>-1</width><height>-1</height>
      </pixmap>
      </vbox>
      
      
       <vbox>
      <pixmap width-request="'$PR_X'" height-request="'$PR_Y'">
      <variable>vPMAP2</variable>
      <input file>'"$IMGELNK"'</input>
      <width>'$MAXUNSCALED_X'</width><height>'$MAXUNSCALED_X'</height>
      </pixmap>


3. Imagehandling - light
Inject this instead of the vanilla image-handling
Code:

#imagehandling
    *│*image*|*'.xpm '*|*'.svg '*|*'.gif '*)
    nbpic=0
   
    case $vSTATUSBAR in
    *'.xpm '*) nbpic=1;;
    *'.svg '*) nbpic=2;;
    *'.gif '*)
            ctl=`file -b "$vCHOOSER"|awk -v mw="$MAXUNSCALED_X" -v mh="$MAXUNSCALED_Y" '{if ($(NF-2)*$NF!=0){if ($(NF-2)<=mw&&$NF<=mh){z=1} else z=2;print z;}}'`
            case $ctl in
             1) nbpic=1;;
             2) nbpic=2;;
             *) echo : ;;
            esac     
      ;;
     
   *│*image*)
            ctl=`exiv2 -ps "$vCHOOSER"|awk -v mw="$MAXUNSCALED_X" -v mh="$MAXUNSCALED_Y" 'NR==4&&NF>3{if ($(NF-2)*$NF!=0){if ($(NF-2)<=mw&&$NF<=mh){z=1} else z=2;print z;}}'`
             case $ctl in
             1) nbpic=1;;
             2) nbpic=2;;
             *) echo : ;;
            esac
    ;;
      
   esac

   echo $nbpic > $NB_PAGE
   ln -fsn  "$vCHOOSER"  $IMGELNK
   ln -fsn  /dev/null    $FILELNK
   
;;
##imagehandling



Some comments:
1. The above handles the most common image types in puppy-land.
2. In the light-version I assume that the size of xpm's allways are below the limit- so scaling xpm´s is not considered.
"Likewise" svg¨s is assumed to allways need scaling.
This implies that - if we encounter svg-icons - they will be scaled.
3. In case mtpaint dont have "identify"-code we have to resort to other tools presumably present.
Exiv2 covers several images - especially png,jpgs matters.
The fallback for not covered imagetypes is _file_
However each imagetype needs a special parsing of the _file_.output.
Gifs are normally smallsized - but do exist on every puppy -
so I used it as an example of using _file_.

xpms - and especially svgs are NOT identical with respect to the
the parsing needed to fetch the metrics.We have to write our own parser -
if we want a more heavier version.
Bottomline:The codesize surges if we want to cover all image-types
with specific parsingcode.
4. My construct above is a bit heavy on cases - because I wanted to get rid of the repititive lnk-lines
5. *) echo : ;; is there because if we dont get valid metrics i.e nbpic=0 - we could let it pass,display a default-error-pic or whatever we fancy.Otherwise we dont need that case.
6. Awk is just a validator,parser to resolve the ctl-value.
Bash,shell-scripters may be tempted to inject vars directly in
awk-code - but in doing so we plague awk with speedbumps.
Use the -v switch.
----
----
----
We can get a lot of kicks out of MochiMoppels baby - but as I
indicated in the previous post we might want to restrain ourselves a bit:
Showing the listings of every packer with a list option may not allways be what we want

Inquiring minds may want this:
Code:

    *x-exec*|*sharedlib*)
     strings "$vCHOOSER" >$MSGFILE && $(hexdump -C "$vCHOOSER" >>$MSGFILE)
     ln -fsn  "$MSGFILE"   $FILELNK
     ;;
      *x-shell*)
      ln -fsn  "$vCHOOSER"  $FILELNK
     
      ;;


NOTE: the x-exec..: first comes strings,then the hexcodes.

Last edited by some1 on Tue 07 Feb 2017, 23:57; edited 1 time in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1246
Location: Japan

PostPosted: Mon 06 Feb 2017, 05:18    Post subject:  

One general remark: I started this project to learn more about chooser and if it can be used as a text viewer. This is something I haven't found in Puppy so far. To build an image viewer was the last thing on my mind. There are plenty already available. So yes, it's basic, but it is functional and a "real" viewer for large images is only a (double) click away. Even the text support is still basic. I could post more code for less common codesets but this would only bloat the script and would make it more and more difficult to understand how this all is intended to work. Here is my rough roadmap:
1) Broaden the functionality with simple (sample) code
2) Look out for bugs (they are real - I've seen them already)
3) Deepen functionality
4) Streamline, prettify and clean the code (this job will never end)

dejan555 wrote:
For bigger images maybe adding scrollbars for start?
AFAIK pixmap doesn't support scrollbars
some1 wrote:
it would be nice - if you ALSO maintained and published a barebone/blueprint-script- somewhat like your original script.
Let me think of it. I can't promise anything Laughing
some1 wrote:
1)I could not access the proc-dir,because proc did not have a MIME-type.
I doubt that this is the reason. /proc is accessible sometimes, sometimes it is not. When it is not accessible I also can't open it with chooser's big brothers, e.g. the Open dialog in Geany. I figured that this has nothing to do with the script or gtkdialog. Well behaving users shouldn't have business in /proc anyway Wink
some1 wrote:
Clicking a header in the TREEVIEW-part of CHOOSER - i.e. sorting the column- had the result that afterwards I was unable to make a selection,the script became unusable.
I can't reproduce this. I would appreciate if you could find the root cause or at least a scenario that triggers this bug.
some1 wrote:
Big files load very slowly into the viewpane. So - to reduce stutter/avoid crashes implementing a test for filesize could be relevant for some uses/users
How slow is "very slowly"? Are you talking about text files? I don't expect anyone to read novels in the viewer. Log files can be big, but even 3MB monsters pose no problems. I've tested with insane and unrealistic 10MB files, that's not really smooth anymore but not unbearable either. Image files can cause stutter, but then I would assume that the user switches to a dedicated viewer.

Thanks for your sample code. I will respond separately and will also add a "special barebone edition" which will contain your code - and my changes Laughing
Back to top
View user's profile Send private message 
belham2

Joined: 15 Aug 2016
Posts: 628

PostPosted: Mon 06 Feb 2017, 14:44    Post subject:  

MochiMoppel wrote:
Update 2017-02-04 (see also initial post)

Shift+Click opens file in editor
There is no elegant way to achieve this with gtkdialog but I tried to keep the code simple. It now functions (almost) the same as in ROX-Filer.




mochi,

It may not be elegant to you, but I think it is great. It's simple, and yes, elegant to me to shift+click open in file editor Wink Thanks!!
Back to top
View user's profile Send private message 
dejan555


Joined: 30 Nov 2008
Posts: 2794
Location: Montenegro

PostPosted: Mon 06 Feb 2017, 16:48    Post subject:  

MochiMoppel wrote:

dejan555 wrote:
For bigger images maybe adding scrollbars for start?
AFAIK pixmap doesn't support scrollbars


hmm, maybe not by itself, but after wraping it in hbox it's possible:

Code:
<hbox scrollable="true" hscrollbar-policy="1" vscrollbar-policy="1">
                <pixmap...

...</pixmap></hbox>


But then it wouldn't show the center of image by default but top-left corner and you would need to scroll for the rest

_________________
Dpup 487 | Puppy Gallery | My photo gallery | mtPaint works
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
Display posts from previous:   Sort by:   
Page 2 of 8 [114 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1012s ][ Queries: 14 (0.0097s) ][ GZIP on ]