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 Mon 11 Dec 2017, 17:14
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 12 of 12 [172 Posts]   Goto page: Previous 1, 2, 3, ..., 10, 11, 12
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 1397
Location: Japan

PostPosted: Wed 13 Sep 2017, 09:03    Post subject:  

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

Next steps
I think I've reached the end of the line. I may throw in some convenience buttons and some tooltips, but basically that's it.
commandbox.png
 Description   
 Filesize   80.22 KB
 Viewed   411 Time(s)

commandbox.png

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


Joined: 26 Jan 2011
Posts: 1397
Location: Japan

PostPosted: Fri 20 Oct 2017, 00:30    Post subject:  

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.

When wmctrl is installed MMview displays images in "real" fullscreen. Without wmctrl the window manager's tray may still be visible, a kind of "good enough" fullscreen.
four_image_modes.jpg
 Description   
 Filesize   43.36 KB
 Viewed   320 Time(s)

four_image_modes.jpg


Last edited by MochiMoppel on Wed 08 Nov 2017, 08:34; edited 1 time in total
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1645

PostPosted: Fri 20 Oct 2017, 05:42    Post subject:  

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.
Quote:
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:
<window type-hint="6"
https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#GdkWindowTypeHint


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:
TEMPDIR=/tmp/mm_view.${USER}
?

Thanks &
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 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1397
Location: Japan

PostPosted: Sat 21 Oct 2017, 23:28    Post subject:  

@SFR: Thanks for your feedback. Very much appreciated.
Quote:
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 Laughing
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 or Very Mad Is there any workaround for that?

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


Joined: 26 Oct 2011
Posts: 1645

PostPosted: Sun 22 Oct 2017, 08:49    Post subject:  

Quote:
I can remove not only wmctrl support but also the decorated="false" attribute, right?

Yep.

Quote:
Is there any workaround for that?

Here's what I came up with so far. Comments explain everything, I hope:

Code:
#!/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

Quote:
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/questions/1314/how-to-set-default-file-permissions-for-all-folders-files-in-a-directory
but the '-d' (default) option gives 'operation not supported' in FD...

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

_________________
[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 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1397
Location: Japan

PostPosted: Wed 25 Oct 2017, 22:35    Post subject:  

SFR wrote:
Here's what I came up with so far.

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


Joined: 26 Jan 2011
Posts: 1397
Location: Japan

PostPosted: Thu 09 Nov 2017, 00:57    Post subject:  

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
text_fullscreen.jpg
 Description   
 Filesize   63.14 KB
 Viewed   98 Time(s)

text_fullscreen.jpg

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 12 of 12 [172 Posts]   Goto page: Previous 1, 2, 3, ..., 10, 11, 12
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.0660s ][ Queries: 15 (0.0125s) ][ GZIP on ]