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
step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#141 Post by step »

You're correct

Code: Select all

# echo -n $'Hello\nWorld' | tr -s '\r\n' '\x01'
Hello0World# tr --version
tr (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering.
# echo -n $'Hello\nWorld' | busybox tr -s '\r\n' '\x01'
HelloWorld# 

[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]

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

#142 Post by MochiMoppel »

Fatdog again? I'm getting increasingly frustrated. Slacko and Tahrpup use busybox.

It appears that coreutils tr does not understand '\x01'. Though '\01' (or just '\1') should work in both coreutils and busybox, it is not understood by sed.

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

#143 Post by step »

I added "busybox" in front of "tr" and got clean output.
I share your frustration, though not about Fatdog but instead about the inconsistencies between busybox and GNU coreutils. I often end up replacing tr/sed/cut/grep pipelines with a single call to gawk, so I don't have to remember the syntax flavors of each utility.
[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]

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

#144 Post by SFR »

Code: Select all

$'\x01'
^ works fine for me in FD with both BB's and CU's tr.

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
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#145 Post by tallboy »

I am remastering and playing around with Lucid 5.2.8.7, (yes, I actually consider upgrading to a newer puppy - from 5.2.8.005-1 8) ). I have followed the development of MMview, so I decided to give it a go.
I am very impressed with MMview, but it need further development.

I have been a user of Lynx, the hierarchical terminal browser, for many years. I never use it as a browser, but as a file manager! Incredibly quick to navigate down through the layers using he right arrow key until reaching bottom. There you can see the file contents with less or other viewers, and link to editors and other programs for working with the file, from the keyboard. I had hoped for some of the same functionality in MMview, but it is of course not hierarchical. :(
Some remarks:
I miss a better indication of which window having focus, Places or files. May I suggest a change in pattern or color when ones laves a location, perhaps?

I also find the use of both keys and mouse a bit distracting, I prefer keys only in a program like this one. It is a bit unfair to compare MMview to Lynx, but I really miss the hierarchy function, it's so easy to use.

Strange behaviour, intended or not?:
To get a feeling of the program, I unintentionally ended up in /root/Choises/MIME-types/ and scrolled down to application_vnd.ms-work, and used Ctrl-F5 to see the contents. The file is empty, but to my surprise Abiword opened, ready for writing, with no real address in the status line of the frame, just the word root, no slashes.
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

#146 Post by MochiMoppel »

@tallboy: Thanks for playing around with MMview. I'm very impressed that you are impressed because MMview hardly works with Lucid 5.2.8.7. Most of the filetypes it is supposed to display are not recognized. Why? Lucid 5.2.8.7 uses an old version of the file command and there are probaly other factors that cause this version to often return only the mime-type of a file, but not the mime-encoding. And even the mime-type can be ambiguous. E.g. directories and symlinked scripts are reported as "application/x-not-regular-file". MMview can't work with such fuzzy information. Look at the statusbar of the screenshot in the initial post. I bet your statusbar looks different.
tallboy wrote:I had hoped for some of the same functionality in MMview, but it is of course not hierarchical.
I don't understand what you mean by "hierarchical".
tallboy wrote:I miss a better indication of which window having focus, Places or files.
That's your job: Choose a better GTK theme. Lucid by default uses Stardust, which indeed makes is hard to detect any difference between a focussed and not focussed selection. Lucid comes with GTK theme chooser and GTK theme maker. For me I changed selected text to bright red (see my screenshots) and have no difficulty to figure out if the Places pane or the file list has focus, but this is a global change and I have no business to interfere with a user's preferred GTK theme.
tallboy wrote:I also find the use of both keys and mouse a bit distracting
Then don't use a mouse. You can operate MMview only with keys.
tallboy wrote:Strange behaviour, intended or not?:
To get a feeling of the program, I unintentionally ended up in /root/Choises/MIME-types/ and scrolled down to application_vnd.ms-work, and used Ctrl-F5 to see the contents. The file is empty, but to my surprise Abiword opened
The strangeness is not intended, but the result is.
application_vnd.ms-work is a script and it is not empty. Ctrl-F5 does not let you "see the contents", it is supposed to run an executable. And since application_vnd.ms-work is supposed to open the defaultwordprocessor you will be greeted by Abiword when you apply Ctrl+F5. Hardly a surprise. The problem here is that you couldn't see the script contents in the viewer pane, which might have made you believe that the file is empty, but this is a result of the aforementioned problems with mime detection.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#147 Post by musher0 »

@tallboy

If I may:
You could compile the newest file utility (v. 5.31) on Lucid, could you not?
Sources: http://www.darwinsys.com/file (developer's page)
ftp://ftp.astron.com/pub/file (code)
Version 5.31 is at the bottom of the ftp page listing.
It is very easy to compile this utility.

About the lack of contrast of a particular GTK2 theme, you could leave
your general GTK2 theme alone and use a second GTK2 theme that has
the contrast you want, expressly for Mochi's MMView. This "two GTK2
themes" approach is nicely explained by urukrama here:
https://urukrama.wordpress.com/2008/07/ ... plications

My take on it is here. It's in French, and it's responding to a different
issue, but the examples may be helpful.

IHTH.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

some1
Posts: 117
Joined: Thu 17 Jan 2013, 11:07

#148 Post by some1 »

File is basically just a parser - with som default resolvements -
the more specific data are in the mime-database,the magic-files.

There are ways to update the mime-database -
and for USER to apply his/her own types.

As I recall - the puppy-wiki has a paragraph about adding mime-types.


MMview depends on the mime-types MochiMoppel covers,
probably those in Slacko/Tahr.
No objections to that.
----

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

#149 Post by tallboy »

Thank you for the feedback, Moppi. When I played with MMview, it slowly dawned on me that Lucid wasn't the ideal platform for MMview. But even if I wasn't so impressed with my results with MMview, because of Lucid, I am very impressed by the way you work and your dedication to the project. I bow to you.

Re hierachical: Even if I know what it means, but I could not find the words for an explanation (I'm a foreigner, you know!), so I cheated: :D Merriam-Webster dictionary present a definition of hierarchy as a graded or ranked series or a hierarchy of values.
A better explanation of Lynx is maybe that it see the directories and files as a tree. I once demonstrated it's use - with pictures - in this thread: http://www.murga-linux.com/puppy/viewto ... 137#839137

tallboy

stemsee

#150 Post by stemsee »

When previewing images/text/pdf etc what would it take to implement pinch to zoom in the preview window? For those of us with touch screens.

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

#151 Post by MochiMoppel »

stemsee wrote:When previewing images/text/pdf etc what would it take to implement pinch to zoom in the preview window?..
1) Installing at least GTK 3.14 (introduced the GtkGesture object)
2) Modifying the gtkdialog source code to support it. Good luck! :lol:

stemsee

#152 Post by stemsee »

MochiMoppel wrote:1) Installing at least GTK 3.14 (introduced the GtkGesture object)
2) Modifying the gtkdialog source code to support it. Good luck! :lol:
Pinch to zoom in/out works in geany and viewnior and browsers so teir gtkdialog source code must already be modified, right?

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

#153 Post by MochiMoppel »

Some unfinished business:
stemsee wrote:Pinch to zoom in/out works in geany and viewnior and browsers so teir gtkdialog source code must already be modified, right?
Wrong. None of them uses gtkdialog.

mime-types
some1 wrote:There are ways to update the mime-database -
and for USER to apply his/her own types.
For Lucid users this would be close to impossible as neither the update utility nor the database are included. And for updating the mime-types of directories and symlinks this may not even be sufficient. File must be clever enough to know what a directory is. No need for a database but maybe a recompilation as musher0 suggested? Who knows. Bottomline: this mime stuff is not trivial and I don't expect users to tinker with these files. If Lucid can't be changed, then MMview must change. I like Lucid and I'm pretty confident that I can adapt the script to Lucid's quirks, maybe not 100% but almost. If the changes don't affect overall performance I will do it. A new challenge :lol:

contrast
musher0 wrote:About the lack of contrast of a particular GTK2 theme, you could leave your general GTK2 theme alone and use a second GTK2 theme that has the contrast you want, expressly for Mochi's MMView
The easiest solution with the best performance possible is no theme at all. Either calling MMview with a small script

Code: Select all

#!/bin/bash
export GTK2_RC_FILES=
/path/to/mm_view
or inserting export GTK2_RC_FILES= at the beginning of the mm_view script. The result is a well balanced, no-nonsense, retro-style look from the 90s (see screenshot). I'm inclined to do that and give MMview a distinctive look, but I'm afraid users would kill me.

It is also possible to style only the leftmost "Places" pane and the main file list. Zigbert's GtkDialog - tips tread has an example how to enforce monospace text. Similar approach is possible for the chooser widget. This could be placed somewhere at the beginning of the script:

Code: Select all

MMSTYLE=/tmp/mm_view/mmstyle.txt
echo '
style "MMV" {
base[SELECTED]="Navy"                    # background of selected and focussed item
text[SELECTED]="white"                   # text color of selected and focussed item
base[ACTIVE]="LightSteelBlue"            # background of marked but unfocussed item
text[ACTIVE]="black"                     # text color of marked but unfocussed item
} class "GtkTreeView" style "MMV"
' > $MMSTYLE
export GTK2_RC_FILES=$MMSTYLE:/root/.gtkrc-2.0
I prefer to make no changes to MMview and count on the users to use a suitable theme that suits their taste and needs.
Attachments
mm_view_themeless.png
(50.67 KiB) Downloaded 834 times

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#154 Post by dancytron »

Nothing worthwhile to add, other than I just tried this out and it is really good.

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

possible universal 'playlist' manager

#155 Post by wiak »

Nice project - I really like it.

I've also found something extra you might find useful to handle right-click options in any file manager. It's xhplay (by mcewanw) which in conjunction with his modified xhippo can be used as a kind of universal 'playlist' manager, with which you can select from list of files what to play or view or edit or work on generally. It's not perfect as it stands, but works quite well, and I'm using it to make playlists of Audio files/video files and/or image files (jpg, animated gif, whatever...) but with slight mod of xhplay I've discovered you can also use any kind of file in a playlist (html, pdf, rtf, doc - again whatever. mcewanw probably already knew that...).

Overall I use the combination of file manager and xhippo/modded-xhplay as a rudimentary, easy to understand document management system - just calling up previously constructed playlists whenever wanted and using xhippo to control what to play/view/edit. To load files into xhippo you just highlight them in a filemanager and drag them into xhippo window (or use file manager right-click command Open-with for those filemanagers that provide that facility). You can also load any pre-made playlists (of any mixed file types) directly using xhippo load playlist command in xhippo itself.

I've recently posted in mcewanw's xhippo thread (link below) with details in the hope that he'll improve on my rough idea and supply a dotpet (since I can't do that). Also hoping he'll modify xhippo itself (or similar program 'potamus') to allow passing new file items into an already active playlist, but I he hasn't responded to my post yet. Though I'm no programmer myself I used to manage a small programming team that mcewanw helped me with in the past, and he had a virtual network with programming resources on it, which I still login to. However I haven't been in touch with him personally for a long time cos I've not been active in computing world - hopefully he'll get back to me on this if not via the forum.

I'm sure he'd like your universal file viewer program and maybe contribute.

It's nice.

Here is the xhplay/xhippo link (to my post on mcewanw xhippo thread):

http://www.murga-linux.com/puppy/viewto ... 816#960816

wiak

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

#156 Post by MochiMoppel »

@dancytron, wiak: Thanks for your feedback. Good to know that some people find this endeavour useful.

@wiak: xhippo and MMview follow different concepts and have not much in common. One interesting aspect is the concept of "playlists". In case of documents there should be a better word ("project files"?). The closest you can get in MMview would be a set of files/folders in the bookmarks area. I assume that many people haven't yet discovered how useful GTK bookmarks can be. From a programming point of view they are easy to maintain and - that's their beauty - they can be changed on-the-fly, so you could have different, predefined bookmark sets (call them "playlists") and display them in the bookmarks area as needed. I've experimented with this feature to automatically display the last used directories as a kind of view history. I'm undecided if anything of this is really needed. I suggest that for the time being you make good use of bookmarks. The area is already prepared and it's a waste of space not to use it.

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

#157 Post by MochiMoppel »

Update 2017-08-07 (see also initial post)

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

Though in theory with the versatile Commandbox/Terminal combo all file management operations can be performed, I often wished simpler access to basic functions. And then there are many users with an anaemic, VTE-less gtkdialog for whom the Commandbox is not an option.

Speaking of VTE: I will remove the Terminal from MMview. Works great, but few Puppies support it. Scheduled for next update.

MIME type recognition
Strange MIME type definitions were the root cause of MMview's poor performance under Lucid 5.2.8.
I reduced the dependence on the file command and rewrote the fill_statusbar function. Newly defined patterns in other functions are designed to make file type detection more robust.

Rename (move)
Menu File > Rename displays a Rename dialog similar to ROX-Filer. Unlike ROX-Filer it does not display the full path but only the basename, which I hope makes renaming a bit easier. Moving the file by adding the full path of its target location is still supported though.

Duplicate (copy)
This does basically the same as the irritating ROX-Filer "Copy" command - hopefully a bit better.
The Ctrl+C shortcut is normally associated with the "copy to holding space" kind of copy, the one that always comes in tandem with the "Paste" command. What ROX means is the "copy source file to target file" kind of copy. I prefer to call it "Duplicate". In its simplest form it creates a duplicate of the selected file in the same folder (requires a different name). When adding a full (absolute or relative) path the file can be copied to a different directory. Calling it "Duplicate" is also a good excuse for assigning the Ctrl+D shortcut, thus leaving the Ctrl+C shortcut intact for clipboard copies.

Delete
Does pretty much what one would expect, with an important extra feature: Wildcard characters are supported. As MMview does not support multiple selections, deleting multiple files could become tedious. WIldcard can make this job easier, e.g. '*.mp3' would wipe all mp3 files of the current directory. Be careful.

Other changes
- added support for .mpg videos
- added support for wmctrl (if installed will cause dialogs Find/Rename/Duplicate/Delete to stay on top)


Issues
An unresolved issue in Lucid 5.2.8: Viewing size of subfolders (F1 pressed after selecting folder) does not work due to an outdated sort command used in Lucid. I consider this feature (and Lucid) unimportant enough not to search for a fix.

General Gtk-filechooser issue: Chooser permanently scans the displayed file list and immediately updates the display when a file/folder is renamed or removed. This is not true for files/folders at the root level '/'. It's a bit irritating when nothing seems to have changed after a rename/delete operation but maybe this behavior is intentional (root level practically newer changes => no scan?).
Attachments
mmview_new_menuitems.png
(58.8 KiB) Downloaded 547 times

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#158 Post by smokey01 »

Nice.

The new functions Copy, Rename and Delete would be nice on a right click.

Thanks

User avatar
perdido
Posts: 1528
Joined: Mon 09 Dec 2013, 16:29
Location: ¿Altair IV , Just north of Eeyore Junction.?

#159 Post by perdido »

I have seven different versions of MMview on my desktop :)

When I open two different versions at same time there is no way to tell them apart except by looking at the MMview icon eyes that have changed color.
I am having a staring contest with icon eyes :shock:

Maybe an "About" on menu task bar somewhere with version number and author name could keep me from wondering which version I have open :)

Thank You Mochimoppel!

.

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

#160 Post by misko_2083 »

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.
Image
Attachments
mm_view_example.gz
(40.3 KiB) Downloaded 138 times

Post Reply