Building MMview, a universal file viewer

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Building MMview, a universal file viewer

#1 Post by MochiMoppel »

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 of MMview
Supports common text formats
Supports most image formats, incl. RAW formats
Supports common audio/video formats (displays metadata, requires ffprobe or avprobe)
Supports common file compression formats
Supports eBook format EPUB
Supports directories (displays disk usage, sizes of subdirectories)
Supports executables (displays usage message)
Supports virtual files in /proc and /sys (for geeks!)
Search text in files
Command line interface
File create/rename/move/copy/delete
Horizontal or vertical layout
Fullscreen mode
Line wrapping
Line numbers
Can display character codes and Unicode names of any text selection
Can display file properties, MD5 checksums, ID3 tags of audio files
Can display image metadata (Exif, IPTC , XMP)
Can play audio files (requires ffplay or avplay)
Can play video files in separate window (requires ffplay or avplay)
Displays full paths, MIME types and charsets
Starts with last used directory and last used window size
Provides keyboard shortcuts for most actions
ROX-Filer compatible: "Open With ..." menu
ROX-Filer compatible: Shift+! opens shell command box
ROX-Filer compatible: Dblclick or Enter/Space key opens file in its default application

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: Jumps to the file in list (changes chooser's directory as needed)
Entering first letter of a file name jumps to the file in list

Changelog
Attachments
mm_view_20200709.gz
Uncompress gzipped file and make script executable
(25.52 KiB) Downloaded 1870 times
mm_quickview.png
Screenshot shows older version 2017-02-09
(233.85 KiB) Downloaded 4442 times
Last edited by MochiMoppel on Thu 09 Jul 2020, 04:17, edited 76 times in total.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#2 Post by greengeek »

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)

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#3 Post by zigbert »

This is a great initiative. Maybe we will for the first time see a workable filemanager based on gtkdialog.
Entering first letter of a file name jumps to the file in list
This beats Rox ;)

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: Select all

ffmpeg -i /path/input_file.mp3" -f au - | aplay
ffplay -i /path/input_file.mp3

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#4 Post by vovchik »

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. :)

With kind regards,
vovchik

belham2
Posts: 1715
Joined: Mon 15 Aug 2016, 22:47

#5 Post by belham2 »

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:
Attachments
quickview1.png
(206.65 KiB) Downloaded 4180 times

keniv
Posts: 583
Joined: Tue 06 Oct 2009, 21:00
Location: Scotland

#6 Post by keniv »

@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: Select all

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

User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

#7 Post by Rattlehead »

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... :P :P :P

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#8 Post by slavvo67 »

Very nice... ahhh but those pesky pdf files...

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#9 Post by drunkjedi »

Hi MochiMoppel,
Great coding again friend.
Thanks mate.

Great thing about these simple codes, they work on both 32 and 64bit...
zigbert wrote:
Entering first letter of a file name jumps to the file in list
This beats Rox ;)
ROX in Fatdog does this.
It's a forked branch by Jun7 or something similar, I don't remember exactly.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#10 Post by zigbert »

drunkjedi wrote:
zigbert wrote:
Entering first letter of a file name jumps to the file in list
This beats Rox ;)
ROX in Fatdog does this.
It's a forked branch by Jun7 or something similar, I don't remember exactly.
Thanks for the info !

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#11 Post by MochiMoppel »

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 :lol: .

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, 16:27, edited 1 time in total.

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#12 Post by slavvo67 »

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?

keniv
Posts: 583
Joined: Tue 06 Oct 2009, 21:00
Location: Scotland

#13 Post by keniv »

@MochiMoppel
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.

User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

#14 Post by Rattlehead »

MochiMoppel wrote: @Rattlehead: Aspirin is not good for you. A glass of Rioja Gran Reserva works better!
:lol: Thank you for the medical advice, 100% agreed, I used the word "aspirin" as a metaphor only :P

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#15 Post by MochiMoppel »

drunkjedi wrote:
zigbert wrote:
Entering first letter of a file name jumps to the file in list
This beats Rox ;)
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.

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#16 Post by drunkjedi »

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.
Image
Last edited by drunkjedi on Fri 03 Feb 2017, 13:24, edited 2 times in total.

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#17 Post by drunkjedi »

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?

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#18 Post by MochiMoppel »

drunkjedi wrote:How to set shortcuts in Rox?
Explained by disciple here (a thread you visited and bookmarked :wink: )
In what file do they get saved?
/root/.config/rox.sourceforge.net/ROX-Filer/menus2
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.

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#19 Post by drunkjedi »

How silly of me.

Sorry I forgot that.

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#20 Post by drunkjedi »

Ok In Fatdog's /root/.config/rox.sourceforge.net/ROX-Filer/menus2 I see following line

Code: Select all

; (gtk_accel_path "<filer>/Select/Reg Select..." "asciicircum")
Do you think that's it?

Post Reply