<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[阿Tim日志]]></title> 
<link>https://atim.cn/index.php</link> 
<description><![CDATA[专业的php开发者.开发团队的带队人]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[阿Tim日志]]></copyright>
<item>
<link>https://atim.cn/post//</link>
<title><![CDATA[使用GTK编写中文软件]]></title> 
<author>bkkkd &lt;partybase@gmail.com&gt;</author>
<category><![CDATA[软件应用]]></category>
<pubDate>Wed, 26 Oct 2005 13:17:13 +0000</pubDate> 
<guid>https://atim.cn/post//</guid> 
<description>
<![CDATA[ 
	GTK/GNOME 系列widgets中, 输入和显示已经是国际化了的. 所以用它们编写中文软件十分容易. 把西文软件改写成中文软件也十分容易.<br /><br/><br /><br/> &nbsp; &nbsp;* 在程序中包含 locale.h<br /><br/> &nbsp; &nbsp;* 在gtk_init前设置locale: gtk_set_locale()<br /><br/> &nbsp; &nbsp;* 接着调用 gtk_rc_add_default_file(\&quot;rcfilename\&quot;), 其中rcfilename中 含有缺省的fontset<br /><br/> &nbsp; &nbsp;* 如果不用资源文件, 则应对widget设置fontset<br /><br/> &nbsp; &nbsp;* 编译 gcc `gtk-config --cflags` entry.c -o entry `gtk-config --libs`<br /><br/> &nbsp; &nbsp;* 把文件 <a href="http://www.linuxforum.net/chinese/develop/gtk/gtkrc.zh">gtkrc.zh</a> 拷贝到当前目录下 <br /><br/><br /><br/>在 gtk 的 text 组件中如果设置了font, 则不能正常显示中文. 解决的方法是把font释放(unref), 然后使用<br/>gtk_fontset_load 字体集. 对于其它组件也是如此, 有的组件需要先拷贝一个 GtkStyle, 然后按上述方法解决.<br /><br/><br /><br/>下面的程序在显示中文时未使用中文平台, 输入使用的是Chinput中的XIM协议支持 , 输出结<br /><br/>果:<img border="0" onclick="<br/>function onclick(event) &#123;<br/> &nbsp; &nbsp;window.open("http://www.linuxforum.net/chinese/develop/gtk/gtk.gif");<br/>&#125;<br/>" onmouseover="<br/>function onmouseover(event) &#123;<br/> &nbsp; &nbsp;if (this.alt) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;this.style.cursor = "hand";<br/> &nbsp; &nbsp;&#125;<br/>&#125;<br/>" onload="<br/>function onload(event) &#123;<br/> &nbsp; &nbsp;if (this.width > screen.width - 333) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;this.width = screen.width - 333;<br/> &nbsp; &nbsp; &nbsp; &nbsp;this.alt = "\u70B9\u51FB\u67E5\u770B\u539F\u56FE\uFF01";<br/> &nbsp; &nbsp;&#125;<br/>&#125;<br/>" alt="点击查看原图" src="http://www.linuxforum.net/chinese/develop/gtk/gtk.gif" /><br /><br/>//file entry.c <br /><br/>#include &nbsp;<br /><br/>#include &nbsp;<br /><br/>int main (int argc, char *argv[]) <br /><br/>&#123; <br /><br/>GtkWidget *window; <br /><br/>GtkWidget *vbox; <br /><br/>GtkWidget *entry;<br /><br/>GtkWidget *text; <br /><br/>GtkWidget *button; <br /><br/>gtk_set_locale(); <br /><br/>gtk_rc_add_default_file(\&quot;./gtkrc.zh\&quot;); <br /><br/>gtk_init (&amp;argc, &amp;argv); /* create a new window */ <br /><br/>window = gtk_window_new(GTK_WINDOW_TOPLEVEL); <br /><br/>// gtk_widget_set_usize( GTK_WIDGET (window), 200, 500); <br /><br/>gtk_window_set_title(GTK_WINDOW (window), \&quot;GTK Entry\&quot;); <br /><br/>gtk_signal_connect(GTK_OBJECT (window), \&quot;delete_event\&quot;, (GtkSignalFunc) gtk_exit, NULL); <br /><br/>vbox = gtk_vbox_new (FALSE, 0); <br /><br/>gtk_container_add (GTK_CONTAINER (window), vbox); <br /><br/>gtk_widget_show (vbox); entry = gtk_entry_new_with_max_length (60); <br /><br/>gtk_entry_select_region (GTK_ENTRY (entry), 0, GTK_ENTRY(entry)-&gt;text_length); <br /><br/>gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0); <br /><br/>gtk_widget_show (entry); text = gtk_text_new (NULL, NULL); <br /><br/>gtk_text_set_editable (GTK_TEXT (text), TRUE); <br /><br/>gtk_box_pack_start (GTK_BOX (vbox), text, TRUE, TRUE, 0); <br /><br/>gtk_widget_show(text); button = gtk_button_new_with_label (\&quot;关闭窗口\&quot;); <br /><br/>gtk_signal_connect_object (GTK_OBJECT (button), \&quot;clicked\&quot;, GTK_SIGNAL_FUNC(gtk_exit), GTK_OBJECT (window)); <br /><br/>gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); <br /><br/>gtk_widget_grab_default (button); <br /><br/>gtk_widget_show (button); <br /><br/>gtk_widget_show(window); <br /><br/>gtk_main(); <br /><br/>return(0); <br /><br/>&#125;<br/>
]]>
</description>
</item><item>
<link>https://atim.cn/post//#blogcomment</link>
<title><![CDATA[[评论] 使用GTK编写中文软件]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://atim.cn/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>