/usr/lib/gtkdialog/box_splash and animated gif icons?

Please post any bugs you have found
Message
Author
User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#31 Post by Argolance »

Bonjour à vous,
wiak wrote:I was referring to Argolances earlier post, which did say gtkdialog3 only worked with that old Precise gtkdialog-splash (with animated gifs). But, as I said, I also found gtkdialog4 also worked fine in my test.
I'm sorry if I misled you, but that's not what I meant and tried to report:
Argolance wrote:I imported box_splash in my Puppy Precise 5.7.3 based system [...] I see that box_splash supports animated gifs too [...]. This works as long as the /tmp/yaf-splash is linked to /usr/sbin/gtkdialog3. If I delete this link, box_splash creates automatically a link to /usr/sbin/gtkdialog which is a link to gtkdialog4 and animated gifs are not supported anymore.
So, this was concerning box_splash and not the "old" puppy precise "gtkdialog-splash". To be more accurate, I imported both /usr/lib/gtkdialog/box_splash and /usr/bin/gtkdialog-splash from Tahr 6.0.5 to my Puppy Precise based system. This /usr/bin/gtkdialog-splash is not a script like the old one but just returns to box_splash via this command:
Contents:

Code: Select all

exec /usr/lib/gtkdialog/box_splash "$@"
As attached file, "gtk-splash" for those who might find it useful. It is the Puppy Precise gtkdialog-splash but renamed and modified to be totally stand-alone, avoiding any conflict with other programs of the same type and perhaps other unexpected problems.

[EDIT]: this may be added to /root/.jwmrc:

Code: Select all

<Group>
<Class>gtk-splash</Class>
<Option>nolist</Option>
<Option>layer:above</Option>
<Option>nofocus</Option>
</Group>
or gtk-splash modified to work using this class if already existing:

Code: Select all

<!-- created 130618, a class for all future popups -->
<Group>
<Class>splashwindow</Class>
<Option>nolist</Option>
<Option>layer:above</Option>
<Option>nofocus</Option>
</Group>
Cordialement.
Attachments
181012_123548_582x368_easyshot.jpg
(58.37 KiB) Downloaded 724 times
gtk-splash.gz
To be renamed as gtk-splash without .gz
(5.55 KiB) Downloaded 262 times
Last edited by Argolance on Fri 12 Oct 2018, 11:50, edited 1 time in total.

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

#32 Post by wiak »

Argolance wrote:Bonjour à vous,
wiak wrote:I was referring to Argolances earlier post, which did say gtkdialog3 only worked with that old Precise gtkdialog-splash (with animated gifs). But, as I said, I also found gtkdialog4 also worked fine in my test.
I'm sorry if I misled you, but that's not what I meant and tried to report:
Argolance wrote:I imported box_splash in my Puppy Precise 5.7.3 based system [...] I see that box_splash supports animated gifs too [...]. This works as long as the /tmp/yaf-splash is linked to /usr/sbin/gtkdialog3. If I delete this link, box_splash creates automatically a link to /usr/sbin/gtkdialog which is a link to gtkdialog4 and animated gifs are not supported anymore.
So, this was concerning box_splash and not the "old" puppy precise "gtkdialog-splash".
Ah, sorry, my mistake entirely; I misread your earlier post.

wiak

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#33 Post by fredx181 »

ITSMERSH wrote:
fredx181 wrote:Just experimented for fun :lol: :
......
Extract launch.tar.gz and run "launch" (inside "launch" folder)
Has 15 seconds timeout, it's using the older gtkdialog-splash that Argolance shared earlier in this thread.

Fred
Uaaahhh, that's really great.

Exactly what I need for my QTR Suite (my Music Suite to run, control and connect all the programs from a project). I have added a option to the launch script, so it combines the sound of a rocket launch (using aplay) for about 18 seconds (faded out) while displaying the gif image when starting QTR Suite.

Great, thanks!
Haha, you're welcome !

Can you share someway that rocket launch sound and the code of your setup ?
Sorry for the off-topic Argolance, but please understand, that rocket sound is a must have addition ! :) 8)

Fred

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#34 Post by Argolance »

Bonsoir,
Sorry for the off-topic Argolance, but please understand, that rocket sound is a must have addition !
Do not worry! On the contrary, I am delighted to see that this topic is attracting some interest...
Do as you feel like it!

Cordialement.

ITSMERSH

#35 Post by ITSMERSH »

fredx181 wrote:Haha, you're welcome !

Can you share someway that rocket launch sound and the code of your setup ?
Sorry for the off-topic Argolance, but please understand, that rocket sound is a must have addition ! :) 8)

Fred
Yes, this is a must have addition! :wink:

All in one package at datafilehost.com. Since they have changed the duration of keeping files it will stay at least for 90 days after last download.

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#36 Post by fredx181 »

ITSMERSH wrote:
fredx181 wrote:Haha, you're welcome !

Can you share someway that rocket launch sound and the code of your setup ?
Sorry for the off-topic Argolance, but please understand, that rocket sound is a must have addition ! :) 8)

Fred
Yes, this is a must have addition! :wink:

All in one package at datafilehost.com. Since they have changed the duration of keeping files it will stay at least for 90 days after last download.
Ok, turned up the volume to the maximum, and went to Mars, stayed there for a while and after that traveled to Pluto, but...
My WIFI didn't work, could that be a bug in your program ?
Also I asked around there, nobody had ever heard of the Puppy Linux Discussion Forum, strange...

Hmmm.. very inconvenient, I had to travel back to Earth just to thank you, so...

Thank you !! :) Works nicely !

P.S. Decided to stay on Earth, the food on Pluto is terrible.

Fred

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

#37 Post by MochiMoppel »

Argolance wrote:I imported box_splash in my Puppy Precise 5.7.3 based system [...] I see that box_splash supports animated gifs too [...]. This works as long as the /tmp/yaf-splash is linked to /usr/sbin/gtkdialog3. If I delete this link, box_splash creates automatically a link to /usr/sbin/gtkdialog which is a link to gtkdialog4 and animated gifs are not supported anymore.
If box_splash really supports animated gifs when it calls gtkdialog3 but not when it calls gtkdialog4 then my earlier suspicion that gtkdialog is to blame would be true.

That's hard to believe and it's not what I have experienced. Could it be that somehow you finally symlinked to your old gtkdialog-splash?

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#38 Post by fredx181 »

Here's what I think that is the point:

- When using box_splash with yaf-splash linked to gtkdialog3 then -icon_width value doesn't really resize, it just makes "room". (second pic)
- When using box_splash with yaf-splash linked to gtkdialog4 then -icon_width does resize, e.g. when using a .png of size 128x128 and use "-icon_width 48", it does display as 48x48 (first pic)
So when using a .gif (with yaf-splash linked to gtkdialog4), it "tries" to resize, resulting in that it doesn't display as animated.
EDIT: And if using a .gif with yaf-splash linked to gtkdialog3, then .gif animation works, just need to give it enough room by adjusting -icon_width.
BTW, I found that some systems may have gtkdialog3 as a symlink to gtkdialog. (it's the case on d-pup-Stretch from radky)

Fred
Attachments
2018-10-14-103833_210x98_scrot.png
Using box_splash with yaf-splash linked to gtkdialog4, -icon_width 48
vlc.png = size 128x128 displays as 48x48
(4.23 KiB) Downloaded 521 times
2018-10-14-103536_210x178_scrot.png
Using box_splash with yaf-splash linked to gtkdialog3, -icon_width 48
vlc.png = size 128x128, the -icon_width 48 setting gives not enough &quot;room&quot;
(11.67 KiB) Downloaded 520 times

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

#39 Post by MochiMoppel »

Confirmed.
gtkdialog3 doesn't understand <width> but supports width-request attribute.
width-request results in cropping but not (proportional) scaling, Since gtkdialog3 ignores <width>, the tag that results in scaling, box_splash calling gtkdialog3 can display animated gifs. Depending on the width setting animated gifs may be cropped, but they are still animated.

Suddenly everything Argolance reported makes sense: The "old" gtkdialog-splash expects gtkdialog3, the newer ones and box_splash expect gtkdialog4. When he runs box_splash in Precise where an "old" gtkdialog-splash, the one that came with Precise, had already created the symlink /tmp/yaf-splash to gtkdialog3, box_splash would meticulously check if the required gtkdialog4 is installed (which in Precise it is) , but then would gladly use any /tmp/yaf-splash it finds, without checking if it links to the correct gtkdialog.

Still box_splash needs some changes. I'll post a fixed version.

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

#40 Post by wiak »

As mentioned above, my most recent code addition in my fork called gtkwialog was to allow preserving or not preserving aspect ratio of a pixbuf image related to the initial creation of a pixmap. The additional code I used satisfied my intention. That was a while ago, and since I've not been coding since then I had forgotten what was involved but looking at it again now I see that I did not implement similar functionality for the pixmap <input file> mechanism since that wasn't my concern at the time. However, I will try that in gtkwialog now (since the code change is very similar); I have no idea however what effect the different gtk function with additional capability to 'not-preserve-aspect-ratio' on scaling (i.e. supplying width parameter) will have on an animated gif file input loading since I can't determine that from the Gtk reference functiond description. So may well be irrelevant for this thread issue. Nevertheless, worth a try I feel, so I'll test that C code addition. It could (???) in any case be useful in other scenarios to also be able to not-preserve-aspect-ratio on input file images (EDIT: but not sure of difference in practice to what I already achieved in that regard... I believe, from re-examining gtkwialog sources, the input from file code will only come into play on refreshing the image - so doubt relevance in this thread issue - but for my earlier purposes, I probably should have that too - I forgot about refresh possibility). I'll attempt that in gtkwialog tomorrow, since late at night here just now, and report back accordingly.

There may be some other remedy regarding scaling and animated gif, of course.

wiak

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

#41 Post by wiak »

Yeah, seems to be that any value for <width> or <height> other than -1 prevents gif animation (or of course leaving width and height values out altogether). I'm using the following simple test program (this is with gtkwialog, which accepts the preserve-aspect-ratio tag, which can of course be omitted if using gtkdialog instead).

Code: Select all

#! /bin/sh
# Needs test.gif image in script start directory

export MAIN_DIALOG='
<window>
  <vbox>
    <pixmap preserve-aspect-ratio="false">
      <variable>IMAGEN</variable>
      <height>300</height>
      <input file>./try.gif</input>
    </pixmap>
  </vbox>
</window>'
gtkwialog  -p MAIN_DIALOG
I haven't actually tried my new code yet and also a couple of other things I'll try. For example, there is a break statement in current gtkwialog and gtkwialog and gtkdialog4 code to load only one image into pixbuf (different code altogether in gtkdialog3 for pixbuf stuff - no such break); I will try removing that break in the gtkwialog pixbuf loading loop... - not sure how that effects animated gif type file (I don't know animated gif format, except number of images in the file, so suspicious if that break statement is the problem in gtkdialog4).

gtkdialog3 uses GtkImageMenuItem [EDIT: No - that's just for menu stock/icons] functions (deprecated), gtkwialog4 on the other hand uses straight GtkImage functions.

I'm just documenting these points here to remind me when I look into it further tomorrow.

wiak
Last edited by wiak on Mon 15 Oct 2018, 23:46, edited 1 time in total.

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

#42 Post by MochiMoppel »

Here my proposal for a fixed box_splash.
IMO more fixed and efficient code is needed, but I tried to keep my changes to a minimum. Changes are marked in the code so they are easy to remove if you don't like them.

Animated GIFs support
This was the easiest part. Just changed ICON_WIDTH=32 to ICON_WIDTH=-1
By default icons are now displayed in their original size. Since the user is free to use the -icon_width option if resizing is required, a 32px default made no sense anyway.

Mouse cursor kills dialog
This bug drives me nuts as long as I can remember. It occurs when the mouse cursor happens to be at the same position as the opening dialog. Example: Mouse cursor near the center, box_splash (or gtkdialog-splash) opens with its default -placement (center) and -close (mouseover) options. In this case box_splash closes immediately before the user has a chance to read the message. Surely a "splash", but a useless one.
I tried to fix this idiotic behavior by adding a 150 ms grace period during which an exit is not possible. This gives the dialog the necessary time to load the image and "settle down" and prevents a phony premature "mouseover" event.

-deco
This option now works. A variable assignment was missing.

Always on top
This forces the message to pop up on top of any other window, e.g. a fullscreen youtube window. IMO should be standard for such info/alert dialogs. Note: This will not work when the -deco option is used (actually I've never seen it being used, so probably not a problem)
Attachments
box_splash_fixed.gz
This is a gzipped script and the extension is NOT a fake extension ;-)
(4.24 KiB) Downloaded 238 times

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

#43 Post by wiak »

wiak wrote:My own assumption is that all will be fine if <width> is not used or set perhaps to -1 when animated gif the image
...
I'm saying that based on the C code in gtkdialog4 where, by default, width and height default to -1).
Okay, I've taken time to look at the pixmap code now and none of my previous thoughts are particularly relevant (except my quoted comment above).

It seems to me quite simply that in gtkdialog (any version) unscaled images can include animations whereas scaled images cannot.

In gtkdialog3 or in gtkdialog4 (where width and height are default -1), the GtkImage is created by the Gtk convenience function:

Code: Select all

gtk_image_new_from_file
which has result, according to Gtk docs:
If the file isn't found or can't be loaded, the resulting GtkImage will display a "broken image" icon. This function never returns NULL, it always returns a valid GtkImage widget.

If the file contains an animation, the image will contain an animation.
Scaled images are an enhancement of gtkdialog4 (identified by width and height not equal to default -1). For this capability, Gtk function gtk_image_new_from_file is not used since it does not include size/scaling capability built in. Rather, the image is first loaded into a pixbuf using a Gdk function:

Code: Select all

gdk_pixbuf_new_from_file_at_size
(the result is just a re-scaled pixbuf - no animation)

followed by creating the GtkImage from the pixbuf using Gtk function:

Code: Select all

gtk_image_new_from_pixbuf
So no animation capability for re-sized/scaled image.

So, as I said in earlier post, if you need animation with gtkdialog4, make sure width and height are set to -1 (or not set at all in which case they default to -1), which is value the gtkdialog4 code uses to determine whether or not to use animation-capable function gtk_image_new_from_file.

wiak

EDIT: This thread should really be in 'Programming' section since not actually any bug per se (well, I suppose box_splash wasn't able to animate gifs when expected, so a sort of a simple bug in that not using -1 for width for default case...). If the facility to scale gif animations was wanted, maybe it could be done by using gdk_pixbuf_animation_new_from_file, than maybe getting static frames from that (gdk_pixbuf_animation_get_static_image?) and scaling them and then iterating to next frame (gdk_pixbuf_animation_iter_advance???), each time creating a GtkImage of the frame using gtk_image_new_from_pixbuf. But I'm just guessing and clearly that is complicated. For example - the following library details seem relevant for those into doing this:

https://github.com/GNOME/gdk-pixbuf/blo ... led-anim.c

Also: https://github.com/GNOME/gdk-pixbuf/blo ... f-loader.c

Does anyone know an easy way in C/GTK+? Can be done in Python apparently, which internally may do something like I suggest. See the one Answer:

https://stackoverflow.com/questions/248 ... with-pygtk

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#44 Post by fredx181 »

MochiMoppel wrote:Here my proposal for a fixed box_splash.
....
....
Thanks for the fixes !

There's still one (small) thing that annoys me, it is that sometimes the dialog turns out much wider than intended.
For example when I use variable for $msg to get two lines, e.g.

Code: Select all

msg=`echo -e "Processing\nThis may take a while . . ."`
./box_splash_fixed -icon ./prefs.png -icon_width 48 -placement center -bg blue -fg white -text "$msg" -close never -timeout 5
See first pic.

I think a good "fix" would be changing line 183:

Code: Select all

#NR_CHARS="$((${#text}+1))"
# fredx181, commented out above, in case multiple lines, find the longest line for NR_CHARS
NR_CHARS="$(echo -e "$text" | awk '{ print length }' | sort -n | tail -1)"
See second pic, gives less width.

Fred
Attachments
more-width.png
Much wider than intended.
(12.51 KiB) Downloaded 298 times
less-width.png
Less width, used modified box_splash as described above
(11.26 KiB) Downloaded 300 times

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#45 Post by Argolance »

Bonjour,
fredx181 wrote:There's still one (small) thing that annoys me, it is that sometimes the dialog turns out much wider than intended
Sometimes very much more than intended to the point of filling almost the entire desktop (see picture at the beginning of this thread).
I'll add another small annoying thing: the icon is not centered horizontally (:arrow: reported in this thread).

[EDIT]: something else, just as a suggestion.
I wonder if it would not be interesting to disable automatic wraping to avoid words or expressions being cut in half (as shown in the images below) or allow to get the text in a single line. Both versions, the old and the new one have this defect.

Cordialement.
Attachments
181006_160413_442x62_easyshot.jpg
box_splash
(4.24 KiB) Downloaded 292 times
181006_144715_272x55_easyshot.jpg
&quot;Old&quot; gtkdialog-splash
(4.63 KiB) Downloaded 283 times

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

#46 Post by MochiMoppel »

fredx181 wrote:There's still one (small) thing that annoys me, it is that sometimes the dialog turns out much wider than intended.
One of the small things I meant when I wrote "more fixed and efficient code is needed".
I wanted to fix the same line, but for a different reason.
As you can still see from the comments in the script, this line is a modified and more efficient version of

Code: Select all

NR_CHARS="`echo "$text" | wc -c`"
Of course this is wrong as echo without the -n option will add a linefeed character and a text containing 6 characters will have a character count of 7. Not a big deal, but with an image-only splash box, this will create an ugly. empty space at the right edge for 1 useless linefeed character.

The modified version attempts to produce the same (wrong) result. A case of bug emulation :lol:

Like you I also wondered why all characters and not just those of the longest line were counted but I didn't dig deeper. It seems that you are right and that different counting gives better results. Your code could be made shorter though. Instead of

Code: Select all

NR_CHARS="$(echo -e "$text" | awk '{ print length }' | sort -n | tail -1)"
the wc command can return the length of the longest line:

Code: Select all

NR_CHARS="$(echo "$text"| wc -L )"
(I removed the -e option to make it backward compatible
Argolance wrote:I'll add another small annoying thing: the icon is not centered horizontally
You mean vertically? That's intentional, I guess. A spacer is added below the icon to keep it in the upper left corner
I wonder if it would not be interesting to disable automatic wraping
Just do it! Set -wrap to "false" and see what happens :lol: Can have surprising and not always pleasant effects.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#47 Post by Argolance »

Bonjour,
MochiMoppel wrote:You mean vertically?
Yes I do! :?
That's intentional, I guess. A spacer is added below the icon to keep it in the upper left corner
Intentional, but still ugly. :)
Just do it! Set -wrap to "false" and see what happens :lol: Can have surprising and not always pleasant effects.
It is what I did with gtk-splash...
On the one hand, I only think that it can sometimes be useful to display a text on a single line and on the other hand, to put the line breaks exactly where you want them and no longer let the program put them a little randomly in the middle of a word or expression (please, see attached pictures).

Cordialement.
Attachments
181019_124247_400x68_easyshot.jpg
(7.33 KiB) Downloaded 533 times
181019_125138_373x68_easyshot.jpg
(7.34 KiB) Downloaded 533 times

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#48 Post by fredx181 »

Hi, here's attached modified box_splash_fixed

Changes:
- Find the longest line (if given multiple lines of text), more info here:
http://murga-linux.com/puppy/viewtopic. ... 81#1007581
- Center the icon vertically

@MochiMoppel

Code: Select all

NR_CHARS="$(echo "$text"| wc -L )"
Ok, thanks, works fine also

@Argolance, yes, I like it also when the icon is vertically centered.
To try making the icon display vertically centered, I first removed this line in the main dialog:

Code: Select all

<text space-expand="true" space-fill="true"><label>""</label></text>
That worked ok for the centered icon, but not when using only text (no icon).
So moved it to this section and works fine for me (with or without icon):

Code: Select all

 if [ "$ICON" ]; then
....
....
# fredx181, in case only text, no icon. Moved from the main dialog below to here
else
	icon="<text space-expand=\"true\" space-fill=\"true\"><label>\"\"</label></text>"
fi
Added comments with my name for the changes, but I'm not very good with that.

Fred
Attachments
box_splash_fixed_mod.tar.gz
Modified box_splash_fixed
(4.59 KiB) Downloaded 253 times
Last edited by fredx181 on Fri 19 Oct 2018, 15:04, edited 1 time in total.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#49 Post by Argolance »

Thanks fredx181, works fine for me. :D
Ultimately text attributes should be simply configurable in the same way as the font size and color...
Attachments
181019_135906_260x202_easyshot.jpg
gtk-splash
(5.97 KiB) Downloaded 514 times

ITSMERSH

#50 Post by ITSMERSH »

That seems to be funny, though, I think it doesn't make any sense to have angled text in a SPLASH info box. :wink:

Post Reply