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
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#81 Post by drunkjedi »

MochiMoppel wrote:@stemsee MiView? Why not "MM MiEV"? Mitsubish Motors i-MiEV. Oh, I smell trouble.
Mi reminds me of Chinese Phone maker Xiaomi.

They make,
Mi Phone (copies UI of iPhone, calls it MIUI),
Mi Pad,
Mi note,
Mi notebook Air,
Mi WiFi+ (wireless repeater),
Mi powerbank,
Mi Band (Fitness tracker band),
Mi Air purifier,
Mi Water purifier,
Mi Smart Scale (personal weighing scale),
Mi Induction Heating Pressure Rice Cooker,
Mi Robotic Vacuum,
Mi Drones,
And Mi whatever....

Heard they were gonna sell Washing M/C too, called....... Mi washing m/c. :shock:

I don't think they have a department to think of names for their products.
Ha ha.

stemsee

#82 Post by stemsee »

@MochiMoppel

As a Honours linguist and a rampant polyglot I can explain the problems with MMview

['3m]['3m]['viju:w^h]
1) The initial vowel is formed under pulmonic air pressure flowing through an open approximation vocal-tract (open-mouth) along with glottal activity giving rise to voicing which continuous through the next sound

2) The <m> /m/ is made by complete stricture in the place of articulation, bi-labial (lips), (it is a nasal sonorant), the airflow is forced through the nasal cavity, while the glottis continues to provide voice.
Each /m/ trails off with ^h aspiration. And aspiration possibly occurs during the onset too, depending on whether or not the speaker has fluecny in English pronunciation or not!

er this happens twice in a short space of time!!!!!!

3) <view> /view/ Then the articulators are called upon to change radically into a labio-dental fricative, followed by a short-lived release phase as the 'i' vowel is sounded during a short spell of open-approximation, during which lip rounding occurs to form the 'oo' sound [u:] /u/, which tapers off into a gliding <double u> /w/ [w] accompanied by more aspiration ^h.

well, my dear fellow, people are lazy, and can't be bothered with all of that! This why MiView works and eMeMView doesn't!

CHEERS!
sayonara!
stemsee <stemsee> /stemsee/ [st3msi:]

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Building a universal file viewer

#83 Post by L18L »

MochiMoppel wrote:@L18L Error messages don't look any nicer in Japanese :lol: . As you may have noticed I never gettext my scripts. I don't mind if anyone takes the trouble and adds it, but be warned that I change texts frequently, so "internationalization" should be one of the very last tasks.
There isn't any trouble adding gettext messages to a shell script.

Handling changes is usual "business", no problem at all.
Frequenz does not matter.

What happens if you change a text?
Nothing bad. This text appears in English.
The old translation which is no more valid is kept in the translation file.
Any old script version continues using the old translation.

What happens if you add a text?
Nothing bad. This text appears in English.

Thus "internationalization" should NOT be one of the very last tasks.
MMview is already too good to be restricted to users who understand some English. :D

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

#84 Post by MochiMoppel »

Update 2017-03-20 (see also initial post)

New vertical layout
One of the weak points of MMview is the layout. Sometimes I wish I could get the chooser out of the way and make the viewer occupy the whole window.
Technically it's no problem to do that by hiding/unhiding the chooser. The show-stopper appears when unhiding: Chooser always reverts to "Recently Used". It's impossible to continue at the previous location. Hiding means resetting and therefore is useless.

Making the chooser narrower is also no option. The left Places pane can't be hidden, its minimum width is fixed at 140px. and the tree widget, displaying the file list, contains a bug since the vertical scrollbar never disappears, even when it's not required. All this makes the chooser unnecessarily wide.

I figured that with a new vertical layout, putting the viewer beneath the chooser, we could gain considerable viewer space without compromising too much chooser functionality.

The new vertical layout is an option and can be switched on/off from the Preferences menu. The chooser height is set at 200px but can be changed in the script by setting the variable CHOOSER_HIGHT. The vertical layout may be especially suitable for reading text

Optimized scaling and layout
In order to provide maximal space for the viewer I fine-tuned image scaling and made many spacings and margins customizable. The section "Window settings" at the beginning of the script contains a couple of variables. E.g. setting all *SPACING and *MARGIN variables to a value of 0 may not look nice but would leave more room to the viewer and would result in slightly larger images.

A very effective way to gain space is hiding the menubar by setting MENUBAR_HIGHT to 1. For keyboard users nothing changes. The menubar is still accessible with F10 and can be used as before.

Support for audio/video files in Tharpup
The script now supports avprobe and avplay. Both tools seem to be compatible with ffprobe and ffplay. Have fun!

Better suppport of SVG files
Tharpup contains a background file FbBox-twilight.jpg, which is not a JPG. According to its MIME it's a SVG, but it's not a "scalable vector graphic" either. It's the equivalent of a JPG, pasted into a DOC document - that's what I receive when I ask my aunt to send me a picture, only that my aunt would not change the DOC extension to JPG. Anyway, MMview now supports such bizarre constructs.

Other changes
- Support for xsel in Fatdog (proposed by SFR)
- some clarification of du output for directories (proposed by mavrothal).
- User settings are now stored separately from tmp files. Directory $HOME/tmp/mm_view is still temporary and will be destroyed by the Puppy shutdown process, but experienced users may change the location to something more permanent like $HOME/.config/mm_view. I prefer to keep the user's system clean from any traces of the script, at least until a proper uninstall process is in place.
Attachments
mm_view_vertical.jpg
(85.8 KiB) Downloaded 444 times

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

#85 Post by greengeek »

Just nitpicking but the spelling of height is incorrect in the definitions but not in your notes:

Code: Select all

DEFAULT_HIGHT=500   # Default window height
CHOOSER_WIDTH=500   # Effective only in horizontal layout (default 500)
CHOOSER_HIGHT=200   # Effective only in vertical layout (default 200)
MENUBAR_HIGHT=25  

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#86 Post by Keef »

As it is a variable, the spelling matters not as long as it is consistent. Besides, that way the variable names are equal length and it looks neater!

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

#87 Post by MochiMoppel »

I knew somebody would ask...

Thank you, Keef. Highly appreciated :wink:

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

#88 Post by greengeek »

Ok, the spelling police is off to bed for the night.
However I don't see the variable names as all being the same length. Hmmph. May have to hunt out my micrometer tomorrow.
8)

ps: by the way - you left the "e" out of highly.

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#89 Post by Lobster »

Hey @MochiMoppe

:D

Went to the first post to download latest
Downloaded OK - then told me it would decompress in location and remove original file.

Did not seem to?
Am I at fault?

Also tried from command line . . .

Code: Select all

# gunzip mm_view_20170320.gz 

gzip: mm_view_20170320.gz: not in gzip format
# 
Incidentally congratulations on a great initiative, I want to look at your code for tips . . . 8)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#90 Post by 01micko »

Lobster wrote:Am I at fault?
Yes.. RTFM .. "Remove fake gz extension" (stated in the 'download' table; "description" row).

I don't like the trend either but hey, I'm _not_ a trend setter.
Puppy Linux Blog - contact me for access

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#91 Post by Lobster »

01micko wrote:
Lobster wrote:Am I at fault?
Yes.. RTFM .. "Remove fake gz extension" (stated in the 'download' table; "description" row).

I don't like the trend either but hey, I'm _not_ a trend setter.
:roll:

Read The Faking Manual? Should have guessed :oops:
Thanks for taking time off from the next Slacko64 development and guitar strumming in your 'man-shed' to answer . . .

Appreciate it :mrgreen:

Live Long and Puppy (traditional)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

hope you don't mind my efforts, Mochi

#92 Post by Puppus Dogfellow »

awesome again, Mochi!
MochiMoppel wrote:@stemsee MiView? Why not "MM MiEV"? Mitsubish Motors i-MiEV. Oh, I smell trouble.
MochiMoppel wrote:New question: Could someone suggest a better name? Quickview is already taken. .
i call it (and call it with) mmv--renamed it mmv so it's quicker from the terminal. (Double) eM Vee for MochiMoppel (file) Viewer is the rationale for The Bull With The Em Horns (yeah, they're more positioned like ears) Icon--pet gives both a dmv (Department of Motor Vehicles, speaking of mitsubishi (--and i was pretty fond of my 91 dsm gsx) and speaking of many, many files...) and an mmv version of the icon. that ring through the bull's nose is supposed to be in the shape of a directory folder/that directory folder thing's supposed to be a ring in da bull MV's nose.

the two entries end up in the file system menu as MochiMoppel File Viewer.
(i think it deserves two slots).

:cry: :D
Attachments
dabullmv-mmv-dmv.jpg
(2.8 KiB) Downloaded 805 times

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

#93 Post by MochiMoppel »

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

F1 becomes a multi-purpose shortcut
So far F1 allowed to pull usage messages from executables. Additionally it now displays on-demand info for directories and archives. Sort of context sensitive shortcut.

Support for archives
This is experimental and I don't even know if this can be useful. F1 will list the files contained in .pet or other archives. It is supposed to work for .tar, .pet , .txz, .gz , .gzip, .bzip2, .deb. archives. It does not work for initrd.gz. I would ge grateful for any help to improve this feature since I don't know much about archives.

Directory info
F1 will add information about the disk usage of a directory's subfolders. Since subfolders are sorted by size this will make is easy to spot the biggest "disk eaters". IMHO a useful feature.

Run menu
F5 will run any selected executable in a console window. The title of the console window corresponds to the executed file name, which makes it easier to find the the right window when running multiple consoles. The windows can be closed with any key, not just the with the awkward key combos Ctrl+D or Alt+F4.
Attachments
mmview_archive.png
(147.88 KiB) Downloaded 792 times
mmview_directories.png
(116 KiB) Downloaded 774 times
mmview_runinconsole.png
(209.82 KiB) Downloaded 785 times

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

#94 Post by greengeek »

Brilliant. Love the F1 functionality (and the prompts to try it...).
I notice if I click on something like /root/Startup/parcellite the view pane displays nothing. Would it be possible to display something like "symlink to.." or even just "symlink"?
Also with /root/Startup/network_tray there is no view pane display (possibly might be in future versions if a suitable viewer/decoder/interpreter is available) - but in the meantime might it be acceptable for the viewer to say something such as: "unsupported file type" or "C encoded file" etc etc?

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#95 Post by SFR »

MochiMoppel wrote:It does not work for initrd.gz. I would ge grateful for any help to improve this feature since I don't know much about archives.
Something like this should handle most of them:

Code: Select all

--- mm_view_20170406		2017-04-06 15:02:30.573360371 +0200
+++ mm_view_20170406_new	2017-04-06 15:19:08.486695165 +0200
@@ -205,7 +205,7 @@
 		;;
 
 	### ARCHIVES ###
-	*│*gzip*|*│*x-xz*|*│*x-bzip2*|*'.deb '*)		# .tar, .pet , .txz, .gz , .gzip, .bzip2, .deb
+	*│*gzip*|*│*x-xz*|*│*x-bzip2*|*'.deb '*|*'/initrd'*)		# .tar, .pet , .txz, .gz , .gzip, .bzip2, .deb, initrd*
 				MESSAGE=$'\n\tTry F1 to view package content'
 		;;
 
@@ -255,6 +255,19 @@
 		;;
 
 	### LIST ARCHIVE CONTENT ###
+	*'/initrd'*)
+		COMPRESSION=${vSTATUSBAR##*x-}						# '/initrd.gz │ application/x-gzip; charset=binary' => 'gzip; charset=binary'
+		COMPRESSION=${COMPRESSION##*application/}			# '/initrd.gz | application/gzip; charset=binary' => 'gzip; charset=binary'
+		COMPRESSION=${COMPRESSION%;*}						# 'gzip; charset=binary' => 'gzip'
+		case $COMPRESSION in
+			gzip)		CMND='gunzip -c -d'		;;
+			bzip2)		CMND='bunzip2 -c -d'	;;
+			xz|lzma)	CMND='unxz -c -d'		;;
+			lz4)		CMND='unlz4 -c -d'		;;
+			*)			CMND='cat'				;;			# not compressed
+		esac
+		${CMND} "$vCHOOSER" | cpio -ivt > $MSGFILE			# the output isn't really pretty with non-monospaced font
+		;;
 	*│*gzip*|*│*x-xz*|*│*x-bzip2*)							# extensions .tar, .pet , .txz, .gz , .gzip, .bzip2
 		COMPRESSION=${vSTATUSBAR##*x-}						# '/foo.pet │ application/x-gzip; charset=binary' => 'gzip; charset=binary'
 		COMPRESSION=${COMPRESSION%;*}						# 'gzip; charset=binary' => 'gzip'
There are also special cases out there, e.g. double compressed or ext2 images, but they're rather rare.
Theoretically, lzo(p) is also supported, but 'file -i' (at least in Fatdog) returns 'application/octet-stream' for it as well as for cpio, so it can't be used in the above scheme.

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#96 Post by misko_2083 »

greengeek wrote:Brilliant. Love the F1 functionality (and the prompts to try it...).
I notice if I click on something like /root/Startup/parcellite the view pane displays nothing. Would it be possible to display something like "symlink to.." or even just "symlink"?
Also with /root/Startup/network_tray there is no view pane display (possibly might be in future versions if a suitable viewer/decoder/interpreter is available) - but in the meantime might it be acceptable for the viewer to say something such as: "unsupported file type" or "C encoded file" etc etc?
Yes, like with the file command.

Code: Select all

file $FILE

Code: Select all

find $FILENAME -type f -exec file -b '{}' \; -printf '%s\n'
Like 3 years ago I made this little bash/zenity combo to analyse the content of usb drives. Some bits could be usefull (attach)[/code]
Attachments
ausb.sh.bz2
(1.76 KiB) Downloaded 206 times

bpuppy

Re. The multiviewer

#97 Post by bpuppy »

Just awsome!

I was longing for that same fonctionnality I used to have (ions ago) when I was using Total Commander's Quickviewer on an XP.

It's also quite incredible that we get it from a 20K script too!
It runs smoothly on PuppyTahr 605. I will also try it out on Fatdog 710.

Thank you so much MochiMoppel !!

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

#98 Post by slavvo67 »

Hi Mochi and others:

I think this is a great project but I noticed on a drive with a lot of files (lots of directories and subdirectories), it seems to slow down or hang to a point where it is not usable. I used one of the first scripts so I'm not sure if this has been addressed somewhere down the line.

As usual, this was in Quirky Xerus64.

Best,

Slavvo67

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

#99 Post by MochiMoppel »

@greengeek When the target of a symlink is not displayed then not because it's a symlink but because the target is not viewable. And when nothing can be displayed I prefer to display nothing.

@SFR Thanks for the code. Seems that MIME application/x-gzip can be a lot of things. I don't like that :lol: I will use the code for my next update with a small change: I will use the busybox version of cpio. The output format is less ugly and can be easier turned into a palatable format for proportional fonts.

What I'm still not sure about are the MIME declarations in use. Having experienced problems with the 'x-' prefix, can I be sure that MIME is always labeled as 'x-gzip' and 'x-xz' and not 'gzip' and 'xz'? After all zip is reported as application/zip. I also don't know if the tar command really needs the -I option since it seems to sniff the compression program without it.

@misko_2083 The file command is already used for every selected file (see status bar).

@bpuppy Pleased to see that you like it and pleased to see that you are active again in the forum after more than 2 years. Yes, TC was great. I paid for it and still get updates but haven't used it for a long time. IIRC TC's Quickview had some weak spots. Search functionality was one of them. I'll try to make it better. Stay tuned.

@slavvo67 Already fixed.

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

#100 Post by greengeek »

MochiMoppel wrote:@greengeek When the target of a symlink is not displayed then not because it's a symlink but because the target is not viewable. And when nothing can be displayed I prefer to display nothing
Thanks for the reply. I see from your reply to misko_2083 that even for an unviewable file you display the "file" result in the status bar - would you also consider displaying something in the display pane which prompts the user to view the status bar? Maybe something such as "contents not readable" ?

Or is there perhaps some way to highlight the status bar text as an alternative so that it catches the users eye?
cheers!

Post Reply