<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" 
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Bug Captor の 開發日記帳-GTK+</title>
<link>http://blog.roodo.com/toki_kanno/archives/cat_10357.html</link>
<description>一些開發程式時的碎碎唸，先找個地方記起來免的忘記</description>
<language>zh-tw</language>
<generator>Roodo Blog System</generator>
<copyright>All Rights Reserved</copyright>
<atom:link href="http://blog.roodo.com/toki_kanno/archives/cat_10357.xml" rel="self" type="application/rss+xml" />
<item>
	<title>一些常用的檔名轉換函式</title>
	<description><![CDATA[
			
g_filename_from_uri(const gchar *uri, gchar **hostname,                                             GError **error);
可以把以uri格式(*1)表示的檔案名稱轉換成該作業系統可接受的格式(*2)
其中hostname和error可為NULL
memo1: 轉出來的檔名是UTF8格式的，直接就可以餵給g_fopen了，不要再轉啦!!!
memo2: Win32下它會雞婆幫你把 / 轉成 \，請「手動」把它再轉回來ORZ

(*1) EX: file:///D:/%E6%B8%AC%E8%A9%A6.zip
(*2) EX: D:\測試.zip

g_filename_display_name(const gchar *filename);
轉換檔名成為可讀的UTF8格式，不可逆，記得把原來的檔名留下來。

		]]>
	</description>
	<content:encoded><![CDATA[
			<ul><br />
<li><b>g_filename_from_uri(const gchar *uri, gchar **hostname,                                             GError **error);</b></li><br />
可以把以uri格式(*1)表示的檔案名稱轉換成該作業系統可接受的格式(*2)<br />
其中hostname和error可為NULL<br />
<font color=red><b>memo1: 轉出來的檔名是UTF8格式的，直接就可以餵給g_fopen了，不要再轉啦!!!</b></font><br />
<font color=red><b>memo2: Win32下它會雞婆幫你把 / 轉成 \，請「手動」把它再轉回來ORZ</b></font><br />
<br />
(*1) EX: file:///D:/%E6%B8%AC%E8%A9%A6.zip<br />
(*2) EX: D:\測試.zip<br />
<br />
<li><b>g_filename_display_name(const gchar *filename);</b></li><br />
轉換檔名成為可讀的UTF8格式，不可逆，記得把原來的檔名留下來。<br />
</ul>
		
		]]>
	</content:encoded>
	<link>http://blog.roodo.com/toki_kanno/archives/44718.html</link>
	<guid>http://blog.roodo.com/toki_kanno/archives/44718.html</guid>
	<category>GTK+</category>
	<pubDate>Sat, 19 Mar 2005 18:25:38 +0800</pubDate>
</item>
<item>
	<title>GTK+  下的 file drag&amp;drop open</title>
	<description><![CDATA[
			有許多程式可以將支援的檔案直接拖到程式裡就可以開啟檔案，
GTK+寫的當然也可以，不過有些需要特別注意的地方。

撰寫步驟如下:

設定一個 GtkTargetEntry，其中 type 為 "text/uri-list"，這個不管是 Win32 or Unix 都是一樣的，都可以吃到檔案列表。
static GtkTargetEntry target_table[] = {{ "text/uri-list", 0, 0 }};
對你要設定可拖放檔案的元件(通常為window) 設定成 drag_dest
gtk_drag_dest_set(window, GTK_DEST_DEFAULT_ALL, target_table, 1, GDK_ACTION_COPY);

設定該元件的 window_drag_data_received 事件回呼函式
gtk_signal_connect(GTK_OBJECT(window), "drag_data_received", GTK_SIGNAL_FUNC(window_drag_data_received), NULL); 
static void window_drag_data_received(
GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
	g_print("Got: %s\n",data->data);
}

		]]>
	</description>
	<content:encoded><![CDATA[
			有許多程式可以將支援的檔案直接拖到程式裡就可以開啟檔案，<br />
GTK+寫的當然也可以，不過有些需要特別注意的地方。<br />
<br />
撰寫步驟如下:<br />
<ol><br />
<li>設定一個 GtkTargetEntry，其中 type 為 "text/uri-list"，這個不管是 Win32 or Unix 都是一樣的，都可以吃到檔案列表。</li><br />
<table width=100% border=1 bgcolor = white bordercolor=black cellpadding=0 cellspacing=0><td><font size=1 color=blue>static GtkTargetEntry target_table[] = {{ "text/uri-list", 0, 0 }};</font></td></table><br />
<li>對你要設定可拖放檔案的元件(通常為window) 設定成 drag_dest</li><br />
<table width=100% border=1 bgcolor = white bordercolor=black cellpadding=0 cellspacing=0><td><font size=1 color=blue>gtk_drag_dest_set(window, GTK_DEST_DEFAULT_ALL, target_table, 1, GDK_ACTION_COPY);<br />
</font></td></table><br />
<li>設定該元件的 window_drag_data_received 事件回呼函式</li><br />
<table width=100% border=1 bgcolor = white bordercolor=black cellpadding=0 cellspacing=0><td><font size=1 color=blue>gtk_signal_connect(GTK_OBJECT(window), "drag_data_received", GTK_SIGNAL_FUNC(window_drag_data_received), NULL); </font></td></table><br />
<table width=100% border=1 bgcolor = white bordercolor=black cellpadding=0 cellspacing=0><td><font size=1 color=blue>static void window_drag_data_received(<br />
GtkWidget *widget,<br />
GdkDragContext *context,<br />
gint x,<br />
gint y,<br />
GtkSelectionData *data,<br />
guint info,<br />
guint time)<br />
{<br />
	g_print("Got: %s\n",data->data);<br />
}</font></td></table><br />
</ol>
		
		]]>
	</content:encoded>
	<link>http://blog.roodo.com/toki_kanno/archives/44150.html</link>
	<guid>http://blog.roodo.com/toki_kanno/archives/44150.html</guid>
	<category>GTK+</category>
	<pubDate>Sat, 19 Mar 2005 00:51:16 +0800</pubDate>
</item>
</channel>
</rss>