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.
Message
Author
User avatar
perdido
Posts: 1528
Joined: Mon 09 Dec 2013, 16:29
Location: ¿Altair IV , Just north of Eeyore Junction.?

#76 Post by perdido »

Humble suggestion.

When hilighting a file directory in file window pane it would be nice to see the sub-directories in the viewer window pane. Not all files, just sub-directories.

Just my thought while using.

.

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

Building a universal file viewer

#77 Post by L18L »

jamesbond wrote:
- I can't test the script sufficiently and can not provide support for different environments.
That's okay - we're going to handle that (now that both step and SFR have responded :D)
You can count me in for universal users. :wink:
Attachments
mm_i.png
Just a teaser
made by:
<menu label="'$(gettext geany File)'">
<menuitem label="'$(gettext geany Quit)'"
<menu label="'$(gettext geany Preferences)'">
(72.56 KiB) Downloaded 666 times

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

Building a universal file viewer

#78 Post by L18L »

gettexted and translated using momanager.

TEXTDOMAIN is "puppyview"
Attachments
mm_i18n.png
note, fatdog is full of translations
also usage messages already translated
(42.69 KiB) Downloaded 615 times
mm_quickview_20170310_i18n.gz
remove fake .gz
(15.87 KiB) Downloaded 172 times

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

#79 Post by MochiMoppel »

@all Thanks for joining the naming contest and lots of interesting proposals. Makes it even harder to choose. How about 'MM Inlook'? Would sound familiar - somehow.

For the time being I'll only get rid of the "quick" and change the script name to mm_view. Pure egoism. It helps me to find it in my huge script pit where all of my more serious stuff starts with 'mm_' . I'll take the liberty to refer to it as MMview for the rest of this thread. Eventually, with more input from the community, the 'MM' will have to go. Let's see.

@mavrothal Maybe I can add '(disk usage)' to the output to make it less confusing.
Line wrapping is possible but I see too many disadvantages and have no plans to implement it.

@SFR I haven't yet tried avprobe/avplay. Tahrpup doesn't run well on my current machine, so tahrpup users will have to wait or roll their own code.

Thanks for pointing out Fatdog's xclip deficiency. Makes me wonder about the reasons, but no problem. This should take care of distros with even none of the two utilities installed:

Code: Select all

type -p xclip  && CLIP=xclip || { type -p xsel && CLIP=xsel || CLIP=: ;} ; export CLIP
...
echo -n "$vCHOOSER" | $CLIP -i
File names with consecutive whitespace? You must have seen a lot in your life. But of course you are right. I'll fix the quotation marks.

I'll add (multi) user friendliness to my next update. I will put config settings into $HOME/.config/mm_view, so they may survive a reboot, and truly temporary files into /tmp/mm_view. This should be clean enough for multi-user installations.

@greengeek How do you pronounce "viewmmer"?

@belham2 I'm flattered to see "MochiView File Manager" in such big letters. It's not yet a file manager.

@jamesbond Thanks for your interest. Don't worry, I'm not striving for perfection and I will not ride this horse to death.

@stemsee MiView? Why not "MM MiEV"? Mitsubish Motors i-MiEV. Oh, I smell trouble.

@perdido Some kind of subdirectory display is scheduled for one of the next updates though it will be on-demand only, not when you simply select a directory. The problem is that calculation can take too much time and will cause the script to temporarily freeze. Even the current display, generated by the du command, can be extremely slow, e.g. when you select an external drive with thousands of subdirectories. I will therefore add a timeout to the current display, but you will be able to see the information when hitting the F1 key.

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

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

#80 Post by greengeek »

MochiMoppel wrote: How about 'MM Inlook'? Would sound familiar - somehow.
Haha - you may have just given Microsoft a new idea there. :-)
How do you pronounce "viewmmer"?
Well, I was thinking it would be pronounced something like "vyoo ma". (not really sure how to do phonetic spelling)

"inlook" triggered a few more thoughts:
Can't help myself...

zoomin
zzoomm
zoommin
zoommer
zoommax
immedia
viewmmedia
seemmee
showmmee
inspector
mmonitor
mmicroscope
summary
summation
medium
mmaxiview

I'm going to stop now before my head bursts.

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]

Post Reply