gtkdialog GTK3 question setting window size

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

User avatar
don570
Posts: 796
Joined: Sat Nov 21, 2020 4:43 pm
Has thanked: 6 times
Been thanked: 156 times

Font color

Post by don570 »

I'm using BookwormPup1009
I tried the script with...

Code: Select all

label {
  /* color: lightgoldenrodyellow; */
  background-image: linear-gradient(to bottom, beige 10%, orange 90%);
}
Screenshot-hover(1).png
Screenshot-hover(1).png (84.07 KiB) Viewed 952 times

My question is ---> What determines the font color?
It appears to be black in my example and yellow in 'Sofiya' example

User avatar
MochiMoppel
Posts: 1363
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 23 times
Been thanked: 548 times

Re: gtkdialog GTK3 question setting window size

Post by MochiMoppel »

don570 wrote: Mon Apr 07, 2025 7:32 pm

I'm using BookwormPup1009
I tried the script with...

Code: Select all

label {
  /* color: lightgoldenrodyellow; */
  background-image: linear-gradient(to bottom, beige 10%, orange 90%);
}

My question is ---> What determines the font color?

Determinded by the line that is commented out in your snippet.
Remove the /* and */ comment tags and set color to whatever you want. Without it the system color is used, which happens to be black.

User avatar
don570
Posts: 796
Joined: Sat Nov 21, 2020 4:43 pm
Has thanked: 6 times
Been thanked: 156 times

gtkdialog GTK3 question setting window size

Post by don570 »

Thanks for info...
______________________

User avatar
01micko
Posts: 136
Joined: Mon Jul 13, 2020 4:08 am
Location: Qld
Has thanked: 5 times
Been thanked: 67 times
Contact:

Re: gtkdialog GTK3 question setting window size

Post by 01micko »

@fredx181 This scripts covers both cases close enough. @MochiMoppel will know as soon as he sees which pic is which.

Screenshot-20250408T134516.png
Screenshot-20250408T134516.png (170.19 KiB) Viewed 909 times

Here it is. Uses @Sofiya 's hack. I called it gtest and I'll post the diff from Fred's original. (almost, plus shebang)

Script

Code: Select all

#!/bin/sh

case $1 in
	2|'')GTKDIALOG=gtk2dialog;;
	3)GTKDIALOG=gtkdialog
	TEXTOPTS='visible="false" margin-left="54" margin-right="54"'
	TEXTVAR='<variable>VBOX</variable>'
	TEXTSHOW='<action signal="map-event">show:VBOX</action>'
	;;
esac

export TEST='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS' align="0.5"><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.

Mauris semper neque quis lacinia volutpat. Aenean vestibulum diam ex, sit amet posuere dolor luctus non. Ut consectetur felis blandit ipsum convallis, non lobortis justo facilisis. Ut vitae velit pulvinar, pharetra libero semper, dignissim urna. Nullam quam quam, viverra eget feugiat a, interdum et erat. Morbi fringilla, eros et consequat iaculis, ligula nunc hendrerit neque, ac tincidunt massa sem vitae tortor. Nunc volutpat massa at dapibus pulvinar. Etiam risus sem, dignissim vel blandit eget, maximus lacinia purus.
  "</label>'$TEXTVAR'</text>
    </frame>        
    <hbox>
     <button ok>   
      <action>EXIT:ok</action> 
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG --geometry=520x520 -cp TEST >/dev/null

The diff

Code: Select all

--- gtest.orig	2025-04-08 13:47:41.574870703 +1000
+++ gtest	2025-04-08 13:43:42.022870703 +1000
@@ -1,13 +1,22 @@
 #!/bin/sh
 
+case $1 in
+	2|'')GTKDIALOG=gtk2dialog;;
+	3)GTKDIALOG=gtkdialog
+	TEXTOPTS='visible="false" margin-left="54" margin-right="54"'
+	TEXTVAR='<variable>VBOX</variable>'
+	TEXTSHOW='<action signal="map-event">show:VBOX</action>'
+	;;
+esac
+
 export TEST='
   <window title="Test size">
    <vbox>
     <frame>
-<text><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.
+<text '$TEXTOPTS' align="0.5"><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.
 
 Mauris semper neque quis lacinia volutpat. Aenean vestibulum diam ex, sit amet posuere dolor luctus non. Ut consectetur felis blandit ipsum convallis, non lobortis justo facilisis. Ut vitae velit pulvinar, pharetra libero semper, dignissim urna. Nullam quam quam, viverra eget feugiat a, interdum et erat. Morbi fringilla, eros et consequat iaculis, ligula nunc hendrerit neque, ac tincidunt massa sem vitae tortor. Nunc volutpat massa at dapibus pulvinar. Etiam risus sem, dignissim vel blandit eget, maximus lacinia purus.
-  "</label></text>
+  "</label>'$TEXTVAR'</text>
     </frame>        
     <hbox>
      <button ok>   
@@ -15,5 +24,6 @@
      </button>
     </hbox>
    </vbox>
+   '$TEXTSHOW'
   </window>'
-gtkdialog --geometry=520x520 -cp TEST >/dev/null
+$GTKDIALOG --geometry=520x520 -cp TEST >/dev/null
User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

MochiMoppel wrote: Sun Apr 06, 2025 12:54 pm

gtkdialog (GTK3) vs. gtk2dialog (GTK2). Find the (two?) differences ;)
gtk3_gtk2.png

Code: Select all

#!/bin/sh

export HOW_STOP_CAPTURE='
  <window title="How to end capturing and more"  resizable="false">
   <vbox>
    <frame>
<text xalign="0" wrap="false" use-markup="true"><label>"                       <b>In case Window or Region selected :</b>
'$(gettext 'To select a particular window, just click it anywhere with the left mouse button.')'

'$(gettext 'To select a rectangular area: position mouse cursor at top left corner of desired screen area,
then press and hold down the left mouse button and drag mouse cursor to define the area.')'

'$(gettext 'As soon as you release the mouse button, any delay you preconfigured on the main
configuration screen will take place. That delay will be followed immediately by the av
screencapture itself.')'

<b>In case of ALSA soundsystem with option Soundcard :</b>
Start the source application to record from, e.g. Browser.
If it is already started, <b>restart</b> it.
Otherwise audio recording will not work with ALSA .

<b>Press the tiny X button at the very top-left to end the capture.</b> 
"</label>
<variable>VBOX</variable>
</text>
    </frame>      
    <hbox>
     <checkbox>
      <variable>NOMESSAGE</variable>
      <label>'$(gettext 'Do not show this message again')'</label>
     </checkbox>
     <button ok>
	  <action>[ "$NOMESSAGE" = "true" ] && { echo "Remove this file to show the info message again." > ${HOME}/tkacast-nomessage; }</action>     
      <action>EXIT:ok</action> 
     </button>
    </hbox>
   </vbox>
  </window>'
gtkdialog -cp HOW_STOP_CAPTURE  # --geometry=590x400 

Didn't use CSS because it doesn't work in gtk2dialog.
Also didn't use the visible="false" hack because it seems fine without here.
In general the wrapping policy in GTK3 and GTK2 is different and partly to blame for the geometry inconsistencies. Line wrapping in GTK3 has become more flexible and predictable, but with the awkward behavior in GTK2 it may be better to avoid it altogether when writing code for both variants.

[Edit]: Added resizable="false" , commented out --geometry=590x400. Without the need for a fix geometry the dialog can automatically adjust to the amount of text (and probably to larger font sizes)

the arrow is slightly larger and _ ( O ) is underlined ;)

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
fredx181
Posts: 3431
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 462 times
Been thanked: 1507 times
Contact:

Re: gtkdialog GTK3 question setting window size

Post by fredx181 »

@fredx181 This scripts covers both cases close enough.

Thanks @01micko !

Here it is. Uses @Sofiya 's hack. I called it gtest and I'll post the diff from Fred's original. (almost, plus shebang)

Probably you mean @JakeSFR 's hack ! ;)

User avatar
MochiMoppel
Posts: 1363
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 23 times
Been thanked: 548 times

Re: gtkdialog GTK3 question setting window size

Post by MochiMoppel »

01micko wrote: Tue Apr 08, 2025 3:58 am

@MochiMoppel will know as soon as he sees which pic is which.

Yes - even without looking at the OK button :mrgreen:

Changed your version slightly.
Deleting --geometry=520x520 , thus letting gtkdialog set the window dimension, and assigning TEXTOPTS to TEXTOPTS='visible="false" width-chars="49"' produced this:

gtk2vsgtk3.png
gtk2vsgtk3.png (190.73 KiB) Viewed 810 times

Not sure what align="0.5" is supposed to do here. Is this a typo and meant to be xalign? Even then it may be redundant as 0.5 (=middle aligned) seems to be the default.

One more interesting difference: When adding the text option selectable="true" GTK2 sets the focus to the text widget. GTK3 sets it to the OK button, however without indicating the focus with a "marching ants" border,

User avatar
fredx181
Posts: 3431
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 462 times
Been thanked: 1507 times
Contact:

Re: gtkdialog GTK3 question setting window size

Post by fredx181 »

I think that I like the method from @MochiMoppel the most (without --geometry and with width-chars=..)
Here's what I got for now (added also stylesheet creation for the font for GTK2 and GTK3, not sure if really necessary :?: )
My goal is that it looks (almost) the same, no matter if with GTK2 or GTK3 and no matter if used on an old Puppy (with GTK2 gtkdialog) or on a new Puppy (with GTK3 gtkdialog).
Getting close now, I guess ...

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

# uncomment this line to test with gtk2dialog (if exist)
#[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || exit 0 

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="49"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
font: 11pt "Sans";
font-style: normal;
font-weight: normal;
color: #000000;
padding: 0;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "font" { font_name="Sans 11" text[NORMAL]="#000000" fg[NORMAL]="#000000" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export TEST='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS'><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.

Mauris semper neque quis lacinia volutpat. Aenean vestibulum diam ex, sit amet posuere dolor luctus non. Ut consectetur felis blandit ipsum convallis, non lobortis justo facilisis. Ut vitae velit pulvinar, pharetra libero semper, dignissim urna. Nullam quam quam, viverra eget feugiat a, interdum et erat. Morbi fringilla, eros et consequat iaculis, ligula nunc hendrerit neque, ac tincidunt massa sem vitae tortor. Nunc volutpat massa at dapibus pulvinar. Etiam risus sem, dignissim vel blandit eget, maximus lacinia purus.
  "</label>'$TEXTVAR'</text>
    </frame>        
    <hbox>
     <button ok>   
      <action>EXIT:ok</action> 
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp TEST --styles=/tmp/gtkdialog-test >/dev/null
out.png
out.png (528.19 KiB) Viewed 762 times

For the other example I just increased the value of width-chars=.. to 60

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

# uncomment next line to test with gtk2dialog
#[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || exit 0 

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="60"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
font: 11pt "Sans";
font-style: normal;
font-weight: normal;
color: #000000;
padding: 0;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "font" { font_name="Sans 11" text[NORMAL]="#000000" fg[NORMAL]="#000000" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export HOW_STOP_CAPTURE='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS' use-markup="true"><label>"                       <b>In case Window or Region selected :</b>
'$(gettext 'To select a particular window, just click it anywhere with the left mouse button.')'

'$(gettext 'To select a rectangular area: position mouse cursor at top left corner of desired screen area, then press and hold down the left mouse button and drag mouse cursor to define the area.')'

'$(gettext 'As soon as you release the mouse button, any delay you preconfigured on the main configuration screen will take place. That delay will be followed immediately by the av screencapture itself.')'

<b>In case of ALSA soundsystem with option Soundcard :</b>
Start the source application to record from, e.g. Browser.
If it is already started, <b>restart</b> it.
Otherwise audio recording will not work with ALSA .

<b>Press the tiny X button at the very top-left to end the capture.</b>
 "</label>'$TEXTVAR'</text>
    </frame>        
    <hbox>
     <checkbox>
      <variable>NOMESSAGE</variable>
      <label>'$(gettext 'Do not show this message again')'</label>
     </checkbox>
     <button ok>
	  <action>[ "$NOMESSAGE" = "true" ] && { echo "Remove this file to show the info message again." > ${HOME}/tkacast-nomessage; }</action>     
      <action>EXIT:ok</action> 
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp HOW_STOP_CAPTURE --styles=/tmp/gtkdialog-test >/dev/null
out1.png
out1.png (540.03 KiB) Viewed 762 times
User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

This is great!

Code: Select all

#!/bin/bash

GTKDIALOG=gtkdialog

# uncomment this line to test with gtk2dialog (if exist)
#[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || GTKDIALOG=gtkdialog

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="49"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
  font: 13px system-ui;
  font-style: normal;
  font-weight: normal;
  padding: 0;
  margin: 1px;
  border-radius: 8px;
  border-color: DarkViolet;
}
label {
  /*color: lightgoldenrodyellow;*/
  background-image: linear-gradient(to top right, blue 20%, #000000 80%);
}
button {
  /* color: #000000; */
  border-color: #cbd6ee;
  border-radius: 40px;
  padding-left: 5px;
  padding-right: 5px;
  background: linear-gradient(to bottom, #00acee, #0072e0);
}
button:hover {
  transition: .4s;
  box-shadow: 0 0 0 1px #cbd6ee;
}
button:focus{
  outline: none;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "font" { font_name="Sans 11" text[NORMAL]="#000000" fg[NORMAL]="#000000" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export TEST='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS'><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.

Mauris semper neque quis lacinia volutpat. Aenean vestibulum diam ex, sit amet posuere dolor luctus non. Ut consectetur felis blandit ipsum convallis, non lobortis justo facilisis. Ut vitae velit pulvinar, pharetra libero semper, dignissim urna. Nullam quam quam, viverra eget feugiat a, interdum et erat. Morbi fringilla, eros et consequat iaculis, ligula nunc hendrerit neque, ac tincidunt massa sem vitae tortor. Nunc volutpat massa at dapibus pulvinar. Etiam risus sem, dignissim vel blandit eget, maximus lacinia purus.
  "</label>'$TEXTVAR'</text>
    </frame>
    <hbox>
     <button ok>
      <action>EXIT:ok</action>
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp TEST --styles=/tmp/gtkdialog-test >/dev/null
Attachments
2025-04-09_19-33.png
2025-04-09_19-33.png (349.69 KiB) Viewed 759 times

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

:thumbup: ;)

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

# uncomment next line to test with gtk2dialog
#[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || exit 0

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="60"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
  font: 13px system-ui;
  font-style: normal;
  font-weight: normal;
  padding: 0;
  margin: 1px;
  border-radius: 8px;
  border-color: DarkViolet;
}
label {
  /*color: lightgoldenrodyellow;*/
  background-image: linear-gradient(to top right, blue 20%, #000000 80%);
}
button {
  /* color: #000000; */
  border-color: #cbd6ee;
  border-radius: 40px;
  padding-left: 5px;
  padding-right: 5px;
  background: linear-gradient(to bottom, #00acee, #0072e0);
}
button:hover {
  transition: .4s;
  box-shadow: 0 0 0 1px #cbd6ee;
}
button:focus{
  outline: none;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "font" { font_name="Sans 11" text[NORMAL]="#000000" fg[NORMAL]="#000000" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export HOW_STOP_CAPTURE='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS' use-markup="true"><label>"                       <b>In case Window or Region selected :</b>
'$(gettext 'To select a particular window, just click it anywhere with the left mouse button.')'

'$(gettext 'To select a rectangular area: position mouse cursor at top left corner of desired screen area, then press and hold down the left mouse button and drag mouse cursor to define the area.')'

'$(gettext 'As soon as you release the mouse button, any delay you preconfigured on the main configuration screen will take place. That delay will be followed immediately by the av screencapture itself.')'

<b>In case of ALSA soundsystem with option Soundcard :</b>
Start the source application to record from, e.g. Browser.
If it is already started, <b>restart</b> it.
Otherwise audio recording will not work with ALSA .

<b>Press the tiny X button at the very top-left to end the capture.</b>
 "</label>'$TEXTVAR'</text>
    </frame>
    <hbox>
     <checkbox>
      <variable>NOMESSAGE</variable>
      <label>'$(gettext 'Do not show this message again')'</label>
     </checkbox>
     <button ok>
	  <action>[ "$NOMESSAGE" = "true" ] && { echo "Remove this file to show the info message again." > ${HOME}/tkacast-nomessage; }</action>
      <action>EXIT:ok</action>
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp HOW_STOP_CAPTURE --styles=/tmp/gtkdialog-test >/dev/null
Attachments
2025-04-09_19-42.png
2025-04-09_19-42.png (321.57 KiB) Viewed 757 times

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
fredx181
Posts: 3431
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 462 times
Been thanked: 1507 times
Contact:

Re: gtkdialog GTK3 question setting window size

Post by fredx181 »

@Sofiya
You're not doing a comparison between GTK2 and GTK3, anyway just saying, note that I changed to 11pt (rather than "px") to make it correspond with e.g. "Sans 11" from the GTK2 style sheet in my script.

User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

fredx181 wrote: Wed Apr 09, 2025 4:57 pm

@Sofiya
You're not doing a comparison between GTK2 and GTK3, anyway just saying, note that I changed to 11pt (rather than "px") to make it correspond with e.g. "Sans 11" from the GTK2 style sheet in my script.

I noticed this and this is the correct marking. ;) I also have it in the scripts above

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

alignment left, right, bottom
font: 11pt system-ui; -- uses system font

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

# uncomment next line to test with gtk2dialog
#[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || exit 0

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="60" margin-bottom="10" margin-left="10" margin-right="10"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
  font: 11pt system-ui;
  font-style: normal;
  font-weight: normal;
  padding: 0;
  margin: 1px;
  border-radius: 8px;
  border-color: DarkViolet;
}
label {
  /*color: lightgoldenrodyellow;*/
  background-image: linear-gradient(to top right, blue 20%, #000000 80%);
}
button {
  /* color: #000000; */
  border-color: #cbd6ee;
  border-radius: 40px;
  padding-left: 5px;
  padding-right: 5px;
  background: linear-gradient(to bottom, #00acee, #0072e0);
}
button:hover {
  transition: .4s;
  box-shadow: 0 0 0 1px #cbd6ee;
}
button:focus{
  outline: none;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "font" { font_name="Sans 11" text[NORMAL]="#000000" fg[NORMAL]="#000000" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export HOW_STOP_CAPTURE='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS' use-markup="true"><label>"                       <b>In case Window or Region selected :</b>
'$(gettext 'To select a particular window, just click it anywhere with the left mouse button.')'

'$(gettext 'To select a rectangular area: position mouse cursor at top left corner of desired screen area, then press and hold down the left mouse button and drag mouse cursor to define the area.')'

'$(gettext 'As soon as you release the mouse button, any delay you preconfigured on the main configuration screen will take place. That delay will be followed immediately by the av screencapture itself.')'

<b>In case of ALSA soundsystem with option Soundcard :</b>
Start the source application to record from, e.g. Browser.
If it is already started, <b>restart</b> it.
Otherwise audio recording will not work with ALSA .

<b>Press the tiny X button at the very top-left to end the capture.</b>
 "</label>'$TEXTVAR'</text>
    </frame>
    <hbox>
     <checkbox>
      <variable>NOMESSAGE</variable>
      <label>'$(gettext 'Do not show this message again')'</label>
     </checkbox>
     <button ok>
	  <action>[ "$NOMESSAGE" = "true" ] && notify-send "Welcome to Home."</action>
      <action>EXIT:ok</action>
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp HOW_STOP_CAPTURE --styles=/tmp/gtkdialog-test >/dev/null
Attachments
2025-04-09_20-09.png
2025-04-09_20-09.png (310.77 KiB) Viewed 738 times
Last edited by Sofiya on Wed Apr 09, 2025 7:17 pm, edited 1 time in total.

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

In any case, we can now make beautiful windows :thumbup:

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
fredx181
Posts: 3431
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 462 times
Been thanked: 1507 times
Contact:

Re: gtkdialog GTK3 question setting window size

Post by fredx181 »

Colored GTK2 window experiment (using gtk2dialog):

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

# uncomment this line to test with gtk2dialog (if exist)
[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || exit 0 

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="49"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
font: 11pt "Sans";
font-style: normal;
font-weight: normal;
color: #000000;
padding: 0;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "gtkdialog-splash" { bg[NORMAL] = "#59290f" } class "GtkWindow" style "gtkdialog-splash" style "notebook" { bg[NORMAL] = "#59290f" xthickness = 1 ythickness = 1 } class "GtkNotebook" style "notebook" style "font" { font_name="Sans Bold Italic 11" text[NORMAL]="#ffc91c" fg[NORMAL]="#ffc91c" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export TEST='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS' align="0.5"><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.

Mauris semper neque quis lacinia volutpat. Aenean vestibulum diam ex, sit amet posuere dolor luctus non. Ut consectetur felis blandit ipsum convallis, non lobortis justo facilisis. Ut vitae velit pulvinar, pharetra libero semper, dignissim urna. Nullam quam quam, viverra eget feugiat a, interdum et erat. Morbi fringilla, eros et consequat iaculis, ligula nunc hendrerit neque, ac tincidunt massa sem vitae tortor. Nunc volutpat massa at dapibus pulvinar. Etiam risus sem, dignissim vel blandit eget, maximus lacinia purus.
  "</label>'$TEXTVAR'</text>
    </frame>        
    <hbox>
     <button ok>   
      <action>EXIT:ok</action> 
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp TEST --styles=/tmp/gtkdialog-test >/dev/null
2025-04-09_23-17-13.png
2025-04-09_23-17-13.png (259.78 KiB) Viewed 698 times
User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

fredx181 wrote: Wed Apr 09, 2025 9:24 pm

Colored GTK2 window experiment (using gtk2dialog):

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

# uncomment this line to test with gtk2dialog (if exist)
[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || exit 0 

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="49"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
font: 11pt "Sans";
font-style: normal;
font-weight: normal;
color: #000000;
padding: 0;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "gtkdialog-splash" { bg[NORMAL] = "#59290f" } class "GtkWindow" style "gtkdialog-splash" style "notebook" { bg[NORMAL] = "#59290f" xthickness = 1 ythickness = 1 } class "GtkNotebook" style "notebook" style "font" { font_name="Sans Bold Italic 11" text[NORMAL]="#ffc91c" fg[NORMAL]="#ffc91c" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export TEST='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS' align="0.5"><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.

Mauris semper neque quis lacinia volutpat. Aenean vestibulum diam ex, sit amet posuere dolor luctus non. Ut consectetur felis blandit ipsum convallis, non lobortis justo facilisis. Ut vitae velit pulvinar, pharetra libero semper, dignissim urna. Nullam quam quam, viverra eget feugiat a, interdum et erat. Morbi fringilla, eros et consequat iaculis, ligula nunc hendrerit neque, ac tincidunt massa sem vitae tortor. Nunc volutpat massa at dapibus pulvinar. Etiam risus sem, dignissim vel blandit eget, maximus lacinia purus.
  "</label>'$TEXTVAR'</text>
    </frame>        
    <hbox>
     <button ok>   
      <action>EXIT:ok</action> 
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp TEST --styles=/tmp/gtkdialog-test >/dev/null

2025-04-09_23-17-13.png

gorgeous :thumbup:

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

why does it look like this for me?, do I have a different gtk2dialog

Attachments
2025-04-10_00-58.png
2025-04-10_00-58.png (176.14 KiB) Viewed 689 times
2025-04-10_00-55.png
2025-04-10_00-55.png (468.26 KiB) Viewed 690 times

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
fredx181
Posts: 3431
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 462 times
Been thanked: 1507 times
Contact:

Re: gtkdialog GTK3 question setting window size

Post by fredx181 »

Sofiya wrote: Wed Apr 09, 2025 9:56 pm

why does it look like this for me?, do I have a different gtk2dialog

Hmm.. don't know, looks like I have the same:

Code: Select all

gtk2dialog --version
gtkdialog version 0.8.5 release (C) 2003-2007 Laszlo Pere, 2011-2012 Thunor
Built with support for: GTK+ 2.
User avatar
don570
Posts: 796
Joined: Sat Nov 21, 2020 4:43 pm
Has thanked: 6 times
Been thanked: 156 times

Re: gtkdialog GTK3 question setting window size

Post by don570 »

For what its worth. Here is Easy OS Scarthgap info...

Code: Select all

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

Good method!!

BarryK has gtk3 and gtk3-demo installed in his Scarthgap distro
It is sticking with older scripts....
viewtopic.php?t=13945
In terminal

Code: Select all

gtkdialog -v
Screenshot-font-Mono.png
Screenshot-font-Mono.png (56.01 KiB) Viewed 679 times

______________________________________________________

User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

width-chars="60"
<window title="Test size" width-request="550">

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

# uncomment this line to test with gtk2dialog (if exist)
[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || exit 0
GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="60"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
  font: 11pt system-ui;
  font-style: normal;
  font-weight: normal;
  padding: 0;
  margin: 1px;
  border-radius: 8px;
  border-color: DarkViolet;
}
label {
  /*color: lightgoldenrodyellow;*/
  background-image: linear-gradient(to top right, blue 20%, #000000 80%);
}
button {
  /* color: #000000; */
  border-color: #cbd6ee;
  border-radius: 40px;
  padding-left: 5px;
  padding-right: 5px;
  background: linear-gradient(to bottom, #00acee, #0072e0);
}
button:hover {
  transition: .4s;
  box-shadow: 0 0 0 1px #cbd6ee;
}
button:focus{
  outline: none;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "gtkdialog-splash" { bg[NORMAL] = "#ffaa7f" } class "GtkWindow" style "gtkdialog-splash" style "notebook" { bg[NORMAL] = "#59290f" xthickness = 1 ythickness = 1 } class "GtkNotebook" style "notebook" style "font" { font_name="Sans Bold Italic 11" text[NORMAL]="#ffc91c" fg[NORMAL]="#000000" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export TEST='
  <window title="Test size" width-request="550">
   <vbox>
    <frame>
<text '$TEXTOPTS' align="0.5"><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.

Mauris semper neque quis lacinia volutpat. Aenean vestibulum diam ex, sit amet posuere dolor luctus non. Ut consectetur felis blandit ipsum convallis, non lobortis justo facilisis. Ut vitae velit pulvinar, pharetra libero semper, dignissim urna. Nullam quam quam, viverra eget feugiat a, interdum et erat. Morbi fringilla, eros et consequat iaculis, ligula nunc hendrerit neque, ac tincidunt massa sem vitae tortor. Nunc volutpat massa at dapibus pulvinar. Etiam risus sem, dignissim vel blandit eget, maximus lacinia purus.
  "</label>'$TEXTVAR'</text>
    </frame>
    <hbox>
     <button ok>
      <action>EXIT:ok</action>
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp TEST --styles=/tmp/gtkdialog-test >/dev/null
Attachments
2025-04-10_01-45.png
2025-04-10_01-45.png (138.7 KiB) Viewed 668 times

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
fredx181
Posts: 3431
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 462 times
Been thanked: 1507 times
Contact:

Re: gtkdialog GTK3 question setting window size

Post by fredx181 »

Sofiya wrote: Wed Apr 09, 2025 9:56 pm

why does it look like this for me?, do I have a different gtk2dialog

Looks like your Sans ? font is different from mine, narrower, e.g. compare the f in "efficitur" on first sentence.
Perhaps KDE handles it different. :?:

User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

fredx181 wrote: Thu Apr 10, 2025 7:11 am
Sofiya wrote: Wed Apr 09, 2025 9:56 pm

why does it look like this for me?, do I have a different gtk2dialog

Looks like your Sans ? font is different from mine, narrower, e.g. compare the f in "efficitur" on first sentence.
Perhaps KDE handles it different. :?:

Yes, apparently that's how it is. Because on the void it looks like yours.
I noticed a long time ago that the same font looks different on Void and Arch, so in Hyprland I had to make different settings for the bar because of this.
Every third person began to collect their bags to emphasize their individuality, thereby breaking the general chain.
Therefore, trying to make the same settings for different systems, we will not succeed, since we have to configure them differently everywhere..

Attachments
2025-04-10_16-27.png
2025-04-10_16-27.png (354.47 KiB) Viewed 588 times
2025-04-10_16-31.png
2025-04-10_16-31.png (361.29 KiB) Viewed 588 times

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
MochiMoppel
Posts: 1363
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 23 times
Been thanked: 548 times

Re: gtkdialog GTK3 question setting window size

Post by MochiMoppel »

Sofiya wrote: Thu Apr 10, 2025 1:30 pm

I noticed a long time ago that the same font looks different on Void and Arch

For your gtk2dialog style you use "Sans". That's not a real font. In Bookworm64 it's an alias for "Noto Sans", in other Puppies it's an alias for "DejaVu Sans".
"Noto Sans" is narrower than "DejaVu Sans" . If you want the same result, you have to specify a real font name.

Find out which font the system will use when you specify "Sans"

Code: Select all

# fc-match Sans
NotoSans-Regular.ttf: "Noto Sans" "Regular"

Same for "system-ui":

Code: Select all

# fc-match system-ui
NotoSans-Regular.ttf: "Noto Sans" "Regular"

------
Edit:Corrected typo

Last edited by MochiMoppel on Fri Apr 11, 2025 1:42 am, edited 1 time in total.
User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

Thanks to @MochiMoppel for the tip

I checked that I didn't have the DejaVu Sans font installed on Arch
Installed ttf-dejavu on Arch. Now it looks the same there and there with the same settings font_name="DejaVu Sans Bold Italic 11"

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

# uncomment this line to test with gtk2dialog (if exist)
[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || exit 0
GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="49"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
  font: 11pt system-ui;
  font-style: normal;
  font-weight: normal;
  padding: 0;
  margin: 1px;
  border-radius: 8px;
  border-color: DarkViolet;
}
label {
  /*color: lightgoldenrodyellow;*/
  background-image: linear-gradient(to top right, blue 20%, #000000 80%);
}
button {
  /* color: #000000; */
  border-color: #cbd6ee;
  border-radius: 40px;
  padding-left: 5px;
  padding-right: 5px;
  background: linear-gradient(to bottom, #00acee, #0072e0);
}
button:hover {
  transition: .4s;
  box-shadow: 0 0 0 1px #cbd6ee;
}
button:focus{
  outline: none;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "gtkdialog-splash" { bg[NORMAL] = "#ffaa7f" } class "GtkWindow" style "gtkdialog-splash" style "notebook" { bg[NORMAL] = "#59290f" xthickness = 1 ythickness = 1 } class "GtkNotebook" style "notebook" style "font" { font_name="DejaVu Sans Bold Italic 11" text[NORMAL]="#ffc91c" fg[NORMAL]="#000000" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export TEST='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS' align="0.5"><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.

Mauris semper neque quis lacinia volutpat. Aenean vestibulum diam ex, sit amet posuere dolor luctus non. Ut consectetur felis blandit ipsum convallis, non lobortis justo facilisis. Ut vitae velit pulvinar, pharetra libero semper, dignissim urna. Nullam quam quam, viverra eget feugiat a, interdum et erat. Morbi fringilla, eros et consequat iaculis, ligula nunc hendrerit neque, ac tincidunt massa sem vitae tortor. Nunc volutpat massa at dapibus pulvinar. Etiam risus sem, dignissim vel blandit eget, maximus lacinia purus.
  "</label>'$TEXTVAR'</text>
    </frame>
    <hbox>
     <button ok>
      <action>EXIT:ok</action>
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp TEST --styles=/tmp/gtkdialog-test >/dev/null
Attachments
2025-04-10_19-36.png
2025-04-10_19-36.png (478.24 KiB) Viewed 542 times
2025-04-10_19-06.png
2025-04-10_19-06.png (370.66 KiB) Viewed 542 times
Last edited by Sofiya on Thu Apr 10, 2025 4:58 pm, edited 1 time in total.

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

And yet GTK3 looks prettier :)

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

# uncomment this line to test with gtk2dialog (if exist)
[ $(command -v gtkdialog) ] && GTKDIALOG=gtkdialog || exit 0
GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

TEXTOPTS='visible="false" width-chars="49" margin-bottom="10"'
TEXTVAR='<variable>VBOX</variable>'
TEXTSHOW='<action signal="map-event">show:VBOX</action>'

if [ "$GTKDIALOGVERS" = "3" ]; then # GTK3
# create stylesheet /tmp/gtkdialog-test
echo 'box * {
  font: 10pt system-ui;
  font-style: normal;
  font-weight: normal;
  padding: 0;
  margin: 1px;
  border-radius: 8px;
  border-color: DarkViolet;
}
label {
  /*color: lightgoldenrodyellow;*/
  background-image: linear-gradient(to top right, blue 20%, #000000 80%);
}
button {
  /* color: #000000; */
  border-color: #cbd6ee;
  border-radius: 40px;
  padding-left: 5px;
  padding-right: 5px;
  background: linear-gradient(to bottom, #00acee, #0072e0);
}
button:hover {
  transition: .4s;
  box-shadow: 0 0 0 1px #cbd6ee;
}
button:focus{
  outline: none;
}
' > /tmp/gtkdialog-test

else # GTK2
# create stylesheet /tmp/gtkdialog-test
echo 'style "gtkdialog-splash" { bg[NORMAL] = "#ffaa7f" } class "GtkWindow" style "gtkdialog-splash" style "notebook" { bg[NORMAL] = "#59290f" xthickness = 1 ythickness = 1 } class "GtkNotebook" style "notebook" style "font" { font_name="DejaVu Sans Bold Italic 11" text[NORMAL]="#ffc91c" fg[NORMAL]="#000000" } class "GtkLabel" style "font"
' > /tmp/gtkdialog-test
fi

export TEST='
  <window title="Test size">
   <vbox>
    <frame>
<text '$TEXTOPTS' align="0.5"><label>"Lorem ipsum Morbi erat ex, lacinia nec efficitur eget, sagittis ut orci. Etiam in dolor placerat, pharetra ligula et, bibendum neque. Vestibulum vitae congue lectus, sed ultricies augue. Nam iaculis elit nec velit luctus, vitae rutrum nunc imperdiet. Nunc vel turpis sit amet lectus pellentesque tincidunt. Proin commodo tincidunt enim, at sodales mi dictum ac. Maecenas molestie, metus quis malesuada dictum, leo erat egestas lacus, sit amet tristique urna magna a diam. Donec ultricies dui sit amet mi ornare egestas. Phasellus ultricies lectus non interdum pellentesque. Cras nisi tellus, feugiat sed enim quis, tristique interdum lacus. Sed vel pharetra arcu, ac fermentum neque. Morbi mollis sollicitudin varius. Ut sit amet vulputate velit.

Mauris semper neque quis lacinia volutpat. Aenean vestibulum diam ex, sit amet posuere dolor luctus non. Ut consectetur felis blandit ipsum convallis, non lobortis justo facilisis. Ut vitae velit pulvinar, pharetra libero semper, dignissim urna. Nullam quam quam, viverra eget feugiat a, interdum et erat. Morbi fringilla, eros et consequat iaculis, ligula nunc hendrerit neque, ac tincidunt massa sem vitae tortor. Nunc volutpat massa at dapibus pulvinar. Etiam risus sem, dignissim vel blandit eget, maximus lacinia purus.
  "</label>'$TEXTVAR'</text>
    </frame>
    <hbox>
     <button ok>
      <action>EXIT:ok</action>
     </button>
    </hbox>
   </vbox>
   '$TEXTSHOW'
  </window>'
$GTKDIALOG -cp TEST --styles=/tmp/gtkdialog-test >/dev/null
Attachments
2025-04-10_19-52.png
2025-04-10_19-52.png (445.54 KiB) Viewed 539 times

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
don570
Posts: 796
Joined: Sat Nov 21, 2020 4:43 pm
Has thanked: 6 times
Been thanked: 156 times

Re: gtkdialog GTK3 question setting window size

Post by don570 »

I've noticed with Sofiya script running on BookwormPup 10.0.9..

Code: Select all

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

Results in GTKDIALOGVERS=2

The window shows the text correctly with color in background and black text.
_____________________________________________________________

User avatar
fredx181
Posts: 3431
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 462 times
Been thanked: 1507 times
Contact:

Re: gtkdialog GTK3 question setting window size

Post by fredx181 »

don570 wrote: Thu Apr 10, 2025 7:15 pm

I've noticed with Sofiya script running on BookwormPup 10.0.9..

Code: Select all

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

Results in GTKDIALOGVERS=2

The window shows the text correctly with color in background and black text.
_____________________________________________________________

I guess because it's setting the GTKDIALOG variable to gtk2dialog on the line above it (uncommented line)

Code: Select all

GTKDIALOG=gtkdialog

# uncomment next line to test with gtk2dialog (if exist)
[ $(command -v gtk2dialog) ] && GTKDIALOG=gtk2dialog || exit 0

GTKDIALOGVERS=$($GTKDIALOG -v | grep -o "GTK+.*" | awk '{print $2}' | tr -d ,)

edit: default gtkdialog is GTK3 in BookwormPup64 AFAIK

User avatar
fredx181
Posts: 3431
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 462 times
Been thanked: 1507 times
Contact:

Re: gtkdialog GTK3 question setting window size

Post by fredx181 »

MochiMoppel wrote: Thu Apr 10, 2025 3:04 pm
Sofiya wrote: Thu Apr 10, 2025 1:30 pm

I noticed a long time ago that the same font looks different on Void and Arch

For your gtk2dialog style you use "Sans". That's not a real font. In Bookworm64 it's an alias for "Noto Sans", in other Puppies it's an alias for "DejuVu Sans".
"Noto Sans" is narrower than "DejuVu Sans" . If you want the same result, you have to specify a real font name.

Find out which font the system will use when you specify "Sans"

Code: Select all

# fc-match Sans
NotoSans-Regular.ttf: "Noto Sans" "Regular"

Same for "system-ui":

Code: Select all

# fc-match system-ui
NotoSans-Regular.ttf: "Noto Sans" "Regular"

So I'd say something like this for setting the font name the same for GTK3 and GTK2 in every system: (for me it's "DejaVu Sans")
SYSTEM_UI=$(fc-match system-ui | awk '/:/' | cut -d\" -f2) # get default font name
And in the stylesheet blocks e.g. font: 10pt "'$SYSTEM_UI'"; (GTK3) and font_name="'$SYSTEM_UI' Bold Italic 10" (GTK2)

EDIT later: Above is probably not useful.

User avatar
Sofiya
Posts: 2540
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1570 times
Been thanked: 1728 times

Re: gtkdialog GTK3 question setting window size

Post by Sofiya »

In Bookworm everything will work as gtk2 and gtk3 are installed here

Attachments
Снимок экрана.png
Снимок экрана.png (375.43 KiB) Viewed 488 times

KL-Linux https://sofijacom.github.io
KL LINUX Simple fast free

User avatar
MochiMoppel
Posts: 1363
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 23 times
Been thanked: 548 times

Re: gtkdialog GTK3 question setting window size

Post by MochiMoppel »

fredx181 wrote: Thu Apr 10, 2025 8:26 pm

So I'd say something like this for setting the font name the same for GTK3 and GTK2 in every system: (for me it's "DejaVu Sans")
SYSTEM_UI=$(fc-match system-ui | awk '/:/' | cut -d\" -f2) # get default font name
And in the stylesheet blocks e.g. font: 10pt "'$SYSTEM_UI'"; (GTK3) and font_name="'$SYSTEM_UI' Bold Italic 10" (GTK2)

I don't understand the purpose of this exercise.

Post Reply

Return to “Programming”