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 Tue 21 May 2019, 14:55
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Building MMview, a universal file viewer
Post new topic   Reply to topic View previous topic :: View next topic
Page 18 of 18 [262 Posts]   Goto page: Previous 1, 2, 3, ..., 16, 17, 18
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 1836
Location: Japan

PostPosted: Wed 31 Oct 2018, 10:42    Post subject:  

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

This update emulates the "Open With..." menu of ROX-Filer, aka Right-click options. Actually it's Shift+RightClick.

In MMview the "Open With... " menu item can be selected from the"File" menu or with the mouse by middle-clicking a file in the tree list (right-clicking would not be an option as it can't be configured).

By default MMview searches applications in directory /root/.config/rox.sourceforge.net/SendTo.
This is the same directory from which ROX-Filer constructs its Shift+RightClick menu.
As in ROX-Filer this menu is MIME type sensitive and - if properly maintained ! - only offers applications for the specific MIME type of a selected file. The menu is devided into up to 3 MIME type sections (see screenshot).

This makes it possible for a user to increase MMview's functionality while making it easier for me to keep MMview simple. The screenshot shows an example (of my private setup): Middle-clicking on a JPEG file provides as first item the option to rotate the image. Would be difficult to integrate such option in the normal MMview menu as it doesn't fit anywhere. As my script uses the tool jpegtran, which only works for JPEG files, such menu in MMview would have to be disabled for non-JPEG files. A lot of work. Here the "Open With... " menu comes to the rescue as the upper section is visible only when a JPEG file is selected.

Two differences between ROX-Filer and MMview:
- MMview uses Xdialog to keep the code small and efficient, resulting in a "frugal" look & feel ... no icons! Double-click instead of single-click to select an item.

- MMview tries to emulate ROX-Filer and I can't guarantee that it always succeeds. I haven't found problems so far but that doesn't mean much.

Have fun!
MMview_MiddleClick_menu.jpg
 Description   
 Filesize   96.74 KB
 Viewed   542 Time(s)

MMview_MiddleClick_menu.jpg

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


Joined: 26 Jan 2011
Posts: 1836
Location: Japan

PostPosted: Tue 09 Apr 2019, 07:47    Post subject:  

Update 2019-04-09 (see also initial post)

After covering plain text files, audio/video and - at great length - image files there is one category MMview doesn't yet support: the "raw" display of binary files. Starting with this update I'll add some tools which to my knowledge don't exist in Puppy and which will make the forensic analysis of binary "black boxes" easier.

I also experiment with a multifunctional button, allowing one button to perform up to 9 different actions.

Hexdump
This is the classic hexdump -C command, but with a twist: There are only 10 hex values in a row and the offsets at the left are displayed in decimal and not hexadecimal. Limiting a row to 10 values should make it easier to relate ASCIIs on the right to their hex values on the left. Offsets in dec instead of hex are much more useful when it comes to using commands like head and dd. They are also much easier to grasp. My brain doesn't like hex.

Since hexdumps can be huge, time consuming and can cause a temporary freeze, display in the viewer pane is limited to 10KB

Hexdump in Leafpad
Alternatively hexdump can be redirected to leafpad. This is done in the background and therefore does not disrupt MMview. *Theoretically* there is no size limit.

Hexview
I don't know if this name makes sense. It's a special hexdump format which I created to analyze corrupted text files. When an ASCII control character somehow finds its way into a text file, the MIME format turns to application/octet-stream and the file becomes unreadable (for a text editor). Finding this one toxic character with a normal hexdump is like searching for a needle in a haystack. With the hexview format this character becomes visible immediately. There are much more uses for this format, e.g. when analyzing content and format of binary wordprocessor formats like MS Word .doc files.

Note that this view is displayed with line wrapping by default.

Hexview in Leafpad
Same functionality as in "Hexdump in Leafpad"

Convert text string
Strictly speaking this is a tool and not a view option as it does not relate to the selected file, but it is created with hexdump and is immensely useful, so I put it here.

It can answer simple questions, e.g. what the last letter of MochiMoppel might be, or reveal that Oops is a 6-letter word or detect the components of ( ͡° ͜ʖ ͡°) ,rufwoof's lenny face. It is also possible to paste multiline text selections into the entry field and analyze line endings and whitespaces.

Multifunction button
Used with a 3-button mouse the HEX button can trigger 6 different actions (see tooltip). 9 would be possible and theoretically much more, but I figure that 9 is the practical limit for this feature. Which action is triggered is determined by the duration after which the mouse button is released. After 0.3 sec and up to 1 sec the press action is triggered (the 0.3 sec can be changed with the THRESHOLD variable).
I don't know if users find this useful. Needs a bit of practice. Anyway, all actions (except for the help display) are also accessible from the "View" menu.

Other changes
I deleted the "Preferences" menu and moved the only remaining item (Vertical layout) into the "View" menu.
binary_options.jpg
 Description   
 Filesize   180.4 KB
 Viewed   347 Time(s)

binary_options.jpg

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


Joined: 26 Jan 2011
Posts: 1836
Location: Japan

PostPosted: Tue 14 May 2019, 23:13    Post subject:  

Tips & Tricks No.1

In the future I intend to throw in a couple of tips & tricks that I find noteworthy. I might also add some code snippets from my personal edition that will enhance the functionality but which I have no intention to add to the officially posted version.

Code folding
Someone kindly pointed me to the newest edition of Smokey's newsletter, which to my surprise contains a full code listing of MMview. Just for the record: I didn't write or suggested this contribution. I don't mind either.

1463 lines of code Shocked - this is heavy stuff for the readers and looks intimidating, even to me. Though I try my best to keep the code short I also like to keep everything in one file, which over time adds to quite an amount of bytes.

The trick to make this code digestible without losing one's sanity is code folding. In Geany it's Menu Document -> Fold All. This will shrink the whole stuff to just 47 lines and is the first thing I do whenever I open the script. It allows to examine/edit only the sections of interest. Code folding further applies to the case statements in functions view_instantly and view_on_demand. Code folding is achieved by surrounding the sections that should fold with curly braces.
mmview_folded.png
 Description   
 Filesize   72.45 KB
 Viewed   261 Time(s)

mmview_folded.png

Back to top
View user's profile Send private message 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15343
Location: Paradox Realm

PostPosted: Sat 18 May 2019, 06:28    Post subject:  

Outstanding GNU programming @MochiMoppel Very Happy

Many thanks Cool I will be studying the code ... and feeling inadequate Embarassed

Bravo. Well done. Idea

_________________
Newsletter May 019 now available from Smokey and contributors
New Puppy Development Puppy 9 ... coming ...
Back to top
View user's profile Send private message Visit poster's website 
Leon

Joined: 22 Jun 2005
Posts: 259

PostPosted: Sat 18 May 2019, 14:47    Post subject:  

MochiMoppel wrote:
After covering plain text files, audio/video and - at great length - image files there is one category MMview doesn't yet support: the "raw" display of binary files. Starting with this update I'll add some tools which to my knowledge don't exist in Puppy and which will make the forensic analysis of binary "black boxes" easier.

I also experiment with a multifunctional button, allowing one button to perform up to 9 different actions.

Congratulation and thanks for MMview and thanks for improving it.

Using it in Quirky Beaver 8.7.1 is a pleasure.

I tried many viewers and in one particular case I found MMview really handy. Newer versions of Firefox browser offer an option to save a web page as a picture and that is often much longer than a single screen size. I found MMview is the best of all viewers that i tried when viewing web page contents saved in picture format. With a single left click inside the picture MMview properly maximizes it to a screen width and shows scrollbar when needed. With another single left click inside the picture MMview restores the picture to a previous size. When viewing a web page picture with MMview I sometimes forget that I’m not working with browser.

MochiMoppel wrote:
In the future I intend to throw in a couple of tips & tricks that I find noteworthy. I might also add some code snippets from my personal edition that will enhance the functionality but which I have no intention to add to the officially posted version.

From my experience with using MMview there is only one and only issue left to be solved to use it as default viewer and this is:

How to click a file name in Rox and pass it to MMview to open it?

Is there a trick to do that?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1836
Location: Japan

PostPosted: Sun 19 May 2019, 22:13    Post subject:  

Lobster wrote:
I will be studying the code ...
Have fun! I'm sure you will find plenty of room for improvement. And thanks for the encouragement.

Leon wrote:
From my experience with using MMview there is only one and only issue left to be solved to use it as default viewer and this is:
How to click a file name in Rox and pass it to MMview to open it?
Is there a trick to do that?
I'm glad to hear that you like and actually use the script.
I don't quite agree that there is only one issue left Laughing

What you describe is not possible with the chooser widget. To be more precise: It would be possible to pass a filename to MMview and show the file content in the viewer, but it would not be possible to select the corresponding filename in the file list programmatically (a limitation of the chooser widget) . This would lead to an irritating status where the viewer content is not the content of the highlighted file in the list. If you are interested in such odd behavior I can provide the code but I don't think that I should implement it. It surely will be perceived as a bug.

My best advise is to keep MMview open and drag the filename from ROX-Filer to the MMview file list. This is the only way to have the chooser widget select a specific file (apart from manual selection). This also changes automatically to the relevant directory. I find this method pretty neat. Too bad that there is no other way to do that.
Back to top
View user's profile Send private message 
Leon

Joined: 22 Jun 2005
Posts: 259

PostPosted: Yesterday, at 09:40    Post subject:  

MochiMoppel wrote:
What you describe is not possible with the chooser widget. To be more precise: It would be possible to pass a filename to MMview and show the file content in the viewer, but it would not be possible to select the corresponding filename in the file list programmatically (a limitation of the chooser widget) . This would lead to an irritating status where the viewer content is not the content of the highlighted file in the list. If you are interested in such odd behavior I can provide the code but I don't think that I should implement it. It surely will be perceived as a bug.

My best advise is to keep MMview open and drag the filename from ROX-Filer to the MMview file list. This is the only way to have the chooser widget select a specific file (apart from manual selection). This also changes automatically to the relevant directory. I find this method pretty neat. Too bad that there is no other way to do that.
Thank you for the explanation and for the suggestion.

MochiMoppel wrote:
If you are interested in such odd behavior I can provide the code
Yes, I’m interested.
I could configure Rox right click to open two different versions of MMview. Idea

MochiMoppel wrote:
but I don't think that I should implement it. It surely will be perceived as a bug.
I agree. Very Happy
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 18 of 18 [262 Posts]   Goto page: Previous 1, 2, 3, ..., 16, 17, 18
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.0696s ][ Queries: 13 (0.0281s) ][ GZIP on ]