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
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#161 Post by technosaurus »

misko_2083 wrote:Mochi have you considered displaying file and folder metadata?
You can format the output of the stat command to be more human readable. Here's an example

If it's too slow maybe it could show up with F1.
If you use stat, (or other core utils), please use the busybox compatible variants ... usually short options vs. long options
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#162 Post by tallboy »

MMview now supports Lucid 5.2.8 and provides basic file management functions rename/move/duplicate/delete.

Very nice, Mochi!

Code: Select all

### Universal file viewer
### MochiMoppel 2017-08-07
{ ###HEADER
TEMPDIR=/tmp/mm_view				# For temp files
CNFGDIR=$HOME/tmp/mm_view			# For user settings. ($HOME/tmp not saved to savefile. Eventually should be $HOME/.config/<appname>
[[ -d $TEMPDIR ]] || mkdir -p $TEMPDIR
[[ -d $CNFGDIR ]] || mkdir -p $CNFGDIR
I would presume that $HOME is for those who run a frugal Puppy, and use a savefile. I run live Puppys only, no savefiles. Can you please suggest a modification to your code to be used without a savefile? I know I can set it to whatever I prefer, but I would be more comfortable if I could follow your advice. My choice in Lucid 5.2.8.7 would be /root/.config/mm_view.

tallboy
True freedom is a live Puppy on a multisession CD/DVD.

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

#163 Post by MochiMoppel »

@smokey01: Maybe it would be nice, but the existing built-in right-click menu can't be altered.

@perdido: :lol: A collector? Be happy and use only the latest. And if you can't tell them apart anyway, what does it matter if you don't see the version number...or the author name? BTW: I never thought that someone would take my fashion glasses for eyes. I wish I had such impressive eyes :lol:

@misko_2083:Thanks. I have contemplated already many times to use stat in some form, but I always come to the same conclusion: The basic info like filename, date, size is already viewable and most of the remaining info like blocks and inode is too geeky for a normal user. Those who need it can always use the codebox, type stat $@, and enjoy the output for any file. This is why I find the codebox so useful. But your remark reminds me that we might need a "Properties" view (Ctrl+P ?), which could be a clone of the properties menu in ROX-Filer. I'll add it to my to-do-list but I can't promise anything.

@technosaurus:I've checked misko_2083's and my code and don't find anything that might have sparked your comment, so I file it under "General coding advice". Thanks.

@tallboy: Normally $HOME refers to /root. When you use no save file and save config settings to /root/.config/mm_view, those settings will be lost when you exit Puppy. If you want to keep them you should save them outside of Puppy, somewhere in /mnt/home or /mnt/sda1 or whatever your drive is named.

.
Last edited by MochiMoppel on Tue 15 Aug 2017, 13:28, edited 1 time in total.

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#164 Post by tallboy »

Thank you, mochi. I run my CD as multisession, so I can save the session and keep the setup.

tallboy
True freedom is a live Puppy on a multisession CD/DVD.

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

#165 Post by MochiMoppel »

- double post removed -
Last edited by MochiMoppel on Wed 13 Sep 2017, 13:04, edited 1 time in total.

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

#166 Post by MochiMoppel »

Update 2017-09-13 (see also initial post)

Command line should now work with every Puppy. VTE support has been removed.
This has some advantages:
- Command output in normal text viewer pane often easier to read
- No cutting of output when maximum history lines reached
- Copy & Paste works with familiar shortcuts

Open with last command
That's an option I miss in ROX-Filer. Opens the Commandbox with the last used command instead the default ' $@ '

Command history
ROX-Filer (and every terminal) lets the user scroll through the command history with the Up arrow key.
Theoretically this could be implemented in MMview but would require elaborate code as gtkdialog does not support such behavior. Instead I opted for a lighter and IMO better solution: When the commandbox has focus, pressing Up arrow key will display the command history in the viewer pane. Picking a command from the history involves
- Triple click on command (selects whole line)
- Clean commandbox (by clicking on Clean button at right end of commandbox)
- Middle click in commandbox (pasting selection)

Command templates
I tried to create a user configurable "Frequently Used Commands" menu. Can be done but lacks simplicity. Instead I recommend to create a text file with useful commands, put this file into its own directory and then bookmark this directory. The screenshot shows my oneliners directory as first in the bookmarks list. Clicking on the bookmark will show the contents of the first (= only) file of this directory in the viewer pane. From there I can pick a command just like picking from the command history. Very low-tech but efficient.

As an example the screenshot shows the output of the command

Code: Select all

stat -c $'CHANGED:\t%z\nMODIFIED:\t%y\nACCESSED:\t%x\n' "$@" | sed "s/\..*$//; s/$(date +%Y-%m-%d)/today_____/"
Executing this command with F4 key allows to view comprehensive filedate info for any selected file/directory, much better than chooser's dismal "Modified" column.
Many more oneliners and of course scripts are possible, eventually turning MMview into a customized file manager.

Of course the commandbox can execute any command, not just those related to the selected file. It's very useful for testing and fine-tuning commands since the commands don't scroll away in a convoluted mix of command input and output like in a conventional terminal emulator.
Attachments
commandbox.png
(80.22 KiB) Downloaded 1134 times
Last edited by MochiMoppel on Tue 19 Dec 2017, 01:46, edited 1 time in total.

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

#167 Post by MochiMoppel »

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

At the start of this thread I was a bit reluctant to implement image scaling. Now I find the 2 available image modes not sufficient. For serious image examination the viewer pane is too small. With this update I introduce quick access to fullscreen display.

Fullscreen modes
A single click on the viewer pane is all it takes to view an image fullscreen (and another click closes fullscreen). Leftclick displays the image in its original size, rightclick fits the image to the screen. Beware that fit-to-screen always tries to fill the screen, i.e. small images will be enlarged.

It is possible to switch between 100% size and fit-to-screen size while in fullscreen mode. Tooltips explain the options.
Attachments
four_image_modes.jpg
(43.36 KiB) Downloaded 1011 times
Last edited by MochiMoppel on Tue 19 Dec 2017, 01:43, edited 2 times in total.

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

#168 Post by SFR »

Hey Mochi

Just tried the new version in FD and there's a couple of minor issues.

1. The fullscreen doesn't work for me with Compiz.
Compiz Error
Exceeded max texture size
Can be fixed by using the actual dimensions (SCREEN_W & SCREEN_H), instead of 9999x9999.

As for the panel being visible in fullscreen, it's actually not visible in Compiz and Openbox, so far only JWM resists.
But it also can be fixed without the need of wmctrl, by using:

Code: Select all

<window type-hint="6"
https://developer.gnome.org/gdk3/stable ... owTypeHint


2. When I was playing with the above, I switched to another VT and logged-in as a regular user, and noticed that there's still a problem with multiuser-friendliness.
When I launch MM as root, it creates a temp directory /tmp/mm_view with write permissions only for root, so when I run it as a regular user (later or simultaneously), mm_view can't write to that dir.
What about, e.g.:

Code: Select all

TEMPDIR=/tmp/mm_view.${USER}
?

Thanks &
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
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#169 Post by MochiMoppel »

@SFR: Thanks for your feedback. Very much appreciated.
1. The fullscreen doesn't work for me with Compiz .... Can be fixed by using the actual dimensions (SCREEN_W & SCREEN_H), instead of 9999x9999.
My reason for using 9999: Setting default-height to exact screen height will place bottom part, incl. any horiz. scrollbar, *under* JWM tray, making scrollbar inaccessible. Increasing default-height by only 1 px will put scrollbar above tray, thus value 9999 should be a safe bet until wall size monitors become affordable. JWM is prepared, Compiz is not :lol:
Fortunately type-hint="6" makes these deliberations obsolete. I've never had much luck with type-hint since most values change nothing (in JWM) and I had given up trying to get any use out of this attribute. Good to hear that setting the window's property to _NET_WM_WINDOW_TYPE_DOCK works in JWM, Compiz and Openbox. This means that I can remove not only wmctrl support but also the decorated="false" attribute, right?

One annoyance remains: With <vbox scrollable="true"> gtkdialog adds scrollbars even for images that would perfectly fit on the screen without them. If image's size is within 16px of the screen size (= double scrollbar width), scrollbars appear, and their only purpose is to make the image portion viewable that is covered by the scrollbar... :evil: Is there any workaround for that?
When I launch MM as root, it creates a temp directory /tmp/mm_view with write permissions only for root, so when I run it as a regular user (later or simultaneously), mm_view can't write to that dir
Would it help to create the directory with world write permission? And would there be a way to let any file newly created in that directory inherit this permission? In principle I have no objection to add the user name but I would find it neater to avoid multiple directories.

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

#170 Post by SFR »

I can remove not only wmctrl support but also the decorated="false" attribute, right?
Yep.
Is there any workaround for that?
Here's what I came up with so far. Comments explain everything, I hope:

Code: Select all

#!/bin/sh

# path to a "fullscreen" image
IMG=

read W H <<< `xwininfo -root | awk 'NR>=8&&NR<=9 {print $2}'`


# works with & without geometry (see below) if we invoke it as a separate instance instead of using 'launch' command
#	<action>gtkdialog -p IMAGE_WINDOW_NORMALSIZE</action>
export MAIN='
<button>
	<label>Show image</label>
	<action>launch:IMAGE_WINDOW_NORMALSIZE</action>
</button>'

export IMAGE_WINDOW_NORMALSIZE='
<window type-hint="6" border-width="0" width-request="'${W}'" height-request="'${H}'">
	<eventbox>
		<vbox scrollable="true" shadow-type="0" width="'${W}'" height="'${H}'">
			<pixmap space-expand="true" space-fill="true">
				<input file>'${IMG}'</input>
			</pixmap>
		</vbox>
	</eventbox>
	<variable>IMAGE_WINDOW_NORMALSIZE</variable>
	<action signal="button-press-event" condition="command_is_true( [[ $PTR_BTN == [12] ]] && echo true )">closewindow:IMAGE_WINDOW_NORMALSIZE</action>
</window>
'

# doesn't work with geometry, but works without it:
gtkdialog -p MAIN
#gtkdialog -p MAIN -G 100x100+0+0
Would it help to create the directory with world write permission? And would there be a way to let any file newly created in that directory inherit this permission?
Theoretically using ACL:
https://unix.stackexchange.com/question ... -directory
but the '-d' (default) option gives 'operation not supported' in FD...
In principle I have no objection to add the user name but I would find it neater to avoid multiple directories.
You can always have one main dir (/tmp/mm_view) that has 777 and then one subdir per user. :wink:

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
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#171 Post by MochiMoppel »

SFR wrote:Here's what I came up with so far.
Brilliant :D ! We enter the wonderful world of scrollable boxes. Suddenly shadow-type, width and height work as advertised. There is a lot the documentation is not telling us. I also noticed that mouse clicks are recognized, so no need anymore for eventboxes.

Yeah, the --geometry option is fine as long as no child windows are launched. This option offers more pain than gain. I was already planning to remove the ability to save the last window position. Now I have one more reason.

Speaking of minor issues: In the newest version I invoke the GUI with exec gtkdialog. Exported variables and functions are pretty big, so I figured it would be a good idea to kill the invoking shell and free the environment from unneeded stuff. Unfortunately this also ends trap and temp files are not cleaned up anymore. I will have to entrust the GUI with the clean-up job.

Normally I prefer to pipe the GUI description to gtkdialog with the -s switch, which would avoid to create a big variable for the main dialog, but this method seems to be unpopular (any disadvantages?) and in case of MMview would solve only part of the problem.

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

#172 Post by MochiMoppel »

Update 2017-11-09 (see also initial post)

This (hopefully) fixes the issues discussed before and adds a still missing feature.

Fullscreen text
With this new feature any content of the viewer pane can now be displayed fullscreen by right clicking the viewer pane.
A second right click brings the user back to normal mode.

Minor changes
- Multiuser support (thanks SFR)
- Multiple instances support
- Better support for window managers other than JWM (thanks SFR)
- Better display of fullscreen images (thanks SFR)
- Viewer pane background clickable
- Dead link targets displayed in statusbar (requires GNU readlink)
- Better dialog positioning
- Ability to save last window position removed
- Minimal obstructive show-only-once tooltip in fullscreen text
- Revised tooltip texts
- Improved code folding (in Geany)
- Improved memory management
Attachments
text_fullscreen.jpg
(63.14 KiB) Downloaded 823 times

User avatar
festus
Posts: 235
Joined: Wed 14 Jan 2015, 19:10

#173 Post by festus »

Hello, MochiMoppel

The last couple of days I've been using "mm_view_20171109" in slacko-700-RC3, with much satisfaction.

For my ease of use, I made it into a pet-package, with its category as "Filesystem".

One thing I do miss is the ability to "right-click, open with" certain apps like pupMD5sum for instance. And other context menu choices.

Another feature that would be helpful, imho, would be, File>New Tab, and perhaps, File>New Window.

The more I use it, the more I like it.

Thank you for creating and working on this useful viewer/filemanager.

bliss,
festus :)

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

#174 Post by MochiMoppel »

festus wrote:The last couple of days I've been using "mm_view_20171109" in slacko-700-RC3, with much satisfaction.
Thank you very much for testing. My old hardware doesn't allow me to test in the latest Puppies, so I particularly appreciate feedback from cutting-edge users. I'm glad to hear that you like it.
One thing I do miss is the ability to "right-click, open with" certain apps
I don't :lol:
like pupMD5sum for instance
I don't know this app. If all you need is to know the md5sum: Shortcut Shift+!, type md5sum, press Enter
And other context menu choices.
Such as?
Another feature that would be helpful, imho, would be, File>New Tab,
Tab? Where do you miss tabs?
and perhaps, File>New Window.
Window of File? You can create a new window of MMview by starting a new instance.

Coming back to Rightclick menu, as it has been requested before: Do you mean Rightclick (with its MIME sensitive options on top) or Shift+Rightclick (the OpenWith submenu with its big section of context and MIME insensitive options)? In other words, if you look at this screenshot, the red part or the green part?

User avatar
festus
Posts: 235
Joined: Wed 14 Jan 2015, 19:10

#175 Post by festus »

Ok, thanks for the reply.

I am using MMview more now and have gotten more used to to its operation steps, and I like using it very much.

I use it successfully in slacko-6999 & Xenial-7.5(32 & 64 bit)

Thanks and peace to you, my brother MochiMoppel.

bliss,
festus :)

hamoudoudou

This app can be very useful .. Mt jumps to MTpaint..

#176 Post by hamoudoudou »

wonderful ! lost in the dpup stretch menu MMview, what is that.. i am curious..
This app can be very useful .. Mt jumps to MTpaint..
They are so many apps that we even never use...

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

#177 Post by MochiMoppel »

Update 2018-01-17 (see also initial post)

Some more supported file formats and a - still modest - toolbar

EPUB format for eBooks
This turns MMview into a poor-man's eBook reader.
Selecting an epub file will display some of the eBook's metadata (if provided): Title, Author, Description.
Pushing F1 will open a dialog with a list of all (HTML) files contained in the epub archive. The user may pick a file from this list, which MMview will extract and display in the viewer pane.

Image formats ANI and PCX
With the addition of ANI (animated cursor) and PCX MMview now covers all (?) image formats natively supported by gtkdialog.

These are the formats supported. When extensions are added to the formats they are mandatory (but not case sensitive). Most formats are detected even without an extension.
  • ANI.ani
    BMP
    GIF
    ICO
    JPEG
    PCX.pcx
    PNG
    SVG.svg
    TIFF
    XPM.xpm
Toolbar
There is no interface to add/remove/manage buttons in this toolbar (and probably never will), but it's easy to edit the TOOLBAR variable in the script (currently line 822)
I seldom use icons and buttons since I prefer keyboard shortcuts so I don't know which buttons would be most suitable for a toolbar. Basically any menu item can be added. I think some more would be OK (which ones?), but I also want to avoid clutter.

Other changes
- Shift+click is gone! I liked this feature to open the default editor but I never liked the code involved to achieve a mouse+keyboard binding, which is not supported in gtkdialog. Now with a button in the toolbar I decided to clean the code. Three different ways to open an editor is enough, no need for a fourth option.
- HTML conversion now supports the <pre> tag
- changed menu 'Exit' and button 'Close' to more commonly used 'Quit'
Attachments
screenshot_mm_view_20180117.jpg
(107.51 KiB) Downloaded 473 times

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

#178 Post by MochiMoppel »

I have a strange problem: I can't view a text file when the file contains only 1 byte, e.g. number 0~9.

For such files the file command reports MIME application/octet-stream. MMview ignores this type as it typically indicates binary file content. ROX correctly reports a 1 byte text file as text/plain.

Is anyone able to view a 1-byte text file, probably with a better version of the file command?

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

#179 Post by greengeek »

I seem to have no problem here (on a Slacko 5.6 derivative). I assume you mean:
- create a text file (i used leafpad) containing a single digit (i entered the digit "1")
- Read that text file using the latest MMview version.

(MMview used Geany to open the file)

Seems to work fine.
Attachments
Read1digitSuccess.jpg
(87.85 KiB) Downloaded 361 times

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#180 Post by step »

This is on Fatdog64-721:

Code: Select all

# cd /tmp
# printf 0 > testfile
mm_view . &
# rox -m testfile
text/plain
# file testfile
testfile: very short file (no magic)
mm_view shows and empty pane and detects:
/tmp/testfile │ application/octet-stream; charset=binary

But

Code: Select all

# printf "0\n" > testfile2
# rox -m testfile2
text/plain
# file testfile2
testfile2: ASCII text
mm_view shows "0" and detects:
/tmp/testfile2 │ text/plain; charset=us-ascii
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

Post Reply