当前位置: 首页>>代码示例>>C++>>正文


C++ G_ENUM_CLASS函数代码示例

本文整理汇总了C++中G_ENUM_CLASS函数的典型用法代码示例。如果您正苦于以下问题:C++ G_ENUM_CLASS函数的具体用法?C++ G_ENUM_CLASS怎么用?C++ G_ENUM_CLASS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了G_ENUM_CLASS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: descriptor_name

static const gchar *
descriptor_name (gint val)
{
  GEnumValue *en;

  en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek
          (GST_TYPE_MPEG_TS_DESCRIPTOR_TYPE)), val);
  if (en == NULL)
    /* Else try with DVB enum types */
    en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek
            (GST_TYPE_MPEG_TS_DVB_DESCRIPTOR_TYPE)), val);
  if (en == NULL)
    /* Else try with ATSC enum types */
    en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek
            (GST_TYPE_MPEG_TS_ATSC_DESCRIPTOR_TYPE)), val);
  if (en == NULL)
    /* Else try with ISB enum types */
    en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek
            (GST_TYPE_MPEG_TS_ISDB_DESCRIPTOR_TYPE)), val);
  if (en == NULL)
    /* Else try with misc enum types */
    en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek
            (GST_TYPE_MPEG_TS_MISC_DESCRIPTOR_TYPE)), val);
  if (en == NULL)
    return "UNKNOWN/PRIVATE";
  return en->value_nick;
}
开发者ID:agx,项目名称:gst-plugins-bad,代码行数:27,代码来源:ts-parser.c

示例2: atk_state_type_for_name

/**
 * atk_state_type_for_name:
 * @name: a character string state name
 *
 * Gets the #AtkStateType corresponding to the description string @name.
 *
 * Returns: an #AtkStateType corresponding to @name 
 */
AtkStateType
atk_state_type_for_name (const gchar *name)
{
  GTypeClass *type_class;
  GEnumValue *value;
  AtkStateType type = ATK_STATE_INVALID;

  g_return_val_if_fail (name, ATK_STATE_INVALID);

  type_class = g_type_class_ref (ATK_TYPE_STATE_TYPE);
  g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), ATK_STATE_INVALID);

  value = g_enum_get_value_by_nick (G_ENUM_CLASS (type_class), name);

  if (value)
    {
      type = value->value;
    }
  else
    {
      gint i;

      for (i = ATK_STATE_LAST_DEFINED + 1; i <= last_type; i++)
        {
          if (state_names[i] == NULL)
            continue; 
          if (!strcmp(name, state_names[i])) 
            {
              type = i;
              break;
            }
        }
    }
  return type;
}
开发者ID:h4ck3rm1k3,项目名称:atk,代码行数:43,代码来源:atkstate.c

示例3: preferences_widget_sync_string

static void
preferences_widget_sync_string (const gchar *key, GtkWidget *widget)
{
	gchar *value;

	if (empathy_conf_get_string (empathy_conf_get (), key, &value) && value) {
		if (GTK_IS_ENTRY (widget)) {
			gtk_entry_set_text (GTK_ENTRY (widget), value);
		} else if (GTK_IS_RADIO_BUTTON (widget)) {
			if (strcmp (key, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM) == 0) {
				GType        type;
				GEnumClass  *enum_class;
				GEnumValue  *enum_value;
				GSList      *list;
				GtkWidget   *toggle_widget;
				
				/* Get index from new string */
				type = empathy_contact_list_store_sort_get_type ();
				enum_class = G_ENUM_CLASS (g_type_class_peek (type));
				enum_value = g_enum_get_value_by_nick (enum_class, value);
				
				if (enum_value) { 
					list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
					toggle_widget = g_slist_nth_data (list, enum_value->value);
					gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle_widget), TRUE);
				}
			} else {
				g_warning ("Unhandled key:'%s' just had string change", key);
			}
		}

		g_free (value);
	}
}
开发者ID:gcorvala,项目名称:gsoc2008,代码行数:34,代码来源:empathy-preferences.c

示例4: infinoted_plugin_dbus_perms_to_variant

static GVariant*
infinoted_plugin_dbus_perms_to_variant(const InfAclMask* mask,
                                       const InfAclMask* perms)
{
  GVariantBuilder builder;
  GEnumClass* enum_class;
  guint i;

  enum_class = G_ENUM_CLASS(g_type_class_ref(INF_TYPE_ACL_SETTING));
  g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sb}"));
  for(i = 0; i < enum_class->n_values; ++i)
  {
    if(inf_acl_mask_has(mask, enum_class->values[i].value))
    {
      g_variant_builder_add(
        &builder,
        "{sb}",
        enum_class->values[i].value_nick,
        inf_acl_mask_has(perms, enum_class->values[i].value)
      );
    }
  }

  g_type_class_unref(enum_class);
  return g_variant_builder_end(&builder);
}
开发者ID:JoseRobertoR,项目名称:libinfinity,代码行数:26,代码来源:infinoted-plugin-dbus.c

示例5: atk_state_type_get_name

/**
 * atk_state_type_get_name:
 * @type: The #AtkStateType whose name is required
 *
 * Gets the description string describing the #AtkStateType @type.
 *
 * Returns: the string describing the AtkStateType
 */
const gchar*
atk_state_type_get_name (AtkStateType type)
{
  GTypeClass *type_class;
  GEnumValue *value;
  const gchar *name = NULL;

  type_class = g_type_class_ref (ATK_TYPE_STATE_TYPE);
  g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);

  value = g_enum_get_value (G_ENUM_CLASS (type_class), type);

  if (value)
    {
      name = value->value_nick;
    }
  else
    {
      if (type <= last_type)
        {
          if (type >= 0)
            name = state_names[type];
        }
    }

  return name;
}
开发者ID:h4ck3rm1k3,项目名称:atk,代码行数:35,代码来源:atkstate.c

示例6: main_window_notify_sort_contact_cb

static void
main_window_notify_sort_contact_cb (EmpathyConf       *conf,
				    const gchar       *key,
				    EmpathyMainWindow *window)
{
	gchar *str = NULL;

	if (empathy_conf_get_string (conf, key, &str) && str) {
		GType       type;
		GEnumClass *enum_class;
		GEnumValue *enum_value;

		type = empathy_contact_list_store_sort_get_type ();
		enum_class = G_ENUM_CLASS (g_type_class_peek (type));
		enum_value = g_enum_get_value_by_nick (enum_class, str);
		if (enum_value) {
			/* By changing the value of the GtkRadioAction,
			   it emits a signal that calls main_window_view_sort_contacts_cb
			   which updates the contacts list */
			gtk_radio_action_set_current_value (window->sort_by_name,
							    enum_value->value);
		} else {
			g_warning ("Wrong value for sort_criterium configuration : %s", str);
		}
		g_free (str);
	}
}
开发者ID:blackskad,项目名称:empathy,代码行数:27,代码来源:empathy-main-window.c

示例7: main_window_view_sort_contacts_cb

static void
main_window_view_sort_contacts_cb (GtkRadioAction    *action,
				   GtkRadioAction    *current,
				   EmpathyMainWindow *window)
{
	EmpathyContactListStoreSort value;
	GSList      *group;
	GType        type;
	GEnumClass  *enum_class;
	GEnumValue  *enum_value;

	value = gtk_radio_action_get_current_value (action);
	group = gtk_radio_action_get_group (action);

	/* Get string from index */
	type = empathy_contact_list_store_sort_get_type ();
	enum_class = G_ENUM_CLASS (g_type_class_peek (type));
	enum_value = g_enum_get_value (enum_class, g_slist_index (group, current));

	if (!enum_value) {
		g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioAction index:%d",
			   g_slist_index (group, action));
	} else {
		empathy_conf_set_string (empathy_conf_get (),
					 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
					 enum_value->value_nick);
	}
	empathy_contact_list_store_set_sort_criterium (window->list_store, value);
}
开发者ID:blackskad,项目名称:empathy,代码行数:29,代码来源:empathy-main-window.c

示例8: photos_utils_create_zoom_target_value

GVariant *
photos_utils_create_zoom_target_value (gdouble delta, PhotosZoomEvent event)
{
  GEnumClass *zoom_event_class = NULL; /* TODO: use g_autoptr */
  GEnumValue *event_value;
  GVariant *delta_value;
  GVariant *event_nick_value;
  GVariant *ret_val = NULL;
  g_auto (GVariantBuilder) builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);
  const gchar *event_nick = "none";

  g_return_val_if_fail (delta >= 0.0, NULL);
  g_return_val_if_fail (event != PHOTOS_ZOOM_EVENT_NONE, NULL);

  delta_value = g_variant_new_double (delta);
  g_variant_builder_add (&builder, "{sv}", "delta", delta_value);

  zoom_event_class = G_ENUM_CLASS (g_type_class_ref (PHOTOS_TYPE_ZOOM_EVENT));

  event_value = g_enum_get_value (zoom_event_class, (gint) event);
  if (event_value != NULL)
    event_nick = event_value->value_nick;

  event_nick_value = g_variant_new_string (event_nick);
  g_variant_builder_add (&builder, "{sv}", "event", event_nick_value);

  ret_val = g_variant_builder_end (&builder);

  g_type_class_unref (zoom_event_class);
  g_return_val_if_fail (g_variant_is_floating (ret_val), ret_val);
  return ret_val;
}
开发者ID:uajain,项目名称:gnome-photos,代码行数:32,代码来源:photos-utils.c

示例9: photos_utils_get_zoom_event

PhotosZoomEvent
photos_utils_get_zoom_event (GVariant *dictionary)
{
  GEnumClass *zoom_event_class = NULL;
  GEnumValue *event_value;
  PhotosZoomEvent ret_val = PHOTOS_ZOOM_EVENT_NONE;
  const gchar *event_str;

  g_return_val_if_fail (dictionary != NULL, PHOTOS_ZOOM_EVENT_NONE);
  g_return_val_if_fail (g_variant_is_of_type (dictionary, G_VARIANT_TYPE_VARDICT), PHOTOS_ZOOM_EVENT_NONE);

  if (!g_variant_lookup (dictionary, "event", "&s", &event_str))
    goto out;

  zoom_event_class = G_ENUM_CLASS (g_type_class_ref (PHOTOS_TYPE_ZOOM_EVENT));

  event_value = g_enum_get_value_by_nick (zoom_event_class, event_str);
  if (event_value == NULL)
    event_value = g_enum_get_value_by_name (zoom_event_class, event_str);
  if (event_value == NULL)
    goto out;

  ret_val = (PhotosZoomEvent) event_value->value;

 out:
  g_clear_pointer (&zoom_event_class, g_type_class_unref);
  g_return_val_if_fail (ret_val != PHOTOS_ZOOM_EVENT_NONE, PHOTOS_ZOOM_EVENT_NONE);
  return ret_val;
}
开发者ID:uajain,项目名称:gnome-photos,代码行数:29,代码来源:photos-utils.c

示例10: atk_relation_type_get_name

/**
 * atk_relation_type_get_name:
 * @type: The #AtkRelationType whose name is required
 *
 * Gets the description string describing the #AtkRelationType @type.
 *
 * Returns: the string describing the AtkRelationType
 */
const gchar*
atk_relation_type_get_name (AtkRelationType type)
{
  GTypeClass *type_class;
  GEnumValue *value;
  const gchar *name = NULL;

  type_class = g_type_class_ref (ATK_TYPE_RELATION_TYPE);
  g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);

  value = g_enum_get_value (G_ENUM_CLASS (type_class), type);

  if (value)
    {
      name = value->value_nick;
    }
  else
    {
      if (extra_names)
        {
          gint n = type;

          n -= ATK_RELATION_LAST_DEFINED + 1;

          if (n < extra_names->len)
            name = g_ptr_array_index (extra_names, n);
        }
    }
  g_type_class_unref (type_class);
  return name;
}
开发者ID:Krlos0208,项目名称:Sintetizador_Voz,代码行数:39,代码来源:atkrelation.c

示例11: ges_transition_clip_new

/**
 * ges_transition_clip_new:
 * @vtype: the type of transition to create
 *
 * Creates a new #GESTransitionClip.
 *
 * Returns: a newly created #GESTransitionClip, or %NULL if something
 * went wrong.
 */
GESTransitionClip *
ges_transition_clip_new (GESVideoStandardTransitionType vtype)
{
  GEnumValue *value;
  GEnumClass *klass;
  GESTransitionClip *ret = NULL;

  klass =
      G_ENUM_CLASS (g_type_class_ref (GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE));
  if (!klass) {
    GST_ERROR ("Could not find the StandarTransitionType enum class");
    return NULL;
  }

  value = g_enum_get_value (klass, vtype);
  if (!value) {
    GST_ERROR ("Could not find enum value for %i", vtype);
    return NULL;
  }

  ret = ges_transition_clip_new_for_nick (((gchar *) value->value_nick));
  g_type_class_unref (klass);

  return ret;
}
开发者ID:dark-al,项目名称:gst-editing-services-old,代码行数:34,代码来源:ges-transition-clip.c

示例12: go_conf_load_enum

int
go_conf_load_enum (GOConfNode *node, gchar const *key, GType t, int default_val)
{
	int	 res;
	gchar   *val_str = go_conf_load_string (node, key);
	gboolean use_default = TRUE;

	if (NULL != val_str) {
		GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (t));
		GEnumValue *enum_value = g_enum_get_value_by_nick (enum_class, val_str);
		if (NULL == enum_value)
			enum_value = g_enum_get_value_by_name (enum_class, val_str);

		if (NULL != enum_value) {
			use_default = FALSE;
			res = enum_value->value;
		} else {
			g_warning ("Unknown value '%s' for %s", val_str, key);
		}

		g_type_class_unref (enum_class);
		g_free (val_str);

	}

	if (use_default) {
		d (g_warning ("Using default value '%d'", default_val));
		return default_val;
	}
	return res;
}
开发者ID:UIKit0,项目名称:goffice,代码行数:31,代码来源:go-conf.c

示例13: go_conf_set_enum

void
go_conf_set_enum (GOConfNode *node, gchar const *key, GType t, gint val)
{
	GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (t));
	GEnumValue *enum_value = g_enum_get_value (enum_class, val);
	go_conf_set_string (node, key, enum_value->value_nick);
	g_type_class_unref (enum_class);
}
开发者ID:UIKit0,项目名称:goffice,代码行数:8,代码来源:go-conf.c

示例14: pyg_enum_get_value

/**
 * pyg_enum_get_value:
 * @enum_type: the GType of the flag.
 * @obj: a Python object representing the flag value
 * @val: a pointer to the location to store the integer representation of the flag.
 *
 * Converts a Python object to the integer equivalent.  The conversion
 * will depend on the type of the Python object.  If the object is an
 * integer, it is passed through directly.  If it is a string, it will
 * be treated as a full or short enum name as defined in the GType.
 *
 * Returns: 0 on success or -1 on failure
 */
gint
pyg_enum_get_value(GType enum_type, PyObject *obj, gint *val)
{
    GEnumClass *eclass = NULL;
    gint res = -1;

    g_return_val_if_fail(val != NULL, -1);
    if (!obj) {
	*val = 0;
	res = 0;
    } else if (PYGLIB_PyLong_Check(obj)) {
	*val = PYGLIB_PyLong_AsLong(obj);
	res = 0;

	if (PyObject_TypeCheck(obj, &PyGEnum_Type) && ((PyGEnum *) obj)->gtype != enum_type) {
	    g_warning("expected enumeration type %s, but got %s instead",
		      g_type_name(enum_type),
		      g_type_name(((PyGEnum *) obj)->gtype));
	}
    /* Dumb code duplication, but probably not worth it to have yet another macro. */
    } else if (PyLong_Check(obj)) {
	*val = PyLong_AsLong(obj);
	res = 0;

	if (PyObject_TypeCheck(obj, &PyGEnum_Type) && ((PyGEnum *) obj)->gtype != enum_type) {
	    g_warning("expected enumeration type %s, but got %s instead",
		      g_type_name(enum_type),
		      g_type_name(((PyGEnum *) obj)->gtype));
	}
    } else if (PYGLIB_PyUnicode_Check(obj)) {
	GEnumValue *info;
	char *str = PYGLIB_PyUnicode_AsString(obj);

	if (enum_type != G_TYPE_NONE)
	    eclass = G_ENUM_CLASS(g_type_class_ref(enum_type));
	else {
	    PyErr_SetString(PyExc_TypeError, "could not convert string to enum because there is no GType associated to look up the value");
	    res = -1;
	}
	info = g_enum_get_value_by_name(eclass, str);
	g_type_class_unref(eclass);

	if (!info)
	    info = g_enum_get_value_by_nick(eclass, str);
	if (info) {
	    *val = info->value;
	    res = 0;
	} else {
	    PyErr_SetString(PyExc_TypeError, "could not convert string");
	    res = -1;
	}
    } else {
	PyErr_SetString(PyExc_TypeError,"enum values must be strings or ints");
	res = -1;
    }
    return res;
}
开发者ID:RIFTIO,项目名称:pygobject,代码行数:70,代码来源:pygtype.c

示例15: enum_name

static const gchar *
enum_name (GType instance_type, gint val)
{
  GEnumValue *en;

  en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek (instance_type)), val);

  if (!en)
    return "UNKNOWN/PRIVATE";
  return en->value_nick;
}
开发者ID:agx,项目名称:gst-plugins-bad,代码行数:11,代码来源:ts-parser.c


注:本文中的G_ENUM_CLASS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。