GTK´Â rc ÆÄÀÏÀ» ÀÌ¿ëÇؼ ¾îÇÃÀÇ µðÆúÆ® ȯ°æÀ» ´Ù·é´Ù. À̵éÀº ¾Õ¼ ¼³¸íÇÑ ¾î¶² widgetÀÇ »ö±òÀº ¹°·Ð ¹è°æ¿¡ ³ÖÀ» pixmapÀ» ¼³Á¤ÇÒ ¼öµµ ÀÖ´Ù.
¾îÇÃÀ» ½ÃÀÛÇÏ´Â ºÎºÐ¿¡¼ ÀÌ ÇÔ¼ö¸¦ Æ÷ÇÔ½ÃÅ°ÀÚ.
void gtk_rc_parse (char *filename);
ÀÎÀÚ´Â ¿ì¸® rc ÆÄÀÏÀÇ À̸§ÀÌ´Ù. ÀÌ°ÍÀº GTK°¡ ÀÌ ÆÄÀÏÀ» ÀÐ¾î¼ widgetµéÀÇ ½ºÅ¸ÀÏÀ» ±×°÷¿¡ Á¤ÀÇµÈ ´ë·Î ¼¼ÆÃÇϵµ·Ï ÇÑ´Ù.
¸¸¾à widgetµé Áß¿¡ ´Ù¸¥ °Íµé°ú ±¸º°µÇ¾î¾ß ÇÒ Æ¯º°ÇÑ ½ºÅ¸ÀÏÀ» °¡Á®¾ß ÇÒ °ÍÀÌ ÀÖ´Ù¸é, ¶Ç´Â ´Ù¸¥ ¸ñÀûÀ¸·Î widgetµéÀ» ³í¸®ÀûÀ¸·Î ºÐ·ùÇÏ·Á¸é, ÀÌ ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ´Ù.
void gtk_widget_set_name (GtkWidget *widget,
gchar *name);
ù¹ø° ÀÎÀÚ·Î »õ·Î ¸¸µç widgetÀ» ÁÖ°í, µÎ¹ø° ÀÎÀÚ´Â ±×°Í¿¡ ºÎ¿©ÇÏ°íÀÚ ÇÏ´Â À̸§ÀÌ´Ù. ÀÌ°ÍÀº ÀÌ widgetÀÇ ¼Ó¼ºÀ» rc ÆÄÀÏ¿¡ ÀÖ´Â À̸§À» ÅëÇÏ¿© ¹Ù²Ü ¼ö ÀÖ°Ô ÇÑ´Ù.
ÀÌ·± ½ÄÀ¸·Î ÇÔ¼ö¸¦ È£ÃâÇß´Ù°í »ý°¢ÇØ º¸ÀÚ.
button = gtk_button_new_with_label ("Special Button");
gtk_widget_set_name (button, "special button");
±×·³ ÀÌ ¹öÆ°Àº "special button"À¸·Î À̸§ºÙ°í rc ÆÄÀÏ¿¡¼ "special button. GtkButton"À̶ó´Â À̸§À¸·Î µÉ °ÍÀÌ´Ù. (È®ÀÎÇØ º¸ÀÚ!)
¾Æ·¡ÀÇ rc ÆÄÀÏ ¿¹Á¦´Â main À©µµÀÇ ¼Ó¼ºÀ» ¼¼ÆÃÇÏ°í, ±× main À©µµÀÇ child µéÀº "main button"ÀÇ ½ºÅ¸ÀÏÀ» »ó¼Ó¹Þ°Ô µÈ´Ù. ÀÌ ¾îÇÿ¡¼ ¾²ÀÎ ÄÚµå´Â ÀÌ·¸°Ô µÈ´Ù.
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_name (window, "main window");
±×¸®°í rc ÆÄÀÏ¿¡¼ Á¤ÀǵǴ ½ºÅ¸ÀÏÀº ÀÌ·¸°Ô µÈ´Ù.
widget "main window.*GtkButton*" style "main_button"
"main window"¿¡ ÀÖ´Â ¸ðµç GtkButton widgetÀ» rc ÆÄÀÏ¿¡¼ Á¤ÀÇÇÑ "main_buttons"ÀÇ ½ºÅ¸ÀÏ´ë·Î ¼¼ÆÃÇÑ´Ù.
º¸´Ù½ÃÇÇ, ÀÌ°ÍÀº »ó´çÈ÷ °·ÂÇÏ°í À¯¿¬ÇÑ ½Ã½ºÅÛÀÌ´Ù. ÀÌ°ÍÀ¸·Î ÃÖ°íÀÇ È¿°ú¸¦ ¾ò±â À§ÇØ °¢ÀÚ »ó»ó·ÂÀ» µ¿¿øÇØ º¸±â ¹Ù¶õ´Ù.
GTK rc ÆÄÀÏÀÇ Æ÷¸ËÀº µÚµû¸£´Â ¿¹Á¦¿¡¼ º¸¿©Áö°í ÀÖ´Ù. ÀÌ°ÍÀº GTK ¹èÆ÷º»¿¡ ÇÔ²² ÀÖ´Â testgtkrc ÆÄÀÏÀÌ°í, ³»°¡ ¾à°£ÀÇ ÁÖ¼® °°Àº °ÍÀ» ´õÇß´Ù. ´©±¸µçÁö ÀÌ°ÍÀ» ¾îÇÿ¡ Æ÷ÇÔ½ÃÄѼ »ç¿ëÀÚµéÀÌ ÀÌ¿ëÇÏ°Ô ÇÒ ¼ö ÀÖÀ» °ÍÀÌ´Ù.
WidgetÀÇ ¼Ó¼ºÀ» º¯È½Ãų ¶§ ¸î°¡Áö Á÷°üÀûÀÎ °ÍµéÀÌ ÀÖ´Ù.
À̰͵鿡 µ¡ºÙ¿©, widgetµé¿¡ °¡ÇØÁú ¼ö ÀÖ´Â ¸î°¡Áö state°¡ ÀÖ°í, ¿ì¸®´Â ´Ù¸¥ »ö±ò, ÇȽº¸Ê, ±×¸®°í ÆùÆ®¸¦ °¢ »óÅ¿¡ ¼¼ÆÃÇØ ÁÙ ¼ö ÀÖ´Ù. ÀÌ stateµéÀº ´ÙÀ½°ú °°´Ù.
WidgetÀÇ »ö±òÀ» º¯È½ÃÅ°´Â Å°¿öµåÀÎ "fg"¿Í "bg"¸¦ »ç¿ëÇÒ ¶§ÀÇ Æ÷¸ËÀº ÀÌ·¸´Ù.
fg[<STATE>] = { Red, Green, Blue }
¿©±â¼ STATE´Â À§ÀÇ Ç¥Çöµé(PRELIGHT, ACTIVE µî) Áß Çϳª°í, Red, Green, Blue´Â 0ºÎÅÍ 1±îÁöÀÇ ºÎµ¿¼Ò¼öÁ¡ ¼ö´Ù. À̵éÀº ¹Ýµå½Ã ºÎµ¿¼Ò¼ö·Î Ç¥ÇöµÇ¾î¾ß Çϸç, ±×·¸Áö ¾ÊÀ¸¸é 0À¸·Î ÀÎ½ÄµÉ °ÍÀÌ´Ù. "1"Àº µ¿ÀÛÇÏÁö ¾Ê´Â´Ù, ²À "1.0" À¸·Î ÇØ¾ß ÇÑ´Ù. ´Ü¼øÈ÷ "0"À̶ó°í ÇÏ´Â °ÍÀº ÀνĵÇÁö ¾Ê´Â °ªÀÌ 0À̹ǷΠ¹«¹æÇÒ °ÍÀÌ´Ù.
bg_pixmapÀº À§ÀÇ °æ¿ì¿Í ¸Å¿ì ºñ½ÁÇÏ´Ù, color°¡ filenameÀ¸·Î ´ëÄ¡µÉ »Ó.
pixmap_path´Â ":"À¸·Î ±¸ºÐµÈ °æ·ÎÀÇ ¸®½ºÆ®´Ù. ÀÌ °æ·Î´Â ¿ì¸®°¡ ¼³Á¤ÇÑ ´ë·Î ¾î¶² ÇȽº¸ÊÀÌ¶óµµ Ã£À» °ÍÀÌ´Ù.
fontµµ Á÷°üÀûÀ¸·Î ÀÌ·¸°Ô¸¸ ÇÏ¸é µÈ´Ù.
font = "<font name>"
µü Çϳª ¾î·Á¿î °Ô ÀÖ´Ù¸é ÆùÆ® À̸§ÀÇ ¹®ÀÚ¿À» ´Ù·ç´Â °ÍÀÌ´Ù. xfontsel À̳ª À¯»çÇÑ À¯Æ¿¸®Æ¼µéÀÌ µµ¿òÀÌ µÉ °ÍÀÌ´Ù.
"widget_class"´Â widgetµéÀÇ Å¬·¡½º ½ºÅ¸ÀÏÀ» ¼¼ÆÃÇÑ´Ù. ÀÌ Å¬·¡½ºµéÀº widgetÀÇ °³¿ä ºÎºÐ¿¡¼ º¸ÀΠŬ·¡½º °èÃþ±¸Á¶¿¡ ³ª¿Í ÀÖ´Ù.
"widget"Àº Á÷°üÀûÀ¸·Î, À̸§ ºÙ¿©Áø widgetÀÇ ÁýÇÕÀ» ÁÖ¾îÁø ½ºÅ¸ÀÏ´ë·Î ¼³Á¤Çϸç, ÁÖ¾îÁø widget Ŭ·¡½º¿¡ ´ëÇØ ¾î¶² ½ºÅ¸ÀÏÀÌ¶óµµ ¿À¹ö·ÎµåÇÑ´Ù. ÀÌ·± widgetµéÀº gtk_widget_set_name() ÇÔ¼ö¿¡ ÀÇÇØ ¾îÇà ³»ºÎ¿¡ µî·ÏµÇ¾î ÀÖ´Ù. ÀÌ°ÍÀº widget Ŭ·¡½º ÀüüÀûÀ¸·Î°¡ ¾Æ´Ï¶ó ¾î¶² widgetÀ» basis·Î ÇÏ°í ÀÖ´Â ¾î´À ÇÑ widgetÀÇ Æ¯¼ºÀ» ¼³Á¤ÇØ ÁÙ ¼ö ÀÖµµ·Ï ÇÑ´Ù. »ç¿ëÀÚµéÀÌ ³ª¸§´ë·Î ¼³Á¤ Çؼ ÀÌ¿ëÇÒ ÀÖµµ·Ï, ÀÌ·± Ưº°ÇÑ widgetÀ̶ó¸é ¹¹µçÁö ¹®¼ÈÇØ µÑ °ÍÀ» Àû±Ø ±ÇÇÏ´Â ¹ÙÀÌ´Ù.
Å°¿öµå "parent
"°¡ ¼Ó¼º ¼³Á¤¿¡ ¾²À̸é, ±× widgetÀº parentÀÇ ¼Ó¼ºÀ» µû¸£°Ô
µÈ´Ù.
½ºÅ¸ÀÏÀ» Á¤ÀÇÇϸé¼, ÀÌÀü¿¡ Á¤ÀÇµÈ ½ºÅ¸ÀÏÀ» »õ·Î¿î °Í¿¡ ´ëÀÔÇØ ÁÖ´Â °Íµµ °¡´ÉÇÏ´Ù.
style "main_button" = "button"
{
font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
bg[PRELIGHT] = { 0.75, 0, 0 }
}
ÀÌ ¿¹Á¦´Â "button"ÀÇ ½ºÅ¸ÀÏÀ» ÃëÇؼ, ´ÜÁö ÀÌ°Í¿¡¼ font¿Í prelight background color¸¦ ¹Ù²Ù´Â °ÍÀ¸·Î »õ·Î¿î "main_button" ½ºÅ¸ÀÏÀ» ¸¸µé¾î³½´Ù.
¹°·Ð, ÀÌ·± ¼Ó¼º Áß ¸¹Àº °ÍµéÀº ¸ðµç widget¿¡ ´ëÇØ Àû¿ë°¡´ÉÇÑ °ÍÀÌ ¾Æ´Ï´Ù. ÀÌ°ÍÀº »ó½ÄÀûÀÌ°í °£´ÜÇÑ °ÍÀÌ´Ù. Àû¿ë°¡´ÉÇÑ °ÍÀÌ ÀÖ´Ù¸é Àû¿ëÇÏ¸é µÈ´Ù.
# pixmap_path "<dir 1>:<dir 2>:<dir 3>:..."
#
pixmap_path "/usr/include/X11R6/pixmaps:/home/imain/pixmaps"
#
# style <name> [= <name>]
# {
# <option>
# }
#
# widget <widget_set> style <style_name>
# widget_class <widget_class_set> style <style_name>
# ÀÌ°ÍÀº °¡´ÉÇÑ stateµéÀÇ ¸®½ºÆ®´Ù. À̵é Áß ÀϺδ ƯÁ¤ÇÑ widgetµé¿¡
# ´ëÇؼ´Â Àû¿ëµÇÁö ¾ÊÀ½À» ÁÖÀÇÇ϶ó.
#
# NORMAL - The normal state of a widget, without the mouse over top of
# it, and not being pressed etc.
#
# PRELIGHT - When the mouse is over top of the widget, colors defined
# using this state will be in effect.
#
# ACTIVE - When the widget is pressed or clicked it will be active, and
# the attributes assigned by this tag will be in effect.
#
# INSENSITIVE - When a widget is set insensitive, and cannot be
# activated, it will take these attributes.
#
# SELECTED - When an object is selected, it takes these attributes.
#
# Given these states, we can set the attributes of the widgets in each of
# these states using the following directives.
#
# fg - Sets the foreground color of a widget.
# fg - Sets the background color of a widget.
# bg_pixmap - Sets the background of a widget to a tiled pixmap.
# font - Sets the font to be used with the given widget.
#
# ¿©±â¼ "button"À̶ó ºÒ¸®¿ì´Â ½ºÅ¸ÀÏÀ» ¼¼ÆÃÇÑ´Ù. ÆÄÀÏÀÇ ¸¶Áö¸· ºÎºÐ¿¡¼
# ½ÇÁ¦ÀÇ widget¿¡ ÁöÁ¤µÇ°í ÀÖÀ¸¹Ç·Î ¿©±â¼ÀÇ À̸§Àº Áß¿äÇÏÁö ¾Ê´Ù.
style "window"
{
# ÀÌ°ÍÀº ÁÖ¾îÁø ÇȽº¸ÊÀ¸·Î À©µµÀÇ ÆеùÀ» ¼¼ÆÃÇÑ´Ù.
#bg_pixmap[<STATE>] = "<pixmap filename>"
bg_pixmap[NORMAL] = "warning.xpm"
}
style "scale"
{
# "NORMAL" state¿¡¼ foreground(font) »ö±òÀ» red·Î ¼¼ÆÃÇÑ´Ù.
fg[NORMAL] = { 1.0, 0, 0 }
# ÀÌ widgetÀÇ background pixmapÀ» parentÀÇ ±×°ÍÀ¸·Î ¼¼ÆÃÇÑ´Ù.
bg_pixmap[NORMAL] = "<parent>"
}
style "button"
{
# ¿©±â¼ ¾î¶² ¹öÆ°¿¡ ´ëÇÏ¿© °¡´ÉÇÑ ¸ðµç state¸¦ º¸¿©ÁØ´Ù. µü Çϳª
# Àû¿ëµÇÁö ¾Ê´Â °ÍÀº SELECTED state´Ù.
fg[PRELIGHT] = { 0, 1.0, 1.0 }
bg[PRELIGHT] = { 0, 0, 1.0 }
bg[ACTIVE] = { 1.0, 0, 0 }
fg[ACTIVE] = { 0, 1.0, 0 }
bg[NORMAL] = { 1.0, 1.0, 0 }
fg[NORMAL] = { .99, 0, .99 }
bg[INSENSITIVE] = { 1.0, 1.0, 1.0 }
fg[INSENSITIVE] = { 1.0, 0, 1.0 }
}
# ÀÌ ¿¹Á¦¿¡¼, ¿ì¸®´Â "button" ½ºÅ¸ÀÏÀÇ ¼Ó¼ºÀ» »ó¼Ó¹Þ´Â´Ù. ±×¸®°í
# »õ·Î "main_button" ½ºÅ¸ÀÏÀ» ¸¸µé°Ô µÉ¶§¸é font¿Í background »ö±òÀº
# µû·Î ÁöÁ¤Çؼ ¾´´Ù.
style "main_button" = "button"
{
font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
bg[PRELIGHT] = { 0.75, 0, 0 }
}
style "toggle_button" = "button"
{
fg[NORMAL] = { 1.0, 0, 0 }
fg[ACTIVE] = { 1.0, 0, 0 }
# toggle_buttonÀÇ background pixmapÀ» ±×°ÍÀÇ parent widget(¾îÇÿ¡¼
# Á¤Àǵȴë·Î)ÀÇ ¼Ó¼ºÀ¸·Î ¼¼ÆÃÇÑ´Ù.
bg_pixmap[NORMAL] = "<parent>"
}
style "text"
{
bg_pixmap[NORMAL] = "marble.xpm"
fg[NORMAL] = { 1.0, 1.0, 1.0 }
}
style "ruler"
{
font = "-adobe-helvetica-medium-r-normal--*-80-*-*-*-*-*-*"
}
# pixmap_path "~/.pixmaps"
# À̵éÀº widgetÀÇ Å¸ÀÔµéÀ» À§¿¡¼ Á¤ÀÇµÈ ½ºÅ¸ÀÏ¿¡ µû¸£°Ô ÇÑ´Ù.
# Widget ŸÀÔµéÀº Ŭ·¡½º °èÃþ±¸Á¶¿¡ ¸®½ºÆ®µÇ¾î ÀÖÁö¸¸, ÀÌ ¹®¼¿¡ ¸®½ºÆ®µÈ
# °Íµéµµ »ç¿ëÀڵ鿡°Ô ÁÁÀº Âü°í°¡ µÉ ¼ö ÀÖ´Ù.
widget_class "GtkWindow" style "window"
widget_class "GtkDialog" style "window"
widget_class "GtkFileSelection" style "window"
widget_class "*Gtk*Scale" style "scale"
widget_class "*GtkCheckButton*" style "toggle_button"
widget_class "*GtkRadioButton*" style "toggle_button"
widget_class "*GtkButton*" style "button"
widget_class "*Ruler" style "ruler"
widget_class "*GtkText" style "text"
# ÀÌ°ÍÀº ¸ðµç ¹öÆ°µé("main window"ÀÇ childrenµé)À» main_buttonÀÇ ½ºÅ¸ÀÏ
# ´ë·Î ¼¼ÆÃÇÑ´Ù.
widget "main window.*GtkButton*" style "main_button"