<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阳光烂灿的日子 &#187; program</title>
	<atom:link href="http://www.lerosua.org/tag/program/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lerosua.org</link>
	<description>总会遇见</description>
	<lastBuildDate>Sun, 15 Aug 2010 14:04:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>gtkmm文章：libglade转换至gtkbuilder</title>
		<link>http://www.lerosua.org/2009/08/libglade_to_gtkbuilder/</link>
		<comments>http://www.lerosua.org/2009/08/libglade_to_gtkbuilder/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 02:52:08 +0000</pubDate>
		<dc:creator>lerosua</dc:creator>
				<category><![CDATA[gtkmm]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.lerosua.org/?p=608</guid>
		<description><![CDATA[glade3界面生成器现在能生成两种格式的xml界面描述文件。分别是libglade和gtkbuilder. libglade就是我们以前所使用的，要依赖于libglade库的。而gtkbuilder是gtk 2.12以后版本直接支持的。gtkbuilder是设计来代替libglade的，将会是以后的主流。因此本文将简单介绍一下在gtkmm环境下libglade转换至gtkbuilder的操作。 1.转换旧的glade文件。 如果您的项目中已经用了libglade的文件格式，可通过两种方法将它转换成gtkbuilder格式的。 一是用glade-3打开，在菜单“属性”中将它选择成gtkbuilder，并另存为即可。 二是使用 gtk-builder-convert xxx.glade xxx.xml 命令直接转换。 当然gtkbuilder的后缀名仍可保留为glade,这随你喜欢。 2. 替换代码中的相应函数。 在创建xml文件中: Glib::RefPtr&#60;Gnome::Glade::Xml&#62; main_xml = Gnome::Glade::create&#40;main_ui,&#34;main_notebook&#34;&#41;; 替换成 Glib::RefPtr&#60;Gtk::Builder&#62; main_xml = Gtk::Builder::create_from_file&#40;main_ui, &#34;main_notebook&#34;&#41;; 在获取widget中 Gtk::Button* button_ok = dynamic_cast&#60;Gtk::Button*&#62;&#40;main_xml-&#62;get_widget&#40;&#34;button_ok&#34;&#41;&#41;; 替换成 Gtk::Button* button_ok=0; main_xml-&#62;get_widget&#40;&#34;button_ok&#34;,button_ok&#41;; 转换后，程序可以去除掉libglademm和libglade依赖，但至少要求gtk和gtkmm版本要2.14以上版本才能正常工作。另外libglade里画的菜单和工具栏似乎不能正常转到gtkbuilder中，这点需要注意。]]></description>
			<content:encoded><![CDATA[<p>glade3界面生成器现在能生成两种格式的xml界面描述文件。分别是libglade和gtkbuilder. libglade就是我们以前所使用的，要依赖于libglade库的。而gtkbuilder是gtk 2.12以后版本直接支持的。gtkbuilder是设计来代替libglade的，将会是以后的主流。因此本文将简单介绍一下在gtkmm环境下libglade转换至gtkbuilder的操作。</p>
<p>1.转换旧的glade文件。</p>
<p>如果您的项目中已经用了libglade的文件格式，可通过两种方法将它转换成gtkbuilder格式的。</p>
<p>一是用glade-3打开，在菜单“属性”中将它选择成gtkbuilder，并另存为即可。</p>
<p>二是使用 gtk-builder-convert xxx.glade xxx.xml 命令直接转换。</p>
<p>当然gtkbuilder的后缀名仍可保留为glade,这随你喜欢。</p>
<p>2. 替换代码中的相应函数。<br />
在创建xml文件中:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">Glib<span style="color: #339933;">::</span><span style="color: #202020;">RefPtr</span><span style="color: #339933;">&lt;</span>Gnome<span style="color: #339933;">::</span><span style="color: #202020;">Glade</span><span style="color: #339933;">::</span><span style="color: #202020;">Xml</span><span style="color: #339933;">&gt;</span> main_xml <span style="color: #339933;">=</span> Gnome<span style="color: #339933;">::</span><span style="color: #202020;">Glade</span><span style="color: #339933;">::</span><span style="color: #202020;">create</span><span style="color: #009900;">&#40;</span>main_ui<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;main_notebook&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>替换成</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">Glib<span style="color: #339933;">::</span><span style="color: #202020;">RefPtr</span><span style="color: #339933;">&lt;</span>Gtk<span style="color: #339933;">::</span><span style="color: #202020;">Builder</span><span style="color: #339933;">&gt;</span> main_xml <span style="color: #339933;">=</span> Gtk<span style="color: #339933;">::</span><span style="color: #202020;">Builder</span><span style="color: #339933;">::</span><span style="color: #202020;">create_from_file</span><span style="color: #009900;">&#40;</span>main_ui<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;main_notebook&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>在获取widget中</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">Gtk<span style="color: #339933;">::</span><span style="color: #202020;">Button</span><span style="color: #339933;">*</span> button_ok <span style="color: #339933;">=</span> dynamic_cast<span style="color: #339933;">&lt;</span>Gtk<span style="color: #339933;">::</span><span style="color: #202020;">Button</span><span style="color: #339933;">*&gt;</span><span style="color: #009900;">&#40;</span>main_xml<span style="color: #339933;">-&gt;</span>get_widget<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;button_ok&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>替换成</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">Gtk<span style="color: #339933;">::</span><span style="color: #202020;">Button</span><span style="color: #339933;">*</span> button_ok<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
main_xml<span style="color: #339933;">-&gt;</span>get_widget<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;button_ok&quot;</span><span style="color: #339933;">,</span>button_ok<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>转换后，程序可以去除掉libglademm和libglade依赖，但至少要求gtk和gtkmm版本要2.14以上版本才能正常工作。另外libglade里画的菜单和工具栏似乎不能正常转到gtkbuilder中，这点需要注意。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lerosua.org/2009/08/libglade_to_gtkbuilder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>gtkmm关闭窗口续</title>
		<link>http://www.lerosua.org/2009/03/gtkmm%e5%85%b3%e9%97%ad%e7%aa%97%e5%8f%a3%e7%bb%ad/</link>
		<comments>http://www.lerosua.org/2009/03/gtkmm%e5%85%b3%e9%97%ad%e7%aa%97%e5%8f%a3%e7%bb%ad/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 02:06:29 +0000</pubDate>
		<dc:creator>lerosua</dc:creator>
				<category><![CDATA[gtkmm]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.lerosua.org/?p=432</guid>
		<description><![CDATA[上一篇文章中讲到的窗口，点击关闭后只是隐藏了而已。窗口会一直存在。也许会觉得这样占用资源。当然也可以让它点击关闭即销毁它。只需要在run调用后detele掉它。但注意还需要把窗口指针置0 代码如下修改 about-&#62;run&#40;&#41;; //about-&#62;hide(); delete about; about=0;]]></description>
			<content:encoded><![CDATA[<p>上一篇文章中讲到的窗口，点击关闭后只是隐藏了而已。窗口会一直存在。也许会觉得这样占用资源。当然也可以让它点击关闭即销毁它。只需要在run调用后detele掉它。但注意还需要把窗口指针置0</p>
<p>代码如下修改</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">about<span style="color: #339933;">-&gt;</span>run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//about-&gt;hide();</span>
delete about<span style="color: #339933;">;</span>
about<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lerosua.org/2009/03/gtkmm%e5%85%b3%e9%97%ad%e7%aa%97%e5%8f%a3%e7%bb%ad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gtkmm中关于窗口的关闭按钮问题</title>
		<link>http://www.lerosua.org/2009/03/gtkmm%e4%b8%ad%e5%85%b3%e4%ba%8e%e7%aa%97%e5%8f%a3%e7%9a%84%e5%85%b3%e9%97%ad%e6%8c%89%e9%92%ae%e9%97%ae%e9%a2%98/</link>
		<comments>http://www.lerosua.org/2009/03/gtkmm%e4%b8%ad%e5%85%b3%e4%ba%8e%e7%aa%97%e5%8f%a3%e7%9a%84%e5%85%b3%e9%97%ad%e6%8c%89%e9%92%ae%e9%97%ae%e9%a2%98/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 04:38:58 +0000</pubDate>
		<dc:creator>lerosua</dc:creator>
				<category><![CDATA[gtkmm]]></category>
		<category><![CDATA[aboutdialog]]></category>
		<category><![CDATA[close]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.lerosua.org/?p=428</guid>
		<description><![CDATA[之前用Gtkmm写icalk时创造了一个关于窗口，但它有个bug，关闭按钮没响应。昨天为GMChess创建关于窗口的时候再次遇到这个bug，这次我认真地搜索了一下，终于发现问题所在。 之前我都是创建完about窗口后，再调用show函数显示。 其实是应该调用run函数。我忘记了about窗口其实是dialog类，平时对话框之类不是要调用run然后观其返回值嘛，原来我无形中把about窗口当成window类了。发现有不少人有这错觉哩。而gnome-osd-properties的关于窗口也有关不掉的bug，哈哈哈。 下面给一个菜单调用about窗口的实例源码， void MainWindow::on_menu_about&#40;&#41; &#123; static Gtk::AboutDialog* about&#40;0&#41;; if&#40;about == 0&#41;&#123; std::vector&#60;Glib::ustring&#62; authors; authors.push_back&#40;&#34;lerosua &#34;&#41;; authors.push_back&#40;&#34;wind&#34;&#41;; about = new Gtk::AboutDialog ; Glib::RefPtr&#60;Gdk::Pixbuf&#62; logo = Gdk::Pixbuf::create_from_file&#40;DATA_DIR&#34;/gmchess.png&#34;&#41;; about-&#62;set_logo&#40;logo&#41;; about-&#62;set_program_name&#40;&#34;GMChess&#34;&#41;; about-&#62;set_version&#40;version&#41;; about-&#62;set_website&#40;&#34;http://lerosua.org&#34;&#41;; about-&#62;set_copyright&#40;&#34;Copyright (c) 2009 lerosua&#34;&#41;; about-&#62;set_comments&#40;_&#40;&#34;GMChess is chinese chess game write by gtkmm&#34;&#41;&#41;; about-&#62;set_authors&#40;authors&#41;; about-&#62;set_license &#40;_&#40;&#34;This program is licenced under GNU General Public Licence (GPL) [...]]]></description>
			<content:encoded><![CDATA[<p>之前用Gtkmm写icalk时创造了一个关于窗口，但它有个bug，关闭按钮没响应。昨天为GMChess创建关于窗口的时候再次遇到这个bug，这次我认真地搜索了一下，终于发现问题所在。<br />
之前我都是创建完about窗口后，再调用show函数显示。<br />
其实是应该调用run函数。我忘记了about窗口其实是dialog类，平时对话框之类不是要调用run然后观其返回值嘛，原来我无形中把about窗口当成window类了。发现有不少人有这错觉哩。而gnome-osd-properties的关于窗口也有关不掉的bug，哈哈哈。<br />
下面给一个菜单调用about窗口的实例源码，</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> MainWindow<span style="color: #339933;">::</span><span style="color: #202020;">on_menu_about</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">static</span> Gtk<span style="color: #339933;">::</span><span style="color: #202020;">AboutDialog</span><span style="color: #339933;">*</span>  about<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>about <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		std<span style="color: #339933;">::</span><span style="color: #202020;">vector</span><span style="color: #339933;">&lt;</span>Glib<span style="color: #339933;">::</span><span style="color: #202020;">ustring</span><span style="color: #339933;">&gt;</span> authors<span style="color: #339933;">;</span>
		authors.<span style="color: #202020;">push_back</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;lerosua &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		authors.<span style="color: #202020;">push_back</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;wind&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about <span style="color: #339933;">=</span> new Gtk<span style="color: #339933;">::</span><span style="color: #202020;">AboutDialog</span> <span style="color: #339933;">;</span>
		Glib<span style="color: #339933;">::</span><span style="color: #202020;">RefPtr</span><span style="color: #339933;">&lt;</span>Gdk<span style="color: #339933;">::</span><span style="color: #202020;">Pixbuf</span><span style="color: #339933;">&gt;</span> logo  <span style="color: #339933;">=</span> Gdk<span style="color: #339933;">::</span><span style="color: #202020;">Pixbuf</span><span style="color: #339933;">::</span><span style="color: #202020;">create_from_file</span><span style="color: #009900;">&#40;</span>DATA_DIR<span style="color: #ff0000;">&quot;/gmchess.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about<span style="color: #339933;">-&gt;</span>set_logo<span style="color: #009900;">&#40;</span>logo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about<span style="color: #339933;">-&gt;</span>set_program_name<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;GMChess&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about<span style="color: #339933;">-&gt;</span>set_version<span style="color: #009900;">&#40;</span>version<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about<span style="color: #339933;">-&gt;</span>set_website<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;http://lerosua.org&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about<span style="color: #339933;">-&gt;</span>set_copyright<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Copyright (c) 2009 lerosua&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about<span style="color: #339933;">-&gt;</span>set_comments<span style="color: #009900;">&#40;</span>_<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;GMChess is chinese chess game write by gtkmm&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about<span style="color: #339933;">-&gt;</span>set_authors<span style="color: #009900;">&#40;</span>authors<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about<span style="color: #339933;">-&gt;</span>set_license <span style="color: #009900;">&#40;</span>_<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;This program is licenced under GNU General Public Licence (GPL) version 2.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		about<span style="color: #339933;">-&gt;</span>set_translator_credits<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;lerosua&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">//about-&gt;show();</span>
	<span style="color: #666666; font-style: italic;">//about-&gt;raise();</span>
	about<span style="color: #339933;">-&gt;</span>run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	about<span style="color: #339933;">-&gt;</span>hide<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lerosua.org/2009/03/gtkmm%e4%b8%ad%e5%85%b3%e4%ba%8e%e7%aa%97%e5%8f%a3%e7%9a%84%e5%85%b3%e9%97%ad%e6%8c%89%e9%92%ae%e9%97%ae%e9%a2%98/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
