Esempio n. 1
0
GtkEnumValue*
gtk_type_enum_find_value (GtkType        enum_type,
			  const gchar    *value_name)
{
  g_return_val_if_fail (value_name != NULL, NULL);
  
  if (GTK_FUNDAMENTAL_TYPE (enum_type) == GTK_TYPE_ENUM ||
      GTK_FUNDAMENTAL_TYPE (enum_type) == GTK_TYPE_FLAGS)
    {
      GtkEnumValue *vals;

      vals = gtk_type_enum_get_values (enum_type);
      if (vals)
	while (vals->value_name)
	  {
	    if (strcmp (vals->value_name, value_name) == 0 ||
		strcmp (vals->value_nick, value_name) == 0)
	      return vals;
	    vals++;
	  }
    }
  else
    g_warning ("gtk_type_enum_find_value(): type `%s' is not derived from `GtkEnum' or `GtkFlags'",
	       gtk_type_name (enum_type));
  
  return NULL;
}
Esempio n. 2
0
SV * newSVDefEnumHash (GtkType type, long value) {
	GtkEnumValue * vals;
	SV * result;

	vals = gtk_type_enum_get_values(type);
	if (!vals) {
		warn("Invalid type for enum: %s", gtk_type_name(type));
		return newSViv(value);
	}
	while (vals && vals->value_nick) {
		if (vals->value == value) {
			result = newSVpv(vals->value_nick, 0);
			if (!pgtk_use_minus) {
				char *s = SvPV(result, PL_na);
				while (*s) {
					if (*s == '-') *s = '_';
					s++;
				}
			}
			return result;
		}
		vals++;
	}
	/* Gtk/Gdk may get something wrong here, it's better to return undef
	 * croak("Invalid value %d for %s", value, gtk_type_name(type));*/
	return newSVsv(&PL_sv_undef);
}
Esempio n. 3
0
long SvDefEnumHash (GtkType type, SV *name) {
	long val = 0;
	GtkEnumValue * vals;
	vals = gtk_type_enum_get_values(type);
	if (!vals) {
		warn("Invalid type for enum: %s", gtk_type_name(type));
		return SvIV(name);
	}
	return SvEFValueLookup(vals, SvPV(name, PL_na), type);
}
Esempio n. 4
0
GtkFlagValue*
gtk_type_flags_get_values (GtkType	  flags_type)
{
  return gtk_type_enum_get_values (flags_type);
}