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

📄 threads.c

📁 linux手机上的phonebook代码
💻 C
字号:
/*	contact - LiPS Address Book Application * *	Authors: YE Nan <nan.ye@orange-ftgroup.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 <gem.h>#include "threads.h"voidab_thread_free (ab_thread_t	*thread){	g_return_if_fail(thread);	if (thread->notifier)	{		gdk_threads_enter();		gtk_widget_destroy(thread->notifier);		gdk_threads_leave();	}		g_free(thread);		return;}voidab_thread_print (ab_thread_t	*thread){	g_return_if_fail(thread);		g_print("ab_thread_t [0x%08x]\n",					(guint32)thread);	g_print("|- GThread    : 0x%08x\n", thread->gthread);	g_print("|- Notifier   : 0x%08x\n", thread->notifier);	g_print("|- Func       : 0x%08x\n", thread->func);	g_print("|- User Data  : 0x%08x\n", thread->user_data);	g_print("`- Notifiable : %s\n", 					(thread->notifiable ? "TRUE" : "FALSE"));	return;}ab_thread_t *ab_thread_create (ab_thread_func	 func,									gpointer				 user_data,									gboolean				 notifiable){	ab_thread_t	*thread = NULL;	g_return_val_if_fail(func, NULL);		thread = g_new0(ab_thread_t, 1);	if (notifiable)	{		GtkWidget * notify_window = NULL;				notify_window = gem_notification_new();		gtk_window_move(GTK_WINDOW(notify_window), 50, 50);		if (TRUE)		{			gchar * picpath = NULL;						picpath = g_build_filename(gem_env_get_resource_path(),																 "pixmaps",																 "loading.gif",																 NULL);			/*			g_print("%s(): picpath = %s\n",							__FUNCTION__,							picpath);*/ 			gem_notification_set_image_from_file(GEM_NOTIFICATION(notify_window),																					 picpath);						g_free(picpath);		}				gtk_window_set_position(GTK_WINDOW(notify_window),														GTK_WIN_POS_CENTER_ALWAYS);				thread->notifier = notify_window;	}	else	{		thread->notifier = NULL;	}		thread->user_data	 	= user_data;	thread->func				= func;	thread->gthread			= NULL;	thread->notifiable	= notifiable;		return thread;}ab_thread_t *ab_thread_create_and_run (ab_thread_func	 func,													gpointer				 user_data,													gboolean				 notifiable){	ab_thread_t *thread = NULL;		thread = ab_thread_create(func,														user_data,														notifiable);	if (thread == NULL)	{		return NULL;	}		if (ab_thread_run(thread) == FALSE)	{		ab_thread_free(thread);				return NULL;	}		return NULL;}gpointerab_thread_wrapped_func (gpointer arg){	gpointer res = NULL;	ab_thread_t *thread = (ab_thread_t *)arg;		ab_thread_print(thread);		if (thread->func)	{		if (thread->notifiable)		{			gtk_widget_show_all(thread->notifier);		}		res = thread->func(thread);	}		ab_thread_free(thread);		return res;}gbooleanab_thread_run (ab_thread_t	*thread){	GError * error = NULL;		g_return_val_if_fail(thread, FALSE);		thread->gthread = g_thread_create((GThreadFunc)ab_thread_wrapped_func,																	  (gpointer)thread,																	  TRUE,																	  &error);	if (thread->gthread == NULL)	{		g_print("%s(): create trhead error: %s\n",						__FUNCTION__,						error->message);		g_error_free(error);				ab_thread_free(thread);				return FALSE;	}		if (thread->notifiable)	{		gtk_widget_show_all(thread->notifier);	}		return TRUE;}/*vi:ts=2:nowrap:ai:expandtab */

⌨️ 快捷键说明

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