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 Sat 23 Sep 2017, 23:26
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 1 of 12 [166 Posts]   Goto page: 1, 2, 3, ..., 10, 11, 12 Next
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 1350
Location: Japan

PostPosted: Mon 30 Jan 2017, 04:05    Post subject:  Building a universal file viewer
Subject description: ... using gtkdialog's much underrated chooser widget
 

This recent thread about the undocumented chooser widget brought up the question: What can it be used for?

Not much, as it seems. Among the only 7 scripts in Slacko 5.6 which use it, only Nathan's wallpaper app uses it for image previews. All others use it as a simple file picker.

I take this as a challenge to build something more useful.
Ever since I used TotalCommander, a 2-pane file manager, I liked the Quickview feature: A file list in one pane and the content of the selected file in the other pane. For image files it would be a representation of the image, for text files it would be the file content, for zip files the content of the zip container. With add-ons other file formats may be readable/viewable.

Main Features
Supports common text formats
Supports common image formats
Supports common audio/video formats (displays metadata, requires ffprobe or avprobe)
Supports directories (displays disk usage)
Supports executables (displays usage message)
Supports virtual files in /proc and /sys (for geeks!)
Search function
Horizontal or vertical layout
Displays images in original size or (optionally) in size scaled to viewer
Displays ID3 tags of audio files
Plays audio files (optional) (requires ffplay or avplay)
Plays video files in separate window (optional) (requires ffplay or avplay)
Shows line numbers (optional)
Shows full paths, MIME types and charsets
Starts with last used directory and last used window size/position
Provides keyboard shortcuts for most actions
ROX-Filer compatible: Shift+! opens shell command box
ROX-Filer compatible: Dblclick or Enter/Space key opens file in its default application
ROX-Filer compatible: Shift+Click opens file in text editor
ROX-Filer compatible: Selecting file sends its full path to PRIMARY buffer

Built-in standard features (but nevertheless noteworthy)
Drag'n'drop from Chooser to Desktop: Creates desktop shortcut
Drag'n'drop from Chooser to ROX-Filer: Copies file (while pressing Shift: moves file)
Drag'n'drop from ROX-Filer to Chooser: Selects file in Chooser
Entering first letter of a file name jumps to the file in list
File sizes of symlinks indicate size of linked file, not of the symlink itself

Changelog
2017-09-13
 Added: Better command line compatibility
 Added: Open commandbox with last command
 Added: Command line history
 Removed: VTE (terminal) support

2017-08-07
 Added: Basic file management functions Rename/Move/Duplicate/Delete
 Added: Support for Lucid 5.2.8 (and probably other older Puppies)

2017-06-22
 Fixed: Compatibility issue with Fatdog

2017-06-21
 Added: Support for HTML (*.htm/html), Abiword (*.abw), Notecase (*.ncd) files

2017-05-24
 Fixed: Removed a comment that caused a buffer overflow error on some systems

2017-05-22
 Added: Shell command box
 Added: Terminal pane
 Added: Tooltips for all menu items in "View","Commandbox" and "Terminal" menus
 Added: Shortcut for start/stop of audio/video play (Ctrl+Z)
 Changed: Menu structure

2017-04-16
 Added: Menu item "Show line numbers" ; Shortcut F2
 Added: Menu item "Refresh" ; Shortcut F5
 Added: Menu item "Find ..." ; Shortcut Ctrl+F
 Added: Menu item "Find again" ; Shortcut F3
 Added: Support for initrd.gz images (thanks SFR)
 Added: Support for .iso images and .zip , .7z archives
 Changed: Shortcut for "Execute selected file in console" from F5 to Ctrl+F5
 Changed: Shortcut for "Open in default editor" from F2 to Ctrl+E
 Removed: Display of disk usage for symlinked directories and directory /proc

2017-04-06
 Added: Display of archive contents (supported formats .tar, .pet , .txz, .gz , .gzip, .bzip2, .deb). Experimental!
 Added: On-demand info for directory disk usage. Includes subdirectories (first level only, largest first). Shortcut F1
 Added: Run menu
 Added: Option to run selected executable in console. Shortcut F5
 Improved: Displaying directory size now times out after 1 sec. to prevent stutter. F1 can be used instead.

2017-03-20
 Added: Vertical layout option (Preferences menu)
 Added: Support for audio/video files in Tahrpup
 Improved: Better use of available viewer area
 Improved: Better support for SVG files
 Various minor improvements

2017-03-10
 Added: Preferences menu
 Added: Option to scale images to viewer size (thanks some1)
 Added: Option to autoplay video files
 Added: Support for *.mkv and *.wma files
 Added: Support for "iso*" and "unknown-8bit" charsets (requires iconv)
 Fixed: F2 now works
 Improved: Autoplay option for audio files can now be set from menu
 Improved: Several performance optimizations

2017-02-12
 Added: Menu bar
 Added: Keyboard shortcuts
 Added: Display of usage message for executables (on demand)
 Added: Display of directories' total size (disk usage)
 Added: (Invisible) refresh button. Used by chooser widget. Prevents repeated file inputs of same file.
 Improved: Compatibility with various Puppies ( 'x-' prefix removed from MIME types)
 Improved: Performance when killing audio streams

2017-02-09
 Added: scrollbars for images larger than viewer pane (thanks dejan555)
 Fixed: selecting files didn't preserve "accessed" and "changed" timestamps, causing ROX to mark files in bold

2017-02-05
 Changed: 'pkill' to 'busybox pkill'. Some Puppies seem to miss the busybox symlink (thanks dejan555)
 Removed: Some redundant code in fill_statusbar function

2017-02-04
 Added: Shift+Click support for text files
 Added: Support for ID3 tags and audio/video encoding info; Requires ffprobe
 Added: Autoplay support for audio/video files (experimental and disabled by default); Requires ffplay

2017-01-30
 First version

Newest version
mm_view_20170913.gz
Description  Remove fake gz extension
gz

 Download 
Filename  mm_view_20170913.gz 
Filesize  36.01 KB 
Downloaded  385 Time(s) 
mm_quickview.png
 Description   Screenshot shows older version 2017-02-09
 Filesize   233.85 KB
 Viewed   1787 Time(s)

mm_quickview.png


Last edited by MochiMoppel on Wed 13 Sep 2017, 09:07; edited 34 times in total
Back to top
View user's profile Send private message 
greengeek


Joined: 20 Jul 2010
Posts: 4642
Location: Republic of Novo Zelande

PostPosted: Mon 30 Jan 2017, 05:19    Post subject:  

Nice. Looks handy. I will give this a workout over the next few days. So far a couple of comments:

1) I navigated to a .wav and clicked it - it played in pmusic but then the "NAD5" theme of pmusic disappeared and returned to a default theme. I guess this is nothing to do with navigating via mm_quickview - just some peculiarity of my system but thought I would mention it anyway. Will post back if I find the trigger for this behaviour.

2) I felt it would have been nice to have an "up" arrow or "back arrow". Of course it is possible to click on the directory titles shown above the "places" pane, but it would have been more natural to have an arrow if poss.

Looks good!

EDIT ps: I did not understand what is meant by "Drag'n'drop Chooser => ROX-Filer: Copies file " (will try more tomorrow)
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6475
Location: Valåmoen, Norway

PostPosted: Mon 30 Jan 2017, 14:48    Post subject:  

This is a great initiative. Maybe we will for the first time see a workable filemanager based on gtkdialog.

Quote:
Entering first letter of a file name jumps to the file in list
This beats Rox Wink

Maybe the quickview feature could embed a simple audioplayer as well. The following commands will both play most audio. The latter will play video too...
Code:
ffmpeg -i /path/input_file.mp3" -f au - | aplay
ffplay -i /path/input_file.mp3

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1435
Location: Ukraine

PostPosted: Mon 30 Jan 2017, 15:54    Post subject:  

Dear MochiMoppel,

Brilliant idea and already working nicely. Yes, many tweaks and enhancements may follow, but it is already a great idea and functioning thing. Thanks. Smile

With kind regards,
vovchik
Back to top
View user's profile Send private message 
belham2

Joined: 15 Aug 2016
Posts: 1022

PostPosted: Mon 30 Jan 2017, 16:23    Post subject:  

Wow, mochi, this thing is something! I am always fooling with simple scripts and/or setting up *.desktop files w/ them, and Quickview lets me see all this stuff immediately. Plus, upon re-opening, it remembers where I left off. That is awesome! What would be incredible is what I wrote in the pic I put below (the highlighted). Still, Quickview is already good, and I am in the process of replacing ROX (I usually have 2 file mgrs always, usually PCManFM or Thunar along with ROX). Now ROX is getting removed and replaced by this! I love it. I hope it keeps moving forward and more new features are added. Thank you, Mochi!!

Here it is working in X-tahr-2.0:
quickview1.png
 Description   
 Filesize   206.65 KB
 Viewed   1575 Time(s)

quickview1.png

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

Joined: 06 Oct 2009
Posts: 435
Location: Scotland

PostPosted: Mon 30 Jan 2017, 17:54    Post subject:  

@MochiMoppel
I have it working in the latest version of Lucid 5287 s2. Very fast. However it does not work in Wary 5.5. I used the same file for both and put it in the same place in both. Here is the output of running it in Wary in a terminal.

Code:
# mm_quickview
/root/my-applications/bin/mm_quickview: line 57: unexpected argument `(' to conditional binary operator
/root/my-applications/bin/mm_quickview: line 57: syntax error near `(^'
/root/my-applications/bin/mm_quickview: line 57: `        if [[ $vCHOOSER =~ (^/sys/) ]] ;then '


I'm not sure what this means but I hope it means something to you. Any hope of getting it to work in wary?

Regards,

Ken.
Back to top
View user's profile Send private message 
Rattlehead


Joined: 11 Sep 2008
Posts: 367

PostPosted: Mon 30 Jan 2017, 18:41    Post subject:    

Tested in Tahr605, works flawlessly.

Impressive. Kudos. Additionally, in this case, considering GTK-Dialog's syntax, that looks like freaking barb wire. Whenever I try to come up with something myself I have to take an aspirin later... Razz Razz Razz
Back to top
View user's profile Send private message 
slavvo67

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

PostPosted: Mon 30 Jan 2017, 19:25    Post subject:  

Very nice... ahhh but those pesky pdf files...
Back to top
View user's profile Send private message 
drunkjedi


Joined: 24 May 2015
Posts: 684

PostPosted: Mon 30 Jan 2017, 21:08    Post subject:  

Hi MochiMoppel,
Great coding again friend.
Thanks mate.

Great thing about these simple codes, they work on both 32 and 64bit...

zigbert wrote:
Quote:
Entering first letter of a file name jumps to the file in list
This beats Rox Wink
ROX in Fatdog does this.
It's a forked branch by Jun7 or something similar, I don't remember exactly.
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6475
Location: Valåmoen, Norway

PostPosted: Tue 31 Jan 2017, 08:20    Post subject:  

drunkjedi wrote:
zigbert wrote:
Quote:
Entering first letter of a file name jumps to the file in list
This beats Rox Wink
ROX in Fatdog does this.
It's a forked branch by Jun7 or something similar, I don't remember exactly.
Thanks for the info !
_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1350
Location: Japan

PostPosted: Tue 31 Jan 2017, 22:52    Post subject:  

Thank you all for the unexpected feedback. I hope not to raise too high expectations with this little exercise. After all gtkdialog's toolkit is quite limited, and so is the chooser widget.

My intention is to keep it simple and fast. Speed benchmark: Scrolling through chooser's file list with the UP and DOWN keys on my old Atom netbook. This requires a lot of refreshes and calculations. If scrolling stutters and doesn't feel snappy anymore, I don't implement it - at least not for this auto viewing mode. On demand viewing options for processor intensive tasks may come later.

@greekgeek: I'm sure you will figure it all out when you play with it

@zigbert: I have no intention to turn this into a file manager. I have to be careful not to let it head too far into that direction. My conscience forbids me to build something even less feeble than ROX-Filer Laughing .

Playing audio files is not a problem. The problem is chooser's event handling. You will not care and not even notice when text in the viewer pane is refreshed twice, but you will be utterly annoyed when audio is refreshed repeatedly.

@vovchik: Thank you for your kind encouragement.

@belham2: Good idea. Text in the viewer can be edited, so why not save it? This was one of the first thoughts that came to my mind. 2 reasons why I gave up on it:
1) Conceptually this should remain a viewer. The user should have confidence that no action will change the source data. Allowing saving or even auto-saving would not fit into this concept.
2) Theoretical it would be possible only for smaller files. There is a limit of ~128K for variable size, which will cause chooser to freeze when you attempt to read files bigger than that. I avoid this limitation by setting the variable to export="false", but his makes saving impossible.

Of course you are right that there should be an easy way to edit and save a script that you see in the viewer. One way that already works: drag&drop the file to a Leafpad desktop icon or whatever you want to edit it with (it is not possible to "embed" Leafpad into the viewer pane).

ROX-Filer has a nice solution: When you Shift+click on a text file, the file will open in the default editor. I like that. Gtkdialog does not support mouse+key combinations, but I will implement it somehow. Maybe I should give this priority.

@keniv: Looks like an old bash version in Wary 5.5. Try to steal /bin/bash from a newer Puppy and copy it to Wary 5.5.

@Rattlehead: Aspirin is not good for you. A glass of Rioja Gran Reserva works better!

@slavvo67: Trying to view PDFs in anything else than a dedicated PDF viewer is a waste of time. This goes for many other formats.

@drunkjedi: Thanks for testing in 64bit Puppies.


[Edit] Removed reference to bash with regard to 128k variable limit.

Last edited by MochiMoppel on Tue 05 Sep 2017, 12:27; edited 1 time in total
Back to top
View user's profile Send private message 
slavvo67

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

PostPosted: Tue 31 Jan 2017, 23:02    Post subject:  

Acknowledged. One note, at least in 64 bit, the viewer seems to zoom jpg photos at maybe a 200 % or more. Not sure if it was intended to view photos but just a comment. In that light, it also doesn't adjust with the window size of the file viewer so it will look like maybe a 300% zoom when the file viewer is not full screen and maybe 200% when the file viewer is maximized.

I used something similar in Windows quite a while back. Has anyone tested this with files like .eml for example?
Back to top
View user's profile Send private message 
keniv

Joined: 06 Oct 2009
Posts: 435
Location: Scotland

PostPosted: Wed 01 Feb 2017, 12:26    Post subject:  

@MochiMoppel

Quote:
Looks like an old bash version in Wary 5.5. Try to steal /bin/bash from a newer Puppy and copy it to Wary 5.5.
.

As you suggested, I swapped /bin/bash from Lucid 5287 s2 which as I said I also use and mm_quickview is now working on Wary 5.5.

Thanks for the help.

Ken.
Back to top
View user's profile Send private message 
Rattlehead


Joined: 11 Sep 2008
Posts: 367

PostPosted: Thu 02 Feb 2017, 13:35    Post subject:  

MochiMoppel wrote:

@Rattlehead: Aspirin is not good for you. A glass of Rioja Gran Reserva works better!


Laughing Thank you for the medical advice, 100% agreed, I used the word "aspirin" as a metaphor only Razz
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1350
Location: Japan

PostPosted: Thu 02 Feb 2017, 23:07    Post subject:  

drunkjedi wrote:
zigbert wrote:
Quote:
Entering first letter of a file name jumps to the file in list
This beats Rox Wink
ROX in Fatdog does this.
It's a forked branch by Jun7 or something similar, I don't remember exactly.
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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 12 [166 Posts]   Goto page: 1, 2, 3, ..., 10, 11, 12 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.1177s ][ Queries: 12 (0.0088s) ][ GZIP on ]