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 Wed 18 Oct 2017, 05:37
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Building a universal file viewer
Post new topic   Reply to topic View previous topic :: View next topic
Page 7 of 12 [166 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 Next
Author Message
Lobster
Official Crustacean


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

PostPosted: Tue 21 Mar 2017, 11:32    Post subject:  

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.


Rolling Eyes

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

Appreciate it Mr. Green

Live Long and Puppy (traditional)

_________________
YinYana AI Buddhism
Back to top
View user's profile Send private message Visit poster's website 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 1491
Location: nyc

PostPosted: Wed 22 Mar 2017, 10:59    Post subject: hope you don't mind my efforts, Mochi
Subject description: (i meant well)
 

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

Crying or Very sad Very Happy
dabullmv-mmv-dmv.jpg
 Description   
 Filesize   2.8 KB
 Viewed   654 Time(s)

dabullmv-mmv-dmv.jpg

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


Joined: 26 Jan 2011
Posts: 1365
Location: Japan

PostPosted: Thu 06 Apr 2017, 01:59    Post subject:  

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.
mmview_archive.png
 Description   
 Filesize   147.88 KB
 Viewed   602 Time(s)

mmview_archive.png

mmview_directories.png
 Description   
 Filesize   116 KB
 Viewed   603 Time(s)

mmview_directories.png

mmview_runinconsole.png
 Description   
 Filesize   209.82 KB
 Viewed   605 Time(s)

mmview_runinconsole.png

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


Joined: 20 Jul 2010
Posts: 4658
Location: Republic of Novo Zelande

PostPosted: Thu 06 Apr 2017, 05:26    Post subject:  

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?
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1635

PostPosted: Thu 06 Apr 2017, 09:57    Post subject:  

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:
--- 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!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 19

PostPosted: Thu 06 Apr 2017, 12:14    Post subject:  

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:
file $FILE


Code:
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]
ausb.sh.bz2
Description 
bz2

 Download 
Filename  ausb.sh.bz2 
Filesize  1.76 KB 
Downloaded  41 Time(s) 
Back to top
View user's profile Send private message 
bpuppy
Guest


PostPosted: Fri 07 Apr 2017, 10:45    Post subject:  Re. The multiviewer
Subject description: A whish come true...
 

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 !!
Back to top
slavvo67

Joined: 12 Oct 2012
Posts: 1424
Location: The other Mr. 305

PostPosted: Fri 07 Apr 2017, 17:38    Post subject:  

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
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1365
Location: Japan

PostPosted: Mon 10 Apr 2017, 00:11    Post subject:  

@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 Laughing 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.
Back to top
View user's profile Send private message 
greengeek


Joined: 20 Jul 2010
Posts: 4658
Location: Republic of Novo Zelande

PostPosted: Mon 10 Apr 2017, 04:05    Post subject:  

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!
Back to top
View user's profile Send private message 
perdido


Joined: 09 Dec 2013
Posts: 631
Location: Altair IV , Just north of Eeyore Junction.

PostPosted: Mon 10 Apr 2017, 04:32    Post subject:  

MochiMoppel wrote:
Update 2017-04-06 (see also initial post)



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.

.


Hi MochiMoppel,

This is an improvement.
One thing about it.
When I use the F1 to look at my /mnt/home/ directory I get no directory list in the right-side window due to my /mnt/home/ being a sym-link. Though /mnt/home/ does open and display contents in the left side window when clicked.

Also....
Are there plans to implement the [Esc] key to back out of things?

Thanks Very Happy

.
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1635

PostPosted: Mon 10 Apr 2017, 06:36    Post subject:  

MochiMoppel wrote:
can I be sure that MIME is always labeled as 'x-gzip' and 'x-xz' and not 'gzip' and 'xz'?

At least in case of 'gzip', you can't - file (at least versions 5.04, 5.28 & latest) uses 'x-gzip', however Fatdog uses this patch from Debian:
Code:
Description: Report gz as application/gzip
Author: Daniel Baumann <mail@daniel-baumann.ch>
Bug-Debian: https://bugs.debian.org/688886
Last-Update: 2015-09-18

--- a/magic/Magdir/compress
+++ b/magic/Magdir/compress
@@ -21,7 +21,7 @@
 #   * Produce shorter output - notably, only report compression methods
 #         other than 8 ("deflate", the only method defined in RFC 1952).
 0       string          \037\213        gzip compressed data
-!:mime   application/x-gzip
+!:mime   application/gzip
 !:strength * 2
 >2   byte      <8      \b, reserved method
 >2   byte      >8      \b, unknown method

So, probably all Debian-based distros (including some Puppy derivatives), have it, too.

But there can be more:
https://tools.ietf.org/html/rfc6713 wrote:
Some applications have informally used media types including application/gzip-compressed, application/gzipped, application/x-gunzip, application/x-gzip, application/x-gzip-compressed, and gzip/document to describe data compressed with gzip.

Perhaps using *gzip*) (or even *g*zip*) instead of gzip) in case statement would be more reliable...

Anyway, the bottom line is that application/gzip is the right one.

Quote:
I also don't know if the tar command really needs the -I option since it seems to sniff the compression program without it.

Yeah, it shouldn't have problems with auto-detecting the used compression method.

Quote:
Seems that MIME application/x-gzip can be a lot of things. I don't like that Laughing

Then you're gonna hate this - just checked in UExtract and files with the following extensions can be seen as application/gzip:
  • .adz
  • .apk
  • .bgz
  • .blend
  • .cgz
  • .cld
  • .cpgz
  • .cpio.gz
  • .cpio.gzip
  • .cvd
  • .cxarchive
  • .depot.gz
  • .dia
  • .dsl
  • .dz
  • .emerald
  • .emz
  • .epk
  • .fat
  • .gnumeric
  • .graphmlz
  • .gtp
  • .gz
  • .gzi
  • .gzip
  • .iar
  • .igz
  • .ipk
  • .jgz
  • .mpz
  • .nif
  • .oar
  • .obt
  • .ogz
  • .pet
  • .psz
  • .qpk
  • .qpr
  • .rub
  • .sdz
  • .sifz
  • .svgz
  • .tar.gz
  • .tar.gzip
  • .tg
  • .tgz
  • .unitypackage
  • .vbox-extpack
  • .vgz
  • .wrz
  • .x3d
  • .xcfgz
  • .xjtgz
  • .zabw

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4745

PostPosted: Mon 10 Apr 2017, 19:31    Post subject:  

all posix shells do globbing, so you can use application/*gzip in your case statement. This reminds me of some code I threw together to implement Xarchive in shell and gtkdialog. I only wrote the reading and formatting code for it, but it seems like that might be enough for your usage. I'm on my droid right now, so the link will have to wait, but it is linked to in goingnuts gtkdialog1 (backport to gtk1) thread.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1365
Location: Japan

PostPosted: Tue 11 Apr 2017, 23:24    Post subject:  

@greengeek As I already tried to explain: In principle there is no relation between symlink and viewability, hence no need to highlight, blink or sound anything when a symlink is not viewable. The only case where such relation exists would be a dead link, but this would be evident from the status bar and I don't intend to take additional measures for such case.

@perdido I'm not sure what you are after. The behavior you describe is normal and intended, but maybe not well understood and the "no subdirectories" message is irritating ( a not dereferenced symlink can't have subdirectories by definition). After lot of hair pulling I concluded that it would be best to avoid any ambiguities by treating links like empty directories: Just a hint that it's a symlink to <target> and no additional F1 info. And while I'm at it I will do the same for the /proc directory. Just a hint that it's a virtual file system. Avoids needless processing and delays for calculating useless information.

Regarding [Esc]: Plans? It's already implemented. The [Esc] key serves as the panic key for stopping autoplay and was introduced with Update 2017-02-04 ("To stop the audio: Press ESC key or change to non-audio file or close the window or dbl-click the file, which will stop ffplay and start to play the file in the default player.")

@SFR,technosaurus I think I'll have to tackle any problems resulting from this mess pragmatically. Knowing the specs of files inside an archive is nice but not terribly important. If MMview fails for any less common archive construction, it fails. Not the end of the world. Here is what I will do:
- throw an archive to tar and see if it can display the contents
- if not, feed it to gzip. Ideally the content is a single text file. MMview would display the content of the file, and that's the ultimate purpose of the viewer.
- if it wasn't a gzip file? Bad luck.

As a bonus I will add support for .iso images, .zip and .7z archives, and that should be it. If I screw up or something is really missing the users will let me know ... maybe.
Back to top
View user's profile Send private message 
greengeek


Joined: 20 Jul 2010
Posts: 4658
Location: Republic of Novo Zelande

PostPosted: Wed 12 Apr 2017, 05:39    Post subject:  

MochiMoppel wrote:
@greengeek As I already tried to explain: In principle there is no relation between symlink and viewability, .
Accepted. I think my post was badly written - i was not re-requesting symlink info to be displayed, just asking if file types (for non-viewable files) could be highlighted in some way.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 7 of 12 [166 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 Next
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.0932s ][ Queries: 14 (0.0174s) ][ GZIP on ]