⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gemresource.c.svn-base

📁 一款Linux手机上应用的文件管理器 系统要求就安装Gtk+2.0
💻 SVN-BASE
字号:
/*	libgemwidget - Gtk+ Embedded Widget library * *	Authors: YE Nan <nan.ye@orange-ftgourp.com>  *	 *	This software and associated documentation files (the "Software")  *	are copyright (C) 2005 LiPS Linux Phone Standards Forum [FranceTelecom]  *	All Rights Reserved.  * *	A copyright license is hereby granted for redistribution and use of  *	the Software in source and binary forms, with or without modification,  *	provided that the following conditions are met:  *	- Redistributions of source code must retain the above copyright notice,  *	this copyright license and the following disclaimer.  *  - Redistributions in binary form must reproduce the above copyright  * 	notice, this copyright license and the following disclaimer in the  *	documentation and/or other materials provided with the distribution.  *	- Neither the name of LiPS  nor the names of its Members may be used  *	to endorse or promote products derived from the Software without  *	specific prior written permission.  * *	A patent license for any Necessary Claims owned by Members of LiPS Forum  *	to make, have made, use, import, offer to sell, lease and sell or otherwise  *	distribute any implementation compliant with the any specification adopted  *	by the LiPS Forumcan be obtained from the respective Members on reasonable  *	and non-discriminatory terms and conditions and under reciprocity, as  *	regulated in more detail in the Internal Policy of the LiPS Forum.  * *	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER, ITS MEMBERS AND CONTRIBUTORS  *	"AS IS", AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,  *	THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE  *	AND NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER,  *	ITS MEMBERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,  *	PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;  *	OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  *	WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  *	POSSIBILITY OF SUCH DAMAGE.  */#include <stdio.h>#include <stdlib.h>#include <gtk/gtk.h>#include <gdk-pixbuf/gdk-pixbuf.h>#include "gemresource.h"#include "gemenv.h"#define	GEM_PIC_LARGE_W		64#define	GEM_PIC_LARGE_H		64#define	GEM_PIC_NORMAL_W	32#define	GEM_PIC_NORMAL_H	32#define	GEM_PIC_SMALL_W		20#define	GEM_PIC_SMALL_H		20typedef struct{	gchar							*fname;	GdkPixbuf					*pixbuf;	GemPicSizeHint		 size;} GemPicture;static GData * gem_pics_large		= NULL;static GData * gem_pics_normal	= NULL;static GData * gem_pics_small		= NULL;static voidgem_resource_pic_free (GemPicture * pic){	if (pic == NULL)	{		return;	}	  g_print("%s(): [name = %-20s, ref = %d]\n",            __FUNCTION__,          pic->fname,          (G_OBJECT(pic->pixbuf)->ref_count));  	if (pic->fname)	{		g_free(pic->fname);	}		if (pic->pixbuf)	{    g_object_unref (pic->pixbuf);	}		g_free(pic);		return;}static GemPicture * gem_resource_create_pic (const gchar			*fname,												 GemPicSizeHint		 size){	GemPicture * pic = NULL;	GdkPixbuf * pixbuf = NULL;	GError * error = NULL;	gint w, h;	switch (size)	{		case GEM_PIC_SMALL:			w = GEM_PIC_SMALL_W;			h = GEM_PIC_SMALL_H;			break;					case GEM_PIC_NORMAL:			w = GEM_PIC_NORMAL_W;			h = GEM_PIC_NORMAL_H;			break;					case GEM_PIC_LARGE:			w = GEM_PIC_LARGE_W;			h = GEM_PIC_LARGE_H;			break;				default:			w = GEM_PIC_LARGE_W;			h = GEM_PIC_LARGE_H;			break;	}		pixbuf = gdk_pixbuf_new_from_file_at_size(fname, w, h, &error);	if (error)	{		g_print("%s(): loading pixbuf failure. %s\n",						__FUNCTION__,						error->message);		g_error_free(error);				return NULL;	}			pic = g_new0(GemPicture, 1);	if (pic == NULL)	{		return NULL;	}		pic->fname = g_strdup(fname);	pic->pixbuf = (GdkPixbuf *)pixbuf;	pic->size = size;		return pic;	}gboolean gem_resource_load_pic (const gchar			*fname,											 GemPicSizeHint		 size){	GemPicture * pic = NULL;	GData ** pics_list = NULL;		if (gem_resource_find_pic(fname, size))	{/*    g_print("%s(): existing picutre, name = %s\n",             __FUNCTION__,            fname);*/		return TRUE;	}	pic = gem_resource_create_pic(fname, size);	if (pic == NULL)	{		return FALSE;	}		switch (size)	{		case GEM_PIC_SMALL:			pics_list = &gem_pics_small;			break;					case GEM_PIC_NORMAL:			pics_list = &gem_pics_normal;			break;					case GEM_PIC_LARGE:			pics_list = &gem_pics_large;			break;				default:			pics_list = &gem_pics_large;			break;	}		g_datalist_set_data_full(pics_list,                            fname,                            (gpointer)pic,                            (GDestroyNotify)gem_resource_pic_free);		return TRUE;	}gboolean gem_resource_load_pic_default (const gchar	*fname){	return gem_resource_load_pic(fname, GEM_PIC_LARGE);}GdkPixbuf * gem_resource_find_pic (const gchar			*fname,											 GemPicSizeHint		 size){	GData ** pics_list = NULL;	GemPicture * pic = NULL;		switch (size)	{		case GEM_PIC_SMALL:			pics_list = &gem_pics_small;			break;					case GEM_PIC_NORMAL:			pics_list = &gem_pics_normal;			break;					case GEM_PIC_LARGE:			pics_list = &gem_pics_large;			break;				default:			pics_list = &gem_pics_large;			break;	}		pic = g_datalist_get_data(pics_list, fname);		if (pic == NULL)	{		return NULL;	}	return pic->pixbuf;}static voidgem_picture_entry_list (GQuark key_id,													gpointer data,													gpointer user_data){	GemPicture * pic = (GemPicture *)data;		g_print("%s(): [name = %-20s, ref = %d]\n",					__FUNCTION__,					pic->fname,					(G_OBJECT(pic->pixbuf)->ref_count));		return;}void gem_pictures_list_all(GemPicSizeHint size){	GData ** pics_list = NULL;		switch (size)	{		case GEM_PIC_SMALL:			pics_list = &gem_pics_small;			break;					case GEM_PIC_NORMAL:			pics_list = &gem_pics_normal;			break;					case GEM_PIC_LARGE:			pics_list = &gem_pics_large;			break;				default:			pics_list = &gem_pics_large;			break;	}	g_datalist_foreach(pics_list,										 (GDataForeachFunc)gem_picture_entry_list,											NULL);	return;}gboolean gem_resource_init (void){  g_print("%s(): entering\n", __FUNCTION__);	g_datalist_init (&gem_pics_large);	g_datalist_init (&gem_pics_normal);	g_datalist_init (&gem_pics_small);		return TRUE;}void gem_resource_destroy (void){  g_print("%s(): entering\n", __FUNCTION__);	g_datalist_clear (&gem_pics_large);	g_datalist_clear (&gem_pics_normal);	g_datalist_clear (&gem_pics_small);		return;}/*vi:ts=2:nowrap:ai:expandtab */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -