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

📄 gparamspecs.c

📁 嵌入式下基于MiniGUI的Web Browser
💻 C
📖 第 1 页 / 共 4 页
字号:
/* GObject - GLib Type, Object, Parameter and Signal Library * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. *//* * MT safe */#include	"glibconfig.h"#include	"gparamspecs.h"#include	"gvaluecollector.h"#include	"gvaluearray.h"#include	<string.h>#define	G_FLOAT_EPSILON		(1e-30)#define	G_DOUBLE_EPSILON	(1e-90)/* --- param spec functions --- */static voidparam_char_init (GParamSpec *pspec){  GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);    cspec->minimum = 0x7f;  cspec->maximum = 0x80;  cspec->default_value = 0;}static voidparam_char_set_default (GParamSpec *pspec,			GValue	   *value){  value->data[0].v_int = G_PARAM_SPEC_CHAR (pspec)->default_value;}static gbooleanparam_char_validate (GParamSpec *pspec,		     GValue     *value){  GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);  gint oval = value->data[0].v_int;    value->data[0].v_int = CLAMP (value->data[0].v_int, cspec->minimum, cspec->maximum);    return value->data[0].v_int != oval;}static voidparam_uchar_init (GParamSpec *pspec){  GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);    uspec->minimum = 0;  uspec->maximum = 0xff;  uspec->default_value = 0;}static voidparam_uchar_set_default (GParamSpec *pspec,			 GValue	    *value){  value->data[0].v_uint = G_PARAM_SPEC_UCHAR (pspec)->default_value;}static gbooleanparam_uchar_validate (GParamSpec *pspec,		      GValue     *value){  GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);  guint oval = value->data[0].v_uint;    value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);    return value->data[0].v_uint != oval;}static voidparam_boolean_set_default (GParamSpec *pspec,			   GValue     *value){  value->data[0].v_int = G_PARAM_SPEC_BOOLEAN (pspec)->default_value;}static gbooleanparam_boolean_validate (GParamSpec *pspec,			GValue     *value){  gint oval = value->data[0].v_int;    value->data[0].v_int = value->data[0].v_int != FALSE;    return value->data[0].v_int != oval;}static voidparam_int_init (GParamSpec *pspec){  GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);    ispec->minimum = 0x7fffffff;  ispec->maximum = 0x80000000;  ispec->default_value = 0;}static voidparam_int_set_default (GParamSpec *pspec,		       GValue     *value){  value->data[0].v_int = G_PARAM_SPEC_INT (pspec)->default_value;}static gbooleanparam_int_validate (GParamSpec *pspec,		    GValue     *value){  GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);  gint oval = value->data[0].v_int;    value->data[0].v_int = CLAMP (value->data[0].v_int, ispec->minimum, ispec->maximum);    return value->data[0].v_int != oval;}static gintparam_int_values_cmp (GParamSpec   *pspec,		      const GValue *value1,		      const GValue *value2){  if (value1->data[0].v_int < value2->data[0].v_int)    return -1;  else    return value1->data[0].v_int > value2->data[0].v_int;}static voidparam_uint_init (GParamSpec *pspec){  GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);    uspec->minimum = 0;  uspec->maximum = 0xffffffff;  uspec->default_value = 0;}static voidparam_uint_set_default (GParamSpec *pspec,			GValue     *value){  value->data[0].v_uint = G_PARAM_SPEC_UINT (pspec)->default_value;}static gbooleanparam_uint_validate (GParamSpec *pspec,		     GValue     *value){  GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);  guint oval = value->data[0].v_uint;    value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);    return value->data[0].v_uint != oval;}static gintparam_uint_values_cmp (GParamSpec   *pspec,		       const GValue *value1,		       const GValue *value2){  if (value1->data[0].v_uint < value2->data[0].v_uint)    return -1;  else    return value1->data[0].v_uint > value2->data[0].v_uint;}static voidparam_long_init (GParamSpec *pspec){  GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);  #if SIZEOF_LONG == 4  lspec->minimum = 0x7fffffff;  lspec->maximum = 0x80000000;#else /* SIZEOF_LONG != 4 (8) */  lspec->minimum = 0x7fffffffffffffff;  lspec->maximum = 0x8000000000000000;#endif  lspec->default_value = 0;}static voidparam_long_set_default (GParamSpec *pspec,			GValue     *value){  value->data[0].v_long = G_PARAM_SPEC_LONG (pspec)->default_value;}static gbooleanparam_long_validate (GParamSpec *pspec,		     GValue     *value){  GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);  glong oval = value->data[0].v_long;    value->data[0].v_long = CLAMP (value->data[0].v_long, lspec->minimum, lspec->maximum);    return value->data[0].v_long != oval;}static gintparam_long_values_cmp (GParamSpec   *pspec,		       const GValue *value1,		       const GValue *value2){  if (value1->data[0].v_long < value2->data[0].v_long)    return -1;  else    return value1->data[0].v_long > value2->data[0].v_long;}static voidparam_ulong_init (GParamSpec *pspec){  GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);    uspec->minimum = 0;#if SIZEOF_LONG == 4  uspec->maximum = 0xffffffff;#else /* SIZEOF_LONG != 4 (8) */  uspec->maximum = 0xffffffffffffffff;#endif  uspec->default_value = 0;}static voidparam_ulong_set_default (GParamSpec *pspec,			 GValue     *value){  value->data[0].v_ulong = G_PARAM_SPEC_ULONG (pspec)->default_value;}static gbooleanparam_ulong_validate (GParamSpec *pspec,		      GValue     *value){  GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);  gulong oval = value->data[0].v_ulong;    value->data[0].v_ulong = CLAMP (value->data[0].v_ulong, uspec->minimum, uspec->maximum);    return value->data[0].v_ulong != oval;}static gintparam_ulong_values_cmp (GParamSpec   *pspec,			const GValue *value1,			const GValue *value2){  if (value1->data[0].v_ulong < value2->data[0].v_ulong)    return -1;  else    return value1->data[0].v_ulong > value2->data[0].v_ulong;}static voidparam_int64_init (GParamSpec *pspec){  GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);    lspec->minimum = G_MININT64;  lspec->maximum = G_MAXINT64;  lspec->default_value = 0;}static voidparam_int64_set_default (GParamSpec *pspec,			GValue     *value){  value->data[0].v_int64 = G_PARAM_SPEC_INT64 (pspec)->default_value;}static gbooleanparam_int64_validate (GParamSpec *pspec,		     GValue     *value){  GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);  gint64 oval = value->data[0].v_int64;    value->data[0].v_int64 = CLAMP (value->data[0].v_int64, lspec->minimum, lspec->maximum);    return value->data[0].v_int64 != oval;}static gintparam_int64_values_cmp (GParamSpec   *pspec,		       const GValue *value1,		       const GValue *value2){  if (value1->data[0].v_int64 < value2->data[0].v_int64)    return -1;  else    return value1->data[0].v_int64 > value2->data[0].v_int64;}static voidparam_uint64_init (GParamSpec *pspec){  GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);    uspec->minimum = 0;  uspec->maximum = G_MAXUINT64;  uspec->default_value = 0;}static voidparam_uint64_set_default (GParamSpec *pspec,			 GValue     *value){  value->data[0].v_uint64 = G_PARAM_SPEC_UINT64 (pspec)->default_value;}static gbooleanparam_uint64_validate (GParamSpec *pspec,		      GValue     *value){  GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);  guint64 oval = value->data[0].v_uint64;    value->data[0].v_uint64 = CLAMP (value->data[0].v_uint64, uspec->minimum, uspec->maximum);    return value->data[0].v_uint64 != oval;}static gintparam_uint64_values_cmp (GParamSpec   *pspec,			const GValue *value1,			const GValue *value2){  if (value1->data[0].v_uint64 < value2->data[0].v_uint64)    return -1;  else    return value1->data[0].v_uint64 > value2->data[0].v_uint64;}static voidparam_unichar_init (GParamSpec *pspec){  GParamSpecUnichar *uspec = G_PARAM_SPEC_UNICHAR (pspec);    uspec->default_value = 0;}static voidparam_unichar_set_default (GParamSpec *pspec,			 GValue     *value){  value->data[0].v_uint = G_PARAM_SPEC_UNICHAR (pspec)->default_value;}static gbooleanparam_unichar_validate (GParamSpec *pspec,		        GValue     *value){  gunichar oval = value->data[0].v_uint;  gboolean changed = FALSE;  if (!g_unichar_validate (oval))    {      value->data[0].v_uint = 0;      changed = TRUE;    }  return changed;}static gintparam_unichar_values_cmp (GParamSpec   *pspec,			const GValue *value1,			const GValue *value2){  if (value1->data[0].v_uint < value2->data[0].v_uint)    return -1;  else    return value1->data[0].v_uint > value2->data[0].v_uint;}static voidparam_enum_init (GParamSpec *pspec){  GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);    espec->enum_class = NULL;  espec->default_value = 0;}static voidparam_enum_finalize (GParamSpec *pspec){  GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);  GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_ENUM));    if (espec->enum_class)    {      g_type_class_unref (espec->enum_class);      espec->enum_class = NULL;    }    parent_class->finalize (pspec);}static voidparam_enum_set_default (GParamSpec *pspec,			GValue     *value){  value->data[0].v_long = G_PARAM_SPEC_ENUM (pspec)->default_value;}static gbooleanparam_enum_validate (GParamSpec *pspec,		     GValue     *value){  GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);  glong oval = value->data[0].v_long;    if (!espec->enum_class ||      !g_enum_get_value (espec->enum_class, value->data[0].v_long))    value->data[0].v_long = espec->default_value;    return value->data[0].v_long != oval;}static voidparam_flags_init (GParamSpec *pspec){  GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);    fspec->flags_class = NULL;  fspec->default_value = 0;}static voidparam_flags_finalize (GParamSpec *pspec)

⌨️ 快捷键说明

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