[Cxplorer-cvs 01228] CVS update: libcxp/src

Back to archive index

Yasumichi Akahoshi yasum****@users*****
2005年 9月 3日 (土) 02:24:56 JST


Index: libcxp/src/cxp-mime-manager.c
diff -u libcxp/src/cxp-mime-manager.c:1.3 libcxp/src/cxp-mime-manager.c:1.4
--- libcxp/src/cxp-mime-manager.c:1.3	Fri Sep  2 22:19:11 2005
+++ libcxp/src/cxp-mime-manager.c	Sat Sep  3 02:24:56 2005
@@ -25,6 +25,7 @@
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
+#include "cxp-utils.h"
 #include "cxp-mime-manager.h"
  
 static void cxp_mime_manager_class_init(CxpMimeManagerClass *klass);
@@ -40,6 +41,7 @@
 	gchar **xdgdirs;
 	gint parse_flag;
 	GHashTable *comments;
+	GHashTable *icons;
 };
 
 typedef enum {
@@ -122,6 +124,7 @@
 	{
 		obj->priv->xdgdirs = g_strsplit (XDG_DATA_DIR, ":", 0);
 	}
+	obj->priv->icons = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
 }
 
 static void
@@ -134,6 +137,7 @@
 	g_free(cobj->priv->lang);
 	g_free(cobj->priv->country);
 	g_hash_table_destroy (cobj->priv->comments);
+	g_hash_table_destroy (cobj->priv->icons);
 	g_strfreev (cobj->priv->xdgdirs);
 		
 	g_free(cobj->priv);
@@ -273,3 +277,21 @@
 
 	return result;
 }
+
+GdkPixbuf* cxp_mime_manager_lookup_icon (CxpMimeManager *manager, const gchar *mimetype)
+{
+	GdkPixbuf *icon;
+	gchar *filename;
+
+	if((icon = g_hash_table_lookup(manager->priv->icons, mimetype)) == NULL)
+	{
+		filename = g_strdup_printf(PACKAGE_PIXMAPS_DIR"/%s.png", mimetype);
+		if((icon = gdk_pixbuf_new_from_file(filename, NULL)) == NULL)
+		{
+			icon = gdk_pixbuf_new_from_file(PACKAGE_PIXMAPS_DIR"/not-find.png", NULL);
+		}
+		g_hash_table_replace (manager->priv->icons, g_strdup(mimetype), icon);
+	}
+
+	return	icon;
+}
Index: libcxp/src/cxp-utils.c
diff -u libcxp/src/cxp-utils.c:1.15 libcxp/src/cxp-utils.c:1.16
--- libcxp/src/cxp-utils.c:1.15	Thu Sep  1 00:50:11 2005
+++ libcxp/src/cxp-utils.c	Sat Sep  3 02:24:56 2005
@@ -1,4 +1,4 @@
-/* $Id: cxp-utils.c,v 1.15 2005/08/31 15:50:11 yasumichi Exp $ */
+/* $Id: cxp-utils.c,v 1.16 2005/09/02 17:24:56 yasumichi Exp $ */
 /**
  * \if japanese
  * @file
@@ -6,7 +6,7 @@
  *
  * @author 赤星 柔充
  * @date Fri Jan 21 2005
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
  * \endif
  * \if english
  * @file
@@ -14,7 +14,7 @@
  *
  * @author Yasumichi Akahoshi
  * @date Fri Jan 21 2005
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
  * \endif
  */
 
@@ -427,6 +427,16 @@
 	return	cxp_mime_manager_get_comment_from_mime (manager, mimetype);
 }
 
+GdkPixbuf* cxp_lookup_icon_from_mime (const gchar *mimetype)
+{
+	if(manager == NULL)
+	{
+		manager = cxp_mime_manager_new ();
+	}
+
+	return	cxp_mime_manager_lookup_icon (manager, mimetype);
+}
+
 void cxp_cleanup (void)
 {
 	g_object_unref (manager);


Cxplorer-cvs メーリングリストの案内
Back to archive index