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 Sat 21 Oct 2017, 14:04
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to put color in GTKDIALOG
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [21 Posts]   Goto page: Previous 1, 2
Author Message
don570


Joined: 10 Mar 2010
Posts: 4717
Location: Ontario

PostPosted: Wed 15 Oct 2014, 19:30    Post subject:  

Good info from Zigbert and radky!!

I continued to work on this and here's an example to show how parchive
is modified.




Code:

#!/bin/sh
export COLOUR=3272C0
#  check for dark gtk themes and change  COLOUR
if [ "`cat /root/.gtkrc-2.0 | grep  "Stardust_dark_mouse"`" ]; then
 COLOUR=FFD900
elif [ "`cat /root/.gtkrc-2.0 | grep  "Stardust_dark_touch"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "Azenis"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "TerraNova-Aquarius"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "terminus"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "Murrina-Black"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "DarkRoomCompact"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "PenOSmaster"`" ]; then
 COLOUR=FFD900
 fi
 
 export MAIN_DIALOG="
<window title=\"Example\"  window-position=\"1\">
 <vbox>
 <text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>p</span><span size='"'x-large'"' color='"'#'$COLOUR''"'>Archive</span></b>\"</label></text>
</vbox>
</window>"
 
 gtkdialog -p MAIN_DIALOG

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


Joined: 18 May 2008
Posts: 4745

PostPosted: Wed 15 Oct 2014, 19:33    Post subject:  

Don't forget that many text fields can use Pango markup (colors, bold, italic, ...)
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4717
Location: Ontario

PostPosted: Wed 15 Oct 2014, 19:44    Post subject:  

Radky uses weak quoting for defining the gtkdialog variable.

Most people prefer strong quoting so here is example to show the
COLOUR variable used in a typical situation.
Note that in the window that is formed the black text is automatically
switched to white. The text 'Archive' is under the control of the variable 'COLOUR' .
Note difference in how protection by quoting is done.

Images show the difference in the look of a window when a dark
theme is used. The script was the same!!

Code:

#!/bin/sh
export COLOUR=3272C0
#  check for dark gtk themes and change  COLOUR
if [ "`cat /root/.gtkrc-2.0 | grep  "Stardust_dark_mouse"`" ]; then
 COLOUR=FFD900
elif [ "`cat /root/.gtkrc-2.0 | grep  "Stardust_dark_touch"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "Azenis"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "TerraNova-Aquarius"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "terminus"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "Murrina-Black"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "DarkRoomCompact"`" ]; then
 COLOUR=FFD900
 elif [ "`cat /root/.gtkrc-2.0 | grep  "PenOSmaster"`" ]; then
 COLOUR=FFD900
 fi
 
 TEXT="My Text"
 
 export MAIN_DIALOG='
<window title="Example"  window-position="1">

<vbox>
     <text use-markup="true"><label>"<b><span size='"'x-large'"'>p</span><span size='"'x-large'"' color='"'#$COLOUR'"'>Archive</span></b>"</label></text>
   <text width-request="100"><label>Color Frame</label></text>
   <text use-markup="true"><label>"<b><u><span size='"'large'"'>???</span><span size='"'large'"' color='"'#DA7A05'"'>Over write</span> ??</u></b>"</label></text>
   <text use-markup="true"><label>"<b><span size='"'large'"'  color='"'blue'"'>Danger Zone</span><span size='"'large'"' color='"'red'"'>Destroy</span> '$TEXT'</b>"</label></text>
   <text use-markup="true"><label>"<b><span size='"'large'"' color='"'red'"'>Over write</span>   '$TEXT'</b>    text"</label></text>
   <text use-markup="true"><label>"<u><span size='"'large'"' color='"'#A900FF'"'>??????</span></u>"</label></text>   
</vbox>
</window>'
 
 gtkdialog -p MAIN_DIALOG


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


Joined: 10 Mar 2010
Posts: 4717
Location: Ontario

PostPosted: Thu 16 Oct 2014, 18:48    Post subject:  

For the record here are just some of the many colors that gtkdialog supports...

Quote:

aliceblue antiquewhite aqua aquamarine
azure beige bisque black
blanchedalmond blue blueviolet brown
burlywood cadetblue chartreuse chocolate
coral cornflowerblue cornsilk crimson
cyan darkblue darkcyan darkgoldenrod
darkgray darkgreen darkgrey darkkhaki
darkmagenta darkolivegreen darkorange darkorchid
darkred darksalmon darkseagreen darkslateblue
darkslategray darkslategrey darkturquoise darkviolet
deeppink deepskyblue dimgray dimgrey
dodgerblue firebrick floralwhite forestgreen
fuchsia gainsboro ghostwhite gold
goldenrod gray green greenyellow
grey honeydew hotpink indianred
indigo ivory khaki lavender
lavenderblush lawngreen lemonchiffon lightblue
lightcoral lightcyan lightgoldenrodyello lightgray
lightgreen lightgrey lightpink lightsalmon
lightseagreen lightskyblue lightslategray lightslategrey
lightsteelblue lightyellow lime limegreen
linen magenta maroon mediumaquamarine
mediumblue mediumorchid mediumpurple mediumseagreen
mediumslateblue mediumspringgreen mediumturquoise mediumvioletred
midnightblue mintcream mistyrose moccasin
navajowhite navy oldlace olive
olivedrab orange orangered orchid
palegoldenrod palegreen paleturquoise palevioletred
papayawhip peachpuff peru pink
plum powderblue purple red
rosybrown royalblue saddlebrown salmon
sandybrown seagreen seashell sienna
silver skyblue slateblue slategray
slategrey snow springgreen steelblue
tan teal thistle tomato
turquoise violet wheat white
whitesmoke yellow yellowgreen
Back to top
View user's profile Send private message 
trio


Joined: 21 Dec 2008
Posts: 2083
Location: अनुमोदना

PostPosted: Fri 17 Oct 2014, 00:27    Post subject:  

deleted
_________________
My apps

Last edited by trio on Mon 20 Oct 2014, 04:10; edited 1 time in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4717
Location: Ontario

PostPosted: Sat 18 Oct 2014, 16:06    Post subject:  

egrep command can be used as well to check for a dark theme

This script will change the color of text according to gtk theme.
Certain theme names will trigger the change. Blue turns to orange.
Code:

#!/bin/sh
export COLOUR=3272C0
[ "`egrep "Stardust_dark_mouse|Stardust_dark_touch|Azenis|TerraNova-Aquarius|terminus|Murrina-Black|DarkRoomCompact|PenOSmaster" /root/.gtkrc-2.0`"  ] && COLOUR=FFD900

 export MAIN_DIALOG='
<window title="Example"  window-position="1">
 <vbox>
<text use-markup="true"><label>"<b><span size='"'x-large'"'>p</span><span size='"'x-large'"' color='"'#$COLOUR'"'>Archive</span></b>"</label></text>
</vbox>
</window>'
 
 gtkdialog -p MAIN_DIALOG
 


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