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

📄 gtkdateedit.c.svn-base

📁 一款Linux手机上应用的文件管理器 系统要求就安装Gtk+2.0
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
/*	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 <ctype.h>#include <gtk/gtk.h>#include <gdk/gdkkeysyms.h>#include <string.h>#include <stdlib.h>#include <gtkdateedit.h>static GtkHBoxClass * parent_class = NULL;static void	gtk_date_edit_class_init		(GtkDateEditClass	*klass);static void	gtk_date_edit_init					(GtkDateEdit			*window);static void	gtk_date_edit_finalize			(GObject										*object);static void	gtk_date_edit_destroy				(GtkObject									*object);GTypegtk_date_edit_get_type (void){	static GType date_edit_type = 0;  if (!date_edit_type)	{		static const GTypeInfo date_edit_info =		{			sizeof (GtkDateEditClass),			NULL,		/* base_init */			NULL,		/* base_finalize */			(GClassInitFunc) gtk_date_edit_class_init,			NULL,		/* class_finalize */			NULL,		/* class_data */			sizeof (GtkDateEdit),			0,			/* n_preallocs */			(GInstanceInitFunc) gtk_date_edit_init,		};		date_edit_type = g_type_register_static (GTK_TYPE_HBOX,																												"GtkDateEdit", 																												&date_edit_info, 																												0);	}	return date_edit_type;}static voidgtk_date_edit_class_init (GtkDateEditClass * klass){  GObjectClass * object_class;  GtkObjectClass * gtk_object_class;	parent_class = g_type_class_peek_parent (klass);	  gtk_object_class = (GtkObjectClass *)klass;  gtk_object_class->destroy = gtk_date_edit_destroy;  object_class = (GObjectClass *)klass;  object_class->finalize = gtk_date_edit_finalize; 	  	return;}static void	gtk_date_edit_destroy (GtkObject * object){	GTK_OBJECT_CLASS(parent_class)->destroy(object);  	return;}static voidgtk_date_edit_finalize (GObject * object){	G_OBJECT_CLASS(parent_class)->finalize(object);		return;}void year_edit_insert_text_handler (GtkEntry    *entry,                          const gchar *text,                          gint         length,                          gint        *position,                          gpointer     data){  GtkEditable *editable = GTK_EDITABLE(entry);  int i, count=0;	gchar *result = g_new (gchar, length);			for (i=0; i < length; i++) {    if (!isdigit(text[i]))      continue;    result[count++] = text[i];  }			if (count > 0) 			{				g_signal_handlers_block_by_func (G_OBJECT (editable),																				 G_CALLBACK (year_edit_insert_text_handler),																				 data);									if (strlen(gtk_entry_get_text (GTK_ENTRY (entry))) <= 2 )					gtk_editable_insert_text (editable, result, count, position);				else if (strlen(gtk_entry_get_text (GTK_ENTRY (entry))) == 3)					{							gint year = atoi (gtk_entry_get_text (GTK_ENTRY (entry)));																year = year * 10 + atoi (result);																if (year <= 2037)								gtk_editable_insert_text (editable, result, count, position);							else								{								year = 2037;																											sprintf (result,"%d",year);									gtk_entry_set_text (entry, result);																		}																gtk_widget_child_focus (gtk_widget_get_parent (GTK_WIDGET (entry)), GTK_DIR_TAB_FORWARD);							}																										g_signal_handlers_unblock_by_func (G_OBJECT (editable),																					 G_CALLBACK (year_edit_insert_text_handler),																					 data);			}				g_signal_stop_emission_by_name (G_OBJECT (editable), "insert_text");			g_free (result);	}void mon_edit_insert_text_handler (GtkEntry    *entry,                          const gchar *text,                          gint         length,                          gint        *position,                          gpointer     data){  GtkEditable *editable = GTK_EDITABLE(entry);  int i, count=0;	gchar *result = g_new (gchar, length);			for (i=0; i < length; i++) {    if (!isdigit(text[i]))      continue;    result[count++] = text[i];  }			if (count > 0) 			{				g_signal_handlers_block_by_func (G_OBJECT (editable),																				 G_CALLBACK (mon_edit_insert_text_handler),																				 data);														if (strlen(gtk_entry_get_text (GTK_ENTRY (entry))) == 0)					gtk_editable_insert_text (editable, result, count, position);				else if (strlen(gtk_entry_get_text (GTK_ENTRY (entry))) == 1)					{						gint mon = atoi (gtk_entry_get_text (GTK_ENTRY (entry)));																mon = mon * 10 + atoi (result);																if (mon <= 12)							gtk_editable_insert_text (editable, result, count, position);						else							{								mon = 12;																												sprintf (result,"%d", mon);									gtk_entry_set_text (entry, result);																			}														gtk_widget_child_focus (gtk_widget_get_parent (GTK_WIDGET (entry)), GTK_DIR_TAB_FORWARD);						}																						g_signal_handlers_unblock_by_func (G_OBJECT (editable),																					 G_CALLBACK (mon_edit_insert_text_handler),																					 data);			}				g_signal_stop_emission_by_name (G_OBJECT (editable), "insert_text");			g_free (result);	}void day_edit_insert_text_handler (GtkEntry    *entry,                          const gchar *text,                          gint         length,                          gint        *position,                          gpointer     data){  GtkEditable *editable = GTK_EDITABLE(entry);  int i, count=0;	gchar *result = g_new (gchar, length);		for (i=0; i < length; i++) {    if (!isdigit(text[i]))      continue;    result[count++] = text[i];  }			if (count > 0) 			{				g_signal_handlers_block_by_func (G_OBJECT (editable),																				 G_CALLBACK (day_edit_insert_text_handler),																				 data);						

⌨️ 快捷键说明

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