Page 57 of 76

Posted: Tue 23 Aug 2016, 05:02
by MochiMoppel
Back to topic and to the confusing "resizable" attribute. It turns out that I used it before for the exact purpose it was invented. It removes the "Resize" item from the window menu and prevents user resizing.

With its surprising side effects I can now solve a problem that puzzled me for a long time.

I've created a tiny image viewer with the pixmap widget. Pretty much like Viewnior it uses one dialog window to read images one after another. The problem is that while the dialog window will automatically expand when reading an image bigger than the previous image (that's good!), it will not shrink when the following image is smaller. This puts ugly empty space around the image (see screenshot).

With resizable="false" the window will expand as well, but it will also shrink, adapting window size always to the size of the image. Very neat.

[SOLVED]

Posted: Tue 06 Sep 2016, 11:50
by peebee
Fixed by @MochiMoppel - thank you - http://www.murga-linux.com/puppy/viewto ... 479#922479

Posted: Tue 06 Sep 2016, 18:13
by torm
<action signal="type">activity</action>
if "button-release-event" is the event
does GtkStatusbar widget support that?
Or there is no release event.. ?? it appears to accept button press event..
Maybe I'm barking at the wrong tree, dunno.. zzz :(
Or any good workaround :roll:

Posted: Tue 06 Sep 2016, 18:50
by B.K. Johnson
Post made in wrong thread - DELETED

Request for gtkdialog lint(er), formatter/pretty printer

Posted: Tue 06 Sep 2016, 19:50
by B.K. Johnson
I chose to place this request here rather than under REQUESTS. No ruffled feathers, I hope.

Is there a lint(er) a.k.a. code formatting tool; a.k.a. pretty-printer (to screen) for gtkdialog code?
I would not want one that automatically lints as I type. I think I would find that really distracting. I'd rather use a linter that processes my code after I’ve finished my work.

Posted: Wed 07 Sep 2016, 02:31
by MochiMoppel
torm wrote:<action signal="type">activity</action>
if "button-release-event" is the event
does GtkStatusbar widget support that?
Needs an eventbox to work:

Code: Select all

#! /bin/sh
echo '
<window width-request="200">
    <eventbox>
        <statusbar>
            <input>echo "Click me!"</input>
        </statusbar>
        <action signal="button-press-event">beep</action> 
        <action signal="button-release-event">beep -f100</action> 
    </eventbox>
</window>'|gtkdialog -s

Posted: Fri 09 Sep 2016, 04:31
by recobayu
Alhamdulillah..
Finally, I can make button align to left. Try this code:

Code: Select all

#!/bin/sh
export gui='
<window>
	<vbox>
		<hbox space-fill="true" space-expand="true">
			<button space-fill="false" space-expand="false">
				<input file>/root/puppy-reference/midi-icons/archive48.png</input>
				<label>another okay</label>
			</button>
			<text xalign="0">
				<label>""</label>
			</text>
		</hbox>
	
		<hbox space-fill="true" space-expand="true">
			<button xalign="0" space-fill="false" space-expand="false">
				<input file>/root/puppy-reference/midi-icons/chat48.png</input>
				<label>okay</label>
			</button>
			<text>
				<label>""</label>
			</text>
		</hbox>
	
		<hbox space-fill="true" space-expand="true">
			<button space-fill="false" space-expand="false">
				<input file>/root/puppy-reference/midi-icons/connect48.png</input>
				<label>okay again</label>
			</button>
			<text>
				<label>""</label>
			</text>
		</hbox>
	
		<hbox space-fill="true" space-expand="true">
			<button space-fill="false" space-expand="false">
				<input file>/root/puppy-reference/midi-icons/save48.png</input>
				<label>loooong and over again okay</label>
			</button>
			<text>
				<label>""</label>
			</text>
		</hbox>
	</vbox>
</window>'
gtkdialog -p gui
But, how to make the button's width tobe same?

Edit:
we can smooth it by relief="2" in button tag.

Posted: Fri 09 Sep 2016, 05:49
by MochiMoppel
recobayu wrote:But, how to make the button's width tobe same?
First 2 button same width, no space-fill attributes, no vertical expansion,
Third button unchanged for comparison. It would be nice if icons+labels could also be left aligned, but that might be impossible without space padding the labels.

Code: Select all

#! /bin/sh
export gui=' 
 <window> 
    <vbox> 
       <hbox> 
          <button space-expand="false" width-request="200"> 
             <input file>/root/puppy-reference/midi-icons/archive48.png</input> 
             <label>another okay</label> 
          </button> 
          <text space-expand="true" label=""></text> 
       </hbox> 

       <hbox> 
          <button space-expand="false" width-request="200"> 
             <input file>/root/puppy-reference/midi-icons/chat48.png</input> 
             <label>okay</label> 
          </button> 
          <text space-expand="true" label=""></text> 
       </hbox> 

      <hbox space-fill="true" space-expand="true"> 
          <button space-fill="false" space-expand="false"> 
             <input file>/root/puppy-reference/midi-icons/save48.png</input> 
             <label>loooong and over again okay</label> 
          </button> 
          <text> 
             <label>""</label> 
          </text> 
       </hbox>
      </vbox> 
 </window>' 
 gtkdialog -p gui

Posted: Fri 09 Sep 2016, 06:08
by recobayu
Thank you Mochi, but your icon and text are not left aligned anymore (first button and second). I want to make the button same width and left aligned. If it is not possible, I think relief="2" is the solution.

Posted: Fri 09 Sep 2016, 06:26
by MochiMoppel
recobayu wrote:Thank you Mochi, but your icon and text are not left aligned anymore (first button and second).
What do you mean by "not anymore". Icons and text in your examples were also not left aligned. Only buttons are left aligned. As I said, that's something that may be impossible.
I want to make the button same width and left aligned.
That's what they are now. The buttons (not the button icons+texts !) are same widths and aligned to left window edge.

Posted: Sat 10 Sep 2016, 12:16
by step
@recobayu , just a suggestion, why don't you move the text outside the button, so you can have all buttons left-aligned and same size, and text labels left-aligned and merged with background color?

Posted: Sat 10 Sep 2016, 23:42
by recobayu
step wrote:@recobayu , just a suggestion, why don't you move the text outside the button, so you can have all buttons left-aligned and same size, and text labels left-aligned and merged with background color?
Thank You, Step. If I do that, the clickable area is just on the icon. But with label inside button, its easier to hover and click. Here is my exploration:
http://murga-linux.com/puppy/viewtopic. ... 659#922659

Posted: Sun 11 Sep 2016, 02:34
by MochiMoppel
recobayu wrote: Here is my exploration:
http://murga-linux.com/puppy/viewtopic. ... 659#922659
...which is the same as your earlier code, the code you wanted to change, only without button reliefs. IMHO this makes it worse. You camouflage the fact that the buttons and therefore the click area are all of different size and the user has no clue anymore where to click. Keeping the cursor on the right side (to drag the slider) and then moving a little left to hit a button becomes a hit & miss game.

You are trying again to mimic the tree widget using buttons. Stay with the tree.

Posted: Wed 28 Sep 2016, 02:49
by Geoffrey
A simple solution to make strikethrough text.


Code: Select all

#!/bin/sh
#
STRIKE="$(readlink -e "$0")"
sleep 0.3
[ `pidof "$(basename "$STRIKE")" -o %PPID | wc -w` -gt 1 ] && exit 1

touch /tmp/strikethrough

export DIALOG='
<window title="StrikeThrough" icon-name="gtk-strikethrough">
	<vbox>
		<edit wrap-mode="3">
			<variable>EDIT</variable>
			<height>150</height>
			<width>500</width>
		</edit>
		<vbox>
		<edit file-monitor="true" auto-refresh="true" wrap-mode="3" editable="false">
			<height>150</height>
			<input file>/tmp/strikethrough</input>
		</edit>
		</vbox>
		<hbox homogeneous="true">
		<hbox>
			<button cancel></button>
			<button>
            <label>Create</label>
            <input file stock="gtk-ok"></input>
            <action>`echo "$EDIT" | sed "s/./&\xCC\xB6/g" > /tmp/strikethrough`</action>
            </button>
        </hbox>
		</hbox>
	</vbox>
</window>'

gtkdialog --program=DIALOG

Posted: Wed 28 Sep 2016, 07:36
by zigbert
Geoffrey
Thanks for this one - interesting!

I have put your code in the new post about Text managing

Posted: Wed 28 Sep 2016, 13:08
by Geoffrey
zigbert wrote:Geoffrey
Thanks for this one - interesting!

I have put your code in the new post about Text managing
Yes it is interesting, I was looking for another means to make strikethrough text other than doing it online,
this isn't perfect as there can be some small spaces in the line if you look carefully and when paste in to a text file the line shifts to the right by one character, but it's good enough.
I found the simplest code solutionhere

Code: Select all

echo text | sed $"s/./&\xCC\xB6/g"
I noted that the "$" in the code made no difference, so I removed it.

List of character codeshere

edit:
I compared both ways of doing it, their identical.

I see a space in the line on the "m"
w̶r̶i̶t̶e̶ ̶s̶o̶m̶e̶ ̶t̶e̶x̶t̶ ̶h̶e̶r̶e̶ online strikethrough
w̶r̶i̶t̶e̶ ̶s̶o̶m̶e̶ ̶t̶e̶x̶t̶ ̶h̶e̶r̶e̶ gtkdialog strikethrough

Posted: Thu 29 Sep 2016, 03:48
by MochiMoppel
Geoffrey wrote:this isn't perfect as there can be some small spaces in the line if you look carefully
As you already said: Good enough. Spaces occur when you put the line character, which as any other character has its own width, on top of another character with a different width. If this character (e.g. the relatively wide letter 'm') is wider than the line you will see gaps. These gaps disappear when you use a fixed width font. You may see line gaps here: m̶m̶m̶m̶m̶m̶m̶m̶m̶m̶m̶
Now copy the string into Geany, which can handle UTF-8 and by default uses a fixed width font. See the difference?
I found the simplest code solutionhere
I use almost the same simple code, but made me a GUI. I didn't even bother to put it into a script and entered it directly into a desktop icon, but for "normal" users here is the code:

Code: Select all

xclip -o | sed "s/./&\xCC\xB6/g" | gxmessage -c -file -
Usage: Select some text in any application, then run the script (e.g. via desktop icon or keyboard shortcut)

Since we are here in the gtkdialog thread it should be noted that gtkdialog can produce beautiful strkethrough text, even with colored strike. The only problem is that the text loses its formats when the text is copied to another application. UTF-8 makes the text usable in all aplications that understand Unicode. To see the difference between strikethrough formatting via Pango mark-up in gtkdialog and via UTF-8 you can try this demo:

Code: Select all

#!/bin/sh
function  mark_me_up { echo -n "<span strikethrough='true'  strikethrough_color='red' font='bold 14'>$@</span>" ;}
export -f mark_me_up

echo '
<window>
<vbox>
    <frame>
        <edit>
            <default>"Sample text"</default>
            <variable>vEDIT</variable>
        </edit>
    </frame>

    <frame Pango Markup>
        <text use-markup="true" xalign="left" selectable="true">
            <variable>vTEXT1</variable>
            <input>mark_me_up "$vEDIT"</input>
        </text>
    </frame>

    <frame UTF-8 U+0336>
        <text xalign="left" selectable="true">
            <variable>vTEXT2</variable>
            <input>echo "$vEDIT" | sed "s/./&\xCC\xB6/g"</input>
        </text>
    </frame>


    <button label="Create S̶T̶R̶I̶K̶E̶̶̶">
        <action>refresh:vTEXT1</action>
        <action>refresh:vTEXT2</action>
    </button>
</vbox>
</window>' | gtkdialog -s

Posted: Fri 30 Sep 2016, 22:45
by Geoffrey
MochiMoppel wrote:I use almost the same simple code, but made me a GUI. I didn't even bother to put it into a script and entered it directly into a desktop icon, but for "normal" users here is the code:

Code: Select all

xclip -o | sed "s/./&\xCC\xB6/g" | gxmessage -c -file -
Usage: Select some text in any application, then run the script (e.g. via desktop icon or keyboard shortcut)
Nice, I had a play and opted for this with a hotkey

Code: Select all

#!/bin/sh
xclip -o | sed "s/./&\xCC\xB6/g" | xclip -selection "clipboard"
Select text - press hotkey - paste, result = S̶e̶l̶e̶c̶t̶ ̶t̶e̶x̶t̶

Posted: Sat 01 Oct 2016, 06:43
by MochiMoppel
Yes, that's probably the fastest solution and similar to what was discussed in this recent thread.
You only need to be careful not to use xclip from within gtkdialog, otherwise gtkdialog will acquaint you with its very nasty variable bug.

Posted: Sat 08 Oct 2016, 14:18
by torm
MochiMoppel wrote:
torm wrote:<action signal="type">activity</action>
if "button-release-event" is the event
does GtkStatusbar widget support that?
Needs an eventbox to work:

Code: Select all

#! /bin/sh
echo '
<window width-request="200">
    <eventbox>
        <statusbar>
            <input>echo "Click me!"</input>
        </statusbar>
        <action signal="button-press-event">beep</action> 
        <action signal="button-release-event">beep -f100</action> 
    </eventbox>
</window>'|gtkdialog -s

Thanks for reply
:)
I think I've already tested it, at some point.
And it is emitting at least some signals that can be used.
(to store the new location, etc.)

Tricked it to move around with middle-mouse-button.
However, the result is not as reliable as expected.
Will look into RoxFM and JWM to see if there's some built-in way..

Or, maybe there is some gtk-module to drag around the (not decorated) window?
Something small and simple, that could be used with Gtkdialog?